diff options
author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
---|---|---|
committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/stream.h | |
parent | *: add indent control files (diff) | |
download | frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/stream.h')
-rw-r--r-- | lib/stream.h | 180 |
1 files changed, 88 insertions, 92 deletions
diff --git a/lib/stream.h b/lib/stream.h index c012cc459..33dd64c4a 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -78,7 +78,7 @@ * The stream is empty from endp to size. Without adjusting getp, there are * still endp-getp bytes of valid data to be read from the stream. * - * Methods are provided to get and put to/from the stream, as well as + * Methods are provided to get and put to/from the stream, as well as * retrieve the values of the 3 markers and manipulate the getp marker. * * Note: @@ -92,45 +92,42 @@ */ /* Stream buffer. */ -struct stream -{ - struct stream *next; - - /* Remainder is ***private*** to stream - * direct access is frowned upon! - * Use the appropriate functions/macros - */ - size_t getp; /* next get position */ - size_t endp; /* last valid data position */ - size_t size; /* size of data segment */ - unsigned char *data; /* data pointer */ +struct stream { + struct stream *next; + + /* Remainder is ***private*** to stream + * direct access is frowned upon! + * Use the appropriate functions/macros + */ + size_t getp; /* next get position */ + size_t endp; /* last valid data position */ + size_t size; /* size of data segment */ + unsigned char *data; /* data pointer */ }; /* First in first out queue structure. */ -struct stream_fifo -{ - size_t count; +struct stream_fifo { + size_t count; - struct stream *head; - struct stream *tail; + struct stream *head; + struct stream *tail; }; /* Utility macros. */ #define STREAM_SIZE(S) ((S)->size) - /* number of bytes which can still be written */ +/* number of bytes which can still be written */ #define STREAM_WRITEABLE(S) ((S)->size - (S)->endp) - /* number of bytes still to be read */ +/* number of bytes still to be read */ #define STREAM_READABLE(S) ((S)->endp - (S)->getp) -#define STREAM_CONCAT_REMAIN(S1, S2, size) \ - ((size) - (S1)->endp - (S2)->endp) +#define STREAM_CONCAT_REMAIN(S1, S2, size) ((size) - (S1)->endp - (S2)->endp) /* deprecated macros - do not use in new code */ #define STREAM_PNT(S) stream_pnt((S)) #define STREAM_DATA(S) ((S)->data) #define STREAM_REMAIN(S) STREAM_WRITEABLE((S)) -/* Stream prototypes. +/* Stream prototypes. * For stream_{put,get}S, the S suffix mean: * * c: character (unsigned byte) @@ -138,15 +135,15 @@ struct stream_fifo * l: long (two words) * q: quad (four words) */ -extern struct stream *stream_new (size_t); -extern void stream_free (struct stream *); -extern struct stream * stream_copy (struct stream *, struct stream *src); -extern struct stream *stream_dup (struct stream *); -extern size_t stream_resize (struct stream *, size_t); -extern size_t stream_get_getp (struct stream *); -extern size_t stream_get_endp (struct stream *); -extern size_t stream_get_size (struct stream *); -extern u_char *stream_get_data (struct stream *); +extern struct stream *stream_new(size_t); +extern void stream_free(struct stream *); +extern struct stream *stream_copy(struct stream *, struct stream *src); +extern struct stream *stream_dup(struct stream *); +extern size_t stream_resize(struct stream *, size_t); +extern size_t stream_get_getp(struct stream *); +extern size_t stream_get_endp(struct stream *); +extern size_t stream_get_size(struct stream *); +extern u_char *stream_get_data(struct stream *); /** * Create a new stream structure; copy offset bytes from s1 to the new @@ -156,59 +153,59 @@ extern u_char *stream_get_data (struct stream *); extern struct stream *stream_dupcat(struct stream *s1, struct stream *s2, size_t offset); -extern void stream_set_getp (struct stream *, size_t); -extern void stream_set_endp (struct stream *, size_t); -extern void stream_forward_getp (struct stream *, size_t); -extern void stream_forward_endp (struct stream *, size_t); +extern void stream_set_getp(struct stream *, size_t); +extern void stream_set_endp(struct stream *, size_t); +extern void stream_forward_getp(struct stream *, size_t); +extern void stream_forward_endp(struct stream *, size_t); /* steam_put: NULL source zeroes out size_t bytes of stream */ -extern void stream_put (struct stream *, const void *, size_t); -extern int stream_putc (struct stream *, u_char); -extern int stream_putc_at (struct stream *, size_t, u_char); -extern int stream_putw (struct stream *, u_int16_t); -extern int stream_putw_at (struct stream *, size_t, u_int16_t); -extern int stream_put3 (struct stream *, u_int32_t); -extern int stream_put3_at (struct stream *, size_t, u_int32_t); -extern int stream_putl (struct stream *, u_int32_t); -extern int stream_putl_at (struct stream *, size_t, u_int32_t); -extern int stream_putq (struct stream *, uint64_t); -extern int stream_putq_at (struct stream *, size_t, uint64_t); -extern int stream_put_ipv4 (struct stream *, u_int32_t); -extern int stream_put_in_addr (struct stream *, struct in_addr *); -extern int stream_put_in_addr_at (struct stream *, size_t, struct in_addr *); -extern int stream_put_in6_addr_at (struct stream *, size_t, struct in6_addr *); -extern int stream_put_prefix_addpath (struct stream *, struct prefix *, - int addpath_encode, - u_int32_t addpath_tx_id); -extern int stream_put_prefix (struct stream *, struct prefix *); -extern int stream_put_labeled_prefix (struct stream *, struct prefix *, - mpls_label_t *); -extern void stream_get (void *, struct stream *, size_t); -extern void stream_get_from (void *, struct stream *, size_t, size_t); -extern u_char stream_getc (struct stream *); -extern u_char stream_getc_from (struct stream *, size_t); -extern u_int16_t stream_getw (struct stream *); -extern u_int16_t stream_getw_from (struct stream *, size_t); -extern u_int32_t stream_get3 (struct stream *); -extern u_int32_t stream_get3_from (struct stream *, size_t); -extern u_int32_t stream_getl (struct stream *); -extern u_int32_t stream_getl_from (struct stream *, size_t); -extern uint64_t stream_getq (struct stream *); -extern uint64_t stream_getq_from (struct stream *, size_t); -extern u_int32_t stream_get_ipv4 (struct stream *); +extern void stream_put(struct stream *, const void *, size_t); +extern int stream_putc(struct stream *, u_char); +extern int stream_putc_at(struct stream *, size_t, u_char); +extern int stream_putw(struct stream *, u_int16_t); +extern int stream_putw_at(struct stream *, size_t, u_int16_t); +extern int stream_put3(struct stream *, u_int32_t); +extern int stream_put3_at(struct stream *, size_t, u_int32_t); +extern int stream_putl(struct stream *, u_int32_t); +extern int stream_putl_at(struct stream *, size_t, u_int32_t); +extern int stream_putq(struct stream *, uint64_t); +extern int stream_putq_at(struct stream *, size_t, uint64_t); +extern int stream_put_ipv4(struct stream *, u_int32_t); +extern int stream_put_in_addr(struct stream *, struct in_addr *); +extern int stream_put_in_addr_at(struct stream *, size_t, struct in_addr *); +extern int stream_put_in6_addr_at(struct stream *, size_t, struct in6_addr *); +extern int stream_put_prefix_addpath(struct stream *, struct prefix *, + int addpath_encode, + u_int32_t addpath_tx_id); +extern int stream_put_prefix(struct stream *, struct prefix *); +extern int stream_put_labeled_prefix(struct stream *, struct prefix *, + mpls_label_t *); +extern void stream_get(void *, struct stream *, size_t); +extern void stream_get_from(void *, struct stream *, size_t, size_t); +extern u_char stream_getc(struct stream *); +extern u_char stream_getc_from(struct stream *, size_t); +extern u_int16_t stream_getw(struct stream *); +extern u_int16_t stream_getw_from(struct stream *, size_t); +extern u_int32_t stream_get3(struct stream *); +extern u_int32_t stream_get3_from(struct stream *, size_t); +extern u_int32_t stream_getl(struct stream *); +extern u_int32_t stream_getl_from(struct stream *, size_t); +extern uint64_t stream_getq(struct stream *); +extern uint64_t stream_getq_from(struct stream *, size_t); +extern u_int32_t stream_get_ipv4(struct stream *); /* IEEE-754 floats */ -extern float stream_getf (struct stream *); -extern double stream_getd (struct stream *); -extern int stream_putf (struct stream *, float); -extern int stream_putd (struct stream *, double); +extern float stream_getf(struct stream *); +extern double stream_getd(struct stream *); +extern int stream_putf(struct stream *, float); +extern int stream_putd(struct stream *, double); #undef stream_read #undef stream_write -/* Deprecated: assumes blocking I/O. Will be removed. +/* Deprecated: assumes blocking I/O. Will be removed. Use stream_read_try instead. */ -extern int stream_read (struct stream *, int, size_t); +extern int stream_read(struct stream *, int, size_t); /* Read up to size bytes into the stream. Return code: @@ -220,27 +217,26 @@ extern int stream_read (struct stream *, int, size_t); */ extern ssize_t stream_read_try(struct stream *s, int fd, size_t size); -extern ssize_t stream_recvmsg (struct stream *s, int fd, struct msghdr *, - int flags, size_t size); -extern ssize_t stream_recvfrom (struct stream *s, int fd, size_t len, - int flags, struct sockaddr *from, - socklen_t *fromlen); -extern size_t stream_write (struct stream *, const void *, size_t); +extern ssize_t stream_recvmsg(struct stream *s, int fd, struct msghdr *, + int flags, size_t size); +extern ssize_t stream_recvfrom(struct stream *s, int fd, size_t len, int flags, + struct sockaddr *from, socklen_t *fromlen); +extern size_t stream_write(struct stream *, const void *, size_t); /* reset the stream. See Note above */ -extern void stream_reset (struct stream *); -extern int stream_flush (struct stream *, int); -extern int stream_empty (struct stream *); /* is the stream empty? */ +extern void stream_reset(struct stream *); +extern int stream_flush(struct stream *, int); +extern int stream_empty(struct stream *); /* is the stream empty? */ /* deprecated */ -extern u_char *stream_pnt (struct stream *); +extern u_char *stream_pnt(struct stream *); /* Stream fifo. */ -extern struct stream_fifo *stream_fifo_new (void); -extern void stream_fifo_push (struct stream_fifo *fifo, struct stream *s); -extern struct stream *stream_fifo_pop (struct stream_fifo *fifo); -extern struct stream *stream_fifo_head (struct stream_fifo *fifo); -extern void stream_fifo_clean (struct stream_fifo *fifo); -extern void stream_fifo_free (struct stream_fifo *fifo); +extern struct stream_fifo *stream_fifo_new(void); +extern void stream_fifo_push(struct stream_fifo *fifo, struct stream *s); +extern struct stream *stream_fifo_pop(struct stream_fifo *fifo); +extern struct stream *stream_fifo_head(struct stream_fifo *fifo); +extern void stream_fifo_clean(struct stream_fifo *fifo); +extern void stream_fifo_free(struct stream_fifo *fifo); #endif /* _ZEBRA_STREAM_H */ |