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
;
190 int cache_dynamic_ttl
;
191 int cache_max_create_time
;
194 int cache_scanrc_ttl
;
195 int cache_static_ttl
;
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
;
210 int max_commit_count
;
211 int max_lock_attempts
;
213 int max_repodesc_len
;
221 int scan_hidden_path
;
222 int section_from_path
;
224 int summary_branches
;
228 struct string_list mimetypes
;
229 struct cgit_filter
*about_filter
;
230 struct cgit_filter
*commit_filter
;
231 struct cgit_filter
*source_filter
;
247 struct cgit_environment
{
254 char *request_method
;
260 struct 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
;
268 struct cgit_snapshot_format
{
270 const char *mimetype
;
271 write_archive_fn_t write_func
;
275 extern const char *cgit_version
;
277 extern struct cgit_repolist cgit_repolist
;
278 extern struct cgit_context ctx
;
279 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
281 extern struct cgit_repo
*cgit_add_repo(const char *url
);
282 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
283 extern void cgit_repo_config_cb(const char *name
, const char *value
);
285 extern int chk_zero(int result
, char *msg
);
286 extern int chk_positive(int result
, char *msg
);
287 extern int chk_non_negative(int result
, char *msg
);
289 extern char *trim_end(const char *str
, char c
);
290 extern char *strlpart(char *txt
, int maxlen
);
291 extern char *strrpart(char *txt
, int maxlen
);
293 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
294 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
295 int flags
, void *cb_data
);
297 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
299 extern 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
,
305 extern void cgit_diff_tree(const unsigned char *old_sha1
,
306 const unsigned char *new_sha1
,
307 filepair_fn fn
, const char *prefix
, int ignorews
);
309 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
312 __attribute__((format (printf
,1,2)))
313 extern char *fmt(const char *format
,...);
315 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
316 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
317 extern void cgit_parse_url(const char *url
);
319 extern const char *cgit_repobasename(const char *reponame
);
321 extern int cgit_parse_snapshots_mask(const char *str
);
323 extern int cgit_open_filter(struct cgit_filter
*filter
);
324 extern int cgit_close_filter(struct cgit_filter
*filter
);
326 extern void cgit_prepare_repo_env(struct cgit_repo
* repo
);
328 extern int readfile(const char *path
, char **buf
, size_t *size
);
330 extern char *expand_macros(const char *txt
);