Code

strbuf utils: Added sdb_strbuf_cap().
[sysdb.git] / src / include / utils / strbuf.h
index ebbd9e3afff3dcc4bf143afa6019114c7cb4038f..20cf8706b53038165e73d7892401eb8066e94b59 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <stdarg.h>
 #include <stdio.h>
+#include <unistd.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -136,6 +137,20 @@ sdb_strbuf_read(sdb_strbuf_t *strbuf, int fd, size_t n);
 ssize_t
 sdb_strbuf_chomp(sdb_strbuf_t *strbuf);
 
+/*
+ * sdb_strbuf_skip:
+ * Removes 'n' bytes from the buffer starting at offset 'offset'.
+ */
+void
+sdb_strbuf_skip(sdb_strbuf_t *strbuf, size_t offset, size_t n);
+
+/*
+ * sdb_strbuf_clear:
+ * Clear the buffer but do not deallocate memory.
+ */
+void
+sdb_strbuf_clear(sdb_strbuf_t *strbuf);
+
 /*
  * sdb_strbuf_string:
  * Returns the content of the string buffer. The caller may not modify the
@@ -151,6 +166,15 @@ sdb_strbuf_string(sdb_strbuf_t *strbuf);
 size_t
 sdb_strbuf_len(sdb_strbuf_t *strbuf);
 
+/*
+ * sdb_strbuf_cap:
+ * Returns the current capacity of the string buffer. It describes the max
+ * length of the buffer's content (including terminating nul byte) that may be
+ * stored in the buffer without resizing it.
+ */
+size_t
+sdb_strbuf_cap(sdb_strbuf_t *strbuf);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif