all repos — cgit @ bf8c7a4c93bdc95d841b25a60644cca3ec124625

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