5 #include <git-compat-util.h>
18 #include <string-list.h>
19 #include <xdiff-interface.h>
20 #include <xdiff/xdiff.h>
27 * Dateformats used on misc. pages
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"
35 * Limits used for relative dates
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)
48 #define PAGE_ENCODING "UTF-8"
50 typedef void (*configfn
)(const char *name
, const char *value
);
51 typedef void (*filepair_fn
)(struct diff_filepair
*pair
);
52 typedef void (*linediff_fn
)(char *line
, int len
);
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
;
88 struct cgit_filter
*about_filter
;
89 struct cgit_filter
*commit_filter
;
90 struct cgit_filter
*source_filter
;
93 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
96 struct cgit_repolist
{
99 struct cgit_repo
*repos
;
103 struct commit
*commit
;
106 unsigned long author_date
;
108 char *committer_email
;
109 unsigned long committer_date
;
118 unsigned long tagger_date
;
124 struct object
*object
;
127 struct commitinfo
*commit
;
132 struct refinfo
**refs
;
191 int cache_dynamic_ttl
;
192 int cache_max_create_time
;
195 int cache_scanrc_ttl
;
196 int cache_static_ttl
;
198 int enable_filter_overrides
;
199 int enable_gitweb_owner
;
200 int enable_http_clone
;
201 int enable_index_links
;
202 int enable_commit_graph
;
203 int enable_log_filecount
;
204 int enable_log_linecount
;
205 int enable_remote_branches
;
206 int enable_subject_links
;
207 int enable_tree_linenumbers
;
211 int max_commit_count
;
212 int max_lock_attempts
;
214 int max_repodesc_len
;
222 int scan_hidden_path
;
223 int section_from_path
;
225 int summary_branches
;
229 struct string_list mimetypes
;
230 struct cgit_filter
*about_filter
;
231 struct cgit_filter
*commit_filter
;
232 struct cgit_filter
*source_filter
;
248 struct cgit_environment
{
255 char *request_method
;
261 struct cgit_context
{
262 struct cgit_environment env
;
263 struct cgit_query qry
;
264 struct cgit_config cfg
;
265 struct cgit_repo
*repo
;
266 struct cgit_page page
;
269 struct cgit_snapshot_format
{
271 const char *mimetype
;
272 write_archive_fn_t write_func
;
276 extern const char *cgit_version
;
278 extern struct cgit_repolist cgit_repolist
;
279 extern struct cgit_context ctx
;
280 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
282 extern struct cgit_repo
*cgit_add_repo(const char *url
);
283 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
284 extern void cgit_repo_config_cb(const char *name
, const char *value
);
286 extern int chk_zero(int result
, char *msg
);
287 extern int chk_positive(int result
, char *msg
);
288 extern int chk_non_negative(int result
, char *msg
);
290 extern char *trim_end(const char *str
, char c
);
291 extern char *strlpart(char *txt
, int maxlen
);
292 extern char *strrpart(char *txt
, int maxlen
);
294 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
295 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
296 int flags
, void *cb_data
);
298 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
300 extern int cgit_diff_files(const unsigned char *old_sha1
,
301 const unsigned char *new_sha1
,
302 unsigned long *old_size
, unsigned long *new_size
,
303 int *binary
, int context
, int ignorews
,
306 extern void cgit_diff_tree(const unsigned char *old_sha1
,
307 const unsigned char *new_sha1
,
308 filepair_fn fn
, const char *prefix
, int ignorews
);
310 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
313 __attribute__((format (printf
,1,2)))
314 extern char *fmt(const char *format
,...);
316 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
317 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
318 extern void cgit_parse_url(const char *url
);
320 extern const char *cgit_repobasename(const char *reponame
);
322 extern int cgit_parse_snapshots_mask(const char *str
);
324 extern int cgit_open_filter(struct cgit_filter
*filter
);
325 extern int cgit_close_filter(struct cgit_filter
*filter
);
327 extern void cgit_prepare_repo_env(struct cgit_repo
* repo
);
329 extern int readfile(const char *path
, char **buf
, size_t *size
);
331 extern char *expand_macros(const char *txt
);