mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 20:40:25 +03:00
Added generic line-buffering code (a la stdio)
This commit is contained in:
37
src/include/gpxe/linebuf.h
Normal file
37
src/include/gpxe/linebuf.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _GPXE_LINEBUF_H
|
||||
#define _GPXE_LINEBUF_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Line buffering
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/** 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 */
|
||||
Reference in New Issue
Block a user