On Tue, 2 Jan 2018 16:18:04 -0800
Brandon Williams <[email protected]> wrote:
> diff --git a/pkt-line.h b/pkt-line.h
> index 06c468927..c446e886a 100644
> --- a/pkt-line.h
> +++ b/pkt-line.h
> @@ -111,6 +111,63 @@ char *packet_read_line_buf(char **src_buf, size_t
> *src_len, int *size);
> */
> ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out);
>
> +struct packet_reader {
> + /* source file descriptor */
> + int fd;
> +
> + /* source buffer and its size */
> + char *src_buffer;
> + size_t src_len;
> +
> + /* buffer that pkt-lines are read into and its size */
> + char *buffer;
> + unsigned buffer_size;
Is the intention to support different buffers in the future?
[snip]
> +/*
> + * Peek the next packet line without consuming it and return the status.
> + * The next call to 'packet_reader_read()' will perform a read of the same
> line
> + * that was peeked, consuming the line.
> + *
> + * Only a single line can be peeked at a time.
It is logical to me that if you peeked at a line, and then peeked at it
again, you will get the same line - I would phrase this not as a
restriction ("only a single line") but just as a statement of fact (e.g.
"Peeking at the same line multiple times without an intervening
packet_reader_read will return the same result").
> + */
> +extern enum packet_read_status packet_reader_peek(struct packet_reader
> *reader);
> +
> #define DEFAULT_PACKET_MAX 1000
> #define LARGE_PACKET_MAX 65520
> #define LARGE_PACKET_DATA_MAX (LARGE_PACKET_MAX - 4)