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
;
75 int enable_remote_branches
;
76 int enable_subject_links
;
79 struct cgit_filter
*about_filter
;
80 struct cgit_filter
*commit_filter
;
81 struct cgit_filter
*source_filter
;
84 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
87 struct cgit_repolist
{
90 struct cgit_repo
*repos
;
94 struct commit
*commit
;
97 unsigned long author_date
;
99 char *committer_email
;
100 unsigned long committer_date
;
109 unsigned long tagger_date
;
115 struct object
*object
;
118 struct commitinfo
*commit
;
123 struct refinfo
**refs
;
173 int cache_dynamic_ttl
;
174 int cache_max_create_time
;
177 int cache_scanrc_ttl
;
178 int cache_static_ttl
;
180 int enable_filter_overrides
;
181 int enable_index_links
;
182 int enable_log_filecount
;
183 int enable_log_linecount
;
184 int enable_remote_branches
;
185 int enable_subject_links
;
186 int enable_tree_linenumbers
;
189 int max_commit_count
;
190 int max_lock_attempts
;
192 int max_repodesc_len
;
200 int summary_branches
;
204 struct string_list mimetypes
;
205 struct cgit_filter
*about_filter
;
206 struct cgit_filter
*commit_filter
;
207 struct cgit_filter
*source_filter
;
223 struct cgit_environment
{
230 char *request_method
;
236 struct cgit_context
{
237 struct cgit_environment env
;
238 struct cgit_query qry
;
239 struct cgit_config cfg
;
240 struct cgit_repo
*repo
;
241 struct cgit_page page
;
244 struct cgit_snapshot_format
{
246 const char *mimetype
;
247 write_archive_fn_t write_func
;
251 extern const char *cgit_version
;
253 extern struct cgit_repolist cgit_repolist
;
254 extern struct cgit_context ctx
;
255 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
257 extern struct cgit_repo
*cgit_add_repo(const char *url
);
258 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
259 extern void cgit_repo_config_cb(const char *name
, const char *value
);
261 extern int chk_zero(int result
, char *msg
);
262 extern int chk_positive(int result
, char *msg
);
263 extern int chk_non_negative(int result
, char *msg
);
265 extern char *trim_end(const char *str
, char c
);
266 extern char *strlpart(char *txt
, int maxlen
);
267 extern char *strrpart(char *txt
, int maxlen
);
269 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
270 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
271 int flags
, void *cb_data
);
273 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
275 extern int cgit_diff_files(const unsigned char *old_sha1
,
276 const unsigned char *new_sha1
,
277 unsigned long *old_size
, unsigned long *new_size
,
278 int *binary
, linediff_fn fn
);
280 extern void cgit_diff_tree(const unsigned char *old_sha1
,
281 const unsigned char *new_sha1
,
282 filepair_fn fn
, const char *prefix
);
284 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
);
286 extern char *fmt(const char *format
,...);
288 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
289 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
290 extern void cgit_parse_url(const char *url
);
292 extern const char *cgit_repobasename(const char *reponame
);
294 extern int cgit_parse_snapshots_mask(const char *str
);
296 extern int cgit_open_filter(struct cgit_filter
*filter
);
297 extern int cgit_close_filter(struct cgit_filter
*filter
);
299 extern int readfile(const char *path
, char **buf
, size_t *size
);