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