X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain.c;h=6c3b508f960149ca7f2c8278bf09d747163207d3;hb=474ab6fa492a8b1dde963fdecb1edebc111c5fb2;hp=b590c67169ac52511ddbd110d829b84a01565079;hpb=0303d0d705cfc2a100403a708fca0e93b12d2a93;p=ppastats.git diff --git a/src/main.c b/src/main.c index b590c67..6c3b508 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2014 jeanfi@gmail.com + * Copyright (C) 2011-2015 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 @@ -25,14 +25,15 @@ #include #include -#include "cache.h" +#include +#include #include -#include "html.h" -#include "http.h" -#include "lp_ws.h" -#include "config.h" +#include +#include +#include +#include #include -#include "ppastats.h" +#include static const char *program_name; @@ -97,6 +98,7 @@ static struct option long_options[] = { {"status", required_argument, 0, 's'}, {"skip-js-css", no_argument, 0, 'S'}, {"get-bpph-size", required_argument, 0, 0}, + {"theme-dir", required_argument, 0, 't'}, {0, 0, 0, 0} }; @@ -108,7 +110,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-2014"); + "2011-2015"); } static void print_help() @@ -129,6 +131,7 @@ static void print_help() puts(""); puts(_(" -o, --output-dir=[PATH] generates HTML pages into 'PATH'")); + puts(_(" -t, --theme-dir=[PATH] set theme dir to 'PATH'")); puts(_( " -s, --status=[STATUS] retrieves only package of the given status\n" @@ -149,7 +152,7 @@ static void print_help() int main(int argc, char **argv) { - char *owner, *ppa, *package_status, *output_dir; + char *owner, *ppa, *package_status, *output_dir, *theme_dir, *log, *tmp; int optc, output_html, cmdok, install_static_files, ws_size, opti; program_name = argv[0]; @@ -164,8 +167,9 @@ int main(int argc, char **argv) package_status = NULL; output_html = 0; ws_size = -1; + theme_dir = NULL; - while ((optc = getopt_long(argc, argv, "vho:ds:S", long_options, + while ((optc = getopt_long(argc, argv, "vho:t:ds:S", long_options, &opti)) != -1) { switch (optc) { case 0: @@ -189,6 +193,10 @@ int main(int argc, char **argv) if (optarg) package_status = strdup(optarg); break; + case 't': + if (optarg) + theme_dir = strdup(optarg); + break; case 'S': install_static_files = 0; break; @@ -205,20 +213,29 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - log_open("ppastats.log"); + tmp = path_append(getenv("HOME"), ".ppastats"); + log = path_append(tmp, "ppastats.log"); + log_open(log); + free(tmp); + free(log); owner = argv[optind]; ppa = argv[optind+1]; - if (output_html) + if (output_html) { + if (theme_dir) + html_set_theme_dir(theme_dir); + else + html_set_theme_dir(DEFAULT_THEME_DIR); ppa_to_html(owner, ppa, package_status, output_dir, install_static_files, ws_size); - else + } else { display_published_binaries(owner, ppa, package_status, ws_size); + } /* for valgrind.... */ free(package_status);