|
diff --git a/cgit.h b/cgit.h index 4576efb..0338ebd 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -46,240 +46,242 @@ |
46 | #define TM_HOUR (TM_MIN * 60) |
46 | #define TM_HOUR (TM_MIN * 60) |
47 | #define TM_DAY (TM_HOUR * 24) |
47 | #define TM_DAY (TM_HOUR * 24) |
48 | #define TM_WEEK (TM_DAY * 7) |
48 | #define TM_WEEK (TM_DAY * 7) |
49 | #define TM_YEAR (TM_DAY * 365) |
49 | #define TM_YEAR (TM_DAY * 365) |
50 | #define TM_MONTH (TM_YEAR / 12.0) |
50 | #define TM_MONTH (TM_YEAR / 12.0) |
51 | |
51 | |
52 | |
52 | |
53 | /* |
53 | /* |
54 | * Default encoding |
54 | * Default encoding |
55 | */ |
55 | */ |
56 | #define PAGE_ENCODING "UTF-8" |
56 | #define PAGE_ENCODING "UTF-8" |
57 | |
57 | |
58 | typedef void (*configfn)(const char *name, const char *value); |
58 | typedef void (*configfn)(const char *name, const char *value); |
59 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
59 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
60 | typedef void (*linediff_fn)(char *line, int len); |
60 | typedef void (*linediff_fn)(char *line, int len); |
61 | |
61 | |
62 | struct cacheitem { |
62 | struct cacheitem { |
63 | char *name; |
63 | char *name; |
64 | struct stat st; |
64 | struct stat st; |
65 | int ttl; |
65 | int ttl; |
66 | int fd; |
66 | int fd; |
67 | }; |
67 | }; |
68 | |
68 | |
69 | struct repoinfo { |
69 | struct repoinfo { |
70 | char *url; |
70 | char *url; |
71 | char *name; |
71 | char *name; |
72 | char *path; |
72 | char *path; |
73 | char *desc; |
73 | char *desc; |
74 | char *owner; |
74 | char *owner; |
75 | char *defbranch; |
75 | char *defbranch; |
76 | char *group; |
76 | char *group; |
77 | char *module_link; |
77 | char *module_link; |
78 | char *readme; |
78 | char *readme; |
79 | char *clone_url; |
79 | char *clone_url; |
80 | int snapshots; |
80 | int snapshots; |
81 | int enable_log_filecount; |
81 | int enable_log_filecount; |
82 | int enable_log_linecount; |
82 | int enable_log_linecount; |
83 | }; |
83 | }; |
84 | |
84 | |
85 | struct repolist { |
85 | struct repolist { |
86 | int length; |
86 | int length; |
87 | int count; |
87 | int count; |
88 | struct repoinfo *repos; |
88 | struct repoinfo *repos; |
89 | }; |
89 | }; |
90 | |
90 | |
91 | struct commitinfo { |
91 | struct commitinfo { |
92 | struct commit *commit; |
92 | struct commit *commit; |
93 | char *author; |
93 | char *author; |
94 | char *author_email; |
94 | char *author_email; |
95 | unsigned long author_date; |
95 | unsigned long author_date; |
96 | char *committer; |
96 | char *committer; |
97 | char *committer_email; |
97 | char *committer_email; |
98 | unsigned long committer_date; |
98 | unsigned long committer_date; |
99 | char *subject; |
99 | char *subject; |
100 | char *msg; |
100 | char *msg; |
101 | char *msg_encoding; |
101 | char *msg_encoding; |
102 | }; |
102 | }; |
103 | |
103 | |
104 | struct taginfo { |
104 | struct taginfo { |
105 | char *tagger; |
105 | char *tagger; |
106 | char *tagger_email; |
106 | char *tagger_email; |
107 | int tagger_date; |
107 | int tagger_date; |
108 | char *msg; |
108 | char *msg; |
109 | }; |
109 | }; |
110 | |
110 | |
111 | struct refinfo { |
111 | struct refinfo { |
112 | const char *refname; |
112 | const char *refname; |
113 | struct object *object; |
113 | struct object *object; |
114 | union { |
114 | union { |
115 | struct taginfo *tag; |
115 | struct taginfo *tag; |
116 | struct commitinfo *commit; |
116 | struct commitinfo *commit; |
117 | }; |
117 | }; |
118 | }; |
118 | }; |
119 | |
119 | |
120 | struct reflist { |
120 | struct reflist { |
121 | struct refinfo **refs; |
121 | struct refinfo **refs; |
122 | int alloc; |
122 | int alloc; |
123 | int count; |
123 | int count; |
124 | }; |
124 | }; |
125 | |
125 | |
126 | struct cgit_query { |
126 | struct cgit_query { |
127 | int has_symref; |
127 | int has_symref; |
128 | int has_sha1; |
128 | int has_sha1; |
129 | char *raw; |
129 | char *raw; |
130 | char *repo; |
130 | char *repo; |
131 | char *page; |
131 | char *page; |
132 | char *search; |
132 | char *search; |
133 | char *grep; |
133 | char *grep; |
134 | char *head; |
134 | char *head; |
135 | char *sha1; |
135 | char *sha1; |
136 | char *sha2; |
136 | char *sha2; |
137 | char *path; |
137 | char *path; |
138 | char *name; |
138 | char *name; |
139 | int ofs; |
139 | int ofs; |
140 | }; |
140 | }; |
141 | |
141 | |
| |
142 | struct cgit_config { |
| |
143 | char *agefile; |
| |
144 | char *cache_root; |
| |
145 | char *clone_prefix; |
| |
146 | char *css; |
| |
147 | char *index_header; |
| |
148 | char *index_info; |
| |
149 | char *logo; |
| |
150 | char *logo_link; |
| |
151 | char *module_link; |
| |
152 | char *repo_group; |
| |
153 | char *robots; |
| |
154 | char *root_title; |
| |
155 | char *script_name; |
| |
156 | char *virtual_root; |
| |
157 | int cache_dynamic_ttl; |
| |
158 | int cache_max_create_time; |
| |
159 | int cache_repo_ttl; |
| |
160 | int cache_root_ttl; |
| |
161 | int cache_static_ttl; |
| |
162 | int enable_index_links; |
| |
163 | int enable_log_filecount; |
| |
164 | int enable_log_linecount; |
| |
165 | int max_commit_count; |
| |
166 | int max_lock_attempts; |
| |
167 | int max_msg_len; |
| |
168 | int max_repodesc_len; |
| |
169 | int nocache; |
| |
170 | int renamelimit; |
| |
171 | int snapshots; |
| |
172 | int summary_branches; |
| |
173 | int summary_log; |
| |
174 | int summary_tags; |
| |
175 | }; |
| |
176 | |
142 | struct cgit_context { |
177 | struct cgit_context { |
143 | struct cgit_query qry; |
178 | struct cgit_query qry; |
| |
179 | struct cgit_config cfg; |
144 | }; |
180 | }; |
145 | |
181 | |
146 | extern const char *cgit_version; |
182 | extern const char *cgit_version; |
147 | |
183 | |
148 | extern struct repolist cgit_repolist; |
184 | extern struct repolist cgit_repolist; |
149 | extern struct repoinfo *cgit_repo; |
185 | extern struct repoinfo *cgit_repo; |
150 | extern struct cgit_context ctx; |
186 | extern struct cgit_context ctx; |
151 | extern int cgit_cmd; |
187 | extern int cgit_cmd; |
152 | |
188 | |
153 | extern char *cgit_root_title; |
| |
154 | extern char *cgit_css; |
| |
155 | extern char *cgit_logo; |
| |
156 | extern char *cgit_index_header; |
| |
157 | extern char *cgit_index_info; |
| |
158 | extern char *cgit_logo_link; |
| |
159 | extern char *cgit_module_link; |
| |
160 | extern char *cgit_agefile; |
| |
161 | extern char *cgit_virtual_root; |
| |
162 | extern char *cgit_script_name; |
| |
163 | extern char *cgit_cache_root; |
| |
164 | extern char *cgit_repo_group; |
| |
165 | extern char *cgit_robots; |
| |
166 | extern char *cgit_clone_prefix; |
| |
167 | |
| |
168 | extern int cgit_nocache; |
| |
169 | extern int cgit_snapshots; |
| |
170 | extern int cgit_enable_index_links; |
| |
171 | extern int cgit_enable_log_filecount; |
| |
172 | extern int cgit_enable_log_linecount; |
| |
173 | extern int cgit_max_lock_attempts; |
| |
174 | extern int cgit_cache_root_ttl; |
| |
175 | extern int cgit_cache_repo_ttl; |
| |
176 | extern int cgit_cache_dynamic_ttl; |
| |
177 | extern int cgit_cache_static_ttl; |
| |
178 | extern int cgit_cache_max_create_time; |
| |
179 | extern int cgit_summary_log; |
| |
180 | extern int cgit_summary_tags; |
| |
181 | extern int cgit_summary_branches; |
| |
182 | |
| |
183 | extern int cgit_max_msg_len; |
| |
184 | extern int cgit_max_repodesc_len; |
| |
185 | extern int cgit_max_commit_count; |
| |
186 | |
| |
187 | |
| |
188 | extern int htmlfd; |
189 | extern int htmlfd; |
189 | |
190 | |
| |
191 | extern void cgit_prepare_context(struct cgit_context *ctx); |
190 | extern int cgit_get_cmd_index(const char *cmd); |
192 | extern int cgit_get_cmd_index(const char *cmd); |
191 | extern struct repoinfo *cgit_get_repoinfo(const char *url); |
193 | extern struct repoinfo *cgit_get_repoinfo(const char *url); |
192 | extern void cgit_global_config_cb(const char *name, const char *value); |
194 | extern void cgit_global_config_cb(const char *name, const char *value); |
193 | extern void cgit_repo_config_cb(const char *name, const char *value); |
195 | extern void cgit_repo_config_cb(const char *name, const char *value); |
194 | extern void cgit_querystring_cb(const char *name, const char *value); |
196 | extern void cgit_querystring_cb(const char *name, const char *value); |
195 | |
197 | |
196 | extern int chk_zero(int result, char *msg); |
198 | extern int chk_zero(int result, char *msg); |
197 | extern int chk_positive(int result, char *msg); |
199 | extern int chk_positive(int result, char *msg); |
198 | extern int chk_non_negative(int result, char *msg); |
200 | extern int chk_non_negative(int result, char *msg); |
199 | |
201 | |
200 | extern int hextoint(char c); |
202 | extern int hextoint(char c); |
201 | extern char *trim_end(const char *str, char c); |
203 | extern char *trim_end(const char *str, char c); |
202 | extern char *strlpart(char *txt, int maxlen); |
204 | extern char *strlpart(char *txt, int maxlen); |
203 | extern char *strrpart(char *txt, int maxlen); |
205 | extern char *strrpart(char *txt, int maxlen); |
204 | |
206 | |
205 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
207 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
206 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
208 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
207 | int flags, void *cb_data); |
209 | int flags, void *cb_data); |
208 | |
210 | |
209 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
211 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
210 | |
212 | |
211 | extern int cgit_diff_files(const unsigned char *old_sha1, |
213 | extern int cgit_diff_files(const unsigned char *old_sha1, |
212 | const unsigned char *new_sha1, |
214 | const unsigned char *new_sha1, |
213 | linediff_fn fn); |
215 | linediff_fn fn); |
214 | |
216 | |
215 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
217 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
216 | const unsigned char *new_sha1, |
218 | const unsigned char *new_sha1, |
217 | filepair_fn fn, const char *prefix); |
219 | filepair_fn fn, const char *prefix); |
218 | |
220 | |
219 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
221 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
220 | |
222 | |
221 | extern char *fmt(const char *format,...); |
223 | extern char *fmt(const char *format,...); |
222 | |
224 | |
223 | extern void html(const char *txt); |
225 | extern void html(const char *txt); |
224 | extern void htmlf(const char *format,...); |
226 | extern void htmlf(const char *format,...); |
225 | extern void html_txt(char *txt); |
227 | extern void html_txt(char *txt); |
226 | extern void html_ntxt(int len, char *txt); |
228 | extern void html_ntxt(int len, char *txt); |
227 | extern void html_attr(char *txt); |
229 | extern void html_attr(char *txt); |
228 | extern void html_hidden(char *name, char *value); |
230 | extern void html_hidden(char *name, char *value); |
229 | extern void html_option(char *value, char *text, char *selected_value); |
231 | extern void html_option(char *value, char *text, char *selected_value); |
230 | extern void html_link_open(char *url, char *title, char *class); |
232 | extern void html_link_open(char *url, char *title, char *class); |
231 | extern void html_link_close(void); |
233 | extern void html_link_close(void); |
232 | extern void html_filemode(unsigned short mode); |
234 | extern void html_filemode(unsigned short mode); |
233 | extern int html_include(const char *filename); |
235 | extern int html_include(const char *filename); |
234 | |
236 | |
235 | extern int cgit_read_config(const char *filename, configfn fn); |
237 | extern int cgit_read_config(const char *filename, configfn fn); |
236 | extern int cgit_parse_query(char *txt, configfn fn); |
238 | extern int cgit_parse_query(char *txt, configfn fn); |
237 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
239 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
238 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
240 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
239 | extern void cgit_parse_url(const char *url); |
241 | extern void cgit_parse_url(const char *url); |
240 | |
242 | |
241 | extern char *cache_safe_filename(const char *unsafe); |
243 | extern char *cache_safe_filename(const char *unsafe); |
242 | extern int cache_lock(struct cacheitem *item); |
244 | extern int cache_lock(struct cacheitem *item); |
243 | extern int cache_unlock(struct cacheitem *item); |
245 | extern int cache_unlock(struct cacheitem *item); |
244 | extern int cache_cancel_lock(struct cacheitem *item); |
246 | extern int cache_cancel_lock(struct cacheitem *item); |
245 | extern int cache_exist(struct cacheitem *item); |
247 | extern int cache_exist(struct cacheitem *item); |
246 | extern int cache_expired(struct cacheitem *item); |
248 | extern int cache_expired(struct cacheitem *item); |
247 | |
249 | |
248 | extern char *cgit_repourl(const char *reponame); |
250 | extern char *cgit_repourl(const char *reponame); |
249 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
251 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
250 | const char *filename, const char *query); |
252 | const char *filename, const char *query); |
251 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
253 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
252 | const char *query); |
254 | const char *query); |
253 | |
255 | |
254 | extern const char *cgit_repobasename(const char *reponame); |
256 | extern const char *cgit_repobasename(const char *reponame); |
255 | |
257 | |
256 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
258 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
257 | char *rev, char *path); |
259 | char *rev, char *path); |
258 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
260 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
259 | char *rev, char *path, int ofs, char *grep, |
261 | char *rev, char *path, int ofs, char *grep, |
260 | char *pattern); |
262 | char *pattern); |
261 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
263 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
262 | char *rev); |
264 | char *rev); |
263 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
265 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
264 | char *rev, char *path); |
266 | char *rev, char *path); |
265 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
267 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
266 | char *head, char *rev, char *archivename); |
268 | char *head, char *rev, char *archivename); |
267 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
269 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
268 | char *new_rev, char *old_rev, char *path); |
270 | char *new_rev, char *old_rev, char *path); |
269 | |
271 | |
270 | extern void cgit_object_link(struct object *obj); |
272 | extern void cgit_object_link(struct object *obj); |
271 | |
273 | |
272 | extern void cgit_print_error(char *msg); |
274 | extern void cgit_print_error(char *msg); |
273 | extern void cgit_print_date(time_t secs, char *format); |
275 | extern void cgit_print_date(time_t secs, char *format); |
274 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
276 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
275 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
277 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
276 | extern void cgit_print_docend(); |
278 | extern void cgit_print_docend(); |
277 | extern void cgit_print_pageheader(char *title, int show_search); |
279 | extern void cgit_print_pageheader(char *title, int show_search); |
278 | extern void cgit_print_snapshot_start(const char *mimetype, |
280 | extern void cgit_print_snapshot_start(const char *mimetype, |
279 | const char *filename, |
281 | const char *filename, |
280 | struct cacheitem *item); |
282 | struct cacheitem *item); |
281 | extern void cgit_print_branches(int maxcount); |
283 | extern void cgit_print_branches(int maxcount); |
282 | extern void cgit_print_tags(int maxcount); |
284 | extern void cgit_print_tags(int maxcount); |
283 | |
285 | |
284 | extern void cgit_print_repolist(struct cacheitem *item); |
286 | extern void cgit_print_repolist(struct cacheitem *item); |
285 | extern void cgit_print_summary(); |
287 | extern void cgit_print_summary(); |
|