summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
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)
643 if ((f = fopen(fn, "w")) != NULL) { 643 if ((f = fopen(fn, "w")) != NULL) {
644 flock(fileno(f), LOCK_EX); 644 flock(fileno(f), LOCK_EX);
645 645
646 xs *j = xs_json_dumps_pp(obj, 4); 646 xs_json_dump_pp(obj, 4, f);
647
648 fwrite(j, strlen(j), 1, f);
649 fclose(f); 647 fclose(f);
650 648
651 /* does this object has a parent? */ 649 /* does this object has a parent? */
@@ -1190,9 +1188,7 @@ int following_add(snac *snac, const char *actor, const xs_dict *msg)
1190 FILE *f; 1188 FILE *f;
1191 1189
1192 if ((f = fopen(fn, "w")) != NULL) { 1190 if ((f = fopen(fn, "w")) != NULL) {
1193 xs *j = xs_json_dumps_pp(msg, 4); 1191 xs_json_dump_pp(msg, 4, f);
1194
1195 fwrite(j, 1, strlen(j), f);
1196 fclose(f); 1192 fclose(f);
1197 1193
1198 /* get the filename of the actor object */ 1194 /* get the filename of the actor object */
@@ -1893,9 +1889,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
1893 noti = xs_dict_append(noti, "objid", objid); 1889 noti = xs_dict_append(noti, "objid", objid);
1894 1890
1895 if ((f = fopen(fn, "w")) != NULL) { 1891 if ((f = fopen(fn, "w")) != NULL) {
1896 xs *j = xs_json_dumps_pp(noti, 4); 1892 xs_json_dump_pp(noti, 4, f);
1897
1898 fwrite(j, strlen(j), 1, f);
1899 fclose(f); 1893 fclose(f);
1900 } 1894 }
1901} 1895}
@@ -1970,9 +1964,7 @@ static xs_dict *_enqueue_put(const char *fn, xs_dict *msg)
1970 FILE *f; 1964 FILE *f;
1971 1965
1972 if ((f = fopen(tfn, "w")) != NULL) { 1966 if ((f = fopen(tfn, "w")) != NULL) {
1973 xs *j = xs_json_dumps_pp(msg, 4); 1967 xs_json_dump_pp(msg, 4, f);
1974
1975 fwrite(j, strlen(j), 1, f);
1976 fclose(f); 1968 fclose(f);
1977 1969
1978 rename(tfn, fn); 1970 rename(tfn, fn);
@@ -2569,8 +2561,7 @@ void srv_archive_error(const char *prefix, const xs_str *err,
2569 if (req) { 2561 if (req) {
2570 fprintf(f, "Request headers:\n"); 2562 fprintf(f, "Request headers:\n");
2571 2563
2572 xs *j = xs_json_dumps_pp(req, 4); 2564 xs_json_dump_pp(req, 4, f);
2573 fwrite(j, strlen(j), 1, f);
2574 2565
2575 fprintf(f, "\n"); 2566 fprintf(f, "\n");
2576 } 2567 }
@@ -2579,8 +2570,7 @@ void srv_archive_error(const char *prefix, const xs_str *err,
2579 fprintf(f, "Data:\n"); 2570 fprintf(f, "Data:\n");
2580 2571
2581 if (xs_type(data) == XSTYPE_LIST || xs_type(data) == XSTYPE_DICT) { 2572 if (xs_type(data) == XSTYPE_LIST || xs_type(data) == XSTYPE_DICT) {
2582 xs *j = xs_json_dumps_pp(data, 4); 2573 xs_json_dump_pp(data, 4, f);
2583 fwrite(j, strlen(j), 1, f);
2584 } 2574 }
2585 else 2575 else
2586 fprintf(f, "%s", data); 2576 fprintf(f, "%s", data);