mirror of
https://github.com/ipxe/ipxe
synced 2025-12-20 20:10:18 +03:00
[linebuf] Support buffering of multiple lines
Allow line buffer to accumulate multiple lines, with buffered_line() returning each freshly-completed line as it is encountered. This allows buffered lines to be subsequently processed as a group. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -14,17 +14,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
/** A line buffer */
|
||||
struct line_buffer {
|
||||
/** Current string in the buffer */
|
||||
/** Data buffer */
|
||||
char *data;
|
||||
/** Length of current string, excluding the terminating NUL */
|
||||
/** Length of buffered data */
|
||||
size_t len;
|
||||
/** String is ready to read */
|
||||
int ready;
|
||||
/** Most recently consumed length */
|
||||
size_t consumed;
|
||||
};
|
||||
|
||||
extern char * buffered_line ( struct line_buffer *linebuf );
|
||||
extern ssize_t line_buffer ( struct line_buffer *linebuf,
|
||||
const char *data, size_t len );
|
||||
extern int line_buffer ( struct line_buffer *linebuf,
|
||||
const char *data, size_t len );
|
||||
extern void empty_line_buffer ( struct line_buffer *linebuf );
|
||||
|
||||
#endif /* _IPXE_LINEBUF_H */
|
||||
|
||||
Reference in New Issue
Block a user