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
32 static const char *program_name;
34 static void display_published_binaries(const char *owner, const char *ppa)
36 struct ppa_stats *ppastats;
37 struct package_stats **packages;
38 struct version_stats **versions;
39 struct distro_stats **distros;
40 struct arch_stats **archs;
42 ppastats = create_ppa_stats(owner, ppa);
43 packages = ppastats->packages;
44 while (packages && *packages) {
45 struct package_stats *p = *packages;
47 printf("%s (%d)\n", p->name, p->download_count);
49 versions = p->versions;
52 printf("\t%s (%d)\n", (*versions)->version,
53 (*versions)->download_count);
55 distros = (*versions)->distros;
58 printf("\t\t%s (%d)\n",
60 (*distros)->download_count);
62 archs = (*distros)->archs;
65 printf("\t\t\t%s (%d)\n",
67 (*archs)->download_count);
81 ppa_stats_free(ppastats);
84 static struct option long_options[] = {
85 {"version", no_argument, 0, 'v'},
86 {"help", no_argument, 0, 'h'},
87 {"html", no_argument, 0, 't'},
88 {"debug", no_argument, 0, 'd'},
92 static void print_version()
94 printf("ppastats %s\n", VERSION);
95 printf("Copyright (C) %s jeanfi@gmail.com\n\
96 License GPLv2: GNU GPL version 2 or later \
97 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
98 This is free software: you are free to change and redistribute it.\n\
99 There is NO WARRANTY, to the extent permitted by law.\n",
103 static void print_help()
105 printf("Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n", program_name);
107 puts("ppastats is a command application"
108 " for generating PPA statistics.\n");
110 puts("Prints number of downloads for each published packages of a PPA "
111 "or generates an HTML page containing a graph representation.");
116 -h, --help display this help and exit\n\
117 -v, --version display version information and exit");
123 generates an HTML output.");
127 printf("Report bugs to: %s\n", PACKAGE_BUGREPORT);
129 printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
133 int main(int argc, char **argv)
140 program_name = argv[0];
142 while ((optc = getopt_long(argc, argv, "vhtd", long_options,
163 if (!cmdok || optind + 2 != argc) {
164 fprintf(stderr, "Try `%s --help' for more information.\n",
169 owner = argv[optind];
170 ppa = argv[optind+1];
173 ppa_to_html(owner, ppa);
175 display_published_binaries(owner, ppa);
177 /* for valgrind.... */