1 /* 2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 ** Distributed under the terms of the MIT License. 4 */ 5 #ifndef LINE_BUFFER_H 6 #define LINE_BUFFER_H 7 8 9 #include <OS.h> 10 11 12 struct line_buffer { 13 int32 first; 14 size_t in; 15 size_t size; 16 char *buffer; 17 }; 18 19 status_t init_line_buffer(struct line_buffer &buffer, size_t size); 20 status_t uninit_line_buffer(struct line_buffer &buffer); 21 status_t clear_line_buffer(struct line_buffer &buffer); 22 int32 line_buffer_readable(struct line_buffer &buffer); 23 int32 line_buffer_readable_line(struct line_buffer &buffer, char eol, char eof); 24 int32 line_buffer_writable(struct line_buffer &buffer); 25 ssize_t line_buffer_user_read(struct line_buffer &buffer, char *data, 26 size_t length, char eof = 0, bool* hitEOF = NULL); 27 status_t line_buffer_getc(struct line_buffer &buffer, char *_c); 28 status_t line_buffer_putc(struct line_buffer &buffer, char c); 29 status_t line_buffer_ungetc(struct line_buffer &buffer, char *c); 30 bool line_buffer_tail_getc(struct line_buffer &buffer, char *c); 31 32 #endif /* LINE_BUFFER_H */ 33