5 #include <git-compat-util.h>
18 #include <string-list.h>
19 #include <xdiff-interface.h>
20 #include <xdiff/xdiff.h>
26 * Dateformats used on misc. pages
28 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
29 #define FMT_SHORTDATE "%Y-%m-%d"
30 #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
34 * Limits used for relative dates
37 #define TM_HOUR (TM_MIN * 60)
38 #define TM_DAY (TM_HOUR * 24)
39 #define TM_WEEK (TM_DAY * 7)
40 #define TM_YEAR (TM_DAY * 365)
41 #define TM_MONTH (TM_YEAR / 12.0)
47 #define PAGE_ENCODING "UTF-8"
49 typedef void (*configfn
)(const char *name
, const char *value
);
50 typedef void (*filepair_fn
)(struct diff_filepair
*pair
);
51 typedef void (*linediff_fn
)(char *line
, int len
);
74 int enable_log_filecount
;
75 int enable_log_linecount
;
76 int enable_remote_branches
;
77 int enable_subject_links
;
80 struct cgit_filter
*about_filter
;
81 struct cgit_filter
*commit_filter
;
82 struct cgit_filter
*source_filter
;
85 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
88 struct cgit_repolist
{
91 struct cgit_repo
*repos
;
95 struct commit
*commit
;
98 unsigned long author_date
;
100 char *committer_email
;
101 unsigned long committer_date
;
110 unsigned long tagger_date
;
116 struct object
*object
;
119 struct commitinfo
*commit
;
124 struct refinfo
**refs
;
180 int cache_dynamic_ttl
;
181 int cache_max_create_time
;
184 int cache_scanrc_ttl
;
185 int cache_static_ttl
;
187 int enable_filter_overrides
;
188 int enable_gitweb_owner
;
189 int enable_index_links
;
190 int enable_log_filecount
;
191 int enable_log_linecount
;
192 int enable_remote_branches
;
193 int enable_subject_links
;
194 int enable_tree_linenumbers
;
198 int max_commit_count
;
199 int max_lock_attempts
;
201 int max_repodesc_len
;
209 int section_from_path
;
211 int summary_branches
;
215 struct string_list mimetypes
;
216 struct cgit_filter
*about_filter
;
217 struct cgit_filter
*commit_filter
;
218 struct cgit_filter
*source_filter
;
234 struct cgit_environment
{
241 char *request_method
;
247 struct cgit_context
{
248 struct cgit_environment env
;
249 struct cgit_query qry
;
250 struct cgit_config cfg
;
251 struct cgit_repo
*repo
;
252 struct cgit_page page
;
255 struct cgit_snapshot_format
{
257 const char *mimetype
;
258 write_archive_fn_t write_func
;
262 extern const char *cgit_version
;
264 extern struct cgit_repolist cgit_repolist
;
265 extern struct cgit_context ctx
;
266 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
268 extern struct cgit_repo
*cgit_add_repo(const char *url
);
269 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
270 extern void cgit_repo_config_cb(const char *name
, const char *value
);
272 extern int chk_zero(int result
, char *msg
);
273 extern int chk_positive(int result
, char *msg
);
274 extern int chk_non_negative(int result
, char *msg
);
276 extern char *trim_end(const char *str
, char c
);
277 extern char *strlpart(char *txt
, int maxlen
);
278 extern char *strrpart(char *txt
, int maxlen
);
280 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
281 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
282 int flags
, void *cb_data
);
284 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
286 extern int cgit_diff_files(const unsigned char *old_sha1
,
287 const unsigned char *new_sha1
,
288 unsigned long *old_size
, unsigned long *new_size
,
289 int *binary
, int context
, int ignorews
,
292 extern void cgit_diff_tree(const unsigned char *old_sha1
,
293 const unsigned char *new_sha1
,
294 filepair_fn fn
, const char *prefix
, int ignorews
);
296 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
);
298 __attribute__((format (printf
,1,2)))
299 extern char *fmt(const char *format
,...);
301 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
302 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
303 extern void cgit_parse_url(const char *url
);
305 extern const char *cgit_repobasename(const char *reponame
);
307 extern int cgit_parse_snapshots_mask(const char *str
);
309 extern int cgit_open_filter(struct cgit_filter
*filter
);
310 extern int cgit_close_filter(struct cgit_filter
*filter
);
312 extern int readfile(const char *path
, char **buf
, size_t *size
);
314 extern char *expand_macros(const char *txt
);