5 #include <git-compat-util.h>
18 #include <xdiff-interface.h>
19 #include <xdiff/xdiff.h>
24 * Dateformats used on misc. pages
26 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
27 #define FMT_SHORTDATE "%Y-%m-%d"
28 #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
32 * Limits used for relative dates
35 #define TM_HOUR (TM_MIN * 60)
36 #define TM_DAY (TM_HOUR * 24)
37 #define TM_WEEK (TM_DAY * 7)
38 #define TM_YEAR (TM_DAY * 365)
39 #define TM_MONTH (TM_YEAR / 12.0)
45 #define PAGE_ENCODING "UTF-8"
47 typedef void (*configfn
)(const char *name
, const char *value
);
48 typedef void (*filepair_fn
)(struct diff_filepair
*pair
);
49 typedef void (*linediff_fn
)(char *line
, int len
);
72 int enable_log_filecount
;
73 int enable_log_linecount
;
76 struct cgit_filter
*commit_filter
;
77 struct cgit_filter
*source_filter
;
80 struct cgit_repolist
{
83 struct cgit_repo
*repos
;
87 struct commit
*commit
;
90 unsigned long author_date
;
92 char *committer_email
;
93 unsigned long committer_date
;
102 unsigned long tagger_date
;
108 struct object
*object
;
111 struct commitinfo
*commit
;
116 struct refinfo
**refs
;
165 int cache_dynamic_ttl
;
166 int cache_max_create_time
;
169 int cache_static_ttl
;
171 int enable_index_links
;
172 int enable_log_filecount
;
173 int enable_log_linecount
;
176 int max_commit_count
;
177 int max_lock_attempts
;
179 int max_repodesc_len
;
185 int summary_branches
;
188 struct cgit_filter
*commit_filter
;
189 struct cgit_filter
*source_filter
;
205 struct cgit_context
{
206 struct cgit_query qry
;
207 struct cgit_config cfg
;
208 struct cgit_repo
*repo
;
209 struct cgit_page page
;
212 struct cgit_snapshot_format
{
214 const char *mimetype
;
215 write_archive_fn_t write_func
;
219 extern const char *cgit_version
;
221 extern struct cgit_repolist cgit_repolist
;
222 extern struct cgit_context ctx
;
223 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
225 extern struct cgit_repo
*cgit_add_repo(const char *url
);
226 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
227 extern void cgit_repo_config_cb(const char *name
, const char *value
);
229 extern int chk_zero(int result
, char *msg
);
230 extern int chk_positive(int result
, char *msg
);
231 extern int chk_non_negative(int result
, char *msg
);
233 extern char *trim_end(const char *str
, char c
);
234 extern char *strlpart(char *txt
, int maxlen
);
235 extern char *strrpart(char *txt
, int maxlen
);
237 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
238 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
239 int flags
, void *cb_data
);
241 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
243 extern int cgit_diff_files(const unsigned char *old_sha1
,
244 const unsigned char *new_sha1
,
245 unsigned long *old_size
, unsigned long *new_size
,
246 int *binary
, linediff_fn fn
);
248 extern void cgit_diff_tree(const unsigned char *old_sha1
,
249 const unsigned char *new_sha1
,
250 filepair_fn fn
, const char *prefix
);
252 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
);
254 extern char *fmt(const char *format
,...);
256 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
257 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
258 extern void cgit_parse_url(const char *url
);
260 extern const char *cgit_repobasename(const char *reponame
);
262 extern int cgit_parse_snapshots_mask(const char *str
);
264 extern int cgit_open_filter(struct cgit_filter
*filter
);
265 extern int cgit_close_filter(struct cgit_filter
*filter
);