Code

data: Let sdb_data_format() return the number of bytes written.
[sysdb.git] / src / include / core / data.h
index 54a2ed2d0d703bec5e227dfaafa53ad136753781..230c1c9f887cd434b7c34bd74edf72ec12b88a5d 100644 (file)
@@ -29,7 +29,6 @@
 #define SDB_CORE_DATA_H 1
 
 #include "core/time.h"
-#include "utils/strbuf.h"
 
 #include <inttypes.h>
 #include <stddef.h>
@@ -112,15 +111,19 @@ sdb_data_strlen(sdb_data_t *datum);
 
 /*
  * sdb_data_format:
- * Append the specified datum to the specified string buffer using a default
- * format.
+ * Output the specified datum to the specified string using a default format.
+ * If the buffer size is less than the return value of sdb_data_strlen, the
+ * datum may be truncated. The buffer will always be nul-terminated after
+ * calling this function.
  *
  * Returns:
- *  - 0 on success
+ *  - the number of characters written to the buffer (excluding the terminated
+ *    null byte) or the number of characters which would have been written in
+ *    case the output was truncated
  *  - a negative value else
  */
 int
-sdb_data_format(sdb_data_t *datum, sdb_strbuf_t *buf);
+sdb_data_format(sdb_data_t *datum, char *buf, size_t buflen);
 
 #ifdef __cplusplus
 } /* extern "C" */