5 #include <git-compat-util.h>
18 #include <string-list.h>
19 #include <xdiff-interface.h>
20 #include <xdiff/xdiff.h>
27 * Dateformats used on misc. pages
29 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
30 #define FMT_SHORTDATE "%Y-%m-%d"
31 #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
35 * Limits used for relative dates
38 #define TM_HOUR (TM_MIN * 60)
39 #define TM_DAY (TM_HOUR * 24)
40 #define TM_WEEK (TM_DAY * 7)
41 #define TM_YEAR (TM_DAY * 365)
42 #define TM_MONTH (TM_YEAR / 12.0)
48 #define PAGE_ENCODING "UTF-8"
50 typedef void (*configfn
)(const char *name
, const char *value
);
51 typedef void (*filepair_fn
)(struct diff_filepair
*pair
);
52 typedef void (*linediff_fn
)(char *line
, int len
);
81 int enable_commit_graph
;
82 int enable_log_filecount
;
83 int enable_log_linecount
;
84 int enable_remote_branches
;
85 int enable_subject_links
;
88 struct cgit_filter
*about_filter
;
89 struct cgit_filter
*commit_filter
;
90 struct cgit_filter
*source_filter
;
91 struct string_list submodules
;
94 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
97 struct cgit_repolist
{
100 struct cgit_repo
*repos
;
104 struct commit
*commit
;
107 unsigned long author_date
;
109 char *committer_email
;
110 unsigned long committer_date
;
119 unsigned long tagger_date
;
125 struct object
*object
;
128 struct commitinfo
*commit
;
133 struct refinfo
**refs
;
194 int cache_dynamic_ttl
;
195 int cache_max_create_time
;
198 int cache_scanrc_ttl
;
199 int cache_static_ttl
;
200 int case_sensitive_sort
;
202 int enable_filter_overrides
;
203 int enable_gitweb_owner
;
204 int enable_gitweb_desc
;
205 int enable_gitweb_section
;
206 int enable_http_clone
;
207 int enable_index_links
;
208 int enable_commit_graph
;
209 int enable_log_filecount
;
210 int enable_log_linecount
;
211 int enable_remote_branches
;
212 int enable_subject_links
;
213 int enable_tree_linenumbers
;
217 int max_commit_count
;
218 int max_lock_attempts
;
220 int max_repodesc_len
;
228 int scan_hidden_path
;
229 int section_from_path
;
231 int summary_branches
;
235 struct string_list mimetypes
;
236 struct cgit_filter
*about_filter
;
237 struct cgit_filter
*commit_filter
;
238 struct cgit_filter
*source_filter
;
254 struct cgit_environment
{
261 char *request_method
;
267 struct cgit_context
{
268 struct cgit_environment env
;
269 struct cgit_query qry
;
270 struct cgit_config cfg
;
271 struct cgit_repo
*repo
;
272 struct cgit_page page
;
275 struct cgit_snapshot_format
{
277 const char *mimetype
;
278 write_archive_fn_t write_func
;
282 extern const char *cgit_version
;
284 extern struct cgit_repolist cgit_repolist
;
285 extern struct cgit_context ctx
;
286 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
288 extern struct cgit_repo
*cgit_add_repo(const char *url
);
289 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
290 extern void cgit_repo_config_cb(const char *name
, const char *value
);
292 extern int chk_zero(int result
, char *msg
);
293 extern int chk_positive(int result
, char *msg
);
294 extern int chk_non_negative(int result
, char *msg
);
296 extern char *trim_end(const char *str
, char c
);
297 extern char *strlpart(char *txt
, int maxlen
);
298 extern char *strrpart(char *txt
, int maxlen
);
300 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
301 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
302 int flags
, void *cb_data
);
304 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
306 extern int cgit_diff_files(const unsigned char *old_sha1
,
307 const unsigned char *new_sha1
,
308 unsigned long *old_size
, unsigned long *new_size
,
309 int *binary
, int context
, int ignorews
,
312 extern void cgit_diff_tree(const unsigned char *old_sha1
,
313 const unsigned char *new_sha1
,
314 filepair_fn fn
, const char *prefix
, int ignorews
);
316 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
319 __attribute__((format (printf
,1,2)))
320 extern char *fmt(const char *format
,...);
322 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
323 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
324 extern void cgit_parse_url(const char *url
);
326 extern const char *cgit_repobasename(const char *reponame
);
328 extern int cgit_parse_snapshots_mask(const char *str
);
330 extern int cgit_open_filter(struct cgit_filter
*filter
);
331 extern int cgit_close_filter(struct cgit_filter
*filter
);
333 extern void cgit_prepare_repo_env(struct cgit_repo
* repo
);
335 extern int readfile(const char *path
, char **buf
, size_t *size
);
337 extern char *expand_macros(const char *txt
);