1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (c) 1995 Danny Gasparovski. 4 */ 5 6 #ifndef SBUF_H 7 #define SBUF_H 8 9 #define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc) 10 11 struct sbuf { 12 uint32_t sb_cc; /* actual chars in buffer */ 13 uint32_t sb_datalen; /* Length of data */ 14 char *sb_wptr; /* write pointer. points to where the next 15 * bytes should be written in the sbuf */ 16 char *sb_rptr; /* read pointer. points to where the next 17 * byte should be read from the sbuf */ 18 char *sb_data; /* Actual data */ 19 }; 20 21 void sbfree(struct sbuf *sb); 22 bool sbdrop(struct sbuf *sb, size_t len); 23 void sbreserve(struct sbuf *sb, size_t size); 24 void sbappend(struct socket *sb, struct mbuf *mb); 25 void sbcopy(struct sbuf *sb, size_t off, size_t len, char *p); 26 27 #endif 28