|
diff --git a/cgit.h b/cgit.h index 40e2d40..295441b 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -1,67 +1,54 @@ |
1 | #ifndef CGIT_H |
1 | #ifndef CGIT_H |
2 | #define CGIT_H |
2 | #define CGIT_H |
3 | |
3 | |
4 | |
4 | |
5 | #include <git-compat-util.h> |
5 | #include <git-compat-util.h> |
6 | #include <cache.h> |
6 | #include <cache.h> |
7 | #include <grep.h> |
7 | #include <grep.h> |
8 | #include <object.h> |
8 | #include <object.h> |
9 | #include <tree.h> |
9 | #include <tree.h> |
10 | #include <commit.h> |
10 | #include <commit.h> |
11 | #include <tag.h> |
11 | #include <tag.h> |
12 | #include <diff.h> |
12 | #include <diff.h> |
13 | #include <diffcore.h> |
13 | #include <diffcore.h> |
14 | #include <refs.h> |
14 | #include <refs.h> |
15 | #include <revision.h> |
15 | #include <revision.h> |
16 | #include <log-tree.h> |
16 | #include <log-tree.h> |
17 | #include <archive.h> |
17 | #include <archive.h> |
18 | #include <xdiff/xdiff.h> |
18 | #include <xdiff/xdiff.h> |
19 | #include <utf8.h> |
19 | #include <utf8.h> |
20 | |
20 | |
21 | |
21 | |
22 | /* |
22 | /* |
23 | * The valid cgit repo-commands |
| |
24 | */ |
| |
25 | #define CMD_LOG 1 |
| |
26 | #define CMD_COMMIT 2 |
| |
27 | #define CMD_DIFF 3 |
| |
28 | #define CMD_TREE 4 |
| |
29 | #define CMD_BLOB 5 |
| |
30 | #define CMD_SNAPSHOT 6 |
| |
31 | #define CMD_TAG 7 |
| |
32 | #define CMD_REFS 8 |
| |
33 | #define CMD_PATCH 9 |
| |
34 | |
| |
35 | /* |
| |
36 | * Dateformats used on misc. pages |
23 | * Dateformats used on misc. pages |
37 | */ |
24 | */ |
38 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
25 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
39 | #define FMT_SHORTDATE "%Y-%m-%d" |
26 | #define FMT_SHORTDATE "%Y-%m-%d" |
40 | |
27 | |
41 | |
28 | |
42 | /* |
29 | /* |
43 | * Limits used for relative dates |
30 | * Limits used for relative dates |
44 | */ |
31 | */ |
45 | #define TM_MIN 60 |
32 | #define TM_MIN 60 |
46 | #define TM_HOUR (TM_MIN * 60) |
33 | #define TM_HOUR (TM_MIN * 60) |
47 | #define TM_DAY (TM_HOUR * 24) |
34 | #define TM_DAY (TM_HOUR * 24) |
48 | #define TM_WEEK (TM_DAY * 7) |
35 | #define TM_WEEK (TM_DAY * 7) |
49 | #define TM_YEAR (TM_DAY * 365) |
36 | #define TM_YEAR (TM_DAY * 365) |
50 | #define TM_MONTH (TM_YEAR / 12.0) |
37 | #define TM_MONTH (TM_YEAR / 12.0) |
51 | |
38 | |
52 | |
39 | |
53 | /* |
40 | /* |
54 | * Default encoding |
41 | * Default encoding |
55 | */ |
42 | */ |
56 | #define PAGE_ENCODING "UTF-8" |
43 | #define PAGE_ENCODING "UTF-8" |
57 | |
44 | |
58 | typedef void (*configfn)(const char *name, const char *value); |
45 | typedef void (*configfn)(const char *name, const char *value); |
59 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
46 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
60 | typedef void (*linediff_fn)(char *line, int len); |
47 | typedef void (*linediff_fn)(char *line, int len); |
61 | |
48 | |
62 | struct cacheitem { |
49 | struct cacheitem { |
63 | char *name; |
50 | char *name; |
64 | struct stat st; |
51 | struct stat st; |
65 | int ttl; |
52 | int ttl; |
66 | int fd; |
53 | int fd; |
67 | }; |
54 | }; |
@@ -168,65 +155,64 @@ struct cgit_config { |
168 | int max_repodesc_len; |
155 | int max_repodesc_len; |
169 | int nocache; |
156 | int nocache; |
170 | int renamelimit; |
157 | int renamelimit; |
171 | int snapshots; |
158 | int snapshots; |
172 | int summary_branches; |
159 | int summary_branches; |
173 | int summary_log; |
160 | int summary_log; |
174 | int summary_tags; |
161 | int summary_tags; |
175 | }; |
162 | }; |
176 | |
163 | |
177 | struct cgit_page { |
164 | struct cgit_page { |
178 | time_t modified; |
165 | time_t modified; |
179 | time_t expires; |
166 | time_t expires; |
180 | char *mimetype; |
167 | char *mimetype; |
181 | char *charset; |
168 | char *charset; |
182 | char *filename; |
169 | char *filename; |
183 | char *title; |
170 | char *title; |
184 | }; |
171 | }; |
185 | |
172 | |
186 | struct cgit_context { |
173 | struct cgit_context { |
187 | struct cgit_query qry; |
174 | struct cgit_query qry; |
188 | struct cgit_config cfg; |
175 | struct cgit_config cfg; |
189 | struct cgit_repo *repo; |
176 | struct cgit_repo *repo; |
190 | struct cgit_page page; |
177 | struct cgit_page page; |
191 | }; |
178 | }; |
192 | |
179 | |
193 | extern const char *cgit_version; |
180 | extern const char *cgit_version; |
194 | |
181 | |
195 | extern struct cgit_repolist cgit_repolist; |
182 | extern struct cgit_repolist cgit_repolist; |
196 | extern struct cgit_context ctx; |
183 | extern struct cgit_context ctx; |
197 | extern int cgit_cmd; |
184 | extern int cgit_cmd; |
198 | |
185 | |
199 | extern void cgit_prepare_context(struct cgit_context *ctx); |
186 | extern void cgit_prepare_context(struct cgit_context *ctx); |
200 | extern int cgit_get_cmd_index(const char *cmd); |
| |
201 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
187 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
202 | extern void cgit_global_config_cb(const char *name, const char *value); |
188 | extern void cgit_global_config_cb(const char *name, const char *value); |
203 | extern void cgit_repo_config_cb(const char *name, const char *value); |
189 | extern void cgit_repo_config_cb(const char *name, const char *value); |
204 | extern void cgit_querystring_cb(const char *name, const char *value); |
190 | extern void cgit_querystring_cb(const char *name, const char *value); |
205 | |
191 | |
206 | extern int chk_zero(int result, char *msg); |
192 | extern int chk_zero(int result, char *msg); |
207 | extern int chk_positive(int result, char *msg); |
193 | extern int chk_positive(int result, char *msg); |
208 | extern int chk_non_negative(int result, char *msg); |
194 | extern int chk_non_negative(int result, char *msg); |
209 | |
195 | |
210 | extern int hextoint(char c); |
196 | extern int hextoint(char c); |
211 | extern char *trim_end(const char *str, char c); |
197 | extern char *trim_end(const char *str, char c); |
212 | extern char *strlpart(char *txt, int maxlen); |
198 | extern char *strlpart(char *txt, int maxlen); |
213 | extern char *strrpart(char *txt, int maxlen); |
199 | extern char *strrpart(char *txt, int maxlen); |
214 | |
200 | |
215 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
201 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
216 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
202 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
217 | int flags, void *cb_data); |
203 | int flags, void *cb_data); |
218 | |
204 | |
219 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
205 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
220 | |
206 | |
221 | extern int cgit_diff_files(const unsigned char *old_sha1, |
207 | extern int cgit_diff_files(const unsigned char *old_sha1, |
222 | const unsigned char *new_sha1, |
208 | const unsigned char *new_sha1, |
223 | linediff_fn fn); |
209 | linediff_fn fn); |
224 | |
210 | |
225 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
211 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
226 | const unsigned char *new_sha1, |
212 | const unsigned char *new_sha1, |
227 | filepair_fn fn, const char *prefix); |
213 | filepair_fn fn, const char *prefix); |
228 | |
214 | |
229 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
215 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
230 | |
216 | |
231 | extern char *fmt(const char *format,...); |
217 | extern char *fmt(const char *format,...); |
232 | |
218 | |
|