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
);
77 int enable_commit_graph
;
78 int enable_log_filecount
;
79 int enable_log_linecount
;
80 int enable_remote_branches
;
81 int enable_subject_links
;
84 struct cgit_filter
*about_filter
;
85 struct cgit_filter
*commit_filter
;
86 struct cgit_filter
*source_filter
;
89 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
92 struct cgit_repolist
{
95 struct cgit_repo
*repos
;
99 struct commit
*commit
;
102 unsigned long author_date
;
104 char *committer_email
;
105 unsigned long committer_date
;
114 unsigned long tagger_date
;
120 struct object
*object
;
123 struct commitinfo
*commit
;
128 struct refinfo
**refs
;
185 int cache_dynamic_ttl
;
186 int cache_max_create_time
;
189 int cache_scanrc_ttl
;
190 int cache_static_ttl
;
192 int enable_filter_overrides
;
193 int enable_gitweb_owner
;
194 int enable_index_links
;
195 int enable_commit_graph
;
196 int enable_log_filecount
;
197 int enable_log_linecount
;
198 int enable_remote_branches
;
199 int enable_subject_links
;
200 int enable_tree_linenumbers
;
204 int max_commit_count
;
205 int max_lock_attempts
;
207 int max_repodesc_len
;
215 int scan_hidden_path
;
216 int section_from_path
;
218 int summary_branches
;
222 struct string_list mimetypes
;
223 struct cgit_filter
*about_filter
;
224 struct cgit_filter
*commit_filter
;
225 struct cgit_filter
*source_filter
;
241 struct cgit_environment
{
248 char *request_method
;
254 struct cgit_context
{
255 struct cgit_environment env
;
256 struct cgit_query qry
;
257 struct cgit_config cfg
;
258 struct cgit_repo
*repo
;
259 struct cgit_page page
;
262 struct cgit_snapshot_format
{
264 const char *mimetype
;
265 write_archive_fn_t write_func
;
269 extern const char *cgit_version
;
271 extern struct cgit_repolist cgit_repolist
;
272 extern struct cgit_context ctx
;
273 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
275 extern struct cgit_repo
*cgit_add_repo(const char *url
);
276 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
277 extern void cgit_repo_config_cb(const char *name
, const char *value
);
279 extern int chk_zero(int result
, char *msg
);
280 extern int chk_positive(int result
, char *msg
);
281 extern int chk_non_negative(int result
, char *msg
);
283 extern char *trim_end(const char *str
, char c
);
284 extern char *strlpart(char *txt
, int maxlen
);
285 extern char *strrpart(char *txt
, int maxlen
);
287 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
288 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
289 int flags
, void *cb_data
);
291 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
293 extern int cgit_diff_files(const unsigned char *old_sha1
,
294 const unsigned char *new_sha1
,
295 unsigned long *old_size
, unsigned long *new_size
,
296 int *binary
, int context
, int ignorews
,
299 extern void cgit_diff_tree(const unsigned char *old_sha1
,
300 const unsigned char *new_sha1
,
301 filepair_fn fn
, const char *prefix
, int ignorews
);
303 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
306 __attribute__((format (printf
,1,2)))
307 extern char *fmt(const char *format
,...);
309 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
310 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
311 extern void cgit_parse_url(const char *url
);
313 extern const char *cgit_repobasename(const char *reponame
);
315 extern int cgit_parse_snapshots_mask(const char *str
);
317 extern int cgit_open_filter(struct cgit_filter
*filter
);
318 extern int cgit_close_filter(struct cgit_filter
*filter
);
320 extern int readfile(const char *path
, char **buf
, size_t *size
);
322 extern char *expand_macros(const char *txt
);