xref: /haiku/src/add-ons/kernel/generic/tty/line_buffer.h (revision 47a21c5c89fc9fd155a3929e5a8f6056b92a2053)
191bcf08eSMichael Lotz /*
291bcf08eSMichael Lotz ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3*47a21c5cSAugustin Cavalier ** Distributed under the terms of the MIT License.
491bcf08eSMichael Lotz */
591bcf08eSMichael Lotz #ifndef LINE_BUFFER_H
691bcf08eSMichael Lotz #define LINE_BUFFER_H
791bcf08eSMichael Lotz 
891bcf08eSMichael Lotz 
991bcf08eSMichael Lotz #include <OS.h>
1091bcf08eSMichael Lotz 
1191bcf08eSMichael Lotz 
1291bcf08eSMichael Lotz struct line_buffer {
1391bcf08eSMichael Lotz 	int32	first;
1491bcf08eSMichael Lotz 	size_t	in;
1591bcf08eSMichael Lotz 	size_t	size;
1691bcf08eSMichael Lotz 	char	*buffer;
1791bcf08eSMichael Lotz };
1891bcf08eSMichael Lotz 
1991bcf08eSMichael Lotz status_t init_line_buffer(struct line_buffer &buffer, size_t size);
2091bcf08eSMichael Lotz status_t uninit_line_buffer(struct line_buffer &buffer);
2191bcf08eSMichael Lotz status_t clear_line_buffer(struct line_buffer &buffer);
2291bcf08eSMichael Lotz int32 line_buffer_readable(struct line_buffer &buffer);
2391bcf08eSMichael Lotz int32 line_buffer_readable_line(struct line_buffer &buffer, char eol, char eof);
2491bcf08eSMichael Lotz int32 line_buffer_writable(struct line_buffer &buffer);
2591bcf08eSMichael Lotz ssize_t line_buffer_user_read(struct line_buffer &buffer, char *data,
2691bcf08eSMichael Lotz 			size_t length, char eof = 0, bool* hitEOF = NULL);
2791bcf08eSMichael Lotz status_t line_buffer_getc(struct line_buffer &buffer, char *_c);
2891bcf08eSMichael Lotz status_t line_buffer_putc(struct line_buffer &buffer, char c);
2991bcf08eSMichael Lotz status_t line_buffer_ungetc(struct line_buffer &buffer, char *c);
3091bcf08eSMichael Lotz bool line_buffer_tail_getc(struct line_buffer &buffer, char *c);
3191bcf08eSMichael Lotz 
3291bcf08eSMichael Lotz #endif	/* LINE_BUFFER_H */
33