5 #include <git-compat-util.h>
14 #include <argv-array.h>
19 #include <string-list.h>
20 #include <xdiff-interface.h>
21 #include <xdiff/xdiff.h>
28 * Dateformats used on misc. pages
30 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
31 #define FMT_SHORTDATE "%Y-%m-%d"
32 #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
36 * Limits used for relative dates
39 #define TM_HOUR (TM_MIN * 60)
40 #define TM_DAY (TM_HOUR * 24)
41 #define TM_WEEK (TM_DAY * 7)
42 #define TM_YEAR (TM_DAY * 365)
43 #define TM_MONTH (TM_YEAR / 12.0)
49 #define PAGE_ENCODING "UTF-8"
51 typedef void (*configfn
)(const char *name
, const char *value
);
52 typedef void (*filepair_fn
)(struct diff_filepair
*pair
);
53 typedef void (*linediff_fn
)(char *line
, int len
);
75 struct string_list readme
;
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
;
90 struct cgit_filter
*about_filter
;
91 struct cgit_filter
*commit_filter
;
92 struct cgit_filter
*source_filter
;
93 struct string_list submodules
;
96 typedef void (*repo_config_fn
)(struct cgit_repo
*repo
, const char *name
,
99 struct cgit_repolist
{
102 struct cgit_repo
*repos
;
106 struct commit
*commit
;
109 unsigned long author_date
;
111 char *committer_email
;
112 unsigned long committer_date
;
121 unsigned long tagger_date
;
127 struct object
*object
;
130 struct commitinfo
*commit
;
135 struct refinfo
**refs
;
185 struct string_list readme
;
192 char *repository_sort
;
193 char *virtual_root
; /* Always ends with '/'. */
196 int cache_dynamic_ttl
;
197 int cache_max_create_time
;
200 int cache_scanrc_ttl
;
201 int cache_static_ttl
;
203 int case_sensitive_sort
;
205 int enable_filter_overrides
;
206 int enable_http_clone
;
207 int enable_index_links
;
208 int enable_index_owner
;
209 int enable_commit_graph
;
210 int enable_log_filecount
;
211 int enable_log_linecount
;
212 int enable_remote_branches
;
213 int enable_subject_links
;
214 int enable_tree_linenumbers
;
215 int enable_git_config
;
219 int max_commit_count
;
220 int max_lock_attempts
;
222 int max_repodesc_len
;
230 int scan_hidden_path
;
231 int section_from_path
;
234 int summary_branches
;
240 struct string_list mimetypes
;
241 struct cgit_filter
*about_filter
;
242 struct cgit_filter
*commit_filter
;
243 struct cgit_filter
*source_filter
;
250 const char *mimetype
;
252 const char *filename
;
256 const char *statusmsg
;
259 struct cgit_environment
{
260 const char *cgit_config
;
261 const char *http_host
;
264 const char *path_info
;
265 const char *query_string
;
266 const char *request_method
;
267 const char *script_name
;
268 const char *server_name
;
269 const char *server_port
;
272 struct cgit_context
{
273 struct cgit_environment env
;
274 struct cgit_query qry
;
275 struct cgit_config cfg
;
276 struct cgit_repo
*repo
;
277 struct cgit_page page
;
280 typedef int (*write_archive_fn_t
)(const char *, const char *);
282 struct cgit_snapshot_format
{
284 const char *mimetype
;
285 write_archive_fn_t write_func
;
289 extern const char *cgit_version
;
291 extern struct cgit_repolist cgit_repolist
;
292 extern struct cgit_context ctx
;
293 extern const struct cgit_snapshot_format cgit_snapshot_formats
[];
295 extern char *cgit_default_repo_desc
;
296 extern struct cgit_repo
*cgit_add_repo(const char *url
);
297 extern struct cgit_repo
*cgit_get_repoinfo(const char *url
);
298 extern void cgit_repo_config_cb(const char *name
, const char *value
);
300 extern int chk_zero(int result
, char *msg
);
301 extern int chk_positive(int result
, char *msg
);
302 extern int chk_non_negative(int result
, char *msg
);
304 extern char *trim_end(const char *str
, char c
);
305 extern char *ensure_end(const char *str
, char c
);
306 extern char *strlpart(char *txt
, int maxlen
);
307 extern char *strrpart(char *txt
, int maxlen
);
309 extern void strbuf_ensure_end(struct strbuf
*sb
, char c
);
311 extern void cgit_add_ref(struct reflist
*list
, struct refinfo
*ref
);
312 extern void cgit_free_reflist_inner(struct reflist
*list
);
313 extern int cgit_refs_cb(const char *refname
, const unsigned char *sha1
,
314 int flags
, void *cb_data
);
316 extern void *cgit_free_commitinfo(struct commitinfo
*info
);
318 extern int cgit_diff_files(const unsigned char *old_sha1
,
319 const unsigned char *new_sha1
,
320 unsigned long *old_size
, unsigned long *new_size
,
321 int *binary
, int context
, int ignorews
,
324 extern void cgit_diff_tree(const unsigned char *old_sha1
,
325 const unsigned char *new_sha1
,
326 filepair_fn fn
, const char *prefix
, int ignorews
);
328 extern void cgit_diff_commit(struct commit
*commit
, filepair_fn fn
,
331 __attribute__((format (printf
,1,2)))
332 extern char *fmt(const char *format
,...);
334 __attribute__((format (printf
,1,2)))
335 extern char *fmtalloc(const char *format
,...);
337 extern struct commitinfo
*cgit_parse_commit(struct commit
*commit
);
338 extern struct taginfo
*cgit_parse_tag(struct tag
*tag
);
339 extern void cgit_parse_url(const char *url
);
341 extern const char *cgit_repobasename(const char *reponame
);
343 extern int cgit_parse_snapshots_mask(const char *str
);
345 extern int cgit_open_filter(struct cgit_filter
*filter
);
346 extern int cgit_close_filter(struct cgit_filter
*filter
);
347 extern struct cgit_filter
*cgit_new_filter(const char *cmd
, filter_type filtertype
);
349 extern void cgit_prepare_repo_env(struct cgit_repo
* repo
);
351 extern int readfile(const char *path
, char **buf
, size_t *size
);
353 extern char *expand_macros(const char *txt
);