return json_object_object_add(json, name, object);
}
+int pakfire_json_add_stringf(struct json_object* json,
+ const char* name, const char* format, ...) {
+ char* buffer = NULL;
+ va_list args;
+ int r;
+
+ // Format the input
+ va_start(args, format);
+ r = vasprintf(&buffer, format, args);
+ va_end(args);
+ if (r < 0)
+ return r;
+
+ // Add the string
+ r = pakfire_json_add_stringn(json, name, buffer, r);
+
+ // Cleanup
+ free(buffer);
+
+ return r;
+}
+
int pakfire_json_add_string_array(struct json_object* json, const char* name, char** array) {
int r = 1;
int pakfire_json_add_string(struct json_object* json, const char* name, const char* value);
int pakfire_json_add_stringn(struct json_object* json, const char* name, const char* value, size_t length);
+int pakfire_json_add_stringf(struct json_object* json, const char* name, const char* format, ...)
+ __attribute__((format(printf, 3, 4)));
int pakfire_json_add_int64(struct json_object* json, const char* name, int64_t value);
int pakfire_json_add_uint64(struct json_object* json, const char* name, uint64_t value);
int pakfire_json_add_double(struct json_object* json, const char* name, double value);