Add saxdb_write_sint() to handle signed values.
[srvx.git] / src / saxdb.c
index 6439af0dfac95daa15621275363e6b8cf60edae6..bfb93ca2e3a046921af89206b067a9e115c308dc 100644 (file)
@@ -302,6 +302,14 @@ saxdb_write_int(struct saxdb_context *dest, const char *name, unsigned long valu
     saxdb_write_string(dest, name, buf);
 }
 
+void
+saxdb_write_sint(struct saxdb_context *dest, const char *name, long value) {
+    char buf[16];
+    /* we could optimize this to take advantage of the fact that buf will never need escapes */
+    snprintf(buf, sizeof(buf), "%ld", value);
+    saxdb_write_string(dest, name, buf);
+}
+
 static void
 saxdb_free(void *data) {
     struct saxdb *db = data;