diff options
| author | 2023-08-08 19:29:34 +0200 | |
|---|---|---|
| committer | 2023-08-08 19:29:34 +0200 | |
| commit | 3e5bb109d14e194958a448a0e2feb55f685afaf2 (patch) | |
| tree | fb032c24cef0b1ad6c5c41651fff2be6f203fe92 /mastoapi.c | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | snac2-3e5bb109d14e194958a448a0e2feb55f685afaf2.tar.gz snac2-3e5bb109d14e194958a448a0e2feb55f685afaf2.tar.xz snac2-3e5bb109d14e194958a448a0e2feb55f685afaf2.zip | |
Renamed json dump functions to new xs spec.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 40 |
1 files changed, 20 insertions, 20 deletions
| @@ -39,7 +39,7 @@ int app_add(const char *id, const xs_dict *app) | |||
| 39 | fn = xs_str_cat(fn, ".json"); | 39 | fn = xs_str_cat(fn, ".json"); |
| 40 | 40 | ||
| 41 | if ((f = fopen(fn, "w")) != NULL) { | 41 | if ((f = fopen(fn, "w")) != NULL) { |
| 42 | xs_json_dump_pp(app, 4, f); | 42 | xs_json_dump(app, 4, f); |
| 43 | fclose(f); | 43 | fclose(f); |
| 44 | } | 44 | } |
| 45 | else | 45 | else |
| @@ -102,7 +102,7 @@ int token_add(const char *id, const xs_dict *token) | |||
| 102 | fn = xs_str_cat(fn, ".json"); | 102 | fn = xs_str_cat(fn, ".json"); |
| 103 | 103 | ||
| 104 | if ((f = fopen(fn, "w")) != NULL) { | 104 | if ((f = fopen(fn, "w")) != NULL) { |
| 105 | xs_json_dump_pp(token, 4, f); | 105 | xs_json_dump(token, 4, f); |
| 106 | fclose(f); | 106 | fclose(f); |
| 107 | } | 107 | } |
| 108 | else | 108 | else |
| @@ -358,7 +358,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 358 | if (!xs_is_null(scope)) | 358 | if (!xs_is_null(scope)) |
| 359 | rsp = xs_dict_append(rsp, "scope", scope); | 359 | rsp = xs_dict_append(rsp, "scope", scope); |
| 360 | 360 | ||
| 361 | *body = xs_json_dumps_pp(rsp, 4); | 361 | *body = xs_json_dumps(rsp, 4); |
| 362 | *ctype = "application/json"; | 362 | *ctype = "application/json"; |
| 363 | status = 200; | 363 | status = 200; |
| 364 | 364 | ||
| @@ -962,7 +962,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 962 | 962 | ||
| 963 | acct = xs_dict_append(acct, "avatar", avatar); | 963 | acct = xs_dict_append(acct, "avatar", avatar); |
| 964 | 964 | ||
| 965 | *body = xs_json_dumps_pp(acct, 4); | 965 | *body = xs_json_dumps(acct, 4); |
| 966 | *ctype = "application/json"; | 966 | *ctype = "application/json"; |
| 967 | status = 200; | 967 | status = 200; |
| 968 | } | 968 | } |
| @@ -989,7 +989,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 989 | res = xs_list_append(res, rel); | 989 | res = xs_list_append(res, rel); |
| 990 | } | 990 | } |
| 991 | 991 | ||
| 992 | *body = xs_json_dumps_pp(res, 4); | 992 | *body = xs_json_dumps(res, 4); |
| 993 | *ctype = "application/json"; | 993 | *ctype = "application/json"; |
| 994 | status = 200; | 994 | status = 200; |
| 995 | } | 995 | } |
| @@ -1132,7 +1132,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1132 | } | 1132 | } |
| 1133 | 1133 | ||
| 1134 | if (out != NULL) { | 1134 | if (out != NULL) { |
| 1135 | *body = xs_json_dumps_pp(out, 4); | 1135 | *body = xs_json_dumps(out, 4); |
| 1136 | *ctype = "application/json"; | 1136 | *ctype = "application/json"; |
| 1137 | status = 200; | 1137 | status = 200; |
| 1138 | } | 1138 | } |
| @@ -1222,7 +1222,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1222 | cnt++; | 1222 | cnt++; |
| 1223 | } | 1223 | } |
| 1224 | 1224 | ||
| 1225 | *body = xs_json_dumps_pp(out, 4); | 1225 | *body = xs_json_dumps(out, 4); |
| 1226 | *ctype = "application/json"; | 1226 | *ctype = "application/json"; |
| 1227 | status = 200; | 1227 | status = 200; |
| 1228 | 1228 | ||
| @@ -1277,7 +1277,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1277 | } | 1277 | } |
| 1278 | } | 1278 | } |
| 1279 | 1279 | ||
| 1280 | *body = xs_json_dumps_pp(out, 4); | 1280 | *body = xs_json_dumps(out, 4); |
| 1281 | *ctype = "application/json"; | 1281 | *ctype = "application/json"; |
| 1282 | status = 200; | 1282 | status = 200; |
| 1283 | } | 1283 | } |
| @@ -1360,7 +1360,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1360 | out = xs_list_append(out, mn); | 1360 | out = xs_list_append(out, mn); |
| 1361 | } | 1361 | } |
| 1362 | 1362 | ||
| 1363 | *body = xs_json_dumps_pp(out, 4); | 1363 | *body = xs_json_dumps(out, 4); |
| 1364 | *ctype = "application/json"; | 1364 | *ctype = "application/json"; |
| 1365 | status = 200; | 1365 | status = 200; |
| 1366 | } | 1366 | } |
| @@ -1498,7 +1498,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1498 | } | 1498 | } |
| 1499 | } | 1499 | } |
| 1500 | 1500 | ||
| 1501 | *body = xs_json_dumps_pp(ins, 4); | 1501 | *body = xs_json_dumps(ins, 4); |
| 1502 | *ctype = "application/json"; | 1502 | *ctype = "application/json"; |
| 1503 | status = 200; | 1503 | status = 200; |
| 1504 | } | 1504 | } |
| @@ -1597,7 +1597,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1597 | srv_debug(1, xs_fmt("mastoapi status: bad id %s", id)); | 1597 | srv_debug(1, xs_fmt("mastoapi status: bad id %s", id)); |
| 1598 | 1598 | ||
| 1599 | if (out != NULL) { | 1599 | if (out != NULL) { |
| 1600 | *body = xs_json_dumps_pp(out, 4); | 1600 | *body = xs_json_dumps(out, 4); |
| 1601 | *ctype = "application/json"; | 1601 | *ctype = "application/json"; |
| 1602 | status = 200; | 1602 | status = 200; |
| 1603 | } | 1603 | } |
| @@ -1661,7 +1661,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1661 | res = xs_dict_append(res, "statuses", stl); | 1661 | res = xs_dict_append(res, "statuses", stl); |
| 1662 | res = xs_dict_append(res, "hashtags", htl); | 1662 | res = xs_dict_append(res, "hashtags", htl); |
| 1663 | 1663 | ||
| 1664 | *body = xs_json_dumps_pp(res, 4); | 1664 | *body = xs_json_dumps(res, 4); |
| 1665 | *ctype = "application/json"; | 1665 | *ctype = "application/json"; |
| 1666 | status = 200; | 1666 | status = 200; |
| 1667 | } | 1667 | } |
| @@ -1739,7 +1739,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1739 | app = xs_dict_append(app, "vapid_key", vkey); | 1739 | app = xs_dict_append(app, "vapid_key", vkey); |
| 1740 | app = xs_dict_append(app, "id", id); | 1740 | app = xs_dict_append(app, "id", id); |
| 1741 | 1741 | ||
| 1742 | *body = xs_json_dumps_pp(app, 4); | 1742 | *body = xs_json_dumps(app, 4); |
| 1743 | *ctype = "application/json"; | 1743 | *ctype = "application/json"; |
| 1744 | status = 200; | 1744 | status = 200; |
| 1745 | 1745 | ||
| @@ -1828,7 +1828,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1828 | /* convert to a mastodon status as a response code */ | 1828 | /* convert to a mastodon status as a response code */ |
| 1829 | xs *st = mastoapi_status(&snac, msg); | 1829 | xs *st = mastoapi_status(&snac, msg); |
| 1830 | 1830 | ||
| 1831 | *body = xs_json_dumps_pp(st, 4); | 1831 | *body = xs_json_dumps(st, 4); |
| 1832 | *ctype = "application/json"; | 1832 | *ctype = "application/json"; |
| 1833 | status = 200; | 1833 | status = 200; |
| 1834 | } | 1834 | } |
| @@ -1924,7 +1924,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1924 | } | 1924 | } |
| 1925 | 1925 | ||
| 1926 | if (out != NULL) { | 1926 | if (out != NULL) { |
| 1927 | *body = xs_json_dumps_pp(out, 4); | 1927 | *body = xs_json_dumps(out, 4); |
| 1928 | *ctype = "application/json"; | 1928 | *ctype = "application/json"; |
| 1929 | status = 200; | 1929 | status = 200; |
| 1930 | } | 1930 | } |
| @@ -1967,7 +1967,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1967 | xs *server_key = random_str(); | 1967 | xs *server_key = random_str(); |
| 1968 | wpush = xs_dict_append(wpush, "server_key", server_key); | 1968 | wpush = xs_dict_append(wpush, "server_key", server_key); |
| 1969 | 1969 | ||
| 1970 | *body = xs_json_dumps_pp(wpush, 4); | 1970 | *body = xs_json_dumps(wpush, 4); |
| 1971 | *ctype = "application/json"; | 1971 | *ctype = "application/json"; |
| 1972 | status = 200; | 1972 | status = 200; |
| 1973 | } | 1973 | } |
| @@ -2010,7 +2010,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2010 | rsp = xs_dict_append(rsp, "remote_url", url); | 2010 | rsp = xs_dict_append(rsp, "remote_url", url); |
| 2011 | rsp = xs_dict_append(rsp, "description", desc); | 2011 | rsp = xs_dict_append(rsp, "description", desc); |
| 2012 | 2012 | ||
| 2013 | *body = xs_json_dumps_pp(rsp, 4); | 2013 | *body = xs_json_dumps(rsp, 4); |
| 2014 | *ctype = "application/json"; | 2014 | *ctype = "application/json"; |
| 2015 | status = 200; | 2015 | status = 200; |
| 2016 | } | 2016 | } |
| @@ -2095,7 +2095,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2095 | } | 2095 | } |
| 2096 | 2096 | ||
| 2097 | if (rsp != NULL) { | 2097 | if (rsp != NULL) { |
| 2098 | *body = xs_json_dumps_pp(rsp, 4); | 2098 | *body = xs_json_dumps(rsp, 4); |
| 2099 | *ctype = "application/json"; | 2099 | *ctype = "application/json"; |
| 2100 | status = 200; | 2100 | status = 200; |
| 2101 | } | 2101 | } |
| @@ -2157,7 +2157,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2157 | } | 2157 | } |
| 2158 | 2158 | ||
| 2159 | if (out != NULL) { | 2159 | if (out != NULL) { |
| 2160 | *body = xs_json_dumps_pp(out, 4); | 2160 | *body = xs_json_dumps(out, 4); |
| 2161 | *ctype = "application/json"; | 2161 | *ctype = "application/json"; |
| 2162 | status = 200; | 2162 | status = 200; |
| 2163 | } | 2163 | } |
| @@ -2226,7 +2226,7 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 2226 | rsp = xs_dict_append(rsp, "remote_url", url); | 2226 | rsp = xs_dict_append(rsp, "remote_url", url); |
| 2227 | rsp = xs_dict_append(rsp, "description", desc); | 2227 | rsp = xs_dict_append(rsp, "description", desc); |
| 2228 | 2228 | ||
| 2229 | *body = xs_json_dumps_pp(rsp, 4); | 2229 | *body = xs_json_dumps(rsp, 4); |
| 2230 | *ctype = "application/json"; | 2230 | *ctype = "application/json"; |
| 2231 | status = 200; | 2231 | status = 200; |
| 2232 | } | 2232 | } |