summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/data.c b/data.c
index cf266fb..a0fe787 100644
--- a/data.c
+++ b/data.c
@@ -256,34 +256,30 @@ int follower_check(snac *snac, char *actor)
256d_char *follower_list(snac *snac) 256d_char *follower_list(snac *snac)
257/* returns the list of followers */ 257/* returns the list of followers */
258{ 258{
259 d_char *list; 259 xs *spec = xs_fmt("%s/followers/" "*.json", snac->basedir);
260 xs *spec; 260 xs *glist = xs_glob(spec, 0, 0);
261 glob_t globbuf; 261 char *p, *v;
262 262 d_char *list = xs_list_new();
263 list = xs_list_new();
264 spec = xs_fmt("%s/followers/" "*.json", snac->basedir);
265 263
266 if (glob(spec, 0, NULL, &globbuf) == 0) { 264 /* iterate the list of files */
267 int n; 265 p = glist;
268 char *fn; 266 while (xs_list_iter(&p, &v)) {
267 FILE *f;
269 268
270 for (n = 0; (fn = globbuf.gl_pathv[n]) != NULL; n++) { 269 /* load the follower data */
271 FILE *f; 270 if ((f = fopen(v, "r")) != NULL) {
271 xs *j = xs_readall(f);
272 fclose(f);
272 273
273 if ((f = fopen(fn, "r")) != NULL) { 274 if (j != NULL) {
274 xs *j = xs_readall(f);
275 xs *o = xs_json_loads(j); 275 xs *o = xs_json_loads(j);
276 276
277 if (o != NULL) 277 if (o != NULL)
278 list = xs_list_append(list, o); 278 list = xs_list_append(list, o);
279
280 fclose(f);
281 } 279 }
282 } 280 }
283 } 281 }
284 282
285 globfree(&globbuf);
286
287 return list; 283 return list;
288} 284}
289 285