summaryrefslogtreecommitdiffabout
path: root/cgit.h
Unidiff
Diffstat (limited to 'cgit.h') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h72
1 files changed, 37 insertions, 35 deletions
diff --git a/cgit.h b/cgit.h
index 4576efb..0338ebd 100644
--- a/cgit.h
+++ b/cgit.h
@@ -46,240 +46,242 @@
46#define TM_HOUR (TM_MIN * 60) 46#define TM_HOUR (TM_MIN * 60)
47#define TM_DAY (TM_HOUR * 24) 47#define TM_DAY (TM_HOUR * 24)
48#define TM_WEEK (TM_DAY * 7) 48#define TM_WEEK (TM_DAY * 7)
49#define TM_YEAR (TM_DAY * 365) 49#define TM_YEAR (TM_DAY * 365)
50#define TM_MONTH (TM_YEAR / 12.0) 50#define TM_MONTH (TM_YEAR / 12.0)
51 51
52 52
53/* 53/*
54 * Default encoding 54 * Default encoding
55 */ 55 */
56#define PAGE_ENCODING "UTF-8" 56#define PAGE_ENCODING "UTF-8"
57 57
58typedef void (*configfn)(const char *name, const char *value); 58typedef void (*configfn)(const char *name, const char *value);
59typedef void (*filepair_fn)(struct diff_filepair *pair); 59typedef void (*filepair_fn)(struct diff_filepair *pair);
60typedef void (*linediff_fn)(char *line, int len); 60typedef void (*linediff_fn)(char *line, int len);
61 61
62struct cacheitem { 62struct cacheitem {
63 char *name; 63 char *name;
64 struct stat st; 64 struct stat st;
65 int ttl; 65 int ttl;
66 int fd; 66 int fd;
67}; 67};
68 68
69struct repoinfo { 69struct repoinfo {
70 char *url; 70 char *url;
71 char *name; 71 char *name;
72 char *path; 72 char *path;
73 char *desc; 73 char *desc;
74 char *owner; 74 char *owner;
75 char *defbranch; 75 char *defbranch;
76 char *group; 76 char *group;
77 char *module_link; 77 char *module_link;
78 char *readme; 78 char *readme;
79 char *clone_url; 79 char *clone_url;
80 int snapshots; 80 int snapshots;
81 int enable_log_filecount; 81 int enable_log_filecount;
82 int enable_log_linecount; 82 int enable_log_linecount;
83}; 83};
84 84
85struct repolist { 85struct repolist {
86 int length; 86 int length;
87 int count; 87 int count;
88 struct repoinfo *repos; 88 struct repoinfo *repos;
89}; 89};
90 90
91struct commitinfo { 91struct commitinfo {
92 struct commit *commit; 92 struct commit *commit;
93 char *author; 93 char *author;
94 char *author_email; 94 char *author_email;
95 unsigned long author_date; 95 unsigned long author_date;
96 char *committer; 96 char *committer;
97 char *committer_email; 97 char *committer_email;
98 unsigned long committer_date; 98 unsigned long committer_date;
99 char *subject; 99 char *subject;
100 char *msg; 100 char *msg;
101 char *msg_encoding; 101 char *msg_encoding;
102}; 102};
103 103
104struct taginfo { 104struct taginfo {
105 char *tagger; 105 char *tagger;
106 char *tagger_email; 106 char *tagger_email;
107 int tagger_date; 107 int tagger_date;
108 char *msg; 108 char *msg;
109}; 109};
110 110
111struct refinfo { 111struct refinfo {
112 const char *refname; 112 const char *refname;
113 struct object *object; 113 struct object *object;
114 union { 114 union {
115 struct taginfo *tag; 115 struct taginfo *tag;
116 struct commitinfo *commit; 116 struct commitinfo *commit;
117 }; 117 };
118}; 118};
119 119
120struct reflist { 120struct reflist {
121 struct refinfo **refs; 121 struct refinfo **refs;
122 int alloc; 122 int alloc;
123 int count; 123 int count;
124}; 124};
125 125
126struct cgit_query { 126struct cgit_query {
127 int has_symref; 127 int has_symref;
128 int has_sha1; 128 int has_sha1;
129 char *raw; 129 char *raw;
130 char *repo; 130 char *repo;
131 char *page; 131 char *page;
132 char *search; 132 char *search;
133 char *grep; 133 char *grep;
134 char *head; 134 char *head;
135 char *sha1; 135 char *sha1;
136 char *sha2; 136 char *sha2;
137 char *path; 137 char *path;
138 char *name; 138 char *name;
139 int ofs; 139 int ofs;
140}; 140};
141 141
142struct cgit_config {
143 char *agefile;
144 char *cache_root;
145 char *clone_prefix;
146 char *css;
147 char *index_header;
148 char *index_info;
149 char *logo;
150 char *logo_link;
151 char *module_link;
152 char *repo_group;
153 char *robots;
154 char *root_title;
155 char *script_name;
156 char *virtual_root;
157 int cache_dynamic_ttl;
158 int cache_max_create_time;
159 int cache_repo_ttl;
160 int cache_root_ttl;
161 int cache_static_ttl;
162 int enable_index_links;
163 int enable_log_filecount;
164 int enable_log_linecount;
165 int max_commit_count;
166 int max_lock_attempts;
167 int max_msg_len;
168 int max_repodesc_len;
169 int nocache;
170 int renamelimit;
171 int snapshots;
172 int summary_branches;
173 int summary_log;
174 int summary_tags;
175};
176
142struct cgit_context { 177struct cgit_context {
143 struct cgit_query qry; 178 struct cgit_query qry;
179 struct cgit_config cfg;
144}; 180};
145 181
146extern const char *cgit_version; 182extern const char *cgit_version;
147 183
148extern struct repolist cgit_repolist; 184extern struct repolist cgit_repolist;
149extern struct repoinfo *cgit_repo; 185extern struct repoinfo *cgit_repo;
150extern struct cgit_context ctx; 186extern struct cgit_context ctx;
151extern int cgit_cmd; 187extern int cgit_cmd;
152 188
153extern char *cgit_root_title;
154extern char *cgit_css;
155extern char *cgit_logo;
156extern char *cgit_index_header;
157extern char *cgit_index_info;
158extern char *cgit_logo_link;
159extern char *cgit_module_link;
160extern char *cgit_agefile;
161extern char *cgit_virtual_root;
162extern char *cgit_script_name;
163extern char *cgit_cache_root;
164extern char *cgit_repo_group;
165extern char *cgit_robots;
166extern char *cgit_clone_prefix;
167
168extern int cgit_nocache;
169extern int cgit_snapshots;
170extern int cgit_enable_index_links;
171extern int cgit_enable_log_filecount;
172extern int cgit_enable_log_linecount;
173extern int cgit_max_lock_attempts;
174extern int cgit_cache_root_ttl;
175extern int cgit_cache_repo_ttl;
176extern int cgit_cache_dynamic_ttl;
177extern int cgit_cache_static_ttl;
178extern int cgit_cache_max_create_time;
179extern int cgit_summary_log;
180extern int cgit_summary_tags;
181extern int cgit_summary_branches;
182
183extern int cgit_max_msg_len;
184extern int cgit_max_repodesc_len;
185extern int cgit_max_commit_count;
186
187
188extern int htmlfd; 189extern int htmlfd;
189 190
191extern void cgit_prepare_context(struct cgit_context *ctx);
190extern int cgit_get_cmd_index(const char *cmd); 192extern int cgit_get_cmd_index(const char *cmd);
191extern struct repoinfo *cgit_get_repoinfo(const char *url); 193extern struct repoinfo *cgit_get_repoinfo(const char *url);
192extern void cgit_global_config_cb(const char *name, const char *value); 194extern void cgit_global_config_cb(const char *name, const char *value);
193extern void cgit_repo_config_cb(const char *name, const char *value); 195extern void cgit_repo_config_cb(const char *name, const char *value);
194extern void cgit_querystring_cb(const char *name, const char *value); 196extern void cgit_querystring_cb(const char *name, const char *value);
195 197
196extern int chk_zero(int result, char *msg); 198extern int chk_zero(int result, char *msg);
197extern int chk_positive(int result, char *msg); 199extern int chk_positive(int result, char *msg);
198extern int chk_non_negative(int result, char *msg); 200extern int chk_non_negative(int result, char *msg);
199 201
200extern int hextoint(char c); 202extern int hextoint(char c);
201extern char *trim_end(const char *str, char c); 203extern char *trim_end(const char *str, char c);
202extern char *strlpart(char *txt, int maxlen); 204extern char *strlpart(char *txt, int maxlen);
203extern char *strrpart(char *txt, int maxlen); 205extern char *strrpart(char *txt, int maxlen);
204 206
205extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); 207extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
206extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, 208extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
207 int flags, void *cb_data); 209 int flags, void *cb_data);
208 210
209extern void *cgit_free_commitinfo(struct commitinfo *info); 211extern void *cgit_free_commitinfo(struct commitinfo *info);
210 212
211extern int cgit_diff_files(const unsigned char *old_sha1, 213extern int cgit_diff_files(const unsigned char *old_sha1,
212 const unsigned char *new_sha1, 214 const unsigned char *new_sha1,
213 linediff_fn fn); 215 linediff_fn fn);
214 216
215extern void cgit_diff_tree(const unsigned char *old_sha1, 217extern void cgit_diff_tree(const unsigned char *old_sha1,
216 const unsigned char *new_sha1, 218 const unsigned char *new_sha1,
217 filepair_fn fn, const char *prefix); 219 filepair_fn fn, const char *prefix);
218 220
219extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); 221extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
220 222
221extern char *fmt(const char *format,...); 223extern char *fmt(const char *format,...);
222 224
223extern void html(const char *txt); 225extern void html(const char *txt);
224extern void htmlf(const char *format,...); 226extern void htmlf(const char *format,...);
225extern void html_txt(char *txt); 227extern void html_txt(char *txt);
226extern void html_ntxt(int len, char *txt); 228extern void html_ntxt(int len, char *txt);
227extern void html_attr(char *txt); 229extern void html_attr(char *txt);
228extern void html_hidden(char *name, char *value); 230extern void html_hidden(char *name, char *value);
229extern void html_option(char *value, char *text, char *selected_value); 231extern void html_option(char *value, char *text, char *selected_value);
230extern void html_link_open(char *url, char *title, char *class); 232extern void html_link_open(char *url, char *title, char *class);
231extern void html_link_close(void); 233extern void html_link_close(void);
232extern void html_filemode(unsigned short mode); 234extern void html_filemode(unsigned short mode);
233extern int html_include(const char *filename); 235extern int html_include(const char *filename);
234 236
235extern int cgit_read_config(const char *filename, configfn fn); 237extern int cgit_read_config(const char *filename, configfn fn);
236extern int cgit_parse_query(char *txt, configfn fn); 238extern int cgit_parse_query(char *txt, configfn fn);
237extern struct commitinfo *cgit_parse_commit(struct commit *commit); 239extern struct commitinfo *cgit_parse_commit(struct commit *commit);
238extern struct taginfo *cgit_parse_tag(struct tag *tag); 240extern struct taginfo *cgit_parse_tag(struct tag *tag);
239extern void cgit_parse_url(const char *url); 241extern void cgit_parse_url(const char *url);
240 242
241extern char *cache_safe_filename(const char *unsafe); 243extern char *cache_safe_filename(const char *unsafe);
242extern int cache_lock(struct cacheitem *item); 244extern int cache_lock(struct cacheitem *item);
243extern int cache_unlock(struct cacheitem *item); 245extern int cache_unlock(struct cacheitem *item);
244extern int cache_cancel_lock(struct cacheitem *item); 246extern int cache_cancel_lock(struct cacheitem *item);
245extern int cache_exist(struct cacheitem *item); 247extern int cache_exist(struct cacheitem *item);
246extern int cache_expired(struct cacheitem *item); 248extern int cache_expired(struct cacheitem *item);
247 249
248extern char *cgit_repourl(const char *reponame); 250extern char *cgit_repourl(const char *reponame);
249extern char *cgit_fileurl(const char *reponame, const char *pagename, 251extern char *cgit_fileurl(const char *reponame, const char *pagename,
250 const char *filename, const char *query); 252 const char *filename, const char *query);
251extern char *cgit_pageurl(const char *reponame, const char *pagename, 253extern char *cgit_pageurl(const char *reponame, const char *pagename,
252 const char *query); 254 const char *query);
253 255
254extern const char *cgit_repobasename(const char *reponame); 256extern const char *cgit_repobasename(const char *reponame);
255 257
256extern void cgit_tree_link(char *name, char *title, char *class, char *head, 258extern void cgit_tree_link(char *name, char *title, char *class, char *head,
257 char *rev, char *path); 259 char *rev, char *path);
258extern void cgit_log_link(char *name, char *title, char *class, char *head, 260extern void cgit_log_link(char *name, char *title, char *class, char *head,
259 char *rev, char *path, int ofs, char *grep, 261 char *rev, char *path, int ofs, char *grep,
260 char *pattern); 262 char *pattern);
261extern void cgit_commit_link(char *name, char *title, char *class, char *head, 263extern void cgit_commit_link(char *name, char *title, char *class, char *head,
262 char *rev); 264 char *rev);
263extern void cgit_refs_link(char *name, char *title, char *class, char *head, 265extern void cgit_refs_link(char *name, char *title, char *class, char *head,
264 char *rev, char *path); 266 char *rev, char *path);
265extern void cgit_snapshot_link(char *name, char *title, char *class, 267extern void cgit_snapshot_link(char *name, char *title, char *class,
266 char *head, char *rev, char *archivename); 268 char *head, char *rev, char *archivename);
267extern void cgit_diff_link(char *name, char *title, char *class, char *head, 269extern void cgit_diff_link(char *name, char *title, char *class, char *head,
268 char *new_rev, char *old_rev, char *path); 270 char *new_rev, char *old_rev, char *path);
269 271
270extern void cgit_object_link(struct object *obj); 272extern void cgit_object_link(struct object *obj);
271 273
272extern void cgit_print_error(char *msg); 274extern void cgit_print_error(char *msg);
273extern void cgit_print_date(time_t secs, char *format); 275extern void cgit_print_date(time_t secs, char *format);
274extern void cgit_print_age(time_t t, time_t max_relative, char *format); 276extern void cgit_print_age(time_t t, time_t max_relative, char *format);
275extern void cgit_print_docstart(char *title, struct cacheitem *item); 277extern void cgit_print_docstart(char *title, struct cacheitem *item);
276extern void cgit_print_docend(); 278extern void cgit_print_docend();
277extern void cgit_print_pageheader(char *title, int show_search); 279extern void cgit_print_pageheader(char *title, int show_search);
278extern void cgit_print_snapshot_start(const char *mimetype, 280extern void cgit_print_snapshot_start(const char *mimetype,
279 const char *filename, 281 const char *filename,
280 struct cacheitem *item); 282 struct cacheitem *item);
281extern void cgit_print_branches(int maxcount); 283extern void cgit_print_branches(int maxcount);
282extern void cgit_print_tags(int maxcount); 284extern void cgit_print_tags(int maxcount);
283 285
284extern void cgit_print_repolist(struct cacheitem *item); 286extern void cgit_print_repolist(struct cacheitem *item);
285extern void cgit_print_summary(); 287extern void cgit_print_summary();