author | Lars Hjemli <hjemli@gmail.com> | 2008-03-27 08:22:13 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-27 08:22:13 (UTC) |
commit | ee4056bd2c902a12dea67874368863fe60ea5a5f (patch) (unidiff) | |
tree | d54da54ace7b8999cf8785d877a0a9cad5262a0c /cgit.c | |
parent | dc3282f0baa14949439593729a45fbe143e3622c (diff) | |
download | cgit-ee4056bd2c902a12dea67874368863fe60ea5a5f.zip cgit-ee4056bd2c902a12dea67874368863fe60ea5a5f.tar.gz cgit-ee4056bd2c902a12dea67874368863fe60ea5a5f.tar.bz2 |
Add cache.h
The functions found in cache.c are only used by cgit.c, so there's no
point in rebuilding all object files when the cache interface is changed.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1,137 +1,138 @@ | |||
1 | /* cgit.c: cgi for the git scm | 1 | /* cgit.c: cgi for the git scm |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "cache.h" | ||
10 | #include "cmd.h" | 11 | #include "cmd.h" |
11 | #include "ui-shared.h" | 12 | #include "ui-shared.h" |
12 | 13 | ||
13 | const char *cgit_version = CGIT_VERSION; | 14 | const char *cgit_version = CGIT_VERSION; |
14 | 15 | ||
15 | void config_cb(const char *name, const char *value) | 16 | void config_cb(const char *name, const char *value) |
16 | { | 17 | { |
17 | if (!strcmp(name, "root-title")) | 18 | if (!strcmp(name, "root-title")) |
18 | ctx.cfg.root_title = xstrdup(value); | 19 | ctx.cfg.root_title = xstrdup(value); |
19 | else if (!strcmp(name, "css")) | 20 | else if (!strcmp(name, "css")) |
20 | ctx.cfg.css = xstrdup(value); | 21 | ctx.cfg.css = xstrdup(value); |
21 | else if (!strcmp(name, "logo")) | 22 | else if (!strcmp(name, "logo")) |
22 | ctx.cfg.logo = xstrdup(value); | 23 | ctx.cfg.logo = xstrdup(value); |
23 | else if (!strcmp(name, "index-header")) | 24 | else if (!strcmp(name, "index-header")) |
24 | ctx.cfg.index_header = xstrdup(value); | 25 | ctx.cfg.index_header = xstrdup(value); |
25 | else if (!strcmp(name, "index-info")) | 26 | else if (!strcmp(name, "index-info")) |
26 | ctx.cfg.index_info = xstrdup(value); | 27 | ctx.cfg.index_info = xstrdup(value); |
27 | else if (!strcmp(name, "logo-link")) | 28 | else if (!strcmp(name, "logo-link")) |
28 | ctx.cfg.logo_link = xstrdup(value); | 29 | ctx.cfg.logo_link = xstrdup(value); |
29 | else if (!strcmp(name, "module-link")) | 30 | else if (!strcmp(name, "module-link")) |
30 | ctx.cfg.module_link = xstrdup(value); | 31 | ctx.cfg.module_link = xstrdup(value); |
31 | else if (!strcmp(name, "virtual-root")) { | 32 | else if (!strcmp(name, "virtual-root")) { |
32 | ctx.cfg.virtual_root = trim_end(value, '/'); | 33 | ctx.cfg.virtual_root = trim_end(value, '/'); |
33 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 34 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
34 | ctx.cfg.virtual_root = ""; | 35 | ctx.cfg.virtual_root = ""; |
35 | } else if (!strcmp(name, "nocache")) | 36 | } else if (!strcmp(name, "nocache")) |
36 | ctx.cfg.nocache = atoi(value); | 37 | ctx.cfg.nocache = atoi(value); |
37 | else if (!strcmp(name, "snapshots")) | 38 | else if (!strcmp(name, "snapshots")) |
38 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 39 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
39 | else if (!strcmp(name, "enable-index-links")) | 40 | else if (!strcmp(name, "enable-index-links")) |
40 | ctx.cfg.enable_index_links = atoi(value); | 41 | ctx.cfg.enable_index_links = atoi(value); |
41 | else if (!strcmp(name, "enable-log-filecount")) | 42 | else if (!strcmp(name, "enable-log-filecount")) |
42 | ctx.cfg.enable_log_filecount = atoi(value); | 43 | ctx.cfg.enable_log_filecount = atoi(value); |
43 | else if (!strcmp(name, "enable-log-linecount")) | 44 | else if (!strcmp(name, "enable-log-linecount")) |
44 | ctx.cfg.enable_log_linecount = atoi(value); | 45 | ctx.cfg.enable_log_linecount = atoi(value); |
45 | else if (!strcmp(name, "cache-root")) | 46 | else if (!strcmp(name, "cache-root")) |
46 | ctx.cfg.cache_root = xstrdup(value); | 47 | ctx.cfg.cache_root = xstrdup(value); |
47 | else if (!strcmp(name, "cache-root-ttl")) | 48 | else if (!strcmp(name, "cache-root-ttl")) |
48 | ctx.cfg.cache_root_ttl = atoi(value); | 49 | ctx.cfg.cache_root_ttl = atoi(value); |
49 | else if (!strcmp(name, "cache-repo-ttl")) | 50 | else if (!strcmp(name, "cache-repo-ttl")) |
50 | ctx.cfg.cache_repo_ttl = atoi(value); | 51 | ctx.cfg.cache_repo_ttl = atoi(value); |
51 | else if (!strcmp(name, "cache-static-ttl")) | 52 | else if (!strcmp(name, "cache-static-ttl")) |
52 | ctx.cfg.cache_static_ttl = atoi(value); | 53 | ctx.cfg.cache_static_ttl = atoi(value); |
53 | else if (!strcmp(name, "cache-dynamic-ttl")) | 54 | else if (!strcmp(name, "cache-dynamic-ttl")) |
54 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 55 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
55 | else if (!strcmp(name, "max-message-length")) | 56 | else if (!strcmp(name, "max-message-length")) |
56 | ctx.cfg.max_msg_len = atoi(value); | 57 | ctx.cfg.max_msg_len = atoi(value); |
57 | else if (!strcmp(name, "max-repodesc-length")) | 58 | else if (!strcmp(name, "max-repodesc-length")) |
58 | ctx.cfg.max_repodesc_len = atoi(value); | 59 | ctx.cfg.max_repodesc_len = atoi(value); |
59 | else if (!strcmp(name, "max-commit-count")) | 60 | else if (!strcmp(name, "max-commit-count")) |
60 | ctx.cfg.max_commit_count = atoi(value); | 61 | ctx.cfg.max_commit_count = atoi(value); |
61 | else if (!strcmp(name, "summary-log")) | 62 | else if (!strcmp(name, "summary-log")) |
62 | ctx.cfg.summary_log = atoi(value); | 63 | ctx.cfg.summary_log = atoi(value); |
63 | else if (!strcmp(name, "summary-branches")) | 64 | else if (!strcmp(name, "summary-branches")) |
64 | ctx.cfg.summary_branches = atoi(value); | 65 | ctx.cfg.summary_branches = atoi(value); |
65 | else if (!strcmp(name, "summary-tags")) | 66 | else if (!strcmp(name, "summary-tags")) |
66 | ctx.cfg.summary_tags = atoi(value); | 67 | ctx.cfg.summary_tags = atoi(value); |
67 | else if (!strcmp(name, "agefile")) | 68 | else if (!strcmp(name, "agefile")) |
68 | ctx.cfg.agefile = xstrdup(value); | 69 | ctx.cfg.agefile = xstrdup(value); |
69 | else if (!strcmp(name, "renamelimit")) | 70 | else if (!strcmp(name, "renamelimit")) |
70 | ctx.cfg.renamelimit = atoi(value); | 71 | ctx.cfg.renamelimit = atoi(value); |
71 | else if (!strcmp(name, "robots")) | 72 | else if (!strcmp(name, "robots")) |
72 | ctx.cfg.robots = xstrdup(value); | 73 | ctx.cfg.robots = xstrdup(value); |
73 | else if (!strcmp(name, "clone-prefix")) | 74 | else if (!strcmp(name, "clone-prefix")) |
74 | ctx.cfg.clone_prefix = xstrdup(value); | 75 | ctx.cfg.clone_prefix = xstrdup(value); |
75 | else if (!strcmp(name, "repo.group")) | 76 | else if (!strcmp(name, "repo.group")) |
76 | ctx.cfg.repo_group = xstrdup(value); | 77 | ctx.cfg.repo_group = xstrdup(value); |
77 | else if (!strcmp(name, "repo.url")) | 78 | else if (!strcmp(name, "repo.url")) |
78 | ctx.repo = cgit_add_repo(value); | 79 | ctx.repo = cgit_add_repo(value); |
79 | else if (!strcmp(name, "repo.name")) | 80 | else if (!strcmp(name, "repo.name")) |
80 | ctx.repo->name = xstrdup(value); | 81 | ctx.repo->name = xstrdup(value); |
81 | else if (ctx.repo && !strcmp(name, "repo.path")) | 82 | else if (ctx.repo && !strcmp(name, "repo.path")) |
82 | ctx.repo->path = trim_end(value, '/'); | 83 | ctx.repo->path = trim_end(value, '/'); |
83 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) | 84 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) |
84 | ctx.repo->clone_url = xstrdup(value); | 85 | ctx.repo->clone_url = xstrdup(value); |
85 | else if (ctx.repo && !strcmp(name, "repo.desc")) | 86 | else if (ctx.repo && !strcmp(name, "repo.desc")) |
86 | ctx.repo->desc = xstrdup(value); | 87 | ctx.repo->desc = xstrdup(value); |
87 | else if (ctx.repo && !strcmp(name, "repo.owner")) | 88 | else if (ctx.repo && !strcmp(name, "repo.owner")) |
88 | ctx.repo->owner = xstrdup(value); | 89 | ctx.repo->owner = xstrdup(value); |
89 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) | 90 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) |
90 | ctx.repo->defbranch = xstrdup(value); | 91 | ctx.repo->defbranch = xstrdup(value); |
91 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) | 92 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) |
92 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | 93 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
93 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) | 94 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) |
94 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 95 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
95 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) | 96 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) |
96 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 97 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
97 | else if (ctx.repo && !strcmp(name, "repo.module-link")) | 98 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
98 | ctx.repo->module_link= xstrdup(value); | 99 | ctx.repo->module_link= xstrdup(value); |
99 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { | 100 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
100 | if (*value == '/') | 101 | if (*value == '/') |
101 | ctx.repo->readme = xstrdup(value); | 102 | ctx.repo->readme = xstrdup(value); |
102 | else | 103 | else |
103 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); | 104 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); |
104 | } else if (!strcmp(name, "include")) | 105 | } else if (!strcmp(name, "include")) |
105 | cgit_read_config(value, config_cb); | 106 | cgit_read_config(value, config_cb); |
106 | } | 107 | } |
107 | 108 | ||
108 | static void querystring_cb(const char *name, const char *value) | 109 | static void querystring_cb(const char *name, const char *value) |
109 | { | 110 | { |
110 | if (!strcmp(name,"r")) { | 111 | if (!strcmp(name,"r")) { |
111 | ctx.qry.repo = xstrdup(value); | 112 | ctx.qry.repo = xstrdup(value); |
112 | ctx.repo = cgit_get_repoinfo(value); | 113 | ctx.repo = cgit_get_repoinfo(value); |
113 | } else if (!strcmp(name, "p")) { | 114 | } else if (!strcmp(name, "p")) { |
114 | ctx.qry.page = xstrdup(value); | 115 | ctx.qry.page = xstrdup(value); |
115 | } else if (!strcmp(name, "url")) { | 116 | } else if (!strcmp(name, "url")) { |
116 | cgit_parse_url(value); | 117 | cgit_parse_url(value); |
117 | } else if (!strcmp(name, "qt")) { | 118 | } else if (!strcmp(name, "qt")) { |
118 | ctx.qry.grep = xstrdup(value); | 119 | ctx.qry.grep = xstrdup(value); |
119 | } else if (!strcmp(name, "q")) { | 120 | } else if (!strcmp(name, "q")) { |
120 | ctx.qry.search = xstrdup(value); | 121 | ctx.qry.search = xstrdup(value); |
121 | } else if (!strcmp(name, "h")) { | 122 | } else if (!strcmp(name, "h")) { |
122 | ctx.qry.head = xstrdup(value); | 123 | ctx.qry.head = xstrdup(value); |
123 | ctx.qry.has_symref = 1; | 124 | ctx.qry.has_symref = 1; |
124 | } else if (!strcmp(name, "id")) { | 125 | } else if (!strcmp(name, "id")) { |
125 | ctx.qry.sha1 = xstrdup(value); | 126 | ctx.qry.sha1 = xstrdup(value); |
126 | ctx.qry.has_sha1 = 1; | 127 | ctx.qry.has_sha1 = 1; |
127 | } else if (!strcmp(name, "id2")) { | 128 | } else if (!strcmp(name, "id2")) { |
128 | ctx.qry.sha2 = xstrdup(value); | 129 | ctx.qry.sha2 = xstrdup(value); |
129 | ctx.qry.has_sha1 = 1; | 130 | ctx.qry.has_sha1 = 1; |
130 | } else if (!strcmp(name, "ofs")) { | 131 | } else if (!strcmp(name, "ofs")) { |
131 | ctx.qry.ofs = atoi(value); | 132 | ctx.qry.ofs = atoi(value); |
132 | } else if (!strcmp(name, "path")) { | 133 | } else if (!strcmp(name, "path")) { |
133 | ctx.qry.path = trim_end(value, '/'); | 134 | ctx.qry.path = trim_end(value, '/'); |
134 | } else if (!strcmp(name, "name")) { | 135 | } else if (!strcmp(name, "name")) { |
135 | ctx.qry.name = xstrdup(value); | 136 | ctx.qry.name = xstrdup(value); |
136 | } | 137 | } |
137 | } | 138 | } |