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
;
189 int cache_dynamic_ttl
;
190 int cache_max_create_time
;
193 int cache_scanrc_ttl
;
194 int cache_static_ttl
;
196 int enable_filter_overrides
;
197 int enable_gitweb_owner
;
198 int enable_http_clone
;
199 int enable_index_links
;
200 int enable_commit_graph
;
201 int enable_log_filecount
;
202 int enable_log_linecount
;
203 int enable_remote_branches
;
204 int enable_subject_links
;
205 int enable_tree_linenumbers
;
209 int max_commit_count
;
210 int max_lock_attempts
;
212 int max_repodesc_len
;
220 int scan_hidden_path
;
221 int section_from_path
;
223 int summary_branches
;
227 struct string_list mimetypes
;
228 struct cgit_filter
*about_filter
;
229 struct cgit_filter
*commit_filter
;
230 struct cgit_filter
*source_filter
;
246 struct cgit_environment
{
253 char *request_method
;
259 struct cgit_context
{
260 struct cgit_environment env
;
261 struct cgit_query qry
;
262 struct cgit_config cfg
;
263 struct cgit_repo
*repo
;
264 struct cgit_page page
;
267 struct cgit_snapshot_format
{
269 const char *mimetype
;
270 write_archive_fn_t write_func
;
274 extern const char *cgit_version
;
276 extern struct cgit_repolist cgit_repolist
;
277 extern struct cgit_context ctx
;
278 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
280 extern struct cgit_repo
*cgit_add_repo(const char *url
);
281 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
282 extern void cgit_repo_config_cb(const char *name
, const char *value
);
284 extern int chk_zero(int result
, char *msg
);
285 extern int chk_positive(int result
, char *msg
);
286 extern int chk_non_negative(int result
, char *msg
);
288 extern char *trim_end(const char *str
, char c
);
289 extern char *strlpart(char *txt
, int maxlen
);
290 extern char *strrpart(char *txt
, int maxlen
);
292 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
293 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
294 int flags
, void *cb_data
);
296 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
298 extern int cgit_diff_files(const unsigned char *old_sha1
,
299 const unsigned char *new_sha1
,
300 unsigned long *old_size
, unsigned long *new_size
,
301 int *binary
, int context
, int ignorews
,
304 extern void cgit_diff_tree(const unsigned char *old_sha1
,
305 const unsigned char *new_sha1
,
306 filepair_fn fn
, const char *prefix
, int ignorews
);
308 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
311 __attribute__((format (printf
,1,2)))
312 extern char *fmt(const char *format
,...);
314 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
315 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
316 extern void cgit_parse_url(const char *url
);
318 extern const char *cgit_repobasename(const char *reponame
);
320 extern int cgit_parse_snapshots_mask(const char *str
);
322 extern int cgit_open_filter(struct cgit_filter
*filter
, struct cgit_repo
* repo
);
323 extern int cgit_close_filter(struct cgit_filter
*filter
);
325 extern int readfile(const char *path
, char **buf
, size_t *size
);
327 extern char *expand_macros(const char *txt
);