|
diff --git a/cgit.c b/cgit.c index b3ff512..300fe46 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -1,354 +1,308 @@ |
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 | |
10 | |
11 | const char cgit_version[] = CGIT_VERSION; |
11 | const char cgit_version[] = CGIT_VERSION; |
12 | |
12 | |
13 | int htmlfd = 0; |
13 | int htmlfd = 0; |
14 | |
14 | |
15 | char *cgit_root = "/usr/src/git"; |
15 | char *cgit_root = "/usr/src/git"; |
16 | char *cgit_root_title = "Git repository browser"; |
16 | char *cgit_root_title = "Git repository browser"; |
17 | char *cgit_css = "/cgit.css"; |
17 | char *cgit_css = "/cgit.css"; |
18 | char *cgit_logo = "/git-logo.png"; |
18 | char *cgit_logo = "/git-logo.png"; |
19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
19 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
20 | char *cgit_virtual_root = NULL; |
20 | char *cgit_virtual_root = NULL; |
21 | |
21 | |
22 | char *cgit_cache_root = "/var/cache/cgit"; |
22 | char *cgit_cache_root = "/var/cache/cgit"; |
23 | |
23 | |
24 | int cgit_max_lock_attempts = 5; |
24 | int cgit_max_lock_attempts = 5; |
25 | int cgit_cache_root_ttl = 5; |
25 | int cgit_cache_root_ttl = 5; |
26 | int cgit_cache_repo_ttl = 5; |
26 | int cgit_cache_repo_ttl = 5; |
27 | int cgit_cache_dynamic_ttl = 5; |
27 | int cgit_cache_dynamic_ttl = 5; |
28 | int cgit_cache_static_ttl = -1; |
28 | int cgit_cache_static_ttl = -1; |
29 | int cgit_cache_max_create_time = 5; |
29 | int cgit_cache_max_create_time = 5; |
30 | |
30 | |
31 | char *cgit_repo_name = NULL; |
31 | char *cgit_repo_name = NULL; |
32 | char *cgit_repo_desc = NULL; |
32 | char *cgit_repo_desc = NULL; |
33 | char *cgit_repo_owner = NULL; |
33 | char *cgit_repo_owner = NULL; |
34 | |
34 | |
35 | int cgit_query_has_symref = 0; |
35 | int cgit_query_has_symref = 0; |
36 | int cgit_query_has_sha1 = 0; |
36 | int cgit_query_has_sha1 = 0; |
37 | |
37 | |
38 | char *cgit_querystring = NULL; |
38 | char *cgit_querystring = NULL; |
39 | char *cgit_query_repo = NULL; |
39 | char *cgit_query_repo = NULL; |
40 | char *cgit_query_page = NULL; |
40 | char *cgit_query_page = NULL; |
41 | char *cgit_query_head = NULL; |
41 | char *cgit_query_head = NULL; |
42 | char *cgit_query_sha1 = NULL; |
42 | char *cgit_query_sha1 = NULL; |
43 | |
43 | |
44 | struct cacheitem cacheitem; |
44 | struct cacheitem cacheitem; |
45 | |
45 | |
46 | void cgit_global_config_cb(const char *name, const char *value) |
46 | void cgit_global_config_cb(const char *name, const char *value) |
47 | { |
47 | { |
48 | if (!strcmp(name, "root")) |
48 | if (!strcmp(name, "root")) |
49 | cgit_root = xstrdup(value); |
49 | cgit_root = xstrdup(value); |
50 | else if (!strcmp(name, "root-title")) |
50 | else if (!strcmp(name, "root-title")) |
51 | cgit_root_title = xstrdup(value); |
51 | cgit_root_title = xstrdup(value); |
52 | else if (!strcmp(name, "css")) |
52 | else if (!strcmp(name, "css")) |
53 | cgit_css = xstrdup(value); |
53 | cgit_css = xstrdup(value); |
54 | else if (!strcmp(name, "logo")) |
54 | else if (!strcmp(name, "logo")) |
55 | cgit_logo = xstrdup(value); |
55 | cgit_logo = xstrdup(value); |
56 | else if (!strcmp(name, "logo-link")) |
56 | else if (!strcmp(name, "logo-link")) |
57 | cgit_logo_link = xstrdup(value); |
57 | cgit_logo_link = xstrdup(value); |
58 | else if (!strcmp(name, "virtual-root")) |
58 | else if (!strcmp(name, "virtual-root")) |
59 | cgit_virtual_root = xstrdup(value); |
59 | cgit_virtual_root = xstrdup(value); |
60 | } |
60 | } |
61 | |
61 | |
62 | void cgit_repo_config_cb(const char *name, const char *value) |
62 | void cgit_repo_config_cb(const char *name, const char *value) |
63 | { |
63 | { |
64 | if (!strcmp(name, "name")) |
64 | if (!strcmp(name, "name")) |
65 | cgit_repo_name = xstrdup(value); |
65 | cgit_repo_name = xstrdup(value); |
66 | else if (!strcmp(name, "desc")) |
66 | else if (!strcmp(name, "desc")) |
67 | cgit_repo_desc = xstrdup(value); |
67 | cgit_repo_desc = xstrdup(value); |
68 | else if (!strcmp(name, "owner")) |
68 | else if (!strcmp(name, "owner")) |
69 | cgit_repo_owner = xstrdup(value); |
69 | cgit_repo_owner = xstrdup(value); |
70 | } |
70 | } |
71 | |
71 | |
72 | void cgit_querystring_cb(const char *name, const char *value) |
72 | void cgit_querystring_cb(const char *name, const char *value) |
73 | { |
73 | { |
74 | if (!strcmp(name,"r")) |
74 | if (!strcmp(name,"r")) |
75 | cgit_query_repo = xstrdup(value); |
75 | cgit_query_repo = xstrdup(value); |
76 | else if (!strcmp(name, "p")) |
76 | else if (!strcmp(name, "p")) |
77 | cgit_query_page = xstrdup(value); |
77 | cgit_query_page = xstrdup(value); |
78 | else if (!strcmp(name, "h")) { |
78 | else if (!strcmp(name, "h")) { |
79 | cgit_query_head = xstrdup(value); |
79 | cgit_query_head = xstrdup(value); |
80 | cgit_query_has_symref = 1; |
80 | cgit_query_has_symref = 1; |
81 | } else if (!strcmp(name, "id")) { |
81 | } else if (!strcmp(name, "id")) { |
82 | cgit_query_sha1 = xstrdup(value); |
82 | cgit_query_sha1 = xstrdup(value); |
83 | cgit_query_has_sha1 = 1; |
83 | cgit_query_has_sha1 = 1; |
84 | } |
84 | } |
85 | } |
85 | } |
86 | |
86 | |
87 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
| |
88 | int flags, void *cb_data) |
| |
89 | { |
| |
90 | struct commit *commit; |
| |
91 | char buf[256], *url; |
| |
92 | |
| |
93 | commit = lookup_commit(sha1); |
| |
94 | if (commit && !parse_commit(commit)){ |
| |
95 | html("<tr><td>"); |
| |
96 | url = cgit_pageurl(cgit_query_repo, "log", |
| |
97 | fmt("h=%s", refname)); |
| |
98 | html_link_open(url, NULL, NULL); |
| |
99 | strncpy(buf, refname, sizeof(buf)); |
| |
100 | html_txt(buf); |
| |
101 | html_link_close(); |
| |
102 | html("</td><td>"); |
| |
103 | pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, buf, |
| |
104 | sizeof(buf), 0, NULL, NULL, 0); |
| |
105 | html_txt(buf); |
| |
106 | html("</td></tr>\n"); |
| |
107 | } else { |
| |
108 | html("<tr><td>"); |
| |
109 | html_txt(buf); |
| |
110 | html("</td><td>"); |
| |
111 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); |
| |
112 | html("</td></tr>\n"); |
| |
113 | } |
| |
114 | return 0; |
| |
115 | } |
| |
116 | |
| |
117 | static void cgit_print_branches() |
| |
118 | { |
| |
119 | html("<table class='list'>"); |
| |
120 | html("<tr><th>Branch name</th><th>Head commit</th></tr>\n"); |
| |
121 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
| |
122 | html("</table>"); |
| |
123 | } |
| |
124 | |
| |
125 | static int get_one_line(char *txt) |
87 | static int get_one_line(char *txt) |
126 | { |
88 | { |
127 | char *t; |
89 | char *t; |
128 | |
90 | |
129 | for(t=txt; *t != '\n' && t != '\0'; t++) |
91 | for(t=txt; *t != '\n' && t != '\0'; t++) |
130 | ; |
92 | ; |
131 | *t = '\0'; |
93 | *t = '\0'; |
132 | return t-txt-1; |
94 | return t-txt-1; |
133 | } |
95 | } |
134 | |
96 | |
135 | static void cgit_print_commit_shortlog(struct commit *commit) |
97 | static void cgit_print_commit_shortlog(struct commit *commit) |
136 | { |
98 | { |
137 | char *h, *t, *p; |
99 | char *h, *t, *p; |
138 | char *tree = NULL, *author = NULL, *subject = NULL; |
100 | char *tree = NULL, *author = NULL, *subject = NULL; |
139 | int len; |
101 | int len; |
140 | time_t sec; |
102 | time_t sec; |
141 | struct tm *time; |
103 | struct tm *time; |
142 | char buf[32]; |
104 | char buf[32]; |
143 | |
105 | |
144 | h = t = commit->buffer; |
106 | h = t = commit->buffer; |
145 | |
107 | |
146 | if (strncmp(h, "tree ", 5)) |
108 | if (strncmp(h, "tree ", 5)) |
147 | die("Bad commit format: %s", |
109 | die("Bad commit format: %s", |
148 | sha1_to_hex(commit->object.sha1)); |
110 | sha1_to_hex(commit->object.sha1)); |
149 | |
111 | |
150 | len = get_one_line(h); |
112 | len = get_one_line(h); |
151 | tree = h+5; |
113 | tree = h+5; |
152 | h += len + 2; |
114 | h += len + 2; |
153 | |
115 | |
154 | while (!strncmp(h, "parent ", 7)) |
116 | while (!strncmp(h, "parent ", 7)) |
155 | h += get_one_line(h) + 2; |
117 | h += get_one_line(h) + 2; |
156 | |
118 | |
157 | if (!strncmp(h, "author ", 7)) { |
119 | if (!strncmp(h, "author ", 7)) { |
158 | author = h+7; |
120 | author = h+7; |
159 | h += get_one_line(h) + 2; |
121 | h += get_one_line(h) + 2; |
160 | t = author; |
122 | t = author; |
161 | while(t!=h && *t!='<') |
123 | while(t!=h && *t!='<') |
162 | t++; |
124 | t++; |
163 | *t='\0'; |
125 | *t='\0'; |
164 | p = t; |
126 | p = t; |
165 | while(--t!=author && *t==' ') |
127 | while(--t!=author && *t==' ') |
166 | *t='\0'; |
128 | *t='\0'; |
167 | while(++p!=h && *p!='>') |
129 | while(++p!=h && *p!='>') |
168 | ; |
130 | ; |
169 | while(++p!=h && !isdigit(*p)) |
131 | while(++p!=h && !isdigit(*p)) |
170 | ; |
132 | ; |
171 | |
133 | |
172 | t = p; |
134 | t = p; |
173 | while(++p && isdigit(*p)) |
135 | while(++p && isdigit(*p)) |
174 | ; |
136 | ; |
175 | *p = '\0'; |
137 | *p = '\0'; |
176 | sec = atoi(t); |
138 | sec = atoi(t); |
177 | time = gmtime(&sec); |
139 | time = gmtime(&sec); |
178 | } |
140 | } |
179 | |
141 | |
180 | while((len = get_one_line(h)) > 0) |
142 | while((len = get_one_line(h)) > 0) |
181 | h += len+2; |
143 | h += len+2; |
182 | |
144 | |
183 | h++; |
145 | h++; |
184 | len = get_one_line(h); |
146 | len = get_one_line(h); |
185 | |
147 | |
186 | subject = h; |
148 | subject = h; |
187 | |
149 | |
188 | html("<tr><td>"); |
150 | html("<tr><td>"); |
189 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
151 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
190 | html_txt(buf); |
152 | html_txt(buf); |
191 | html("</td><td>"); |
153 | html("</td><td>"); |
192 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
154 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
193 | char *url = cgit_pageurl(cgit_query_repo, "view", qry); |
155 | char *url = cgit_pageurl(cgit_query_repo, "view", qry); |
194 | html_link_open(url, NULL, NULL); |
156 | html_link_open(url, NULL, NULL); |
195 | html_txt(subject); |
157 | html_txt(subject); |
196 | html_link_close(); |
158 | html_link_close(); |
197 | html("</td><td>"); |
159 | html("</td><td>"); |
198 | html_txt(author); |
160 | html_txt(author); |
199 | html("</td></tr>\n"); |
161 | html("</td></tr>\n"); |
200 | } |
162 | } |
201 | |
163 | |
202 | static void cgit_print_log(const char *tip, int ofs, int cnt) |
164 | static void cgit_print_log(const char *tip, int ofs, int cnt) |
203 | { |
165 | { |
204 | struct rev_info rev; |
166 | struct rev_info rev; |
205 | struct commit *commit; |
167 | struct commit *commit; |
206 | const char *argv[2] = {NULL, tip}; |
168 | const char *argv[2] = {NULL, tip}; |
207 | int n = 0; |
169 | int n = 0; |
208 | |
170 | |
209 | init_revisions(&rev, NULL); |
171 | init_revisions(&rev, NULL); |
210 | rev.abbrev = DEFAULT_ABBREV; |
172 | rev.abbrev = DEFAULT_ABBREV; |
211 | rev.commit_format = CMIT_FMT_DEFAULT; |
173 | rev.commit_format = CMIT_FMT_DEFAULT; |
212 | rev.verbose_header = 1; |
174 | rev.verbose_header = 1; |
213 | rev.show_root_diff = 0; |
175 | rev.show_root_diff = 0; |
214 | setup_revisions(2, argv, &rev, NULL); |
176 | setup_revisions(2, argv, &rev, NULL); |
215 | prepare_revision_walk(&rev); |
177 | prepare_revision_walk(&rev); |
216 | |
178 | |
217 | html("<h2>Log</h2>"); |
179 | html("<h2>Log</h2>"); |
218 | html("<table class='list'>"); |
180 | html("<table class='list'>"); |
219 | html("<tr><th>Date</th><th>Message</th><th>Author</th></tr>\n"); |
181 | html("<tr><th>Date</th><th>Message</th><th>Author</th></tr>\n"); |
220 | while ((commit = get_revision(&rev)) != NULL && n++ < 100) { |
182 | while ((commit = get_revision(&rev)) != NULL && n++ < 100) { |
221 | cgit_print_commit_shortlog(commit); |
183 | cgit_print_commit_shortlog(commit); |
222 | free(commit->buffer); |
184 | free(commit->buffer); |
223 | commit->buffer = NULL; |
185 | commit->buffer = NULL; |
224 | free_commit_list(commit->parents); |
186 | free_commit_list(commit->parents); |
225 | commit->parents = NULL; |
187 | commit->parents = NULL; |
226 | } |
188 | } |
227 | html("</table>\n"); |
189 | html("</table>\n"); |
228 | } |
190 | } |
229 | |
191 | |
230 | static void cgit_print_repo_summary() |
| |
231 | { |
| |
232 | html("<h2>"); |
| |
233 | html_txt("Repo summary page"); |
| |
234 | html("</h2>"); |
| |
235 | cgit_print_branches(); |
| |
236 | } |
| |
237 | |
| |
238 | static void cgit_print_object(char *hex) |
192 | static void cgit_print_object(char *hex) |
239 | { |
193 | { |
240 | unsigned char sha1[20]; |
194 | unsigned char sha1[20]; |
241 | //struct object *object; |
195 | //struct object *object; |
242 | char type[20]; |
196 | char type[20]; |
243 | unsigned char *buf; |
197 | unsigned char *buf; |
244 | unsigned long size; |
198 | unsigned long size; |
245 | |
199 | |
246 | if (get_sha1_hex(hex, sha1)){ |
200 | if (get_sha1_hex(hex, sha1)){ |
247 | cgit_print_error(fmt("Bad hex value: %s", hex)); |
201 | cgit_print_error(fmt("Bad hex value: %s", hex)); |
248 | return; |
202 | return; |
249 | } |
203 | } |
250 | |
204 | |
251 | if (sha1_object_info(sha1, type, NULL)){ |
205 | if (sha1_object_info(sha1, type, NULL)){ |
252 | cgit_print_error("Bad object name"); |
206 | cgit_print_error("Bad object name"); |
253 | return; |
207 | return; |
254 | } |
208 | } |
255 | |
209 | |
256 | buf = read_sha1_file(sha1, type, &size); |
210 | buf = read_sha1_file(sha1, type, &size); |
257 | if (!buf) { |
211 | if (!buf) { |
258 | cgit_print_error("Error reading object"); |
212 | cgit_print_error("Error reading object"); |
259 | return; |
213 | return; |
260 | } |
214 | } |
261 | |
215 | |
262 | buf[size] = '\0'; |
216 | buf[size] = '\0'; |
263 | html("<h2>Object view</h2>"); |
217 | html("<h2>Object view</h2>"); |
264 | htmlf("sha1=%s<br/>type=%s<br/>size=%i<br/>", hex, type, size); |
218 | htmlf("sha1=%s<br/>type=%s<br/>size=%i<br/>", hex, type, size); |
265 | html("<pre>"); |
219 | html("<pre>"); |
266 | html_txt(buf); |
220 | html_txt(buf); |
267 | html("</pre>"); |
221 | html("</pre>"); |
268 | } |
222 | } |
269 | |
223 | |
270 | static void cgit_print_repo_page(struct cacheitem *item) |
224 | static void cgit_print_repo_page(struct cacheitem *item) |
271 | { |
225 | { |
272 | if (chdir(fmt("%s/%s", cgit_root, cgit_query_repo)) || |
226 | if (chdir(fmt("%s/%s", cgit_root, cgit_query_repo)) || |
273 | cgit_read_config("info/cgit", cgit_repo_config_cb)) { |
227 | cgit_read_config("info/cgit", cgit_repo_config_cb)) { |
274 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
228 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
275 | cgit_print_docstart(title, item); |
229 | cgit_print_docstart(title, item); |
276 | cgit_print_pageheader(title); |
230 | cgit_print_pageheader(title); |
277 | cgit_print_error(fmt("Unable to scan repository: %s", |
231 | cgit_print_error(fmt("Unable to scan repository: %s", |
278 | strerror(errno))); |
232 | strerror(errno))); |
279 | cgit_print_docend(); |
233 | cgit_print_docend(); |
280 | return; |
234 | return; |
281 | } |
235 | } |
282 | setenv("GIT_DIR", fmt("%s/%s", cgit_root, cgit_query_repo), 1); |
236 | setenv("GIT_DIR", fmt("%s/%s", cgit_root, cgit_query_repo), 1); |
283 | char *title = fmt("%s - %s", cgit_repo_name, cgit_repo_desc); |
237 | char *title = fmt("%s - %s", cgit_repo_name, cgit_repo_desc); |
284 | cgit_print_docstart(title, item); |
238 | cgit_print_docstart(title, item); |
285 | cgit_print_pageheader(title); |
239 | cgit_print_pageheader(title); |
286 | if (!cgit_query_page) |
240 | if (!cgit_query_page) |
287 | cgit_print_repo_summary(); |
241 | cgit_print_repo_summary(); |
288 | else if (!strcmp(cgit_query_page, "log")) { |
242 | else if (!strcmp(cgit_query_page, "log")) { |
289 | cgit_print_log(cgit_query_head, 0, 100); |
243 | cgit_print_log(cgit_query_head, 0, 100); |
290 | } else if (!strcmp(cgit_query_page, "view")) { |
244 | } else if (!strcmp(cgit_query_page, "view")) { |
291 | cgit_print_object(cgit_query_sha1); |
245 | cgit_print_object(cgit_query_sha1); |
292 | } |
246 | } |
293 | cgit_print_docend(); |
247 | cgit_print_docend(); |
294 | } |
248 | } |
295 | |
249 | |
296 | static void cgit_fill_cache(struct cacheitem *item) |
250 | static void cgit_fill_cache(struct cacheitem *item) |
297 | { |
251 | { |
298 | htmlfd = item->fd; |
252 | htmlfd = item->fd; |
299 | item->st.st_mtime = time(NULL); |
253 | item->st.st_mtime = time(NULL); |
300 | if (cgit_query_repo) |
254 | if (cgit_query_repo) |
301 | cgit_print_repo_page(item); |
255 | cgit_print_repo_page(item); |
302 | else |
256 | else |
303 | cgit_print_repolist(item); |
257 | cgit_print_repolist(item); |
304 | } |
258 | } |
305 | |
259 | |
306 | static void cgit_refresh_cache(struct cacheitem *item) |
260 | static void cgit_refresh_cache(struct cacheitem *item) |
307 | { |
261 | { |
308 | int i = 0; |
262 | int i = 0; |
309 | |
263 | |
310 | cache_prepare(item); |
264 | cache_prepare(item); |
311 | top: |
265 | top: |
312 | if (++i > cgit_max_lock_attempts) { |
266 | if (++i > cgit_max_lock_attempts) { |
313 | die("cgit_refresh_cache: unable to lock %s: %s", |
267 | die("cgit_refresh_cache: unable to lock %s: %s", |
314 | item->name, strerror(errno)); |
268 | item->name, strerror(errno)); |
315 | } |
269 | } |
316 | if (!cache_exist(item)) { |
270 | if (!cache_exist(item)) { |
317 | if (!cache_lock(item)) { |
271 | if (!cache_lock(item)) { |
318 | sleep(1); |
272 | sleep(1); |
319 | goto top; |
273 | goto top; |
320 | } |
274 | } |
321 | if (!cache_exist(item)) |
275 | if (!cache_exist(item)) |
322 | cgit_fill_cache(item); |
276 | cgit_fill_cache(item); |
323 | cache_unlock(item); |
277 | cache_unlock(item); |
324 | } else if (cache_expired(item) && cache_lock(item)) { |
278 | } else if (cache_expired(item) && cache_lock(item)) { |
325 | if (cache_expired(item)) |
279 | if (cache_expired(item)) |
326 | cgit_fill_cache(item); |
280 | cgit_fill_cache(item); |
327 | cache_unlock(item); |
281 | cache_unlock(item); |
328 | } |
282 | } |
329 | } |
283 | } |
330 | |
284 | |
331 | static void cgit_print_cache(struct cacheitem *item) |
285 | static void cgit_print_cache(struct cacheitem *item) |
332 | { |
286 | { |
333 | static char buf[4096]; |
287 | static char buf[4096]; |
334 | ssize_t i; |
288 | ssize_t i; |
335 | |
289 | |
336 | int fd = open(item->name, O_RDONLY); |
290 | int fd = open(item->name, O_RDONLY); |
337 | if (fd<0) |
291 | if (fd<0) |
338 | die("Unable to open cached file %s", item->name); |
292 | die("Unable to open cached file %s", item->name); |
339 | |
293 | |
340 | while((i=read(fd, buf, sizeof(buf))) > 0) |
294 | while((i=read(fd, buf, sizeof(buf))) > 0) |
341 | write(STDOUT_FILENO, buf, i); |
295 | write(STDOUT_FILENO, buf, i); |
342 | |
296 | |
343 | close(fd); |
297 | close(fd); |
344 | } |
298 | } |
345 | |
299 | |
346 | int main(int argc, const char **argv) |
300 | int main(int argc, const char **argv) |
347 | { |
301 | { |
348 | cgit_read_config("/etc/cgitrc", cgit_global_config_cb); |
302 | cgit_read_config("/etc/cgitrc", cgit_global_config_cb); |
349 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); |
303 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); |
350 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); |
304 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); |
351 | cgit_refresh_cache(&cacheitem); |
305 | cgit_refresh_cache(&cacheitem); |
352 | cgit_print_cache(&cacheitem); |
306 | cgit_print_cache(&cacheitem); |
353 | return 0; |
307 | return 0; |
354 | } |
308 | } |
|