Re: [WIP 01/15] pkt-line: introduce packet_read_with_status
- From
Stefan Beller <sbeller@google.com>
- Date
- Dec 7, 2017, 20:53 UTC
- Message-ID
- <CAGZ79kbV07BsKde1P_3EHjnSj7APTMQk+bbGx79X0nvpU2LD+Q@mail.gmail.com>
- In-Reply-To
- <20171204235823.63299-2-bmwill@google.com>
On Mon, Dec 4, 2017 at 3:58 PM, Brandon Williams <bmwill@google.com> wrote:
Show 20 quoted lines
> diff --git a/pkt-line.h b/pkt-line.h
> index 3dad583e2..f1545929b 100644
> --- a/pkt-line.h
> +++ b/pkt-line.h
> @@ -60,8 +60,16 @@ int write_packetized_from_buf(const char *src_in, size_t len, int fd_out);
> * If options contains PACKET_READ_CHOMP_NEWLINE, a trailing newline (if
> * present) is removed from the buffer before returning.
> */
> +enum packet_read_status {
> + PACKET_READ_ERROR = -1,
> + PACKET_READ_NORMAL,
> + PACKET_READ_FLUSH,
> +};
> #define PACKET_READ_GENTLE_ON_EOF (1u<<0)
> #define PACKET_READ_CHOMP_NEWLINE (1u<<1)
> +enum packet_read_status packet_read_with_status(int fd, char **src_buffer, size_t *src_len,
> + char *buffer, unsigned size, int *pktlen,
> + int options);
> int packet_read(int fd, char **src_buffer, size_t *src_len, char
> *buffer, unsigned size, int options);The documentation that is preceding these lines is very specific to packet_read, e.g.
If options does contain PACKET_READ_GENTLE_ON_EOF,
we will not die on condition 4 (truncated input), but instead return -1which doesn't hold true for the _status version. Can you adapt the comment to explain both read functions?