5 #include <git-compat-util.h>
18 #include <string-list.h>
19 #include <xdiff-interface.h>
20 #include <xdiff/xdiff.h>
25 * Dateformats used on misc. pages
27 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
28 #define FMT_SHORTDATE "%Y-%m-%d"
29 #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
33 * Limits used for relative dates
36 #define TM_HOUR (TM_MIN * 60)
37 #define TM_DAY (TM_HOUR * 24)
38 #define TM_WEEK (TM_DAY * 7)
39 #define TM_YEAR (TM_DAY * 365)
40 #define TM_MONTH (TM_YEAR / 12.0)
46 #define PAGE_ENCODING "UTF-8"
48 typedef void (*configfn
)(const char *name
, const char *value
);
49 typedef void (*filepair_fn
)(struct diff_filepair
*pair
);
50 typedef void (*linediff_fn
)(char *line
, int len
);
73 int enable_log_filecount
;
74 int enable_log_linecount
;
77 struct cgit_filter
*about_filter
;
78 struct cgit_filter
*commit_filter
;
79 struct cgit_filter
*source_filter
;
82 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
85 struct cgit_repolist
{
88 struct cgit_repo
*repos
;
92 struct commit
*commit
;
95 unsigned long author_date
;
97 char *committer_email
;
98 unsigned long committer_date
;
107 unsigned long tagger_date
;
113 struct object
*object
;
116 struct commitinfo
*commit
;
121 struct refinfo
**refs
;
170 int cache_dynamic_ttl
;
171 int cache_max_create_time
;
174 int cache_scanrc_ttl
;
175 int cache_static_ttl
;
177 int enable_filter_overrides
;
178 int enable_index_links
;
179 int enable_log_filecount
;
180 int enable_log_linecount
;
181 int enable_tree_linenumbers
;
184 int max_commit_count
;
185 int max_lock_attempts
;
187 int max_repodesc_len
;
195 int summary_branches
;
198 struct string_list mimetypes
;
199 struct cgit_filter
*about_filter
;
200 struct cgit_filter
*commit_filter
;
201 struct cgit_filter
*source_filter
;
217 struct cgit_environment
{
224 char *request_method
;
230 struct cgit_context
{
231 struct cgit_environment env
;
232 struct cgit_query qry
;
233 struct cgit_config cfg
;
234 struct cgit_repo
*repo
;
235 struct cgit_page page
;
238 struct cgit_snapshot_format
{
240 const char *mimetype
;
241 write_archive_fn_t write_func
;
245 extern const char *cgit_version
;
247 extern struct cgit_repolist cgit_repolist
;
248 extern struct cgit_context ctx
;
249 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
251 extern struct cgit_repo
*cgit_add_repo(const char *url
);
252 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
253 extern void cgit_repo_config_cb(const char *name
, const char *value
);
255 extern int chk_zero(int result
, char *msg
);
256 extern int chk_positive(int result
, char *msg
);
257 extern int chk_non_negative(int result
, char *msg
);
259 extern char *trim_end(const char *str
, char c
);
260 extern char *strlpart(char *txt
, int maxlen
);
261 extern char *strrpart(char *txt
, int maxlen
);
263 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
264 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
265 int flags
, void *cb_data
);
267 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
269 extern int cgit_diff_files(const unsigned char *old_sha1
,
270 const unsigned char *new_sha1
,
271 unsigned long *old_size
, unsigned long *new_size
,
272 int *binary
, linediff_fn fn
);
274 extern void cgit_diff_tree(const unsigned char *old_sha1
,
275 const unsigned char *new_sha1
,
276 filepair_fn fn
, const char *prefix
);
278 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
);
280 extern char *fmt(const char *format
,...);
282 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
283 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
284 extern void cgit_parse_url(const char *url
);
286 extern const char *cgit_repobasename(const char *reponame
);
288 extern int cgit_parse_snapshots_mask(const char *str
);
290 extern int cgit_open_filter(struct cgit_filter
*filter
);
291 extern int cgit_close_filter(struct cgit_filter
*filter
);
293 extern int readfile(const char *path
, char **buf
, size_t *size
);