summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-01-11 23:00:15 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-01-11 23:00:15 (UTC)
commit83a5f35a2724ee60bfd8c5679b98da7008272254 (patch) (unidiff)
treeb530ed30437c963e4e73db433d8a4e9dd9f7e7d6
parentf98e72684bddb5f746f1d4edf663c70076105c9d (diff)
downloadcgit-83a5f35a2724ee60bfd8c5679b98da7008272254.zip
cgit-83a5f35a2724ee60bfd8c5679b98da7008272254.tar.gz
cgit-83a5f35a2724ee60bfd8c5679b98da7008272254.tar.bz2
Move cache_prepare() to cgit
This moves some cgit-specific stuff away from cache.c Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cache.c22
-rw-r--r--cgit.c25
-rw-r--r--cgit.h1
3 files changed, 23 insertions, 25 deletions
diff --git a/cache.c b/cache.c
index 91b89a6..1ff1251 100644
--- a/cache.c
+++ b/cache.c
@@ -12,24 +12,2 @@ const int NOLOCK = -1;
12 12
13void cache_prepare(struct cacheitem *item)
14{
15 if (!cgit_query_repo) {
16 item->name = xstrdup(fmt("%s/index.html", cgit_cache_root));
17 item->ttl = cgit_cache_root_ttl;
18 } else if (!cgit_query_page) {
19 item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root,
20 cgit_query_repo));
21 item->ttl = cgit_cache_repo_ttl;
22 } else {
23 item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root,
24 cgit_query_repo, cgit_query_page,
25 cgit_querystring));
26 if (cgit_query_has_symref)
27 item->ttl = cgit_cache_dynamic_ttl;
28 else if (cgit_query_has_sha1)
29 item->ttl = cgit_cache_static_ttl;
30 else
31 item->ttl = cgit_cache_repo_ttl;
32 }
33}
34
35int cache_exist(struct cacheitem *item) 13int cache_exist(struct cacheitem *item)
diff --git a/cgit.c b/cgit.c
index 5dcba76..d975570 100644
--- a/cgit.c
+++ b/cgit.c
@@ -12,2 +12,24 @@ const char cgit_version[] = CGIT_VERSION;
12 12
13static void cgit_prepare_cache(struct cacheitem *item)
14{
15 if (!cgit_query_repo) {
16 item->name = xstrdup(fmt("%s/index.html", cgit_cache_root));
17 item->ttl = cgit_cache_root_ttl;
18 } else if (!cgit_query_page) {
19 item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root,
20 cgit_query_repo));
21 item->ttl = cgit_cache_repo_ttl;
22 } else {
23 item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root,
24 cgit_query_repo, cgit_query_page,
25 cgit_querystring));
26 if (cgit_query_has_symref)
27 item->ttl = cgit_cache_dynamic_ttl;
28 else if (cgit_query_has_sha1)
29 item->ttl = cgit_cache_static_ttl;
30 else
31 item->ttl = cgit_cache_repo_ttl;
32 }
33}
34
13static void cgit_print_repo_page(struct cacheitem *item) 35static void cgit_print_repo_page(struct cacheitem *item)
@@ -65,3 +87,2 @@ static void cgit_check_cache(struct cacheitem *item)
65 87
66 cache_prepare(item);
67 top: 88 top:
@@ -154,4 +175,4 @@ int main(int argc, const char **argv)
154 175
176 cgit_prepare_cache(&item);
155 if (cgit_nocache) { 177 if (cgit_nocache) {
156 cache_prepare(&item);
157 item.fd = STDOUT_FILENO; 178 item.fd = STDOUT_FILENO;
diff --git a/cgit.h b/cgit.h
index eb8f08c..f915c86 100644
--- a/cgit.h
+++ b/cgit.h
@@ -89,3 +89,2 @@ extern struct commitinfo *cgit_parse_commit(struct commit *commit);
89 89
90extern void cache_prepare(struct cacheitem *item);
91extern int cache_lock(struct cacheitem *item); 90extern int cache_lock(struct cacheitem *item);