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 binary_package_publishing_history **e_cur, **list;
37 char *archive_url = get_archive_url(owner, ppa);
39 list = get_binary_package_publishing_history_list(archive_url);
43 fprintf(stderr, "Failed to retrieve PPA information\n");
49 struct binary_package_publishing_history *binary;
50 const struct distro_arch_series *arch;
51 const struct distro_series *distro;
54 arch = get_distro_arch_series(binary->distro_arch_series_link);
55 distro = get_distro_series(arch->distroseries_link);
57 printf("%s %s %s(%s): %d\n",
58 binary->binary_package_name,
59 binary->binary_package_version,
61 arch->architecture_tag,
62 get_download_count(binary->self_link));
66 binary_package_publishing_history_list_free(list);
69 static struct option long_options[] = {
70 {"version", no_argument, 0, 'v'},
71 {"help", no_argument, 0, 'h'},
72 {"html", no_argument, 0, 't'},
73 {"debug", no_argument, 0, 'd'},
77 static void print_version()
79 printf("ppastats %s\n", VERSION);
80 printf("Copyright (C) %s jeanfi@gmail.com\n\
81 License GPLv2: GNU GPL version 2 or later \
82 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
83 This is free software: you are free to change and redistribute it.\n\
84 There is NO WARRANTY, to the extent permitted by law.\n",
88 static void print_help()
90 printf("Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n", program_name);
92 puts("ppastats is a command application"
93 " for generating PPA statistics.\n");
95 puts("Prints number of downloads for each published packages of a PPA "
96 "or generates an HTML page containing a graph representation.");
101 -h, --help display this help and exit\n\
102 -v, --version display version information and exit");
108 generates an HTML output.");
112 printf("Report bugs to: %s\n", PACKAGE_BUGREPORT);
114 printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
118 int main(int argc, char **argv)
125 program_name = argv[0];
127 while ((optc = getopt_long(argc, argv, "vhtd", long_options,
148 if (!cmdok || optind + 2 != argc) {
149 fprintf(stderr, "Try `%s --help' for more information.\n",
154 owner = argv[optind];
155 ppa = argv[optind+1];
158 ppa_to_html(owner, ppa);
160 display_published_binaries(owner, ppa);
162 /* for valgrind.... */