author | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:46:01 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:46:01 (UTC) |
commit | db6303b58883c4417f5bcc0c1ee34fed6553dca3 (patch) (unidiff) | |
tree | ef7775ade9eef57c5a878f9588fe545a7da2c952 /cgit.h | |
parent | 17e3ff42646f182911fd0e5d872082977538db9e (diff) | |
parent | 97b3d252629a8a3b9d356c2532dec7611438e4b9 (diff) | |
download | cgit-db6303b58883c4417f5bcc0c1ee34fed6553dca3.zip cgit-db6303b58883c4417f5bcc0c1ee34fed6553dca3.tar.gz cgit-db6303b58883c4417f5bcc0c1ee34fed6553dca3.tar.bz2 |
Merge branch 'lh/plugins'
Conflicts:
cgit.c
cgit.h
-rw-r--r-- | cgit.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -4,112 +4,123 @@ | |||
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 <string-list.h> | 18 | #include <string-list.h> |
19 | #include <xdiff-interface.h> | 19 | #include <xdiff-interface.h> |
20 | #include <xdiff/xdiff.h> | 20 | #include <xdiff/xdiff.h> |
21 | #include <utf8.h> | 21 | #include <utf8.h> |
22 | 22 | ||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * Dateformats used on misc. pages | 25 | * Dateformats used on misc. pages |
26 | */ | 26 | */ |
27 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" | 27 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" |
28 | #define FMT_SHORTDATE "%Y-%m-%d" | 28 | #define FMT_SHORTDATE "%Y-%m-%d" |
29 | #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" | 29 | #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" |
30 | 30 | ||
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Limits used for relative dates | 33 | * Limits used for relative dates |
34 | */ | 34 | */ |
35 | #define TM_MIN 60 | 35 | #define TM_MIN 60 |
36 | #define TM_HOUR (TM_MIN * 60) | 36 | #define TM_HOUR (TM_MIN * 60) |
37 | #define TM_DAY (TM_HOUR * 24) | 37 | #define TM_DAY (TM_HOUR * 24) |
38 | #define TM_WEEK (TM_DAY * 7) | 38 | #define TM_WEEK (TM_DAY * 7) |
39 | #define TM_YEAR (TM_DAY * 365) | 39 | #define TM_YEAR (TM_DAY * 365) |
40 | #define TM_MONTH (TM_YEAR / 12.0) | 40 | #define TM_MONTH (TM_YEAR / 12.0) |
41 | 41 | ||
42 | 42 | ||
43 | /* | 43 | /* |
44 | * Default encoding | 44 | * Default encoding |
45 | */ | 45 | */ |
46 | #define PAGE_ENCODING "UTF-8" | 46 | #define PAGE_ENCODING "UTF-8" |
47 | 47 | ||
48 | typedef void (*configfn)(const char *name, const char *value); | 48 | typedef void (*configfn)(const char *name, const char *value); |
49 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 49 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
50 | typedef void (*linediff_fn)(char *line, int len); | 50 | typedef void (*linediff_fn)(char *line, int len); |
51 | 51 | ||
52 | struct cgit_filter { | ||
53 | char *cmd; | ||
54 | char **argv; | ||
55 | int old_stdout; | ||
56 | int pipe_fh[2]; | ||
57 | int pid; | ||
58 | int exitstatus; | ||
59 | }; | ||
60 | |||
52 | struct cgit_repo { | 61 | struct cgit_repo { |
53 | char *url; | 62 | char *url; |
54 | char *name; | 63 | char *name; |
55 | char *path; | 64 | char *path; |
56 | char *desc; | 65 | char *desc; |
57 | char *owner; | 66 | char *owner; |
58 | char *defbranch; | 67 | char *defbranch; |
59 | char *group; | 68 | char *group; |
60 | char *module_link; | 69 | char *module_link; |
61 | char *readme; | 70 | char *readme; |
62 | char *clone_url; | 71 | char *clone_url; |
63 | int snapshots; | 72 | int snapshots; |
64 | int enable_log_filecount; | 73 | int enable_log_filecount; |
65 | int enable_log_linecount; | 74 | int enable_log_linecount; |
66 | int max_stats; | 75 | int max_stats; |
67 | time_t mtime; | 76 | time_t mtime; |
77 | struct cgit_filter *commit_filter; | ||
78 | struct cgit_filter *source_filter; | ||
68 | }; | 79 | }; |
69 | 80 | ||
70 | struct cgit_repolist { | 81 | struct cgit_repolist { |
71 | int length; | 82 | int length; |
72 | int count; | 83 | int count; |
73 | struct cgit_repo *repos; | 84 | struct cgit_repo *repos; |
74 | }; | 85 | }; |
75 | 86 | ||
76 | struct commitinfo { | 87 | struct commitinfo { |
77 | struct commit *commit; | 88 | struct commit *commit; |
78 | char *author; | 89 | char *author; |
79 | char *author_email; | 90 | char *author_email; |
80 | unsigned long author_date; | 91 | unsigned long author_date; |
81 | char *committer; | 92 | char *committer; |
82 | char *committer_email; | 93 | char *committer_email; |
83 | unsigned long committer_date; | 94 | unsigned long committer_date; |
84 | char *subject; | 95 | char *subject; |
85 | char *msg; | 96 | char *msg; |
86 | char *msg_encoding; | 97 | char *msg_encoding; |
87 | }; | 98 | }; |
88 | 99 | ||
89 | struct taginfo { | 100 | struct taginfo { |
90 | char *tagger; | 101 | char *tagger; |
91 | char *tagger_email; | 102 | char *tagger_email; |
92 | unsigned long tagger_date; | 103 | unsigned long tagger_date; |
93 | char *msg; | 104 | char *msg; |
94 | }; | 105 | }; |
95 | 106 | ||
96 | struct refinfo { | 107 | struct refinfo { |
97 | const char *refname; | 108 | const char *refname; |
98 | struct object *object; | 109 | struct object *object; |
99 | union { | 110 | union { |
100 | struct taginfo *tag; | 111 | struct taginfo *tag; |
101 | struct commitinfo *commit; | 112 | struct commitinfo *commit; |
102 | }; | 113 | }; |
103 | }; | 114 | }; |
104 | 115 | ||
105 | struct reflist { | 116 | struct reflist { |
106 | struct refinfo **refs; | 117 | struct refinfo **refs; |
107 | int alloc; | 118 | int alloc; |
108 | int count; | 119 | int count; |
109 | }; | 120 | }; |
110 | 121 | ||
111 | struct cgit_query { | 122 | struct cgit_query { |
112 | int has_symref; | 123 | int has_symref; |
113 | int has_sha1; | 124 | int has_sha1; |
114 | char *raw; | 125 | char *raw; |
115 | char *repo; | 126 | char *repo; |
@@ -132,124 +143,129 @@ struct cgit_query { | |||
132 | 143 | ||
133 | struct cgit_config { | 144 | struct cgit_config { |
134 | char *agefile; | 145 | char *agefile; |
135 | char *cache_root; | 146 | char *cache_root; |
136 | char *clone_prefix; | 147 | char *clone_prefix; |
137 | char *css; | 148 | char *css; |
138 | char *favicon; | 149 | char *favicon; |
139 | char *footer; | 150 | char *footer; |
140 | char *head_include; | 151 | char *head_include; |
141 | char *header; | 152 | char *header; |
142 | char *index_header; | 153 | char *index_header; |
143 | char *index_info; | 154 | char *index_info; |
144 | char *logo; | 155 | char *logo; |
145 | char *logo_link; | 156 | char *logo_link; |
146 | char *module_link; | 157 | char *module_link; |
147 | char *repo_group; | 158 | char *repo_group; |
148 | char *robots; | 159 | char *robots; |
149 | char *root_title; | 160 | char *root_title; |
150 | char *root_desc; | 161 | char *root_desc; |
151 | char *root_readme; | 162 | char *root_readme; |
152 | char *script_name; | 163 | char *script_name; |
153 | char *virtual_root; | 164 | char *virtual_root; |
154 | int cache_size; | 165 | int cache_size; |
155 | int cache_dynamic_ttl; | 166 | int cache_dynamic_ttl; |
156 | int cache_max_create_time; | 167 | int cache_max_create_time; |
157 | int cache_repo_ttl; | 168 | int cache_repo_ttl; |
158 | int cache_root_ttl; | 169 | int cache_root_ttl; |
159 | int cache_static_ttl; | 170 | int cache_static_ttl; |
160 | int embedded; | 171 | int embedded; |
161 | int enable_index_links; | 172 | int enable_index_links; |
162 | int enable_log_filecount; | 173 | int enable_log_filecount; |
163 | int enable_log_linecount; | 174 | int enable_log_linecount; |
164 | int local_time; | 175 | int local_time; |
165 | int max_repo_count; | 176 | int max_repo_count; |
166 | int max_commit_count; | 177 | int max_commit_count; |
167 | int max_lock_attempts; | 178 | int max_lock_attempts; |
168 | int max_msg_len; | 179 | int max_msg_len; |
169 | int max_repodesc_len; | 180 | int max_repodesc_len; |
170 | int max_stats; | 181 | int max_stats; |
171 | int nocache; | 182 | int nocache; |
172 | int noplainemail; | 183 | int noplainemail; |
173 | int noheader; | 184 | int noheader; |
174 | int renamelimit; | 185 | int renamelimit; |
175 | int snapshots; | 186 | int snapshots; |
176 | int summary_branches; | 187 | int summary_branches; |
177 | int summary_log; | 188 | int summary_log; |
178 | int summary_tags; | 189 | int summary_tags; |
179 | struct string_list mimetypes; | 190 | struct string_list mimetypes; |
191 | struct cgit_filter *commit_filter; | ||
192 | struct cgit_filter *source_filter; | ||
180 | }; | 193 | }; |
181 | 194 | ||
182 | struct cgit_page { | 195 | struct cgit_page { |
183 | time_t modified; | 196 | time_t modified; |
184 | time_t expires; | 197 | time_t expires; |
185 | size_t size; | 198 | size_t size; |
186 | char *mimetype; | 199 | char *mimetype; |
187 | char *charset; | 200 | char *charset; |
188 | char *filename; | 201 | char *filename; |
189 | char *etag; | 202 | char *etag; |
190 | char *title; | 203 | char *title; |
191 | int status; | 204 | int status; |
192 | char *statusmsg; | 205 | char *statusmsg; |
193 | }; | 206 | }; |
194 | 207 | ||
195 | struct cgit_context { | 208 | struct cgit_context { |
196 | struct cgit_query qry; | 209 | struct cgit_query qry; |
197 | struct cgit_config cfg; | 210 | struct cgit_config cfg; |
198 | struct cgit_repo *repo; | 211 | struct cgit_repo *repo; |
199 | struct cgit_page page; | 212 | struct cgit_page page; |
200 | }; | 213 | }; |
201 | 214 | ||
202 | struct cgit_snapshot_format { | 215 | struct cgit_snapshot_format { |
203 | const char *suffix; | 216 | const char *suffix; |
204 | const char *mimetype; | 217 | const char *mimetype; |
205 | write_archive_fn_t write_func; | 218 | write_archive_fn_t write_func; |
206 | int bit; | 219 | int bit; |
207 | }; | 220 | }; |
208 | 221 | ||
209 | extern const char *cgit_version; | 222 | extern const char *cgit_version; |
210 | 223 | ||
211 | extern struct cgit_repolist cgit_repolist; | 224 | extern struct cgit_repolist cgit_repolist; |
212 | extern struct cgit_context ctx; | 225 | extern struct cgit_context ctx; |
213 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; | 226 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; |
214 | 227 | ||
215 | extern struct cgit_repo *cgit_add_repo(const char *url); | 228 | extern struct cgit_repo *cgit_add_repo(const char *url); |
216 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); | 229 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
217 | extern void cgit_repo_config_cb(const char *name, const char *value); | 230 | extern void cgit_repo_config_cb(const char *name, const char *value); |
218 | 231 | ||
219 | extern int chk_zero(int result, char *msg); | 232 | extern int chk_zero(int result, char *msg); |
220 | extern int chk_positive(int result, char *msg); | 233 | extern int chk_positive(int result, char *msg); |
221 | extern int chk_non_negative(int result, char *msg); | 234 | extern int chk_non_negative(int result, char *msg); |
222 | 235 | ||
223 | extern char *trim_end(const char *str, char c); | 236 | extern char *trim_end(const char *str, char c); |
224 | extern char *strlpart(char *txt, int maxlen); | 237 | extern char *strlpart(char *txt, int maxlen); |
225 | extern char *strrpart(char *txt, int maxlen); | 238 | extern char *strrpart(char *txt, int maxlen); |
226 | 239 | ||
227 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 240 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
228 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 241 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
229 | int flags, void *cb_data); | 242 | int flags, void *cb_data); |
230 | 243 | ||
231 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 244 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
232 | 245 | ||
233 | extern int cgit_diff_files(const unsigned char *old_sha1, | 246 | extern int cgit_diff_files(const unsigned char *old_sha1, |
234 | const unsigned char *new_sha1, | 247 | const unsigned char *new_sha1, |
235 | unsigned long *old_size, unsigned long *new_size, | 248 | unsigned long *old_size, unsigned long *new_size, |
236 | int *binary, linediff_fn fn); | 249 | int *binary, linediff_fn fn); |
237 | 250 | ||
238 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 251 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
239 | const unsigned char *new_sha1, | 252 | const unsigned char *new_sha1, |
240 | filepair_fn fn, const char *prefix); | 253 | filepair_fn fn, const char *prefix); |
241 | 254 | ||
242 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 255 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
243 | 256 | ||
244 | extern char *fmt(const char *format,...); | 257 | extern char *fmt(const char *format,...); |
245 | 258 | ||
246 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 259 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
247 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 260 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
248 | extern void cgit_parse_url(const char *url); | 261 | extern void cgit_parse_url(const char *url); |
249 | 262 | ||
250 | extern const char *cgit_repobasename(const char *reponame); | 263 | extern const char *cgit_repobasename(const char *reponame); |
251 | 264 | ||
252 | extern int cgit_parse_snapshots_mask(const char *str); | 265 | extern int cgit_parse_snapshots_mask(const char *str); |
253 | 266 | ||
267 | extern int cgit_open_filter(struct cgit_filter *filter); | ||
268 | extern int cgit_close_filter(struct cgit_filter *filter); | ||
269 | |||
254 | 270 | ||
255 | #endif /* CGIT_H */ | 271 | #endif /* CGIT_H */ |