X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain.c;h=ef215eb026cd379f25b9fc6baef2a452d193b93c;hb=cb642aa184b4975dceb8cb596a3285d0e3a91e55;hp=0b193b468f2520f91748942f75f10ef385cd4a78;hpb=50cb5b56107bbbdc5eb1565404015efaba66bed4;p=ppastats.git diff --git a/src/main.c b/src/main.c index 0b193b4..ef215eb 100644 --- a/src/main.c +++ b/src/main.c @@ -1,23 +1,24 @@ -/*a - Copyright (C) 2011 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 published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ +/* + * Copyright (C) 2011-2012 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 + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + #include -#define _(String) gettext (String) +#define _(String) gettext(String) #include #include @@ -26,11 +27,11 @@ #include "cache.h" #include "html.h" +#include "log.h" #include "lp_ws.h" #include "config.h" #include "ppastats.h" -int debug; static const char *program_name; static void display_published_binaries(const char *owner, @@ -98,60 +99,51 @@ static struct option long_options[] = { static void print_version() { printf("ppastats %s\n", VERSION); - printf(_("Copyright (C) %s jeanfi@gmail.com\n\ -License GPLv2: GNU GPL version 2 or later \ -\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"); + printf(_("Copyright (C) %s jeanfi@gmail.com\n" +"License GPLv2: GNU GPL version 2 or later\n" +"\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"); } static void print_help() { printf(_("Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n"), program_name); - puts("ppastats is a command application" - " for generating PPA statistics.\n"); - - puts("Prints number of downloads for each published packages of a PPA " - "or generates an HTML page containing a graph representation."); + puts(_( +"ppastats is a command application for generating PPA statistics.\n")); + puts(_( +"Prints number of downloads for each published packages of a PPA or generates\n" +"an HTML page containing a graph representation.")); puts(""); puts(_("Options:")); - puts(_("\ - -h, --help display this help and exit\n\ - -v, --version display version information and exit")); + puts(_(" -h, --help display this help and exit")); + puts(_(" -v, --version display version information and exit")); puts(""); - puts("\ - -o, --output-dir=[PATH] \ -generates HTML pages into 'PATH'."); + puts(_(" -o, --output-dir=[PATH] generates HTML pages into 'PATH'")); - puts("\ - -s, --status=[STATUS] retrieves only package of the given status\n\ - (possible values are: Pending, Published, \n\ - Superseded, Deleted or Obsolete)."); + puts(_( +" -s, --status=[STATUS] retrieves only package of the given status\n" +" (possible values are: Pending, Published,\n" +" Superseded, Deleted or Obsolete)")); - puts("\ - -S, --skip-js-css skip installation of js and css files"); + puts(_( +" -S, --skip-js-css skip installation of js and css files")); puts(""); - printf("Report bugs to: %s\n", PACKAGE_BUGREPORT); + printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT); puts(""); - printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL); + printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); } - int main(int argc, char **argv) { - char *owner, *ppa; - int optc; - int output_html = 0; - char *package_status = NULL; - int cmdok = 1; - char *output_dir = NULL; - int install_static_files = 1; + char *owner, *ppa, *package_status, *output_dir; + int optc, output_html, cmdok, install_static_files; program_name = argv[0]; @@ -159,6 +151,12 @@ int main(int argc, char **argv) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + cmdok = 1; + install_static_files = 1; + output_dir = NULL; + package_status = NULL; + output_html = 0; + while ((optc = getopt_long(argc, argv, "vho:ds:S", long_options, NULL)) != -1) { switch (optc) { @@ -167,7 +165,7 @@ int main(int argc, char **argv) output_dir = strdup(optarg); break; case 'd': - debug = 1; + log_level = LOG_DEBUG; break; case 'h': print_help(); @@ -189,7 +187,7 @@ 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); }