-rw-r--r-- | ui-repolist.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 25f076f..6d2f93f 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -1,73 +1,74 @@ /* ui-repolist.c: functions for generating the repolist page * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ /* This is needed for strcasestr to be defined by <string.h> */ #define _GNU_SOURCE 1 #include <string.h> #include <time.h> #include "cgit.h" #include "html.h" #include "ui-shared.h" time_t read_agefile(char *path) { FILE *f; static char buf[64], buf2[64]; if (!(f = fopen(path, "r"))) return -1; + buf[0] = 0; if (fgets(buf, sizeof(buf), f) == NULL) return -1; fclose(f); if (parse_date(buf, buf2, sizeof(buf2))) return strtoul(buf2, NULL, 10); else return 0; } static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) { char *path; struct stat s; struct cgit_repo *r = (struct cgit_repo *)repo; if (repo->mtime != -1) { *mtime = repo->mtime; return 1; } path = fmt("%s/%s", repo->path, ctx.cfg.agefile); if (stat(path, &s) == 0) { *mtime = read_agefile(path); r->mtime = *mtime; return 1; } path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); if (stat(path, &s) == 0) *mtime = s.st_mtime; else *mtime = 0; r->mtime = *mtime; return (r->mtime != 0); } static void print_modtime(struct cgit_repo *repo) { time_t t; if (get_repo_modtime(repo, &t)) cgit_print_age(t, -1, NULL); } int is_match(struct cgit_repo *repo) { if (!ctx.qry.search) return 1; if (repo->url && strcasestr(repo->url, ctx.qry.search)) |