]> gitweb.ps.run Git - ps-cgit/blob - cgit.h
Make "owner" column on index page configurable
[ps-cgit] / 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         int commit_sort;
88         time_t mtime;
89         struct cgit_filter *about_filter;
90         struct cgit_filter *commit_filter;
91         struct cgit_filter *source_filter;
92         struct string_list submodules;
93 };
94
95 typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
96               const char *value);
97
98 struct cgit_repolist {
99         int length;
100         int count;
101         struct cgit_repo *repos;
102 };
103
104 struct commitinfo {
105         struct commit *commit;
106         char *author;
107         char *author_email;
108         unsigned long author_date;
109         char *committer;
110         char *committer_email;
111         unsigned long committer_date;
112         char *subject;
113         char *msg;
114         char *msg_encoding;
115 };
116
117 struct taginfo {
118         char *tagger;
119         char *tagger_email;
120         unsigned long tagger_date;
121         char *msg;
122 };
123
124 struct refinfo {
125         const char *refname;
126         struct object *object;
127         union {
128                 struct taginfo *tag;
129                 struct commitinfo *commit;
130         };
131 };
132
133 struct reflist {
134         struct refinfo **refs;
135         int alloc;
136         int count;
137 };
138
139 struct cgit_query {
140         int has_symref;
141         int has_sha1;
142         int has_ssdiff;
143         char *raw;
144         char *repo;
145         char *page;
146         char *search;
147         char *grep;
148         char *head;
149         char *sha1;
150         char *sha2;
151         char *path;
152         char *name;
153         char *mimetype;
154         char *url;
155         char *period;
156         int   ofs;
157         int nohead;
158         char *sort;
159         int showmsg;
160         int ssdiff;
161         int show_all;
162         int context;
163         int ignorews;
164         char *vpath;
165 };
166
167 struct cgit_config {
168         char *agefile;
169         char *cache_root;
170         char *clone_prefix;
171         char *clone_url;
172         char *css;
173         char *favicon;
174         char *footer;
175         char *head_include;
176         char *header;
177         char *index_header;
178         char *index_info;
179         char *logo;
180         char *logo_link;
181         char *mimetype_file;
182         char *module_link;
183         char *project_list;
184         char *readme;
185         char *robots;
186         char *root_title;
187         char *root_desc;
188         char *root_readme;
189         char *script_name;
190         char *section;
191         char *repository_sort;
192         char *virtual_root;
193         char *strict_export;
194         int cache_size;
195         int cache_dynamic_ttl;
196         int cache_max_create_time;
197         int cache_repo_ttl;
198         int cache_root_ttl;
199         int cache_scanrc_ttl;
200         int cache_static_ttl;
201         int case_sensitive_sort;
202         int embedded;
203         int enable_filter_overrides;
204         int enable_http_clone;
205         int enable_index_links;
206         int enable_index_owner;
207         int enable_commit_graph;
208         int enable_log_filecount;
209         int enable_log_linecount;
210         int enable_remote_branches;
211         int enable_subject_links;
212         int enable_tree_linenumbers;
213         int enable_git_config;
214         int local_time;
215         int max_atom_items;
216         int max_repo_count;
217         int max_commit_count;
218         int max_lock_attempts;
219         int max_msg_len;
220         int max_repodesc_len;
221         int max_blob_size;
222         int max_stats;
223         int nocache;
224         int noplainemail;
225         int noheader;
226         int renamelimit;
227         int remove_suffix;
228         int scan_hidden_path;
229         int section_from_path;
230         int snapshots;
231         int section_sort;
232         int summary_branches;
233         int summary_log;
234         int summary_tags;
235         int ssdiff;
236         int commit_sort;
237         struct string_list mimetypes;
238         struct cgit_filter *about_filter;
239         struct cgit_filter *commit_filter;
240         struct cgit_filter *source_filter;
241 };
242
243 struct cgit_page {
244         time_t modified;
245         time_t expires;
246         size_t size;
247         char *mimetype;
248         char *charset;
249         char *filename;
250         char *etag;
251         char *title;
252         int status;
253         char *statusmsg;
254 };
255
256 struct cgit_environment {
257         char *cgit_config;
258         char *http_host;
259         char *https;
260         char *no_http;
261         char *path_info;
262         char *query_string;
263         char *request_method;
264         char *script_name;
265         char *server_name;
266         char *server_port;
267 };
268
269 struct cgit_context {
270         struct cgit_environment env;
271         struct cgit_query qry;
272         struct cgit_config cfg;
273         struct cgit_repo *repo;
274         struct cgit_page page;
275 };
276
277 struct cgit_snapshot_format {
278         const char *suffix;
279         const char *mimetype;
280         write_archive_fn_t write_func;
281         int bit;
282 };
283
284 extern const char *cgit_version;
285
286 extern struct cgit_repolist cgit_repolist;
287 extern struct cgit_context ctx;
288 extern const struct cgit_snapshot_format cgit_snapshot_formats[];
289
290 extern char *cgit_default_repo_desc;
291 extern struct cgit_repo *cgit_add_repo(const char *url);
292 extern struct cgit_repo *cgit_get_repoinfo(const char *url);
293 extern void cgit_repo_config_cb(const char *name, const char *value);
294
295 extern int chk_zero(int result, char *msg);
296 extern int chk_positive(int result, char *msg);
297 extern int chk_non_negative(int result, char *msg);
298
299 extern char *trim_end(const char *str, char c);
300 extern char *strlpart(char *txt, int maxlen);
301 extern char *strrpart(char *txt, int maxlen);
302
303 extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
304 extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
305                         int flags, void *cb_data);
306
307 extern void *cgit_free_commitinfo(struct commitinfo *info);
308
309 extern int cgit_diff_files(const unsigned char *old_sha1,
310                            const unsigned char *new_sha1,
311                            unsigned long *old_size, unsigned long *new_size,
312                            int *binary, int context, int ignorews,
313                            linediff_fn fn);
314
315 extern void cgit_diff_tree(const unsigned char *old_sha1,
316                            const unsigned char *new_sha1,
317                            filepair_fn fn, const char *prefix, int ignorews);
318
319 extern void cgit_diff_commit(struct commit *commit, filepair_fn fn,
320                              const char *prefix);
321
322 __attribute__((format (printf,1,2)))
323 extern char *fmt(const char *format,...);
324
325 extern struct commitinfo *cgit_parse_commit(struct commit *commit);
326 extern struct taginfo *cgit_parse_tag(struct tag *tag);
327 extern void cgit_parse_url(const char *url);
328
329 extern const char *cgit_repobasename(const char *reponame);
330
331 extern int cgit_parse_snapshots_mask(const char *str);
332
333 extern int cgit_open_filter(struct cgit_filter *filter);
334 extern int cgit_close_filter(struct cgit_filter *filter);
335
336 extern void cgit_prepare_repo_env(struct cgit_repo * repo);
337
338 extern int readfile(const char *path, char **buf, size_t *size);
339
340 extern char *expand_macros(const char *txt);
341
342 #endif /* CGIT_H */