2 Copyright (C) 2011 jeanfi@gmail.com
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 static const char *program_name;
31 static void display_published_binaries(const char *owner, const char *ppa)
33 struct binary_package_publishing_history **e_cur, **list;
34 char *archive_url = get_archive_url(owner, ppa);
36 list = get_binary_package_publishing_history_list(archive_url);
40 fprintf(stderr, "Failed to retrieve PPA information\n");
46 struct binary_package_publishing_history *binary;
47 struct distro_arch_series *dist;
50 dist = get_distro_arch_series(binary->distro_arch_series_link);
52 printf("%s %s %s %d\n",
54 binary->binary_package_name,
55 binary->binary_package_version,
56 get_download_count(binary->self_link));
60 binary_package_publishing_history_list_free(list);
63 static struct option long_options[] = {
64 {"version", no_argument, 0, 'v'},
65 {"help", no_argument, 0, 'h'},
66 {"html", no_argument, 0, 't'},
70 static void print_version()
72 printf("ppastats %s\n", VERSION);
73 printf("Copyright (C) %s jeanfi@gmail.com\n\
74 License GPLv2: GNU GPL version 2 or later \
75 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
76 This is free software: you are free to change and redistribute it.\n\
77 There is NO WARRANTY, to the extent permitted by law.\n",
81 static void print_help()
83 printf("Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n", program_name);
85 puts("ppastats is a command application"
86 " for generating PPA statistics.");
88 puts("Prints number of downloads for each published packages of a PPA "
89 "or generates an HTML containing a graph representation.");
94 -h, --help display this help and exit\n\
95 -v, --version display version information and exit");
101 generates an HTML output.");
105 printf("Report bugs to: %s\n", PACKAGE_BUGREPORT);
107 printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
111 int main(int argc, char **argv)
118 program_name = argv[0];
120 while ((optc = getopt_long(argc, argv, "vht", long_options,
138 if (!cmdok || optind + 2 != argc) {
139 fprintf(stderr, "Try `%s --help' for more information.\n",
144 owner = argv[optind];
145 ppa = argv[optind+1];
148 ppa_to_html(owner, ppa);
150 display_published_binaries(owner, ppa);