mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
Added xs_json_load() wherever possible.
This commit is contained in:
parent
381a2f5b7b
commit
15f755960b
2 changed files with 21 additions and 41 deletions
31
data.c
31
data.c
|
@ -595,13 +595,9 @@ int object_get_by_md5(const char *md5, xs_dict **obj)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
flock(fileno(f), LOCK_SH);
|
*obj = xs_json_load(f);
|
||||||
|
|
||||||
xs *j = xs_readall(f);
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
*obj = xs_json_loads(j);
|
|
||||||
|
|
||||||
if (*obj)
|
if (*obj)
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
@ -1012,12 +1008,10 @@ int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg)
|
||||||
xs *fn = timeline_fn_by_md5(snac, md5);
|
xs *fn = timeline_fn_by_md5(snac, md5);
|
||||||
|
|
||||||
if (fn != NULL && (f = fopen(fn, "r")) != NULL) {
|
if (fn != NULL && (f = fopen(fn, "r")) != NULL) {
|
||||||
flock(fileno(f), LOCK_SH);
|
*msg = xs_json_load(f);
|
||||||
|
|
||||||
xs *j = xs_readall(f);
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if ((*msg = xs_json_loads(j)) != NULL)
|
if (*msg != NULL)
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1234,11 +1228,8 @@ int following_get(snac *snac, const char *actor, xs_dict **data)
|
||||||
int status = 200;
|
int status = 200;
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
xs *j = xs_readall(f);
|
*data = xs_json_load(f);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
*data = xs_json_loads(j);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = 404;
|
status = 404;
|
||||||
|
@ -1263,12 +1254,9 @@ xs_list *following_list(snac *snac)
|
||||||
|
|
||||||
/* load the follower data */
|
/* load the follower data */
|
||||||
if ((f = fopen(v, "r")) != NULL) {
|
if ((f = fopen(v, "r")) != NULL) {
|
||||||
xs *j = xs_readall(f);
|
xs *o = xs_json_load(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (j != NULL) {
|
|
||||||
xs *o = xs_json_loads(j);
|
|
||||||
|
|
||||||
if (o != NULL) {
|
if (o != NULL) {
|
||||||
const char *type = xs_dict_get(o, "type");
|
const char *type = xs_dict_get(o, "type");
|
||||||
|
|
||||||
|
@ -1291,7 +1279,6 @@ xs_list *following_list(snac *snac)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -1896,10 +1883,8 @@ xs_dict *notify_get(snac *snac, const char *id)
|
||||||
xs_dict *out = NULL;
|
xs_dict *out = NULL;
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
xs *j = xs_readall(f);
|
out = xs_json_load(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
out = xs_json_loads(j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -2231,9 +2216,7 @@ xs_dict *queue_get(const char *fn)
|
||||||
xs_dict *obj = NULL;
|
xs_dict *obj = NULL;
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
xs *j = xs_readall(f);
|
obj = xs_json_load(f);
|
||||||
obj = xs_json_loads(j);
|
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,9 @@ xs_dict *app_get(const char *id)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
xs *j = xs_readall(f);
|
app = xs_json_load(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
app = xs_json_loads(j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
|
@ -124,10 +123,8 @@ xs_dict *token_get(const char *id)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
xs *j = xs_readall(f);
|
token = xs_json_load(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
token = xs_json_loads(j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
|
|
Loading…
Reference in a new issue