all repos — cgit @ c366bd6fa88fb7dbe1e42c84d56e2bda0b1682c5

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