X-Git-Url: http://git.wpitchoune.net/gitweb/?p=ppastats.git;a=blobdiff_plain;f=src%2Flp_ws.c;h=a813b3396bae030f87c8e48c0aa9d1963fea1aa9;hp=20443716c0790ffc3f9d34d7e5f1782d667c232d;hb=60892f2ef45fa1ee656e1a00cac0578f9d6f9536;hpb=c1699160bcf64cf0b559c713a22720183a9f8934 diff --git a/src/lp_ws.c b/src/lp_ws.c index 2044371..a813b33 100644 --- a/src/lp_ws.c +++ b/src/lp_ws.c @@ -20,6 +20,7 @@ #include #define _(String) gettext(String) +#include #include #include @@ -60,10 +61,9 @@ static json_object *get_json_object(const char *url) struct bpph **get_bpph_list(const char *archive_url, const char *pkg_status) { - struct json_object *o_next; - char *url; - json_object *o; - void **result = NULL; + char *url, *bpph_key; + struct bpph **result = NULL; + struct json_object *o, *bpph_json, *o_next; url = malloc(strlen(archive_url)+ strlen(QUERY_GET_PUBLISHED_BINARIES)+ @@ -86,8 +86,9 @@ struct bpph **get_bpph_list(const char *archive_url, const char *pkg_status) if (!o) break; - result = list_append_list(result, - (void **)json_object_to_bpph_list(o)); + result = (struct bpph **)list_append_list + ((void **)result, + (void **)json_object_to_bpph_list(o)); o_next = json_object_object_get(o, "next_collection_link"); @@ -97,7 +98,16 @@ struct bpph **get_bpph_list(const char *archive_url, const char *pkg_status) json_object_put(o); } - return (struct bpph **)result; + bpph_json = bpph_list_to_json(result); + + bpph_key = malloc(strlen(archive_url + 7) + strlen("/bpph") + 1); + sprintf(bpph_key, "%s/bpph", archive_url + 7); + fcache_put(bpph_key, json_object_to_json_string(bpph_json)); + + json_object_put(bpph_json); + free(bpph_key); + + return result; } int get_download_count(const char *archive_url)