diff options
Diffstat (limited to 'upgrade.c')
-rw-r--r-- | upgrade.c | 73 |
1 files changed, 49 insertions, 24 deletions
@@ -18,7 +18,7 @@ int snac_upgrade(xs_str **error) double f = 0.0; for (;;) { - char *layout = xs_dict_get(srv_config, "layout"); + const char *layout = xs_dict_get(srv_config, "layout"); double nf; f = nf = xs_number_get(layout); @@ -43,7 +43,8 @@ int snac_upgrade(xs_str **error) else if (f < 2.2) { xs *users = user_list(); - char *p, *v; + char *p; + const char *v; p = users; while (xs_list_iter(&p, &v)) { @@ -52,12 +53,13 @@ int snac_upgrade(xs_str **error) if (user_open(&snac, v)) { xs *spec = xs_fmt("%s/actors/" "*.json", snac.basedir); xs *list = xs_glob(spec, 0, 0); - char *g, *fn; + char *g; + const char *fn; g = list; while (xs_list_iter(&g, &fn)) { - xs *l = xs_split(fn, "/"); - char *b = xs_list_get(l, -1); + xs *l = xs_split(fn, "/"); + const char *b = xs_list_get(l, -1); xs *dir = xs_fmt("%s/object/%c%c", srv_basedir, b[0], b[1]); xs *nfn = xs_fmt("%s/%s", dir, b); @@ -77,14 +79,16 @@ int snac_upgrade(xs_str **error) else if (f < 2.3) { xs *users = user_list(); - char *p, *v; + char *p; + const char *v; p = users; while (xs_list_iter(&p, &v)) { snac snac; if (user_open(&snac, v)) { - char *p, *v; + char *p; + const char *v; xs *dir = xs_fmt("%s/hidden", snac.basedir); /* create the hidden directory */ @@ -109,7 +113,8 @@ int snac_upgrade(xs_str **error) else if (f < 2.4) { xs *users = user_list(); - char *p, *v; + char *p; + const char *v; p = users; while (xs_list_iter(&p, &v)) { @@ -132,7 +137,8 @@ int snac_upgrade(xs_str **error) if (f < 2.5) { /* upgrade followers */ xs *users = user_list(); - char *p, *v; + char *p; + const char *v; p = users; while (xs_list_iter(&p, &v)) { @@ -141,7 +147,8 @@ int snac_upgrade(xs_str **error) if (user_open(&snac, v)) { xs *spec = xs_fmt("%s/followers/" "*.json", snac.basedir); xs *dir = xs_glob(spec, 0, 0); - char *p, *v; + char *p; + const char *v; p = dir; while (xs_list_iter(&p, &v)) { @@ -152,12 +159,12 @@ int snac_upgrade(xs_str **error) xs *o = xs_json_loads(s); fclose(f); - char *type = xs_dict_get(o, "type"); + const char *type = xs_dict_get(o, "type"); if (!xs_is_null(type) && strcmp(type, "Follow") == 0) { unlink(v); - char *actor = xs_dict_get(o, "actor"); + const char *actor = xs_dict_get(o, "actor"); if (!xs_is_null(actor)) follower_add(&snac, actor); @@ -175,7 +182,8 @@ int snac_upgrade(xs_str **error) if (f < 2.6) { /* upgrade local/ to public/ */ xs *users = user_list(); - char *p, *v; + char *p; + const char *v; p = users; while (xs_list_iter(&p, &v)) { @@ -184,7 +192,8 @@ int snac_upgrade(xs_str **error) if (user_open(&snac, v)) { xs *spec = xs_fmt("%s/local/" "*.json", snac.basedir); xs *dir = xs_glob(spec, 0, 0); - char *p, *v; + char *p; + const char *v; p = dir; while (xs_list_iter(&p, &v)) { @@ -198,22 +207,29 @@ int snac_upgrade(xs_str **error) xs *meta = xs_dup(xs_dict_get(o, "_snac")); o = xs_dict_del(o, "_snac"); - char *id = xs_dict_get(o, "id"); + const char *id = xs_dict_get(o, "id"); /* store object */ object_add_ow(id, o); /* if it's from us, add to public */ if (xs_startswith(id, snac.actor)) { - char *p, *v; + const xs_list *p; + const char *v; + int c; object_user_cache_add(&snac, id, "public"); p = xs_dict_get(meta, "announced_by"); - while (xs_list_iter(&p, &v)) + + c = 0; + while (xs_list_next(p, &v, &c)) object_admire(id, v, 0); + p = xs_dict_get(meta, "liked_by"); - while (xs_list_iter(&p, &v)) + + c = 0; + while (xs_list_next(p, &v, &c)) object_admire(id, v, 1); } @@ -234,7 +250,8 @@ int snac_upgrade(xs_str **error) if (f < 2.7) { /* upgrade timeline/ to private/ */ xs *users = user_list(); - char *p, *v; + char *p; + const char *v; p = users; while (xs_list_iter(&p, &v)) { @@ -243,7 +260,8 @@ int snac_upgrade(xs_str **error) if (user_open(&snac, v)) { xs *spec = xs_fmt("%s/timeline/" "*.json", snac.basedir); xs *dir = xs_glob(spec, 0, 0); - char *p, *v; + char *p; + const char *v; p = dir; while (xs_list_iter(&p, &v)) { @@ -257,21 +275,28 @@ int snac_upgrade(xs_str **error) xs *meta = xs_dup(xs_dict_get(o, "_snac")); o = xs_dict_del(o, "_snac"); - char *id = xs_dict_get(o, "id"); + const char *id = xs_dict_get(o, "id"); /* store object */ object_add_ow(id, o); { - char *p, *v; + const xs_list *p; + const char *v; + int c = 0; object_user_cache_add(&snac, id, "private"); p = xs_dict_get(meta, "announced_by"); - while (xs_list_iter(&p, &v)) + + c = 0; + while (xs_list_next(p, &v, &c)) object_admire(id, v, 0); + p = xs_dict_get(meta, "liked_by"); - while (xs_list_iter(&p, &v)) + + c = 0; + while (xs_list_next(p, &v, &c)) object_admire(id, v, 1); } |