+static char *get_bpph_list_cache_key(const char *archive_url)
+{
+ char *key;
+
+ key = malloc(strlen(archive_url + 7) + strlen("/bpph") + 1);
+ sprintf(key, "%s/bpph", archive_url + 7);
+
+ return key;
+}
+
+static struct bpph **get_bpph_list_from_cache(const char *key)
+{
+ char *content;
+ struct bpph **list;
+ json_object *json;
+
+ content = fcache_get(key);
+ if (!content)
+ return NULL;
+
+ json = json_tokener_parse(content);
+ if (!json)
+ return NULL;
+
+ list = json_object_to_bpph_list(json);
+
+ json_object_put(json);
+ free(content);
+
+ return list;
+}
+
+static char *get_last_creation_date(struct bpph **list)
+{
+ time_t last, t;
+ struct bpph **cur;
+
+ last = 0;
+
+ if (list)
+ for (cur = list; *cur; cur++) {
+ t = (*cur)->date_created;
+ if (t > last)
+ last = t;
+ }
+
+ if (last)
+ return time_to_str(last);
+ else
+ return NULL;
+}
+
+/**
+ * 'archive_url': LP URL of the archive.
+ * 'size': size of the reply array. Between 1-300, else default value is used.
+ */
+static char *create_query_get_bpph(const char *archive_url,
+ const char *status,
+ int size)
+{
+ static const char *default_opt = "?ws.op=getPublishedBinaries&ws.size=";
+ static const char *status_opt = "&status=";
+ char *url;
+ int n;
+
+ if (size < 1 || size > 300)
+ size = DEFAULT_WS_SIZE;
+
+ n = strlen(archive_url) + strlen(default_opt) + 3 + 1;
+
+ if (status)
+ n += strlen(status_opt) + strlen(status);
+
+ url = malloc(n);
+ sprintf(url, "%s%s%d", archive_url, default_opt, size);
+
+ if (status) {
+ strcat(url, status_opt);
+ strcat(url, status);
+ }
+
+ return url;
+}
+