aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/sbuf.h
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2019-08-07 19:27:14 +0000
committerConrad Meyer <cem@FreeBSD.org>2019-08-07 19:27:14 +0000
commit76cb1112da20279c59bc8189519c4122a4d0d96a (patch)
tree1866888e51f1ea8c830a5b119569d4c78b30d16f /sys/sys/sbuf.h
parentd23813cdb9a927b0c2965fcb4979edaad5f21dae (diff)
downloadsrc-76cb1112da20279c59bc8189519c4122a4d0d96a.tar.gz
src-76cb1112da20279c59bc8189519c4122a4d0d96a.zip
sbuf(9): Add sbuf_nl_terminate() API
The API is used to gracefully terminate text line(s) with a single \n. If the formatted buffer was empty or already ended in \n, it is unmodified. Otherwise, a newline character is appended to it. The API, like other sbuf-modifying routines, is only valid while the sbuf is not FINISHED. Reviewed by: rlibby Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21030
Notes
Notes: svn path=/head/; revision=350693
Diffstat (limited to 'sys/sys/sbuf.h')
-rw-r--r--sys/sys/sbuf.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h
index 3b099fe3f512..10b59f360cd0 100644
--- a/sys/sys/sbuf.h
+++ b/sys/sys/sbuf.h
@@ -58,6 +58,7 @@ struct sbuf {
#define SBUF_FINISHED 0x00020000 /* set by sbuf_finish() */
#define SBUF_DYNSTRUCT 0x00080000 /* sbuf must be freed */
#define SBUF_INSECTION 0x00100000 /* set by sbuf_start_section() */
+#define SBUF_DRAINATEOL 0x00200000 /* drained contents ended in \n */
int s_flags; /* flags */
ssize_t s_sect_len; /* current length of section */
ssize_t s_rec_off; /* current record start offset */
@@ -91,6 +92,7 @@ int sbuf_printf(struct sbuf *, const char *, ...)
__printflike(2, 3);
int sbuf_vprintf(struct sbuf *, const char *, __va_list)
__printflike(2, 0);
+int sbuf_nl_terminate(struct sbuf *);
int sbuf_putc(struct sbuf *, int);
void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *);
int sbuf_trim(struct sbuf *);