blob: 32dfd7a6b741db6d1b87aa9807bf8a69e5b3f70b [file] [log] [blame]
Lars Hjemli0d169ad2006-12-09 15:18:17 +01001#ifndef CGIT_H
2#define CGIT_H
3
Lars Hjemli61c3ca92007-05-08 22:40:59 +02004
5#include <git-compat-util.h>
John Keepinge09574b2015-08-13 12:14:18 +01006#include <stdbool.h>
7
Lars Hjemli61c3ca92007-05-08 22:40:59 +02008#include <cache.h>
9#include <grep.h>
10#include <object.h>
11#include <tree.h>
12#include <commit.h>
13#include <tag.h>
14#include <diff.h>
15#include <diffcore.h>
John Keeping2ab1cd92013-03-02 12:32:12 +000016#include <argv-array.h>
Lars Hjemli61c3ca92007-05-08 22:40:59 +020017#include <refs.h>
18#include <revision.h>
19#include <log-tree.h>
20#include <archive.h>
Lars Hjemlic4d46c72009-02-13 20:43:30 +010021#include <string-list.h>
Lars Hjemlic495cf02009-01-31 10:40:40 +010022#include <xdiff-interface.h>
Lars Hjemli61c3ca92007-05-08 22:40:59 +020023#include <xdiff/xdiff.h>
Lars Hjemlia2ebbd62007-11-05 22:27:43 +010024#include <utf8.h>
Jeff Smith059b3932010-07-29 09:32:30 -050025#include <notes.h>
Johan Herland9a8d39c2010-11-15 18:39:50 +010026#include <graph.h>
Lars Hjemli61c3ca92007-05-08 22:40:59 +020027
John Keeping7105a782015-08-13 12:14:19 +010028/* Add isgraph(x) to Git's sane ctype support (see git-compat-util.h) */
29#undef isgraph
30#define isgraph(x) (isprint((x)) && !isspace((x)))
Lars Hjemli25105d72006-12-10 22:31:36 +010031
Lars Hjemli5db39172007-05-22 23:08:46 +020032
33/*
34 * Limits used for relative dates
35 */
36#define TM_MIN 60
37#define TM_HOUR (TM_MIN * 60)
38#define TM_DAY (TM_HOUR * 24)
39#define TM_WEEK (TM_DAY * 7)
40#define TM_YEAR (TM_DAY * 365)
41#define TM_MONTH (TM_YEAR / 12.0)
42
43
Jonathan Bastien-Filiatrault3845e172007-10-26 18:09:06 -040044/*
45 * Default encoding
46 */
47#define PAGE_ENCODING "UTF-8"
48
Christian Hesse2f8648f2018-06-11 08:26:59 +020049#define BIT(x) (1U << (x))
50
Lars Hjemli25105d72006-12-10 22:31:36 +010051typedef void (*configfn)(const char *name, const char *value);
Lars Hjemli1b49de32007-05-13 11:24:23 +020052typedef void (*filepair_fn)(struct diff_filepair *pair);
Lars Hjemlic4ef6672007-05-13 14:21:19 +020053typedef void (*linediff_fn)(char *line, int len);
Lars Hjemli25105d72006-12-10 22:31:36 +010054
Ferry Huberts9240a822011-03-23 11:57:41 +010055typedef enum {
John Keepingddfaef62014-10-05 10:59:05 +010056 DIFF_UNIFIED, DIFF_SSDIFF, DIFF_STATONLY
John Keeping18302712014-10-05 10:59:04 +010057} diff_type;
58
59typedef enum {
Chris Burroughs96ceb9a2014-08-04 09:23:08 -040060 ABOUT, COMMIT, SOURCE, EMAIL, AUTH, OWNER
Ferry Huberts9240a822011-03-23 11:57:41 +010061} filter_type;
62
Lars Hjemlie976df22009-08-09 13:22:00 +020063struct cgit_filter {
John Keeping7bd90b82014-01-12 17:13:52 +000064 int (*open)(struct cgit_filter *, va_list ap);
65 int (*close)(struct cgit_filter *);
66 void (*fprintf)(struct cgit_filter *, FILE *, const char *prefix);
Jason A. Donenfeldd750c7a2014-01-12 20:58:21 +010067 void (*cleanup)(struct cgit_filter *);
Jason A. Donenfelde83b51b2014-01-13 14:16:18 +010068 int argument_count;
John Keeping7bd90b82014-01-12 17:13:52 +000069};
70
71struct cgit_exec_filter {
72 struct cgit_filter base;
Lars Hjemlie976df22009-08-09 13:22:00 +020073 char *cmd;
74 char **argv;
75 int old_stdout;
Lars Hjemlie976df22009-08-09 13:22:00 +020076 int pid;
Lars Hjemlie976df22009-08-09 13:22:00 +020077};
78
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +010079struct cgit_repo {
Lars Hjemlice1c7332007-02-03 15:02:55 +010080 char *url;
81 char *name;
82 char *path;
83 char *desc;
Jason A. Donenfeldb522a302018-02-12 23:10:06 +010084 char *extra_head_content;
Lars Hjemlice1c7332007-02-03 15:02:55 +010085 char *owner;
Jason A. Donenfeld5f2664f2016-02-22 16:04:15 +010086 char *homepage;
Lars Hjemlib28b1052007-05-16 00:14:51 +020087 char *defbranch;
Lars Hjemlided93932007-05-11 12:12:48 +020088 char *module_link;
Jason A. Donenfelddcbc0432013-05-26 15:20:02 +020089 struct string_list readme;
Lars Hjemlie7af0022009-08-23 22:58:39 +020090 char *section;
Lars Hjemliafcdd082007-12-03 01:49:38 +010091 char *clone_url;
Bernhard Reutner-Fischer808c6852010-12-23 12:47:54 +010092 char *logo;
93 char *logo_link;
John Keepingc1572bb2018-03-31 14:20:01 +010094 char *snapshot_prefix;
Lars Hjemliac70cb42007-02-08 14:47:56 +010095 int snapshots;
Johan Herland9a8d39c2010-11-15 18:39:50 +010096 int enable_commit_graph;
Lars Hjemlie1893442007-05-18 13:55:52 +020097 int enable_log_filecount;
98 int enable_log_linecount;
Lars Hjemli41934a32009-11-07 19:10:58 +010099 int enable_remote_branches;
Lars Hjemli581a0c22010-02-27 13:12:55 +0100100 int enable_subject_links;
Jason A. Donenfeldc326f3e2016-01-14 14:53:28 +0100101 int enable_html_serving;
Lars Hjemlifb2f3f62008-12-07 13:17:21 +0100102 int max_stats;
Jason A. Donenfeld389cc172013-04-08 16:57:12 +0200103 int branch_sort;
Tobias Bieniek792f8132012-10-13 16:10:30 +0200104 int commit_sort;
Lars Hjemli88131702008-11-29 16:46:37 +0100105 time_t mtime;
Lars Hjemli537c05f2009-08-09 13:27:21 +0200106 struct cgit_filter *about_filter;
Lars Hjemlie976df22009-08-09 13:22:00 +0200107 struct cgit_filter *commit_filter;
108 struct cgit_filter *source_filter;
Jason A. Donenfelda5e15532014-01-13 04:04:52 +0100109 struct cgit_filter *email_filter;
Chris Burroughs96ceb9a2014-08-04 09:23:08 -0400110 struct cgit_filter *owner_filter;
Lars Hjemli6857bec2011-06-15 10:04:13 +0200111 struct string_list submodules;
Lukas Fleischerc58cec92015-01-29 12:52:49 +0100112 int hide;
113 int ignore;
Lars Hjemlice1c7332007-02-03 15:02:55 +0100114};
115
Lars Hjemli74061ed2009-08-24 00:04:58 +0200116typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
117 const char *value);
118
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100119struct cgit_repolist {
Lars Hjemlice1c7332007-02-03 15:02:55 +0100120 int length;
121 int count;
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100122 struct cgit_repo *repos;
Lars Hjemlice1c7332007-02-03 15:02:55 +0100123};
124
Lars Hjemli2101e262006-12-15 18:17:36 +0100125struct commitinfo {
126 struct commit *commit;
127 char *author;
Lars Hjemli77078ba2006-12-16 14:25:41 +0100128 char *author_email;
129 unsigned long author_date;
John Keeping45c87ca2016-01-19 19:33:02 +0000130 int author_tz;
Lars Hjemli2101e262006-12-15 18:17:36 +0100131 char *committer;
Lars Hjemli77078ba2006-12-16 14:25:41 +0100132 char *committer_email;
133 unsigned long committer_date;
John Keeping45c87ca2016-01-19 19:33:02 +0000134 int committer_tz;
Lars Hjemli2101e262006-12-15 18:17:36 +0100135 char *subject;
136 char *msg;
Jonathan Bastien-Filiatrault3845e172007-10-26 18:09:06 -0400137 char *msg_encoding;
Lars Hjemli2101e262006-12-15 18:17:36 +0100138};
139
Lars Hjemlia69061f2007-01-17 01:09:51 +0100140struct taginfo {
141 char *tagger;
142 char *tagger_email;
Lars Hjemlia8305a92008-09-14 09:45:37 +0200143 unsigned long tagger_date;
John Keeping45c87ca2016-01-19 19:33:02 +0000144 int tagger_tz;
Lars Hjemlia69061f2007-01-17 01:09:51 +0100145 char *msg;
146};
147
Lars Hjemlie397ff72007-10-25 09:30:06 +0200148struct refinfo {
149 const char *refname;
150 struct object *object;
151 union {
152 struct taginfo *tag;
153 struct commitinfo *commit;
154 };
155};
156
157struct reflist {
158 struct refinfo **refs;
159 int alloc;
160 int count;
161};
162
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100163struct cgit_query {
164 int has_symref;
165 int has_sha1;
John Keeping18302712014-10-05 10:59:04 +0100166 int has_difftype;
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100167 char *raw;
168 char *repo;
169 char *page;
170 char *search;
171 char *grep;
172 char *head;
173 char *sha1;
174 char *sha2;
175 char *path;
176 char *name;
Lars Hjemlie154edd2008-08-09 21:11:41 +0200177 char *url;
Lars Hjemlif86a23f2008-12-06 17:38:19 +0100178 char *period;
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100179 int ofs;
Lars Hjemli5632ba32008-10-11 19:05:50 +0200180 int nohead;
Benjamin Closed71c0c72008-11-25 06:25:35 -0800181 char *sort;
Lars Hjemli0274b572008-11-29 18:39:41 +0100182 int showmsg;
John Keeping18302712014-10-05 10:59:04 +0100183 diff_type difftype;
Aaron Griffin65ced7c2010-02-03 18:31:17 -0600184 int show_all;
Johan Herland6180e612010-06-10 20:15:27 +0200185 int context;
Johan Herland2cc8b992010-06-24 17:52:57 +0200186 int ignorews;
John Keeping30304d82015-08-12 15:55:28 +0100187 int follow;
Johan Herland0ff143d2010-06-10 01:09:26 +0200188 char *vpath;
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100189};
190
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100191struct cgit_config {
192 char *agefile;
193 char *cache_root;
194 char *clone_prefix;
Lars Hjemlia1429db2011-06-06 20:49:13 +0000195 char *clone_url;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100196 char *css;
Lars Hjemli502865a2008-07-19 20:40:30 +0200197 char *favicon;
Lars Hjemlide5e9282008-06-26 13:53:30 +0200198 char *footer;
Mark Lodatob5a3a202009-03-15 00:11:54 -0400199 char *head_include;
Lars Hjemlib1159552009-01-29 21:27:39 +0100200 char *header;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100201 char *logo;
202 char *logo_link;
Ferry Hubertsd01c6002011-07-19 10:51:58 +0200203 char *mimetype_file;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100204 char *module_link;
Jason A. Donenfeld35165022010-07-29 17:52:29 +0200205 char *project_list;
Jason A. Donenfelddcbc0432013-05-26 15:20:02 +0200206 struct string_list readme;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100207 char *robots;
208 char *root_title;
Lars Hjemli4c991602008-04-29 00:55:34 +0200209 char *root_desc;
Lars Hjemlic6431a72008-04-29 01:06:30 +0200210 char *root_readme;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100211 char *script_name;
Lars Hjemlie7af0022009-08-23 22:58:39 +0200212 char *section;
Jason A. Donenfeldfdfb6a62012-10-16 23:32:40 +0200213 char *repository_sort;
John Keepingb1f17f12013-04-01 19:03:34 +0100214 char *virtual_root; /* Always ends with '/'. */
Felix Hanleye0c6f232010-11-08 19:41:13 +0100215 char *strict_export;
Lars Hjemli939d32f2008-04-28 11:32:42 +0200216 int cache_size;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100217 int cache_dynamic_ttl;
218 int cache_max_create_time;
219 int cache_repo_ttl;
220 int cache_root_ttl;
Lars Hjemlid7468272009-08-20 17:41:54 +0200221 int cache_scanrc_ttl;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100222 int cache_static_ttl;
Jason A. Donenfeld61ff1002013-05-28 16:33:30 +0200223 int cache_about_ttl;
Lukas Fleischera3722ec2014-02-05 10:23:58 +0100224 int cache_snapshot_ttl;
Jason A. Donenfeld184c5652012-07-12 19:13:39 +0200225 int case_sensitive_sort;
Lars Hjemli7a8b3b42009-07-25 12:25:06 +0200226 int embedded;
Lars Hjemli2273c2c2009-08-24 08:53:21 +0200227 int enable_filter_overrides;
John Keeping30304d82015-08-12 15:55:28 +0100228 int enable_follow_links;
Dan McGee42231322011-01-12 12:06:07 -0600229 int enable_http_clone;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100230 int enable_index_links;
Florian Pritzb1e172a2013-02-01 10:59:13 +0100231 int enable_index_owner;
Jeff Smithc1cd2902017-10-01 23:39:08 -0500232 int enable_blame;
Johan Herland9a8d39c2010-11-15 18:39:50 +0100233 int enable_commit_graph;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100234 int enable_log_filecount;
235 int enable_log_linecount;
Lars Hjemli41934a32009-11-07 19:10:58 +0100236 int enable_remote_branches;
Lars Hjemli581a0c22010-02-27 13:12:55 +0100237 int enable_subject_links;
Jason A. Donenfeldc326f3e2016-01-14 14:53:28 +0100238 int enable_html_serving;
Lars Hjemlib0f946b2009-08-21 14:26:52 +0200239 int enable_tree_linenumbers;
Jason A. Donenfeld521e10c2012-10-09 06:56:14 -0400240 int enable_git_config;
Stefan Naewe0f0ab142008-08-01 14:54:38 +0200241 int local_time;
Aaron Griffin80476b02010-02-04 18:08:16 -0600242 int max_atom_items;
Lars Hjemlic6078b82008-05-03 10:54:39 +0200243 int max_repo_count;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100244 int max_commit_count;
245 int max_lock_attempts;
246 int max_msg_len;
247 int max_repodesc_len;
Georg Lukasef07ccc2009-11-28 03:44:33 +0100248 int max_blob_size;
Lars Hjemlifb2f3f62008-12-07 13:17:21 +0100249 int max_stats;
Martin Szulecki2f56e392009-08-07 14:05:17 +0200250 int noplainemail;
Lars Hjemli7a8b3b42009-07-25 12:25:06 +0200251 int noheader;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100252 int renamelimit;
Jason A. Donenfeld2e4a9412010-07-29 19:47:50 +0200253 int remove_suffix;
Johan Herlanddf522792010-11-15 20:41:00 +0100254 int scan_hidden_path;
Lars Hjemli797110e2010-08-21 15:44:09 +0200255 int section_from_path;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100256 int snapshots;
Tobias Bieniek7a4e7c82012-10-09 20:53:29 +0200257 int section_sort;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100258 int summary_branches;
259 int summary_log;
260 int summary_tags;
John Keeping18302712014-10-05 10:59:04 +0100261 diff_type difftype;
Jason A. Donenfeld389cc172013-04-08 16:57:12 +0200262 int branch_sort;
Tobias Bieniek792f8132012-10-13 16:10:30 +0200263 int commit_sort;
Lars Hjemlic4d46c72009-02-13 20:43:30 +0100264 struct string_list mimetypes;
Lars Hjemli537c05f2009-08-09 13:27:21 +0200265 struct cgit_filter *about_filter;
Lars Hjemlif35db1c2009-07-31 17:42:57 +0200266 struct cgit_filter *commit_filter;
Lars Hjemli46b7abe2009-07-31 16:55:27 +0200267 struct cgit_filter *source_filter;
Jason A. Donenfelda5e15532014-01-13 04:04:52 +0100268 struct cgit_filter *email_filter;
Chris Burroughs96ceb9a2014-08-04 09:23:08 -0400269 struct cgit_filter *owner_filter;
Jason A. Donenfeldd6e92002014-01-14 21:49:31 +0100270 struct cgit_filter *auth_filter;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100271};
272
Lars Hjemlif3c1a182008-03-24 00:51:19 +0100273struct cgit_page {
274 time_t modified;
275 time_t expires;
Lars Hjemlie5da4bc2008-08-06 10:53:50 +0200276 size_t size;
John Keeping57d09bf2013-04-07 12:46:45 +0100277 const char *mimetype;
278 const char *charset;
279 const char *filename;
280 const char *etag;
281 const char *title;
Lars Hjemlie429fb02009-06-07 20:43:08 +0200282 int status;
John Keeping57d09bf2013-04-07 12:46:45 +0100283 const char *statusmsg;
Lars Hjemlif3c1a182008-03-24 00:51:19 +0100284};
285
Lars Hjemli60a26272009-08-10 08:21:09 +0200286struct cgit_environment {
Lukas Fleischer3a843242013-04-01 17:11:14 +0200287 const char *cgit_config;
288 const char *http_host;
289 const char *https;
290 const char *no_http;
291 const char *path_info;
292 const char *query_string;
293 const char *request_method;
294 const char *script_name;
295 const char *server_name;
296 const char *server_port;
Jason A. Donenfeldd6e92002014-01-14 21:49:31 +0100297 const char *http_cookie;
298 const char *http_referer;
299 unsigned int content_length;
300 int authenticated;
Lars Hjemli60a26272009-08-10 08:21:09 +0200301};
302
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100303struct cgit_context {
Lars Hjemli60a26272009-08-10 08:21:09 +0200304 struct cgit_environment env;
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100305 struct cgit_query qry;
Lars Hjemlib228d4f2008-02-16 13:07:13 +0100306 struct cgit_config cfg;
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100307 struct cgit_repo *repo;
Lars Hjemlif3c1a182008-03-24 00:51:19 +0100308 struct cgit_page page;
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100309};
310
John Keeping2ab1cd92013-03-02 12:32:12 +0000311typedef int (*write_archive_fn_t)(const char *, const char *);
312
Lars Hjemlif34478c2008-03-24 16:00:27 +0100313struct cgit_snapshot_format {
314 const char *suffix;
315 const char *mimetype;
316 write_archive_fn_t write_func;
Lars Hjemlif34478c2008-03-24 16:00:27 +0100317};
318
Lars Hjemlif6925032007-06-18 09:42:10 +0200319extern const char *cgit_version;
Lars Hjemli5a106eb2006-12-11 16:38:30 +0100320
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100321extern struct cgit_repolist cgit_repolist;
Lars Hjemlid14d77f2008-02-16 11:53:40 +0100322extern struct cgit_context ctx;
Lars Hjemlif34478c2008-03-24 16:00:27 +0100323extern const struct cgit_snapshot_format cgit_snapshot_formats[];
Lars Hjemlice1c7332007-02-03 15:02:55 +0100324
Jason A. Donenfeld521e10c2012-10-09 06:56:14 -0400325extern char *cgit_default_repo_desc;
Lars Hjemli163037e2008-03-24 17:26:08 +0100326extern struct cgit_repo *cgit_add_repo(const char *url);
Lars Hjemlid1f3bbe2008-02-16 13:56:09 +0100327extern struct cgit_repo *cgit_get_repoinfo(const char *url);
Lars Hjemli44923f82006-12-11 17:25:41 +0100328extern void cgit_repo_config_cb(const char *name, const char *value);
Lars Hjemli44923f82006-12-11 17:25:41 +0100329
Lars Hjemliab2ab952007-02-08 13:53:13 +0100330extern int chk_zero(int result, char *msg);
331extern int chk_positive(int result, char *msg);
Michael Krelin127f43d2007-07-20 20:56:43 +0200332extern int chk_non_negative(int result, char *msg);
Lars Hjemliab2ab952007-02-08 13:53:13 +0100333
Lars Hjemli382805e2007-06-26 18:04:31 +0200334extern char *trim_end(const char *str, char c);
John Keepingb1f17f12013-04-01 19:03:34 +0100335extern char *ensure_end(const char *str, char c);
Lars Hjemli52e605c2007-01-04 16:53:03 +0100336
John Keepingd2e20e32013-04-07 14:03:47 +0100337extern void strbuf_ensure_end(struct strbuf *sb, char c);
338
Lars Hjemlie397ff72007-10-25 09:30:06 +0200339extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
Lukas Fleischer1268afe2013-03-04 13:25:33 +0100340extern void cgit_free_reflist_inner(struct reflist *list);
Christian Hessede83de22015-07-28 10:42:01 +0200341extern int cgit_refs_cb(const char *refname, const struct object_id *oid,
Lars Hjemlie397ff72007-10-25 09:30:06 +0200342 int flags, void *cb_data);
343
John Keepingd9dff372016-08-13 11:51:58 +0100344extern void cgit_free_commitinfo(struct commitinfo *info);
John Keepingb19d8892016-08-13 11:52:51 +0100345extern void cgit_free_taginfo(struct taginfo *info);
Lars Hjemlic4ef6672007-05-13 14:21:19 +0200346
John Keeping044e2d22015-08-12 15:34:48 +0100347void cgit_diff_tree_cb(struct diff_queue_struct *q,
348 struct diff_options *options, void *data);
349
Christian Hesse11695a52016-09-04 12:38:18 +0200350extern int cgit_diff_files(const struct object_id *old_oid,
351 const struct object_id *new_oid,
Lars Hjemlic495cf02009-01-31 10:40:40 +0100352 unsigned long *old_size, unsigned long *new_size,
Johan Herland2cc8b992010-06-24 17:52:57 +0200353 int *binary, int context, int ignorews,
354 linediff_fn fn);
Lars Hjemlic4ef6672007-05-13 14:21:19 +0200355
Christian Hesse11695a52016-09-04 12:38:18 +0200356extern void cgit_diff_tree(const struct object_id *old_oid,
357 const struct object_id *new_oid,
Johan Herland2cc8b992010-06-24 17:52:57 +0200358 filepair_fn fn, const char *prefix, int ignorews);
Lars Hjemlic4ef6672007-05-13 14:21:19 +0200359
Johan Herland1415f3f2010-09-30 20:15:14 +0200360extern void cgit_diff_commit(struct commit *commit, filepair_fn fn,
361 const char *prefix);
Lars Hjemliaaa24bd2006-12-16 14:58:20 +0100362
Mark Lodatoa4c58d92010-09-04 11:09:57 -0400363__attribute__((format (printf,1,2)))
Lars Hjemli0d169ad2006-12-09 15:18:17 +0100364extern char *fmt(const char *format,...);
365
John Keepingfd00d2f2013-04-07 14:40:50 +0100366__attribute__((format (printf,1,2)))
367extern char *fmtalloc(const char *format,...);
368
Lars Hjemli2101e262006-12-15 18:17:36 +0100369extern struct commitinfo *cgit_parse_commit(struct commit *commit);
Lars Hjemlia69061f2007-01-17 01:09:51 +0100370extern struct taginfo *cgit_parse_tag(struct tag *tag);
Lars Hjemli30ccdca2007-05-18 03:00:54 +0200371extern void cgit_parse_url(const char *url);
Lars Hjemli0d169ad2006-12-09 15:18:17 +0100372
Michael Krelin1cb8bed2007-07-21 15:24:07 +0200373extern const char *cgit_repobasename(const char *reponame);
374
Michael Krelindc3c9b52007-07-21 18:00:53 +0200375extern int cgit_parse_snapshots_mask(const char *str);
John Keepingc712d5a2018-03-31 16:15:48 +0100376extern const struct object_id *cgit_snapshot_get_sig(const char *ref,
377 const struct cgit_snapshot_format *f);
Christian Hesse2f8648f2018-06-11 08:26:59 +0200378extern const unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f);
Lars Hjemli74620f12006-12-11 16:48:03 +0100379
John Keeping3d8a6502014-01-12 17:13:50 +0000380extern int cgit_open_filter(struct cgit_filter *filter, ...);
Lars Hjemlid6f60722009-07-31 17:38:38 +0200381extern int cgit_close_filter(struct cgit_filter *filter);
John Keeping632efb22014-01-12 17:13:51 +0000382extern void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix);
John Keeping7bd90b82014-01-12 17:13:52 +0000383extern void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv);
Jason A. Donenfeld3eae4062014-01-10 05:19:05 +0100384extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype);
Jason A. Donenfeldd750c7a2014-01-12 20:58:21 +0100385extern void cgit_cleanup_filters(void);
Jason A. Donenfelde83b51b2014-01-13 14:16:18 +0100386extern void cgit_init_filters(void);
Lars Hjemlid6f60722009-07-31 17:38:38 +0200387
Lars Hjemli3ec6b302011-06-06 19:29:58 +0000388extern void cgit_prepare_repo_env(struct cgit_repo * repo);
389
Lars Hjemlie16f1782009-08-18 17:17:41 +0200390extern int readfile(const char *path, char **buf, size_t *size);
Lars Hjemli28d781f2008-04-13 12:42:27 +0200391
Lars Hjemliba56a372010-03-22 00:09:43 +0100392extern char *expand_macros(const char *txt);
393
Christian Hesseaa943bc2015-08-16 14:53:52 +0200394extern char *get_mimetype_for_filename(const char *filename);
Christian Hessef5c83d72015-08-14 16:50:56 +0200395
Lars Hjemli0d169ad2006-12-09 15:18:17 +0100396#endif /* CGIT_H */