|
diff --git a/cgit.h b/cgit.h index 0338ebd..598d8c3 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -21,221 +21,221 @@ |
21 | |
21 | |
22 | /* |
22 | /* |
23 | * The valid cgit repo-commands |
23 | * The valid cgit repo-commands |
24 | */ |
24 | */ |
25 | #define CMD_LOG 1 |
25 | #define CMD_LOG 1 |
26 | #define CMD_COMMIT 2 |
26 | #define CMD_COMMIT 2 |
27 | #define CMD_DIFF 3 |
27 | #define CMD_DIFF 3 |
28 | #define CMD_TREE 4 |
28 | #define CMD_TREE 4 |
29 | #define CMD_BLOB 5 |
29 | #define CMD_BLOB 5 |
30 | #define CMD_SNAPSHOT 6 |
30 | #define CMD_SNAPSHOT 6 |
31 | #define CMD_TAG 7 |
31 | #define CMD_TAG 7 |
32 | #define CMD_REFS 8 |
32 | #define CMD_REFS 8 |
33 | #define CMD_PATCH 9 |
33 | #define CMD_PATCH 9 |
34 | |
34 | |
35 | /* |
35 | /* |
36 | * Dateformats used on misc. pages |
36 | * Dateformats used on misc. pages |
37 | */ |
37 | */ |
38 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
38 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
39 | #define FMT_SHORTDATE "%Y-%m-%d" |
39 | #define FMT_SHORTDATE "%Y-%m-%d" |
40 | |
40 | |
41 | |
41 | |
42 | /* |
42 | /* |
43 | * Limits used for relative dates |
43 | * Limits used for relative dates |
44 | */ |
44 | */ |
45 | #define TM_MIN 60 |
45 | #define TM_MIN 60 |
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 cgit_repo { |
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 cgit_repolist { |
86 | int length; |
86 | int length; |
87 | int count; |
87 | int count; |
88 | struct repoinfo *repos; |
88 | struct cgit_repo *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 { |
142 | struct cgit_config { |
143 | char *agefile; |
143 | char *agefile; |
144 | char *cache_root; |
144 | char *cache_root; |
145 | char *clone_prefix; |
145 | char *clone_prefix; |
146 | char *css; |
146 | char *css; |
147 | char *index_header; |
147 | char *index_header; |
148 | char *index_info; |
148 | char *index_info; |
149 | char *logo; |
149 | char *logo; |
150 | char *logo_link; |
150 | char *logo_link; |
151 | char *module_link; |
151 | char *module_link; |
152 | char *repo_group; |
152 | char *repo_group; |
153 | char *robots; |
153 | char *robots; |
154 | char *root_title; |
154 | char *root_title; |
155 | char *script_name; |
155 | char *script_name; |
156 | char *virtual_root; |
156 | char *virtual_root; |
157 | int cache_dynamic_ttl; |
157 | int cache_dynamic_ttl; |
158 | int cache_max_create_time; |
158 | int cache_max_create_time; |
159 | int cache_repo_ttl; |
159 | int cache_repo_ttl; |
160 | int cache_root_ttl; |
160 | int cache_root_ttl; |
161 | int cache_static_ttl; |
161 | int cache_static_ttl; |
162 | int enable_index_links; |
162 | int enable_index_links; |
163 | int enable_log_filecount; |
163 | int enable_log_filecount; |
164 | int enable_log_linecount; |
164 | int enable_log_linecount; |
165 | int max_commit_count; |
165 | int max_commit_count; |
166 | int max_lock_attempts; |
166 | int max_lock_attempts; |
167 | int max_msg_len; |
167 | int max_msg_len; |
168 | int max_repodesc_len; |
168 | int max_repodesc_len; |
169 | int nocache; |
169 | int nocache; |
170 | int renamelimit; |
170 | int renamelimit; |
171 | int snapshots; |
171 | int snapshots; |
172 | int summary_branches; |
172 | int summary_branches; |
173 | int summary_log; |
173 | int summary_log; |
174 | int summary_tags; |
174 | int summary_tags; |
175 | }; |
175 | }; |
176 | |
176 | |
177 | struct cgit_context { |
177 | struct cgit_context { |
178 | struct cgit_query qry; |
178 | struct cgit_query qry; |
179 | struct cgit_config cfg; |
179 | struct cgit_config cfg; |
| |
180 | struct cgit_repo *repo; |
180 | }; |
181 | }; |
181 | |
182 | |
182 | extern const char *cgit_version; |
183 | extern const char *cgit_version; |
183 | |
184 | |
184 | extern struct repolist cgit_repolist; |
185 | extern struct cgit_repolist cgit_repolist; |
185 | extern struct repoinfo *cgit_repo; |
| |
186 | extern struct cgit_context ctx; |
186 | extern struct cgit_context ctx; |
187 | extern int cgit_cmd; |
187 | extern int cgit_cmd; |
188 | |
188 | |
189 | extern int htmlfd; |
189 | extern int htmlfd; |
190 | |
190 | |
191 | extern void cgit_prepare_context(struct cgit_context *ctx); |
191 | extern void cgit_prepare_context(struct cgit_context *ctx); |
192 | extern int cgit_get_cmd_index(const char *cmd); |
192 | extern int cgit_get_cmd_index(const char *cmd); |
193 | extern struct repoinfo *cgit_get_repoinfo(const char *url); |
193 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
194 | 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); |
195 | 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); |
196 | extern void cgit_querystring_cb(const char *name, const char *value); |
196 | extern void cgit_querystring_cb(const char *name, const char *value); |
197 | |
197 | |
198 | extern int chk_zero(int result, char *msg); |
198 | extern int chk_zero(int result, char *msg); |
199 | extern int chk_positive(int result, char *msg); |
199 | extern int chk_positive(int result, char *msg); |
200 | extern int chk_non_negative(int result, char *msg); |
200 | extern int chk_non_negative(int result, char *msg); |
201 | |
201 | |
202 | extern int hextoint(char c); |
202 | extern int hextoint(char c); |
203 | extern char *trim_end(const char *str, char c); |
203 | extern char *trim_end(const char *str, char c); |
204 | extern char *strlpart(char *txt, int maxlen); |
204 | extern char *strlpart(char *txt, int maxlen); |
205 | extern char *strrpart(char *txt, int maxlen); |
205 | extern char *strrpart(char *txt, int maxlen); |
206 | |
206 | |
207 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
207 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
208 | 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, |
209 | int flags, void *cb_data); |
209 | int flags, void *cb_data); |
210 | |
210 | |
211 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
211 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
212 | |
212 | |
213 | extern int cgit_diff_files(const unsigned char *old_sha1, |
213 | extern int cgit_diff_files(const unsigned char *old_sha1, |
214 | const unsigned char *new_sha1, |
214 | const unsigned char *new_sha1, |
215 | linediff_fn fn); |
215 | linediff_fn fn); |
216 | |
216 | |
217 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
217 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
218 | const unsigned char *new_sha1, |
218 | const unsigned char *new_sha1, |
219 | filepair_fn fn, const char *prefix); |
219 | filepair_fn fn, const char *prefix); |
220 | |
220 | |
221 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
221 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
222 | |
222 | |
223 | extern char *fmt(const char *format,...); |
223 | extern char *fmt(const char *format,...); |
224 | |
224 | |
225 | extern void html(const char *txt); |
225 | extern void html(const char *txt); |
226 | extern void htmlf(const char *format,...); |
226 | extern void htmlf(const char *format,...); |
227 | extern void html_txt(char *txt); |
227 | extern void html_txt(char *txt); |
228 | extern void html_ntxt(int len, char *txt); |
228 | extern void html_ntxt(int len, char *txt); |
229 | extern void html_attr(char *txt); |
229 | extern void html_attr(char *txt); |
230 | extern void html_hidden(char *name, char *value); |
230 | extern void html_hidden(char *name, char *value); |
231 | extern void html_option(char *value, char *text, char *selected_value); |
231 | extern void html_option(char *value, char *text, char *selected_value); |
232 | extern void html_link_open(char *url, char *title, char *class); |
232 | extern void html_link_open(char *url, char *title, char *class); |
233 | extern void html_link_close(void); |
233 | extern void html_link_close(void); |
234 | extern void html_filemode(unsigned short mode); |
234 | extern void html_filemode(unsigned short mode); |
235 | extern int html_include(const char *filename); |
235 | extern int html_include(const char *filename); |
236 | |
236 | |
237 | extern int cgit_read_config(const char *filename, configfn fn); |
237 | extern int cgit_read_config(const char *filename, configfn fn); |
238 | extern int cgit_parse_query(char *txt, configfn fn); |
238 | extern int cgit_parse_query(char *txt, configfn fn); |
239 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
239 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
240 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
240 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
241 | extern void cgit_parse_url(const char *url); |
241 | extern void cgit_parse_url(const char *url); |
|