aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2002-10-04 09:58:17 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2002-10-04 09:58:17 +0000
commitc5f9218b48ead7bd8838450c541449bb221ed9bc (patch)
tree769a78b7fdf83c2fefa71b0a4bfd162f398a203c
parentbafe85a4adc3c0f9405bdf65ddec2771b4cbb4e7 (diff)
downloadsrc-c5f9218b48ead7bd8838450c541449bb221ed9bc.tar.gz
src-c5f9218b48ead7bd8838450c541449bb221ed9bc.zip
Add the new function "sbuf_done()" which returns non-zero if the sbuf is
finished. This allows sbufs to be used for request/response scenarioes without needing additional communication flags. Sponsored by: DARPA & NAI Labs.
Notes
Notes: svn path=/head/; revision=104449
-rw-r--r--share/man/man9/sbuf.95
-rw-r--r--sys/kern/subr_sbuf.c10
-rw-r--r--sys/sys/sbuf.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9
index 8e40f26ab0e5..1aa53240cadb 100644
--- a/share/man/man9/sbuf.9
+++ b/share/man/man9/sbuf.9
@@ -46,6 +46,7 @@
.Nm sbuf_finish ,
.Nm sbuf_data ,
.Nm sbuf_len ,
+.Nm sbuf_done ,
.Nm sbuf_delete
.Nd safe string formatting
.Sh SYNOPSIS
@@ -85,6 +86,8 @@
.Fn sbuf_data "struct sbuf *s"
.Ft int
.Fn sbuf_len "struct sbuf *s"
+.Ft int
+.Fn sbuf_done "struct sbuf *s"
.Ft void
.Fn sbuf_delete "struct sbuf *s"
.Sh DESCRIPTION
@@ -279,6 +282,8 @@ functions return the actual string and its length, respectively;
.Fn sbuf_data
only works on a finished
.Fa sbuf .
+.Fn sbuf_done
+returns non-zero if the sbuf is finished.
.Pp
Finally, the
.Fn sbuf_delete
diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c
index 5892d894781e..9e63e8e7aaf5 100644
--- a/sys/kern/subr_sbuf.c
+++ b/sys/kern/subr_sbuf.c
@@ -558,3 +558,13 @@ sbuf_delete(struct sbuf *s)
if (isdyn)
SBFREE(s);
}
+
+/*
+ * Check if an sbuf has been finished.
+ */
+int
+sbuf_done(struct sbuf *s)
+{
+
+ return(SBUF_ISFINISHED(s));
+}
diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h
index a63603e4e2ea..606c1ca91fee 100644
--- a/sys/sys/sbuf.h
+++ b/sys/sys/sbuf.h
@@ -70,6 +70,7 @@ int sbuf_overflowed(struct sbuf *);
void sbuf_finish(struct sbuf *);
char *sbuf_data(struct sbuf *);
int sbuf_len(struct sbuf *);
+int sbuf_done(struct sbuf *);
void sbuf_delete(struct sbuf *);
#ifdef _KERNEL