summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-03 09:02:08 +0200
committerdefault <nobody@localhost>2023-08-03 09:02:08 +0200
commitf5a3dbf8d652dbf87f9ff27b50d11f6364551a61 (patch)
treea3c8fabb5baa25bde203a9cc8089134b8774d723 /data.c
parent2137d2f13310aca3cef6a0fc7735fdf4aac53e8c (diff)
Use xs_json_dump_pp() wherever possible.
Diffstat (limited to 'data.c')
-rw-r--r--data.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/data.c b/data.c
index 62e326c..80200d2 100644
--- a/data.c
+++ b/data.c
@@ -643,9 +643,7 @@ int _object_add(const char *id, const xs_dict *obj, int ow)
if ((f = fopen(fn, "w")) != NULL) {
flock(fileno(f), LOCK_EX);
- xs *j = xs_json_dumps_pp(obj, 4);
-
- fwrite(j, strlen(j), 1, f);
+ xs_json_dump_pp(obj, 4, f);
fclose(f);
/* does this object has a parent? */
@@ -1190,9 +1188,7 @@ int following_add(snac *snac, const char *actor, const xs_dict *msg)
FILE *f;
if ((f = fopen(fn, "w")) != NULL) {
- xs *j = xs_json_dumps_pp(msg, 4);
-
- fwrite(j, 1, strlen(j), f);
+ xs_json_dump_pp(msg, 4, f);
fclose(f);
/* get the filename of the actor object */
@@ -1893,9 +1889,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
noti = xs_dict_append(noti, "objid", objid);
if ((f = fopen(fn, "w")) != NULL) {
- xs *j = xs_json_dumps_pp(noti, 4);
-
- fwrite(j, strlen(j), 1, f);
+ xs_json_dump_pp(noti, 4, f);
fclose(f);
}
}
@@ -1970,9 +1964,7 @@ static xs_dict *_enqueue_put(const char *fn, xs_dict *msg)
FILE *f;
if ((f = fopen(tfn, "w")) != NULL) {
- xs *j = xs_json_dumps_pp(msg, 4);
-
- fwrite(j, strlen(j), 1, f);
+ xs_json_dump_pp(msg, 4, f);
fclose(f);
rename(tfn, fn);
@@ -2569,8 +2561,7 @@ void srv_archive_error(const char *prefix, const xs_str *err,
if (req) {
fprintf(f, "Request headers:\n");
- xs *j = xs_json_dumps_pp(req, 4);
- fwrite(j, strlen(j), 1, f);
+ xs_json_dump_pp(req, 4, f);
fprintf(f, "\n");
}
@@ -2579,8 +2570,7 @@ void srv_archive_error(const char *prefix, const xs_str *err,
fprintf(f, "Data:\n");
if (xs_type(data) == XSTYPE_LIST || xs_type(data) == XSTYPE_DICT) {
- xs *j = xs_json_dumps_pp(data, 4);
- fwrite(j, strlen(j), 1, f);
+ xs_json_dump_pp(data, 4, f);
}
else
fprintf(f, "%s", data);