mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Use xs_glob() in follower_list().
This commit is contained in:
parent
53c62db73d
commit
365b27ffb2
1 changed files with 13 additions and 17 deletions
30
data.c
30
data.c
|
@ -256,34 +256,30 @@ int follower_check(snac *snac, char *actor)
|
||||||
d_char *follower_list(snac *snac)
|
d_char *follower_list(snac *snac)
|
||||||
/* returns the list of followers */
|
/* returns the list of followers */
|
||||||
{
|
{
|
||||||
d_char *list;
|
xs *spec = xs_fmt("%s/followers/" "*.json", snac->basedir);
|
||||||
xs *spec;
|
xs *glist = xs_glob(spec, 0, 0);
|
||||||
glob_t globbuf;
|
char *p, *v;
|
||||||
|
d_char *list = xs_list_new();
|
||||||
|
|
||||||
list = xs_list_new();
|
/* iterate the list of files */
|
||||||
spec = xs_fmt("%s/followers/" "*.json", snac->basedir);
|
p = glist;
|
||||||
|
while (xs_list_iter(&p, &v)) {
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
if (glob(spec, 0, NULL, &globbuf) == 0) {
|
/* load the follower data */
|
||||||
int n;
|
if ((f = fopen(v, "r")) != NULL) {
|
||||||
char *fn;
|
xs *j = xs_readall(f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
for (n = 0; (fn = globbuf.gl_pathv[n]) != NULL; n++) {
|
if (j != NULL) {
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
|
||||||
xs *j = xs_readall(f);
|
|
||||||
xs *o = xs_json_loads(j);
|
xs *o = xs_json_loads(j);
|
||||||
|
|
||||||
if (o != NULL)
|
if (o != NULL)
|
||||||
list = xs_list_append(list, o);
|
list = xs_list_append(list, o);
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globfree(&globbuf);
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue