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
*commit_filter
;
78 struct cgit_filter
*source_filter
;
81 struct cgit_repolist
{
84 struct cgit_repo
*repos
;
88 struct commit
*commit
;
91 unsigned long author_date
;
93 char *committer_email
;
94 unsigned long committer_date
;
103 unsigned long tagger_date
;
109 struct object
*object
;
112 struct commitinfo
*commit
;
117 struct refinfo
**refs
;
166 int cache_dynamic_ttl
;
167 int cache_max_create_time
;
170 int cache_static_ttl
;
172 int enable_index_links
;
173 int enable_log_filecount
;
174 int enable_log_linecount
;
177 int max_commit_count
;
178 int max_lock_attempts
;
180 int max_repodesc_len
;
187 int summary_branches
;
190 struct string_list mimetypes
;
191 struct cgit_filter
*commit_filter
;
192 struct cgit_filter
*source_filter
;
208 struct cgit_context
{
209 struct cgit_query qry
;
210 struct cgit_config cfg
;
211 struct cgit_repo
*repo
;
212 struct cgit_page page
;
215 struct cgit_snapshot_format
{
217 const char *mimetype
;
218 write_archive_fn_t write_func
;
222 extern const char *cgit_version
;
224 extern struct cgit_repolist cgit_repolist
;
225 extern struct cgit_context ctx
;
226 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
228 extern struct cgit_repo
*cgit_add_repo(const char *url
);
229 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
230 extern void cgit_repo_config_cb(const char *name
, const char *value
);
232 extern int chk_zero(int result
, char *msg
);
233 extern int chk_positive(int result
, char *msg
);
234 extern int chk_non_negative(int result
, char *msg
);
236 extern char *trim_end(const char *str
, char c
);
237 extern char *strlpart(char *txt
, int maxlen
);
238 extern char *strrpart(char *txt
, int maxlen
);
240 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
241 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
242 int flags
, void *cb_data
);
244 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
246 extern int cgit_diff_files(const unsigned char *old_sha1
,
247 const unsigned char *new_sha1
,
248 unsigned long *old_size
, unsigned long *new_size
,
249 int *binary
, linediff_fn fn
);
251 extern void cgit_diff_tree(const unsigned char *old_sha1
,
252 const unsigned char *new_sha1
,
253 filepair_fn fn
, const char *prefix
);
255 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
);
257 extern char *fmt(const char *format
,...);
259 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
260 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
261 extern void cgit_parse_url(const char *url
);
263 extern const char *cgit_repobasename(const char *reponame
);
265 extern int cgit_parse_snapshots_mask(const char *str
);
267 extern int cgit_open_filter(struct cgit_filter
*filter
);
268 extern int cgit_close_filter(struct cgit_filter
*filter
);