summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/cgit.c b/cgit.c
index 97f5e08..db96905 100644
--- a/cgit.c
+++ b/cgit.c
@@ -407,44 +407,44 @@ static void process_request(void *cbdata)
407 cmd->fn(ctx); 407 cmd->fn(ctx);
408 408
409 if (cmd->want_layout) 409 if (cmd->want_layout)
410 cgit_print_docend(); 410 cgit_print_docend();
411} 411}
412 412
413int cmp_repos(const void *a, const void *b) 413int cmp_repos(const void *a, const void *b)
414{ 414{
415 const struct cgit_repo *ra = a, *rb = b; 415 const struct cgit_repo *ra = a, *rb = b;
416 return strcmp(ra->url, rb->url); 416 return strcmp(ra->url, rb->url);
417} 417}
418 418
419void print_repo(struct cgit_repo *repo) 419void print_repo(FILE *f, struct cgit_repo *repo)
420{ 420{
421 printf("repo.url=%s\n", repo->url); 421 fprintf(f, "repo.url=%s\n", repo->url);
422 printf("repo.name=%s\n", repo->name); 422 fprintf(f, "repo.name=%s\n", repo->name);
423 printf("repo.path=%s\n", repo->path); 423 fprintf(f, "repo.path=%s\n", repo->path);
424 if (repo->owner) 424 if (repo->owner)
425 printf("repo.owner=%s\n", repo->owner); 425 fprintf(f, "repo.owner=%s\n", repo->owner);
426 if (repo->desc) 426 if (repo->desc)
427 printf("repo.desc=%s\n", repo->desc); 427 fprintf(f, "repo.desc=%s\n", repo->desc);
428 if (repo->readme) 428 if (repo->readme)
429 printf("repo.readme=%s\n", repo->readme); 429 fprintf(f, "repo.readme=%s\n", repo->readme);
430 printf("\n"); 430 fprintf(f, "\n");
431} 431}
432 432
433void print_repolist(struct cgit_repolist *list) 433void print_repolist(FILE *f, struct cgit_repolist *list, int start)
434{ 434{
435 int i; 435 int i;
436 436
437 for(i = 0; i < list->count; i++) 437 for(i = start; i < list->count; i++)
438 print_repo(&list->repos[i]); 438 print_repo(f, &list->repos[i]);
439} 439}
440 440
441 441
442static void cgit_parse_args(int argc, const char **argv) 442static void cgit_parse_args(int argc, const char **argv)
443{ 443{
444 int i; 444 int i;
445 int scan = 0; 445 int scan = 0;
446 446
447 for (i = 1; i < argc; i++) { 447 for (i = 1; i < argc; i++) {
448 if (!strncmp(argv[i], "--cache=", 8)) { 448 if (!strncmp(argv[i], "--cache=", 8)) {
449 ctx.cfg.cache_root = xstrdup(argv[i]+8); 449 ctx.cfg.cache_root = xstrdup(argv[i]+8);
450 } 450 }
@@ -473,25 +473,25 @@ static void cgit_parse_args(int argc, const char **argv)
473 } 473 }
474 if (!strncmp(argv[i], "--ofs=", 6)) { 474 if (!strncmp(argv[i], "--ofs=", 6)) {
475 ctx.qry.ofs = atoi(argv[i]+6); 475 ctx.qry.ofs = atoi(argv[i]+6);
476 } 476 }
477 if (!strncmp(argv[i], "--scan-tree=", 12)) { 477 if (!strncmp(argv[i], "--scan-tree=", 12)) {
478 scan++; 478 scan++;
479 scan_tree(argv[i] + 12); 479 scan_tree(argv[i] + 12);
480 } 480 }
481 } 481 }
482 if (scan) { 482 if (scan) {
483 qsort(cgit_repolist.repos, cgit_repolist.count, 483 qsort(cgit_repolist.repos, cgit_repolist.count,
484 sizeof(struct cgit_repo), cmp_repos); 484 sizeof(struct cgit_repo), cmp_repos);
485 print_repolist(&cgit_repolist); 485 print_repolist(stdout, &cgit_repolist, 0);
486 exit(0); 486 exit(0);
487 } 487 }
488} 488}
489 489
490static int calc_ttl() 490static int calc_ttl()
491{ 491{
492 if (!ctx.repo) 492 if (!ctx.repo)
493 return ctx.cfg.cache_root_ttl; 493 return ctx.cfg.cache_root_ttl;
494 494
495 if (!ctx.qry.page) 495 if (!ctx.qry.page)
496 return ctx.cfg.cache_repo_ttl; 496 return ctx.cfg.cache_repo_ttl;
497 497