#include <json/json.h>
#include "cache.h"
+#include "list.h"
#include "lp_ws.h"
#include "lp_json.h"
#include "ppastats.h"
return NULL;
}
+static void **list_add_list(void **list1, void **list2)
+{
+ int n1, n2, n;
+ void **list;
+
+ n1 = list_length(list1);
+ n2 = list_length(list2);
+
+ n = n1 + n2 + 1;
+
+ list = malloc(sizeof(void *)*(n+1));
+
+ memcpy(list, list1, n1*sizeof(void *));
+ memcpy(list+n1, list2, n2*sizeof(void *));
+
+ list[n1+n2] = NULL;
+
+ free(list1);
+
+ return list;
+}
+
+#define json_object_to_bpph_list \
+json_object_to_binary_package_publishing_history_list
+
struct binary_package_publishing_history * *
get_binary_package_publishing_history_list(const char *archive_url,
const char *package_status)
{
+ struct json_object *o_next;
char *url = malloc(strlen(archive_url)+
strlen(QUERY_GET_PUBLISHED_BINARIES)+
strlen("&status=")+
9+
1);
json_object *o;
- struct binary_package_publishing_history **result;
+ void **result = NULL;
strcpy(url, archive_url);
strcat(url, QUERY_GET_PUBLISHED_BINARIES);
-
if (package_status) {
strcat(url, "&status=");
strcat(url, package_status);
}
- o = get_json_object(url);
- free(url);
+ while (url) {
+ o = get_json_object(url);
+ free(url);
+ url = NULL;
- if (!o)
- return NULL;
+ if (!o)
+ break;
- result = json_object_to_binary_package_publishing_history_list(o);
+ result = list_add_list(result,
+ (void **)json_object_to_bpph_list(o));
- json_object_put(o);
+ o_next = json_object_object_get(o, "next_collection_link");
- return result;
+ if (o_next)
+ url = strdup(json_object_get_string(o_next));
+
+ json_object_put(o);
+ }
+
+ return (struct binary_package_publishing_history **)result;
}
int get_download_count(const char *archive_url)