From c75862be119ac38a67f841fcc7da339be423973a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sun, 1 Jul 2012 09:30:31 +0000 Subject: [PATCH] added --get-bpph-size to specify the size of the requests to get the list of binary packages. --- NEWS | 3 +++ src/html.c | 5 +++-- src/html.h | 6 +++++- src/lp_ws.c | 10 ++++++---- src/lp_ws.h | 5 ++++- src/main.c | 22 ++++++++++++++++------ src/ppastats.1 | 6 +++++- src/ppastats.c | 5 +++-- src/ppastats.h | 6 +++++- 9 files changed, 50 insertions(+), 18 deletions(-) diff --git a/NEWS b/NEWS index 0d0a887..c02ba43 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,10 @@ * v0.0.8 ** set transfer encoding to gzip as recommended by LP documentation. + Only supported since Curl 7.21.6 ** persistent cache for distro and arch information. ** fixed a '"' in the html output of the package page. +** added --get-bpph-size to specify the size of the requests to get + the list of binary packages. * v0.0.7 ** More crash-resistant on network failure (patch from Peter diff --git a/src/html.c b/src/html.c index a471665..900830a 100644 --- a/src/html.c +++ b/src/html.c @@ -547,7 +547,8 @@ ppa_to_html(const char *owner, const char *ppa, const char *package_status, const char *output_dir, - const int install_static_files) + const int install_static_files, + int ws_size) { struct ppa_stats *ppastats; char *path, *f_dst; @@ -586,7 +587,7 @@ ppa_to_html(const char *owner, free(js_dir); } - ppastats = create_ppa_stats(owner, ppa, package_status); + ppastats = create_ppa_stats(owner, ppa, package_status, ws_size); path = path_new(output_dir, "ppa", ".html"); diff --git a/src/html.h b/src/html.h index 2c4c1ec..45cedb2 100644 --- a/src/html.h +++ b/src/html.h @@ -22,10 +22,14 @@ #include "lp.h" +/* + * 'ws_size': size of the reply array of the getPublishedBinaries request. + */ void ppa_to_html(const char *owner, const char *ppa, const char *package_status, const char *output_dir, - const int install_static_files); + const int install_static_files, + int ws_size); #endif diff --git a/src/lp_ws.c b/src/lp_ws.c index f57aa3b..3086e6f 100644 --- a/src/lp_ws.c +++ b/src/lp_ws.c @@ -112,7 +112,7 @@ static char *get_last_creation_date(struct bpph **list) return NULL; } -/** +/* * 'archive_url': LP URL of the archive. * 'size': size of the reply array. Between 1-300, else default value is used. */ @@ -123,7 +123,7 @@ static char *create_query_get_bpph(const char *archive_url, static const char *default_opt = "?ws.op=getPublishedBinaries&ws.size="; static const char *status_opt = "&status="; char *url; - int n; + size_t n; if (size < 1 || size > 300) size = DEFAULT_WS_SIZE; @@ -144,7 +144,9 @@ static char *create_query_get_bpph(const char *archive_url, return url; } -struct bpph **get_bpph_list(const char *archive_url, const char *pkg_status) +struct bpph **get_bpph_list(const char *archive_url, + const char *pkg_status, + int ws_size) { char *url, *key, *tmp; struct bpph **result; @@ -152,7 +154,7 @@ struct bpph **get_bpph_list(const char *archive_url, const char *pkg_status) char *date; int ok; - url = create_query_get_bpph(archive_url, pkg_status, -1); + url = create_query_get_bpph(archive_url, pkg_status, ws_size); key = get_bpph_list_cache_key(archive_url); diff --git a/src/lp_ws.h b/src/lp_ws.h index 4676939..217ee38 100644 --- a/src/lp_ws.h +++ b/src/lp_ws.h @@ -22,8 +22,11 @@ #include "lp.h" +/* + * 'ws_size': size of the reply array of the getPublishedBinaries request. + */ struct bpph ** -get_bpph_list(const char *archive_url, const char *package_status); +get_bpph_list(const char *archive_url, const char *package_status, int ws_size); int get_download_count(const char *archive_url); diff --git a/src/main.c b/src/main.c index 7bd87fc..8af2dc6 100644 --- a/src/main.c +++ b/src/main.c @@ -37,7 +37,8 @@ static const char *program_name; static void display_published_binaries(const char *owner, const char *ppa, - const char *package_status) + const char *package_status, + int ws_size) { struct ppa_stats *ppastats; struct package_stats **packages; @@ -45,7 +46,7 @@ static void display_published_binaries(const char *owner, struct distro_stats **distros; struct arch_stats **archs; - ppastats = create_ppa_stats(owner, ppa, package_status); + ppastats = create_ppa_stats(owner, ppa, package_status, ws_size); packages = ppastats->packages; while (packages && *packages) { struct package_stats *p = *packages; @@ -94,6 +95,7 @@ static struct option long_options[] = { {"debug", no_argument, 0, 'd'}, {"status", required_argument, 0, 's'}, {"skip-js-css", no_argument, 0, 'S'}, + {"get-bpph-size", required_argument, 0, 0}, {0, 0, 0, 0} }; @@ -134,6 +136,9 @@ static void print_help() puts(_( " -S, --skip-js-css skip installation of js and css files")); + puts(_( +" --get-bpph-size=[s] size of the replies of webservice requests to get\n" +" the list of binary packages. Between 1 and 300.")); puts(""); printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT); @@ -144,7 +149,7 @@ static void print_help() int main(int argc, char **argv) { char *owner, *ppa, *package_status, *output_dir; - int optc, output_html, cmdok, install_static_files; + int optc, output_html, cmdok, install_static_files, ws_size, opti; program_name = argv[0]; @@ -157,10 +162,15 @@ int main(int argc, char **argv) output_dir = NULL; package_status = NULL; output_html = 0; + ws_size = -1; while ((optc = getopt_long(argc, argv, "vho:ds:S", long_options, - NULL)) != -1) { + &opti)) != -1) { switch (optc) { + case 0: + if (!strcmp(long_options[opti].name, "get-bpph-size")) + ws_size = atoi(optarg); + break; case 'o': output_html = 1; output_dir = strdup(optarg); @@ -198,9 +208,9 @@ int main(int argc, char **argv) if (output_html) ppa_to_html(owner, ppa, package_status, output_dir, - install_static_files); + install_static_files, ws_size); else - display_published_binaries(owner, ppa, package_status); + display_published_binaries(owner, ppa, package_status, ws_size); /* for valgrind.... */ free(package_status); diff --git a/src/ppastats.1 b/src/ppastats.1 index e54943d..0773ce6 100644 --- a/src/ppastats.1 +++ b/src/ppastats.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. -.TH PPASTATS "1" "May 2012" "ppastats 0.0.x" "User Commands" +.TH PPASTATS "1" "July 2012" "ppastats 0.0.x" "User Commands" .SH NAME ppastats \- PPA Statistics command line tool .SH SYNOPSIS @@ -28,6 +28,10 @@ Superseded, Deleted or Obsolete) .TP \fB\-S\fR, \fB\-\-skip\-js\-css\fR skip installation of js and css files +.TP +\fB\-\-get\-bpph\-size\fR=\fI[s]\fR +size of the replies of webservice requests to get +the list of binary packages. Between 1 and 300. .SH "REPORTING BUGS" Report bugs to: jeanfi@gmail.com .PP diff --git a/src/ppastats.c b/src/ppastats.c index 4d8b874..d14d1a4 100644 --- a/src/ppastats.c +++ b/src/ppastats.c @@ -231,7 +231,8 @@ pkg_add_distro(struct package_stats *pkg, struct ppa_stats * create_ppa_stats(const char *owner, const char *ppa_name, - const char *package_status) + const char *package_status, + int ws_size) { struct ppa_stats *ppa; struct bpph **history, **h_cur, *h; @@ -246,7 +247,7 @@ create_ppa_stats(const char *owner, struct daily_download_total **totals; ppa_url = get_archive_url(owner, ppa_name); - history = get_bpph_list(ppa_url, package_status); + history = get_bpph_list(ppa_url, package_status, ws_size); free(ppa_url); if (!history) { diff --git a/src/ppastats.h b/src/ppastats.h index 0b89956..e88893d 100644 --- a/src/ppastats.h +++ b/src/ppastats.h @@ -62,9 +62,13 @@ struct ppa_stats { struct daily_download_total **daily_download_totals; }; +/* + * 'ws_size': size of the reply array of the getPublishedBinaries request. + */ struct ppa_stats *create_ppa_stats(const char *owner, const char *ppa, - const char *package_status); + const char *package_status, + int ws_size); void ppa_stats_free(struct ppa_stats *ppastats); #endif -- 2.7.4