]> git.cameronkatri.com Git - cgit.git/blob - cgit.h
css: vertically align the cgit logo image
[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 int has_ssdiff;
141 char *raw;
142 char *repo;
143 char *page;
144 char *search;
145 char *grep;
146 char *head;
147 char *sha1;
148 char *sha2;
149 char *path;
150 char *name;
151 char *mimetype;
152 char *url;
153 char *period;
154 int ofs;
155 int nohead;
156 char *sort;
157 int showmsg;
158 int ssdiff;
159 int show_all;
160 int context;
161 int ignorews;
162 char *vpath;
163 };
164
165 struct cgit_config {
166 char *agefile;
167 char *cache_root;
168 char *clone_prefix;
169 char *clone_url;
170 char *css;
171 char *favicon;
172 char *footer;
173 char *head_include;
174 char *header;
175 char *index_header;
176 char *index_info;
177 char *logo;
178 char *logo_link;
179 char *module_link;
180 char *project_list;
181 char *readme;
182 char *robots;
183 char *root_title;
184 char *root_desc;
185 char *root_readme;
186 char *script_name;
187 char *section;
188 char *virtual_root;
189 char *strict_export;
190 int cache_size;
191 int cache_dynamic_ttl;
192 int cache_max_create_time;
193 int cache_repo_ttl;
194 int cache_root_ttl;
195 int cache_scanrc_ttl;
196 int cache_static_ttl;
197 int embedded;
198 int enable_filter_overrides;
199 int enable_gitweb_owner;
200 int enable_http_clone;
201 int enable_index_links;
202 int enable_commit_graph;
203 int enable_log_filecount;
204 int enable_log_linecount;
205 int enable_remote_branches;
206 int enable_subject_links;
207 int enable_tree_linenumbers;
208 int local_time;
209 int max_atom_items;
210 int max_repo_count;
211 int max_commit_count;
212 int max_lock_attempts;
213 int max_msg_len;
214 int max_repodesc_len;
215 int max_blob_size;
216 int max_stats;
217 int nocache;
218 int noplainemail;
219 int noheader;
220 int renamelimit;
221 int remove_suffix;
222 int scan_hidden_path;
223 int section_from_path;
224 int snapshots;
225 int summary_branches;
226 int summary_log;
227 int summary_tags;
228 int ssdiff;
229 struct string_list mimetypes;
230 struct cgit_filter *about_filter;
231 struct cgit_filter *commit_filter;
232 struct cgit_filter *source_filter;
233 };
234
235 struct cgit_page {
236 time_t modified;
237 time_t expires;
238 size_t size;
239 char *mimetype;
240 char *charset;
241 char *filename;
242 char *etag;
243 char *title;
244 int status;
245 char *statusmsg;
246 };
247
248 struct cgit_environment {
249 char *cgit_config;
250 char *http_host;
251 char *https;
252 char *no_http;
253 char *path_info;
254 char *query_string;
255 char *request_method;
256 char *script_name;
257 char *server_name;
258 char *server_port;
259 };
260
261 struct cgit_context {
262 struct cgit_environment env;
263 struct cgit_query qry;
264 struct cgit_config cfg;
265 struct cgit_repo *repo;
266 struct cgit_page page;
267 };
268
269 struct cgit_snapshot_format {
270 const char *suffix;
271 const char *mimetype;
272 write_archive_fn_t write_func;
273 int bit;
274 };
275
276 extern const char *cgit_version;
277
278 extern struct cgit_repolist cgit_repolist;
279 extern struct cgit_context ctx;
280 extern const struct cgit_snapshot_format cgit_snapshot_formats[];
281
282 extern struct cgit_repo *cgit_add_repo(const char *url);
283 extern struct cgit_repo *cgit_get_repoinfo(const char *url);
284 extern void cgit_repo_config_cb(const char *name, const char *value);
285
286 extern int chk_zero(int result, char *msg);
287 extern int chk_positive(int result, char *msg);
288 extern int chk_non_negative(int result, char *msg);
289
290 extern char *trim_end(const char *str, char c);
291 extern char *strlpart(char *txt, int maxlen);
292 extern char *strrpart(char *txt, int maxlen);
293
294 extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
295 extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
296 int flags, void *cb_data);
297
298 extern void *cgit_free_commitinfo(struct commitinfo *info);
299
300 extern int cgit_diff_files(const unsigned char *old_sha1,
301 const unsigned char *new_sha1,
302 unsigned long *old_size, unsigned long *new_size,
303 int *binary, int context, int ignorews,
304 linediff_fn fn);
305
306 extern void cgit_diff_tree(const unsigned char *old_sha1,
307 const unsigned char *new_sha1,
308 filepair_fn fn, const char *prefix, int ignorews);
309
310 extern void cgit_diff_commit(struct commit *commit, filepair_fn fn,
311 const char *prefix);
312
313 __attribute__((format (printf,1,2)))
314 extern char *fmt(const char *format,...);
315
316 extern struct commitinfo *cgit_parse_commit(struct commit *commit);
317 extern struct taginfo *cgit_parse_tag(struct tag *tag);
318 extern void cgit_parse_url(const char *url);
319
320 extern const char *cgit_repobasename(const char *reponame);
321
322 extern int cgit_parse_snapshots_mask(const char *str);
323
324 extern int cgit_open_filter(struct cgit_filter *filter);
325 extern int cgit_close_filter(struct cgit_filter *filter);
326
327 extern void cgit_prepare_repo_env(struct cgit_repo * repo);
328
329 extern int readfile(const char *path, char **buf, size_t *size);
330
331 extern char *expand_macros(const char *txt);
332
333 #endif /* CGIT_H */