|
diff --git a/cgit.h b/cgit.h index 1b23369..c1a231d 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -1,276 +1,244 @@ |
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 | * Dateformats used on misc. pages |
23 | * Dateformats used on misc. pages |
24 | */ |
24 | */ |
25 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
25 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
26 | #define FMT_SHORTDATE "%Y-%m-%d" |
26 | #define FMT_SHORTDATE "%Y-%m-%d" |
27 | |
27 | |
28 | |
28 | |
29 | /* |
29 | /* |
30 | * Limits used for relative dates |
30 | * Limits used for relative dates |
31 | */ |
31 | */ |
32 | #define TM_MIN 60 |
32 | #define TM_MIN 60 |
33 | #define TM_HOUR (TM_MIN * 60) |
33 | #define TM_HOUR (TM_MIN * 60) |
34 | #define TM_DAY (TM_HOUR * 24) |
34 | #define TM_DAY (TM_HOUR * 24) |
35 | #define TM_WEEK (TM_DAY * 7) |
35 | #define TM_WEEK (TM_DAY * 7) |
36 | #define TM_YEAR (TM_DAY * 365) |
36 | #define TM_YEAR (TM_DAY * 365) |
37 | #define TM_MONTH (TM_YEAR / 12.0) |
37 | #define TM_MONTH (TM_YEAR / 12.0) |
38 | |
38 | |
39 | |
39 | |
40 | /* |
40 | /* |
41 | * Default encoding |
41 | * Default encoding |
42 | */ |
42 | */ |
43 | #define PAGE_ENCODING "UTF-8" |
43 | #define PAGE_ENCODING "UTF-8" |
44 | |
44 | |
45 | typedef void (*configfn)(const char *name, const char *value); |
45 | typedef void (*configfn)(const char *name, const char *value); |
46 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
46 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
47 | typedef void (*linediff_fn)(char *line, int len); |
47 | typedef void (*linediff_fn)(char *line, int len); |
48 | |
48 | |
49 | struct cacheitem { |
49 | struct cacheitem { |
50 | char *name; |
50 | char *name; |
51 | struct stat st; |
51 | struct stat st; |
52 | int ttl; |
52 | int ttl; |
53 | int fd; |
53 | int fd; |
54 | }; |
54 | }; |
55 | |
55 | |
56 | struct cgit_repo { |
56 | struct cgit_repo { |
57 | char *url; |
57 | char *url; |
58 | char *name; |
58 | char *name; |
59 | char *path; |
59 | char *path; |
60 | char *desc; |
60 | char *desc; |
61 | char *owner; |
61 | char *owner; |
62 | char *defbranch; |
62 | char *defbranch; |
63 | char *group; |
63 | char *group; |
64 | char *module_link; |
64 | char *module_link; |
65 | char *readme; |
65 | char *readme; |
66 | char *clone_url; |
66 | char *clone_url; |
67 | int snapshots; |
67 | int snapshots; |
68 | int enable_log_filecount; |
68 | int enable_log_filecount; |
69 | int enable_log_linecount; |
69 | int enable_log_linecount; |
70 | }; |
70 | }; |
71 | |
71 | |
72 | struct cgit_repolist { |
72 | struct cgit_repolist { |
73 | int length; |
73 | int length; |
74 | int count; |
74 | int count; |
75 | struct cgit_repo *repos; |
75 | struct cgit_repo *repos; |
76 | }; |
76 | }; |
77 | |
77 | |
78 | struct commitinfo { |
78 | struct commitinfo { |
79 | struct commit *commit; |
79 | struct commit *commit; |
80 | char *author; |
80 | char *author; |
81 | char *author_email; |
81 | char *author_email; |
82 | unsigned long author_date; |
82 | unsigned long author_date; |
83 | char *committer; |
83 | char *committer; |
84 | char *committer_email; |
84 | char *committer_email; |
85 | unsigned long committer_date; |
85 | unsigned long committer_date; |
86 | char *subject; |
86 | char *subject; |
87 | char *msg; |
87 | char *msg; |
88 | char *msg_encoding; |
88 | char *msg_encoding; |
89 | }; |
89 | }; |
90 | |
90 | |
91 | struct taginfo { |
91 | struct taginfo { |
92 | char *tagger; |
92 | char *tagger; |
93 | char *tagger_email; |
93 | char *tagger_email; |
94 | int tagger_date; |
94 | int tagger_date; |
95 | char *msg; |
95 | char *msg; |
96 | }; |
96 | }; |
97 | |
97 | |
98 | struct refinfo { |
98 | struct refinfo { |
99 | const char *refname; |
99 | const char *refname; |
100 | struct object *object; |
100 | struct object *object; |
101 | union { |
101 | union { |
102 | struct taginfo *tag; |
102 | struct taginfo *tag; |
103 | struct commitinfo *commit; |
103 | struct commitinfo *commit; |
104 | }; |
104 | }; |
105 | }; |
105 | }; |
106 | |
106 | |
107 | struct reflist { |
107 | struct reflist { |
108 | struct refinfo **refs; |
108 | struct refinfo **refs; |
109 | int alloc; |
109 | int alloc; |
110 | int count; |
110 | int count; |
111 | }; |
111 | }; |
112 | |
112 | |
113 | struct cgit_query { |
113 | struct cgit_query { |
114 | int has_symref; |
114 | int has_symref; |
115 | int has_sha1; |
115 | int has_sha1; |
116 | char *raw; |
116 | char *raw; |
117 | char *repo; |
117 | char *repo; |
118 | char *page; |
118 | char *page; |
119 | char *search; |
119 | char *search; |
120 | char *grep; |
120 | char *grep; |
121 | char *head; |
121 | char *head; |
122 | char *sha1; |
122 | char *sha1; |
123 | char *sha2; |
123 | char *sha2; |
124 | char *path; |
124 | char *path; |
125 | char *name; |
125 | char *name; |
126 | int ofs; |
126 | int ofs; |
127 | }; |
127 | }; |
128 | |
128 | |
129 | struct cgit_config { |
129 | struct cgit_config { |
130 | char *agefile; |
130 | char *agefile; |
131 | char *cache_root; |
131 | char *cache_root; |
132 | char *clone_prefix; |
132 | char *clone_prefix; |
133 | char *css; |
133 | char *css; |
134 | char *index_header; |
134 | char *index_header; |
135 | char *index_info; |
135 | char *index_info; |
136 | char *logo; |
136 | char *logo; |
137 | char *logo_link; |
137 | char *logo_link; |
138 | char *module_link; |
138 | char *module_link; |
139 | char *repo_group; |
139 | char *repo_group; |
140 | char *robots; |
140 | char *robots; |
141 | char *root_title; |
141 | char *root_title; |
142 | char *script_name; |
142 | char *script_name; |
143 | char *virtual_root; |
143 | char *virtual_root; |
144 | int cache_dynamic_ttl; |
144 | int cache_dynamic_ttl; |
145 | int cache_max_create_time; |
145 | int cache_max_create_time; |
146 | int cache_repo_ttl; |
146 | int cache_repo_ttl; |
147 | int cache_root_ttl; |
147 | int cache_root_ttl; |
148 | int cache_static_ttl; |
148 | int cache_static_ttl; |
149 | int enable_index_links; |
149 | int enable_index_links; |
150 | int enable_log_filecount; |
150 | int enable_log_filecount; |
151 | int enable_log_linecount; |
151 | int enable_log_linecount; |
152 | int max_commit_count; |
152 | int max_commit_count; |
153 | int max_lock_attempts; |
153 | int max_lock_attempts; |
154 | int max_msg_len; |
154 | int max_msg_len; |
155 | int max_repodesc_len; |
155 | int max_repodesc_len; |
156 | int nocache; |
156 | int nocache; |
157 | int renamelimit; |
157 | int renamelimit; |
158 | int snapshots; |
158 | int snapshots; |
159 | int summary_branches; |
159 | int summary_branches; |
160 | int summary_log; |
160 | int summary_log; |
161 | int summary_tags; |
161 | int summary_tags; |
162 | }; |
162 | }; |
163 | |
163 | |
164 | struct cgit_page { |
164 | struct cgit_page { |
165 | time_t modified; |
165 | time_t modified; |
166 | time_t expires; |
166 | time_t expires; |
167 | char *mimetype; |
167 | char *mimetype; |
168 | char *charset; |
168 | char *charset; |
169 | char *filename; |
169 | char *filename; |
170 | char *title; |
170 | char *title; |
171 | }; |
171 | }; |
172 | |
172 | |
173 | struct cgit_context { |
173 | struct cgit_context { |
174 | struct cgit_query qry; |
174 | struct cgit_query qry; |
175 | struct cgit_config cfg; |
175 | struct cgit_config cfg; |
176 | struct cgit_repo *repo; |
176 | struct cgit_repo *repo; |
177 | struct cgit_page page; |
177 | struct cgit_page page; |
178 | }; |
178 | }; |
179 | |
179 | |
180 | struct cgit_snapshot_format { |
180 | struct cgit_snapshot_format { |
181 | const char *suffix; |
181 | const char *suffix; |
182 | const char *mimetype; |
182 | const char *mimetype; |
183 | write_archive_fn_t write_func; |
183 | write_archive_fn_t write_func; |
184 | int bit; |
184 | int bit; |
185 | }; |
185 | }; |
186 | |
186 | |
187 | extern const char *cgit_version; |
187 | extern const char *cgit_version; |
188 | |
188 | |
189 | extern struct cgit_repolist cgit_repolist; |
189 | extern struct cgit_repolist cgit_repolist; |
190 | extern struct cgit_context ctx; |
190 | extern struct cgit_context ctx; |
191 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; |
191 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; |
192 | extern int cgit_cmd; |
192 | extern int cgit_cmd; |
193 | |
193 | |
194 | extern void cgit_prepare_context(struct cgit_context *ctx); |
194 | extern void cgit_prepare_context(struct cgit_context *ctx); |
195 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
195 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
196 | extern void cgit_global_config_cb(const char *name, const char *value); |
196 | extern void cgit_global_config_cb(const char *name, const char *value); |
197 | extern void cgit_repo_config_cb(const char *name, const char *value); |
197 | extern void cgit_repo_config_cb(const char *name, const char *value); |
198 | extern void cgit_querystring_cb(const char *name, const char *value); |
198 | extern void cgit_querystring_cb(const char *name, const char *value); |
199 | |
199 | |
200 | extern int chk_zero(int result, char *msg); |
200 | extern int chk_zero(int result, char *msg); |
201 | extern int chk_positive(int result, char *msg); |
201 | extern int chk_positive(int result, char *msg); |
202 | extern int chk_non_negative(int result, char *msg); |
202 | extern int chk_non_negative(int result, char *msg); |
203 | |
203 | |
204 | extern int hextoint(char c); |
204 | extern int hextoint(char c); |
205 | extern char *trim_end(const char *str, char c); |
205 | extern char *trim_end(const char *str, char c); |
206 | extern char *strlpart(char *txt, int maxlen); |
206 | extern char *strlpart(char *txt, int maxlen); |
207 | extern char *strrpart(char *txt, int maxlen); |
207 | extern char *strrpart(char *txt, int maxlen); |
208 | |
208 | |
209 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
209 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
210 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
210 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
211 | int flags, void *cb_data); |
211 | int flags, void *cb_data); |
212 | |
212 | |
213 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
213 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
214 | |
214 | |
215 | extern int cgit_diff_files(const unsigned char *old_sha1, |
215 | extern int cgit_diff_files(const unsigned char *old_sha1, |
216 | const unsigned char *new_sha1, |
216 | const unsigned char *new_sha1, |
217 | linediff_fn fn); |
217 | linediff_fn fn); |
218 | |
218 | |
219 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
219 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
220 | const unsigned char *new_sha1, |
220 | const unsigned char *new_sha1, |
221 | filepair_fn fn, const char *prefix); |
221 | filepair_fn fn, const char *prefix); |
222 | |
222 | |
223 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
223 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
224 | |
224 | |
225 | extern char *fmt(const char *format,...); |
225 | extern char *fmt(const char *format,...); |
226 | |
226 | |
227 | extern int cgit_read_config(const char *filename, configfn fn); |
227 | extern int cgit_read_config(const char *filename, configfn fn); |
228 | extern int cgit_parse_query(char *txt, configfn fn); |
228 | extern int cgit_parse_query(char *txt, configfn fn); |
229 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
229 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
230 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
230 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
231 | extern void cgit_parse_url(const char *url); |
231 | extern void cgit_parse_url(const char *url); |
232 | |
232 | |
233 | extern char *cache_safe_filename(const char *unsafe); |
233 | extern char *cache_safe_filename(const char *unsafe); |
234 | extern int cache_lock(struct cacheitem *item); |
234 | extern int cache_lock(struct cacheitem *item); |
235 | extern int cache_unlock(struct cacheitem *item); |
235 | extern int cache_unlock(struct cacheitem *item); |
236 | extern int cache_cancel_lock(struct cacheitem *item); |
236 | extern int cache_cancel_lock(struct cacheitem *item); |
237 | extern int cache_exist(struct cacheitem *item); |
237 | extern int cache_exist(struct cacheitem *item); |
238 | extern int cache_expired(struct cacheitem *item); |
238 | extern int cache_expired(struct cacheitem *item); |
239 | |
239 | |
240 | extern char *cgit_repourl(const char *reponame); |
| |
241 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
| |
242 | const char *filename, const char *query); |
| |
243 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
| |
244 | const char *query); |
| |
245 | |
| |
246 | extern const char *cgit_repobasename(const char *reponame); |
240 | extern const char *cgit_repobasename(const char *reponame); |
247 | |
241 | |
248 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
| |
249 | char *rev, char *path); |
| |
250 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
| |
251 | char *rev, char *path, int ofs, char *grep, |
| |
252 | char *pattern); |
| |
253 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
| |
254 | char *rev); |
| |
255 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
| |
256 | char *rev, char *path); |
| |
257 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
| |
258 | char *head, char *rev, char *archivename); |
| |
259 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
| |
260 | char *new_rev, char *old_rev, char *path); |
| |
261 | |
| |
262 | extern void cgit_object_link(struct object *obj); |
| |
263 | |
| |
264 | extern void cgit_print_error(char *msg); |
| |
265 | extern void cgit_print_date(time_t secs, char *format); |
| |
266 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
| |
267 | extern void cgit_print_http_headers(struct cgit_context *ctx); |
| |
268 | extern void cgit_print_docstart(struct cgit_context *ctx); |
| |
269 | extern void cgit_print_docend(); |
| |
270 | extern void cgit_print_pageheader(struct cgit_context *ctx); |
| |
271 | extern void cgit_print_filemode(unsigned short mode); |
| |
272 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
| |
273 | const char *hex, int snapshots); |
| |
274 | extern int cgit_parse_snapshots_mask(const char *str); |
242 | extern int cgit_parse_snapshots_mask(const char *str); |
275 | |
243 | |
276 | #endif /* CGIT_H */ |
244 | #endif /* CGIT_H */ |
|