iPXE
|
Line buffering. More...
Go to the source code of this file.
Data Structures | |
struct | line_buffer |
A line buffer. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
char * | buffered_line (struct line_buffer *linebuf) |
Retrieve buffered-up line. More... | |
int | line_buffer (struct line_buffer *linebuf, const char *data, size_t len) |
Buffer up received data by lines. More... | |
void | empty_line_buffer (struct line_buffer *linebuf) |
Discard line buffer contents. More... | |
Line buffering.
Definition in file linebuf.h.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
char* buffered_line | ( | struct line_buffer * | linebuf | ) |
Retrieve buffered-up line.
linebuf | Line buffer |
line | Buffered line, or NULL if no line ready to read |
Definition at line 45 of file linebuf.c.
References line_buffer::consumed, line_buffer::data, line_buffer::len, and NULL.
Referenced by http_rx_chunk_len(), http_rx_headers(), http_rx_trailers(), linebuf_consume_okx(), linebuf_empty_okx(), and linebuf_init_okx().
int line_buffer | ( | struct line_buffer * | linebuf, |
const char * | data, | ||
size_t | len | ||
) |
Buffer up received data by lines.
linebuf | Line buffer |
data | New data to add |
len | Length of new data to add |
len | Consumed length, or negative error number |
After calling line_buffer(), use buffered_line() to determine whether or not a complete line is available. Carriage returns and newlines will have been stripped, and the line will be NUL-terminated. This buffered line is valid only until the next call to line_buffer() (or to empty_line_buffer()).
Note that line buffers use dynamically allocated storage; you should call empty_line_buffer() before freeing a struct
line_buffer
.
Definition at line 91 of file linebuf.c.
References assert(), line_buffer::consumed, cr, line_buffer::data, data, EINVAL, ENOMEM, len, line_buffer::len, memchr(), memcpy(), and realloc().
Referenced by http_rx_linebuf(), and linebuf_consume_okx().
void empty_line_buffer | ( | struct line_buffer * | linebuf | ) |
Discard line buffer contents.
linebuf | Line buffer |
Definition at line 65 of file linebuf.c.
References line_buffer::consumed, line_buffer::data, free, line_buffer::len, and NULL.
Referenced by http_free(), http_rx_chunk_len(), http_rx_trailers(), http_tx_request(), and linebuf_empty_okx().