X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain.c;h=b590c67169ac52511ddbd110d829b84a01565079;hb=0303d0d705cfc2a100403a708fca0e93b12d2a93;hp=ef215eb026cd379f25b9fc6baef2a452d193b93c;hpb=03afbf21a42fd2ee8d5d54e21fa9e948c3d6e883;p=ppastats.git diff --git a/src/main.c b/src/main.c index ef215eb..b590c67 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 jeanfi@gmail.com + * Copyright (C) 2011-2014 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -26,17 +26,20 @@ #include #include "cache.h" +#include #include "html.h" -#include "log.h" +#include "http.h" #include "lp_ws.h" #include "config.h" +#include #include "ppastats.h" 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; @@ -44,7 +47,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; @@ -93,6 +96,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} }; @@ -104,7 +108,7 @@ static void print_version() "\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n"), - "2011-2012"); + "2011-2014"); } static void print_help() @@ -133,6 +137,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); @@ -143,7 +150,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]; @@ -156,10 +163,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); @@ -187,25 +199,34 @@ int main(int argc, char **argv) } if (!cmdok || optind + 2 != argc) { - fprintf(stderr, _("Try `%s --help' for more information.\n"), + fprintf(stderr, + _("Try `%s --help' for more information.\n"), program_name); exit(EXIT_FAILURE); } + log_open("ppastats.log"); + owner = argv[optind]; ppa = argv[optind+1]; if (output_html) - ppa_to_html(owner, ppa, package_status, output_dir, - install_static_files); + ppa_to_html(owner, + ppa, + package_status, + output_dir, + 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); free(output_dir); - lp_ws_cleanup(); + http_cleanup(); cache_cleanup(); + fcache_cleanup(); + html_cleanup(); exit(EXIT_SUCCESS); }