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
);
76 int enable_log_filecount
;
77 int enable_log_linecount
;
78 int enable_remote_branches
;
79 int enable_subject_links
;
82 struct cgit_filter
*about_filter
;
83 struct cgit_filter
*commit_filter
;
84 struct cgit_filter
*source_filter
;
87 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
90 struct cgit_repolist
{
93 struct cgit_repo
*repos
;
97 struct commit
*commit
;
100 unsigned long author_date
;
102 char *committer_email
;
103 unsigned long committer_date
;
112 unsigned long tagger_date
;
118 struct object
*object
;
121 struct commitinfo
*commit
;
126 struct refinfo
**refs
;
183 int cache_dynamic_ttl
;
184 int cache_max_create_time
;
187 int cache_scanrc_ttl
;
188 int cache_static_ttl
;
190 int enable_filter_overrides
;
191 int enable_gitweb_owner
;
192 int enable_index_links
;
193 int enable_log_filecount
;
194 int enable_log_linecount
;
195 int enable_remote_branches
;
196 int enable_subject_links
;
197 int enable_tree_linenumbers
;
201 int max_commit_count
;
202 int max_lock_attempts
;
204 int max_repodesc_len
;
212 int section_from_path
;
214 int summary_branches
;
218 struct string_list mimetypes
;
219 struct cgit_filter
*about_filter
;
220 struct cgit_filter
*commit_filter
;
221 struct cgit_filter
*source_filter
;
237 struct cgit_environment
{
244 char *request_method
;
250 struct cgit_context
{
251 struct cgit_environment env
;
252 struct cgit_query qry
;
253 struct cgit_config cfg
;
254 struct cgit_repo
*repo
;
255 struct cgit_page page
;
258 struct cgit_snapshot_format
{
260 const char *mimetype
;
261 write_archive_fn_t write_func
;
265 extern const char *cgit_version
;
267 extern struct cgit_repolist cgit_repolist
;
268 extern struct cgit_context ctx
;
269 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
271 extern struct cgit_repo
*cgit_add_repo(const char *url
);
272 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
273 extern void cgit_repo_config_cb(const char *name
, const char *value
);
275 extern int chk_zero(int result
, char *msg
);
276 extern int chk_positive(int result
, char *msg
);
277 extern int chk_non_negative(int result
, char *msg
);
279 extern char *trim_end(const char *str
, char c
);
280 extern char *strlpart(char *txt
, int maxlen
);
281 extern char *strrpart(char *txt
, int maxlen
);
283 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
284 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
285 int flags
, void *cb_data
);
287 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
289 extern int cgit_diff_files(const unsigned char *old_sha1
,
290 const unsigned char *new_sha1
,
291 unsigned long *old_size
, unsigned long *new_size
,
292 int *binary
, int context
, int ignorews
,
295 extern void cgit_diff_tree(const unsigned char *old_sha1
,
296 const unsigned char *new_sha1
,
297 filepair_fn fn
, const char *prefix
, int ignorews
);
299 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
302 __attribute__((format (printf
,1,2)))
303 extern char *fmt(const char *format
,...);
305 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
306 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
307 extern void cgit_parse_url(const char *url
);
309 extern const char *cgit_repobasename(const char *reponame
);
311 extern int cgit_parse_snapshots_mask(const char *str
);
313 extern int cgit_open_filter(struct cgit_filter
*filter
);
314 extern int cgit_close_filter(struct cgit_filter
*filter
);
316 extern int readfile(const char *path
, char **buf
, size_t *size
);
318 extern char *expand_macros(const char *txt
);