]> git.cameronkatri.com Git - cgit.git/blob - cgit.h
Merge branch 'stable'
[cgit.git] / cgit.h
1 #ifndef CGIT_H
2 #define CGIT_H
3
4
5 #include <git-compat-util.h>
6 #include <cache.h>
7 #include <grep.h>
8 #include <object.h>
9 #include <tree.h>
10 #include <commit.h>
11 #include <tag.h>
12 #include <diff.h>
13 #include <diffcore.h>
14 #include <refs.h>
15 #include <revision.h>
16 #include <log-tree.h>
17 #include <archive.h>
18 #include <string-list.h>
19 #include <xdiff-interface.h>
20 #include <xdiff/xdiff.h>
21 #include <utf8.h>
22 #include <notes.h>
23 #include <graph.h>
24
25
26 /*
27 * Dateformats used on misc. pages
28 */
29 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
30 #define FMT_SHORTDATE "%Y-%m-%d"
31 #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
32
33
34 /*
35 * Limits used for relative dates
36 */
37 #define TM_MIN 60
38 #define TM_HOUR (TM_MIN * 60)
39 #define TM_DAY (TM_HOUR * 24)
40 #define TM_WEEK (TM_DAY * 7)
41 #define TM_YEAR (TM_DAY * 365)
42 #define TM_MONTH (TM_YEAR / 12.0)
43
44
45 /*
46 * Default encoding
47 */
48 #define PAGE_ENCODING "UTF-8"
49
50 typedef void (*configfn)(const char *name, const char *value);
51 typedef void (*filepair_fn)(struct diff_filepair *pair);
52 typedef void (*linediff_fn)(char *line, int len);
53
54 typedef enum {
55 ABOUT, COMMIT, SOURCE
56 } filter_type;
57
58 struct cgit_filter {
59 char *cmd;
60 char **argv;
61 int old_stdout;
62 int pipe_fh[2];
63 int pid;
64 int exitstatus;
65 };
66
67 struct cgit_repo {
68 char *url;
69 char *name;
70 char *path;
71 char *desc;
72 char *owner;
73 char *defbranch;
74 char *module_link;
75 char *readme;
76 char *section;
77 char *clone_url;
78 char *logo;
79 char *logo_link;
80 int snapshots;
81 int enable_commit_graph;
82 int enable_log_filecount;
83 int enable_log_linecount;
84 int enable_remote_branches;
85 int enable_subject_links;
86 int max_stats;
87 time_t mtime;
88 struct cgit_filter *about_filter;
89 struct cgit_filter *commit_filter;
90 struct cgit_filter *source_filter;
91 };
92
93 typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
94 const char *value);
95
96 struct cgit_repolist {
97 int length;
98 int count;
99 struct cgit_repo *repos;
100 };
101
102 struct commitinfo {
103 struct commit *commit;
104 char *author;
105 char *author_email;
106 unsigned long author_date;
107 char *committer;
108 char *committer_email;
109 unsigned long committer_date;
110 char *subject;
111 char *msg;
112 char *msg_encoding;
113 };
114
115 struct taginfo {
116 char *tagger;
117 char *tagger_email;
118 unsigned long tagger_date;
119 char *msg;
120 };
121
122 struct refinfo {
123 const char *refname;
124 struct object *object;
125 union {
126 struct taginfo *tag;
127 struct commitinfo *commit;
128 };
129 };
130
131 struct reflist {
132 struct refinfo **refs;
133 int alloc;
134 int count;
135 };
136
137 struct cgit_query {
138 int has_symref;
139 int has_sha1;
140 char *raw;
141 char *repo;
142 char *page;
143 char *search;
144 char *grep;
145 char *head;
146 char *sha1;
147 char *sha2;
148 char *path;
149 char *name;
150 char *mimetype;
151 char *url;
152 char *period;
153 int ofs;
154 int nohead;
155 char *sort;
156 int showmsg;
157 int ssdiff;
158 int show_all;
159 int context;
160 int ignorews;
161 char *vpath;
162 };
163
164 struct cgit_config {
165 char *agefile;
166 char *cache_root;
167 char *clone_prefix;
168 char *css;
169 char *favicon;
170 char *footer;
171 char *head_include;
172 char *header;
173 char *index_header;
174 char *index_info;
175 char *logo;
176 char *logo_link;
177 char *module_link;
178 char *project_list;
179 char *readme;
180 char *robots;
181 char *root_title;
182 char *root_desc;
183 char *root_readme;
184 char *script_name;
185 char *section;
186 char *virtual_root;
187 char *strict_export;
188 int cache_size;
189 int cache_dynamic_ttl;
190 int cache_max_create_time;
191 int cache_repo_ttl;
192 int cache_root_ttl;
193 int cache_scanrc_ttl;
194 int cache_static_ttl;
195 int embedded;
196 int enable_filter_overrides;
197 int enable_gitweb_owner;
198 int enable_http_clone;
199 int enable_index_links;
200 int enable_commit_graph;
201 int enable_log_filecount;
202 int enable_log_linecount;
203 int enable_remote_branches;
204 int enable_subject_links;
205 int enable_tree_linenumbers;
206 int local_time;
207 int max_atom_items;
208 int max_repo_count;
209 int max_commit_count;
210 int max_lock_attempts;
211 int max_msg_len;
212 int max_repodesc_len;
213 int max_blob_size;
214 int max_stats;
215 int nocache;
216 int noplainemail;
217 int noheader;
218 int renamelimit;
219 int remove_suffix;
220 int scan_hidden_path;
221 int section_from_path;
222 int snapshots;
223 int summary_branches;
224 int summary_log;
225 int summary_tags;
226 int ssdiff;
227 struct string_list mimetypes;
228 struct cgit_filter *about_filter;
229 struct cgit_filter *commit_filter;
230 struct cgit_filter *source_filter;
231 };
232
233 struct cgit_page {
234 time_t modified;
235 time_t expires;
236 size_t size;
237 char *mimetype;
238 char *charset;
239 char *filename;
240 char *etag;
241 char *title;
242 int status;
243 char *statusmsg;
244 };
245
246 struct cgit_environment {
247 char *cgit_config;
248 char *http_host;
249 char *https;
250 char *no_http;
251 char *path_info;
252 char *query_string;
253 char *request_method;
254 char *script_name;
255 char *server_name;
256 char *server_port;
257 };
258
259 struct cgit_context {
260 struct cgit_environment env;
261 struct cgit_query qry;
262 struct cgit_config cfg;
263 struct cgit_repo *repo;
264 struct cgit_page page;
265 };
266
267 struct cgit_snapshot_format {
268 const char *suffix;
269 const char *mimetype;
270 write_archive_fn_t write_func;
271 int bit;
272 };
273
274 extern const char *cgit_version;
275
276 extern struct cgit_repolist cgit_repolist;
277 extern struct cgit_context ctx;
278 extern const struct cgit_snapshot_format cgit_snapshot_formats[];
279
280 extern struct cgit_repo *cgit_add_repo(const char *url);
281 extern struct cgit_repo *cgit_get_repoinfo(const char *url);
282 extern void cgit_repo_config_cb(const char *name, const char *value);
283
284 extern int chk_zero(int result, char *msg);
285 extern int chk_positive(int result, char *msg);
286 extern int chk_non_negative(int result, char *msg);
287
288 extern char *trim_end(const char *str, char c);
289 extern char *strlpart(char *txt, int maxlen);
290 extern char *strrpart(char *txt, int maxlen);
291
292 extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
293 extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
294 int flags, void *cb_data);
295
296 extern void *cgit_free_commitinfo(struct commitinfo *info);
297
298 extern int cgit_diff_files(const unsigned char *old_sha1,
299 const unsigned char *new_sha1,
300 unsigned long *old_size, unsigned long *new_size,
301 int *binary, int context, int ignorews,
302 linediff_fn fn);
303
304 extern void cgit_diff_tree(const unsigned char *old_sha1,
305 const unsigned char *new_sha1,
306 filepair_fn fn, const char *prefix, int ignorews);
307
308 extern void cgit_diff_commit(struct commit *commit, filepair_fn fn,
309 const char *prefix);
310
311 __attribute__((format (printf,1,2)))
312 extern char *fmt(const char *format,...);
313
314 extern struct commitinfo *cgit_parse_commit(struct commit *commit);
315 extern struct taginfo *cgit_parse_tag(struct tag *tag);
316 extern void cgit_parse_url(const char *url);
317
318 extern const char *cgit_repobasename(const char *reponame);
319
320 extern int cgit_parse_snapshots_mask(const char *str);
321
322 extern int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo);
323 extern int cgit_close_filter(struct cgit_filter *filter);
324
325 extern int readfile(const char *path, char **buf, size_t *size);
326
327 extern char *expand_macros(const char *txt);
328
329 #endif /* CGIT_H */