projects
/
ppastats.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
next release will be 1.3.3
[ppastats.git]
/
src
/
main.c
diff --git
a/src/main.c
b/src/main.c
index
7bd87fc
..
6c3b508
100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2011-201
2
jeanfi@gmail.com
+ * Copyright (C) 2011-201
5
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
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@
-25,19
+25,22
@@
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
-#include "cache.h"
-#include "html.h"
-#include "http.h"
-#include "log.h"
-#include "lp_ws.h"
-#include "config.h"
-#include "ppastats.h"
+#include <cache.h>
+#include <config.h>
+#include <fcache.h>
+#include <html.h>
+#include <http.h>
+#include <lp_ws.h>
+#include <pio.h>
+#include <plog.h>
+#include <ppastats.h>
static const char *program_name;
static void display_published_binaries(const char *owner,
const char *ppa,
static const char *program_name;
static void display_published_binaries(const char *owner,
const char *ppa,
- const char *package_status)
+ const char *package_status,
+ int ws_size)
{
struct ppa_stats *ppastats;
struct package_stats **packages;
{
struct ppa_stats *ppastats;
struct package_stats **packages;
@@
-45,7
+48,7
@@
static void display_published_binaries(const char *owner,
struct distro_stats **distros;
struct arch_stats **archs;
struct distro_stats **distros;
struct arch_stats **archs;
- ppastats = create_ppa_stats(owner, ppa, package_status);
+ ppastats = create_ppa_stats(owner, ppa, package_status
, ws_size
);
packages = ppastats->packages;
while (packages && *packages) {
struct package_stats *p = *packages;
packages = ppastats->packages;
while (packages && *packages) {
struct package_stats *p = *packages;
@@
-94,6
+97,8
@@
static struct option long_options[] = {
{"debug", no_argument, 0, 'd'},
{"status", required_argument, 0, 's'},
{"skip-js-css", no_argument, 0, 'S'},
{"debug", no_argument, 0, 'd'},
{"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}
};
{0, 0, 0, 0}
};
@@
-105,7
+110,7
@@
static void print_version()
"<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\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"),
"<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\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-201
2
");
+ "2011-201
5
");
}
static void print_help()
}
static void print_help()
@@
-126,6
+131,7
@@
static void print_help()
puts("");
puts(_(" -o, --output-dir=[PATH] generates HTML pages into 'PATH'"));
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"
puts(_(
" -s, --status=[STATUS] retrieves only package of the given status\n"
@@
-134,6
+140,9
@@
static void print_help()
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(_(
+" --get-bpph-size=[s] size of the replies of webservice requests to get\n"
+" the list of binary packages. Between 1 and 300."));
puts("");
printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT);
puts("");
printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT);
@@
-143,8
+152,8
@@
static void print_help()
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
- char *owner, *ppa, *package_status, *output_dir;
- int optc, output_html, cmdok, install_static_files;
+ 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];
program_name = argv[0];
@@
-157,10
+166,16
@@
int main(int argc, char **argv)
output_dir = NULL;
package_status = NULL;
output_html = 0;
output_dir = NULL;
package_status = NULL;
output_html = 0;
+ ws_size = -1;
+ theme_dir = NULL;
- while ((optc = getopt_long(argc, argv, "vho:ds:S", long_options,
-
NULL
)) != -1) {
+ while ((optc = getopt_long(argc, argv, "vho:
t:
ds:S", long_options,
+
&opti
)) != -1) {
switch (optc) {
switch (optc) {
+ case 0:
+ if (!strcmp(long_options[opti].name, "get-bpph-size"))
+ ws_size = atoi(optarg);
+ break;
case 'o':
output_html = 1;
output_dir = strdup(optarg);
case 'o':
output_html = 1;
output_dir = strdup(optarg);
@@
-178,6
+193,10
@@
int main(int argc, char **argv)
if (optarg)
package_status = strdup(optarg);
break;
if (optarg)
package_status = strdup(optarg);
break;
+ case 't':
+ if (optarg)
+ theme_dir = strdup(optarg);
+ break;
case 'S':
install_static_files = 0;
break;
case 'S':
install_static_files = 0;
break;
@@
-188,25
+207,43
@@
int main(int argc, char **argv)
}
if (!cmdok || optind + 2 != argc) {
}
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);
}
program_name);
exit(EXIT_FAILURE);
}
+ 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];
owner = argv[optind];
ppa = argv[optind+1];
- if (output_html)
- ppa_to_html(owner, ppa, package_status, output_dir,
- install_static_files);
- else
- display_published_binaries(owner, ppa, package_status);
+ 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 {
+ display_published_binaries(owner, ppa, package_status, ws_size);
+ }
/* for valgrind.... */
free(package_status);
free(output_dir);
http_cleanup();
cache_cleanup();
/* for valgrind.... */
free(package_status);
free(output_dir);
http_cleanup();
cache_cleanup();
+ fcache_cleanup();
+ html_cleanup();
exit(EXIT_SUCCESS);
}
exit(EXIT_SUCCESS);
}