all repos — cgit @ e032761a5ebc3372ab0abd0c9bcd8436d89485ae

a hyperfast web frontend for git written in c

cgit.h (view raw)

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