Re: [WIP 01/15] pkt-line: introduce packet_read_with_status
- From
- Brandon Williams <bmwill@google.com>
- Date
- Dec 8, 2017, 18:03 UTC
- Message-ID
- <20171208180334.GF152943@google.com>
- In-Reply-To
- <CAGZ79kbV07BsKde1P_3EHjnSj7APTMQk+bbGx79X0nvpU2LD+Q@mail.gmail.com>
On 12/07, Stefan Beller wrote:
Show 31 quoted lines
> On Mon, Dec 4, 2017 at 3:58 PM, Brandon Williams <bmwill@google.com> wrote:
>
> > 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 -1
>
> which doesn't hold true for the _status version. Can you adapt the comment
> to explain both read functions?Good point, I'll makes changes and document the _status version separately.
-- Brandon Williams