From 996b091b50ccdc317b2a7501dd2fe18b0a3d421a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 12 Jan 2007 17:08:37 +0000 Subject: Added generic line-buffering code (a la stdio) --- src/include/gpxe/linebuf.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/include/gpxe/linebuf.h (limited to 'src/include') diff --git a/src/include/gpxe/linebuf.h b/src/include/gpxe/linebuf.h new file mode 100644 index 000000000..72b477526 --- /dev/null +++ b/src/include/gpxe/linebuf.h @@ -0,0 +1,37 @@ +#ifndef _GPXE_LINEBUF_H +#define _GPXE_LINEBUF_H + +/** @file + * + * Line buffering + * + */ + +#include +#include + +/** A line buffer */ +struct line_buffer { + /** Current data in the buffer */ + char *data; + /** Length of current data */ + size_t len; + /** Bitmask of terminating characters to skip over */ + unsigned int skip_terminators; +}; + +/** + * Retrieve buffered-up line + * + * @v linebuf Line buffer + * @ret line Buffered line, or NULL if no line present + */ +static inline char * buffered_line ( struct line_buffer *linebuf ) { + return linebuf->data; +} + +extern int line_buffer ( struct line_buffer *linebuf, const char *data, + size_t len ); +extern void empty_line_buffer ( struct line_buffer *linebuf ); + +#endif /* _GPXE_LINEBUF_H */ -- cgit v1.2.3-55-g7522