2006-12-09 14:18:17 +00:00
|
|
|
#ifndef CGIT_H
|
|
|
|
#define CGIT_H
|
|
|
|
|
2007-05-08 20:40:59 +00:00
|
|
|
|
|
|
|
#include <git-compat-util.h>
|
|
|
|
#include <cache.h>
|
|
|
|
#include <grep.h>
|
|
|
|
#include <object.h>
|
|
|
|
#include <tree.h>
|
|
|
|
#include <commit.h>
|
|
|
|
#include <tag.h>
|
|
|
|
#include <diff.h>
|
|
|
|
#include <diffcore.h>
|
|
|
|
#include <refs.h>
|
|
|
|
#include <revision.h>
|
|
|
|
#include <log-tree.h>
|
|
|
|
#include <archive.h>
|
|
|
|
#include <xdiff/xdiff.h>
|
2007-11-05 21:27:43 +00:00
|
|
|
#include <utf8.h>
|
2007-05-08 20:40:59 +00:00
|
|
|
|
2006-12-10 21:31:36 +00:00
|
|
|
|
2007-05-22 21:08:46 +00:00
|
|
|
/*
|
|
|
|
* Dateformats used on misc. pages
|
|
|
|
*/
|
|
|
|
#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
|
|
|
|
#define FMT_SHORTDATE "%Y-%m-%d"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Limits used for relative dates
|
|
|
|
*/
|
|
|
|
#define TM_MIN 60
|
|
|
|
#define TM_HOUR (TM_MIN * 60)
|
|
|
|
#define TM_DAY (TM_HOUR * 24)
|
|
|
|
#define TM_WEEK (TM_DAY * 7)
|
|
|
|
#define TM_YEAR (TM_DAY * 365)
|
|
|
|
#define TM_MONTH (TM_YEAR / 12.0)
|
|
|
|
|
|
|
|
|
2007-10-26 22:09:06 +00:00
|
|
|
/*
|
|
|
|
* Default encoding
|
|
|
|
*/
|
|
|
|
#define PAGE_ENCODING "UTF-8"
|
|
|
|
|
2006-12-10 21:31:36 +00:00
|
|
|
typedef void (*configfn)(const char *name, const char *value);
|
2007-05-13 09:24:23 +00:00
|
|
|
typedef void (*filepair_fn)(struct diff_filepair *pair);
|
2007-05-13 12:21:19 +00:00
|
|
|
typedef void (*linediff_fn)(char *line, int len);
|
2006-12-10 21:31:36 +00:00
|
|
|
|
|
|
|
struct cacheitem {
|
|
|
|
char *name;
|
|
|
|
struct stat st;
|
|
|
|
int ttl;
|
|
|
|
int fd;
|
|
|
|
};
|
|
|
|
|
2008-02-16 12:56:09 +00:00
|
|
|
struct cgit_repo {
|
2007-02-03 14:02:55 +00:00
|
|
|
char *url;
|
|
|
|
char *name;
|
|
|
|
char *path;
|
|
|
|
char *desc;
|
|
|
|
char *owner;
|
2007-05-15 22:14:51 +00:00
|
|
|
char *defbranch;
|
2007-05-18 20:48:22 +00:00
|
|
|
char *group;
|
2007-05-11 10:12:48 +00:00
|
|
|
char *module_link;
|
2007-05-23 20:46:54 +00:00
|
|
|
char *readme;
|
2007-12-03 00:49:38 +00:00
|
|
|
char *clone_url;
|
2007-02-08 13:47:56 +00:00
|
|
|
int snapshots;
|
2007-05-18 11:55:52 +00:00
|
|
|
int enable_log_filecount;
|
|
|
|
int enable_log_linecount;
|
2007-02-03 14:02:55 +00:00
|
|
|
};
|
|
|
|
|
2008-02-16 12:56:09 +00:00
|
|
|
struct cgit_repolist {
|
2007-02-03 14:02:55 +00:00
|
|
|
int length;
|
|
|
|
int count;
|
2008-02-16 12:56:09 +00:00
|
|
|
struct cgit_repo *repos;
|
2007-02-03 14:02:55 +00:00
|
|
|
};
|
|
|
|
|
2006-12-15 17:17:36 +00:00
|
|
|
struct commitinfo {
|
|
|
|
struct commit *commit;
|
|
|
|
char *author;
|
2006-12-16 13:25:41 +00:00
|
|
|
char *author_email;
|
|
|
|
unsigned long author_date;
|
2006-12-15 17:17:36 +00:00
|
|
|
char *committer;
|
2006-12-16 13:25:41 +00:00
|
|
|
char *committer_email;
|
|
|
|
unsigned long committer_date;
|
2006-12-15 17:17:36 +00:00
|
|
|
char *subject;
|
|
|
|
char *msg;
|
2007-10-26 22:09:06 +00:00
|
|
|
char *msg_encoding;
|
2006-12-15 17:17:36 +00:00
|
|
|
};
|
|
|
|
|
2007-01-17 00:09:51 +00:00
|
|
|
struct taginfo {
|
|
|
|
char *tagger;
|
|
|
|
char *tagger_email;
|
|
|
|
int tagger_date;
|
|
|
|
char *msg;
|
|
|
|
};
|
|
|
|
|
2007-10-25 07:30:06 +00:00
|
|
|
struct refinfo {
|
|
|
|
const char *refname;
|
|
|
|
struct object *object;
|
|
|
|
union {
|
|
|
|
struct taginfo *tag;
|
|
|
|
struct commitinfo *commit;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct reflist {
|
|
|
|
struct refinfo **refs;
|
|
|
|
int alloc;
|
|
|
|
int count;
|
|
|
|
};
|
|
|
|
|
2008-02-16 10:53:40 +00:00
|
|
|
struct cgit_query {
|
|
|
|
int has_symref;
|
|
|
|
int has_sha1;
|
|
|
|
char *raw;
|
|
|
|
char *repo;
|
|
|
|
char *page;
|
|
|
|
char *search;
|
|
|
|
char *grep;
|
|
|
|
char *head;
|
|
|
|
char *sha1;
|
|
|
|
char *sha2;
|
|
|
|
char *path;
|
|
|
|
char *name;
|
|
|
|
int ofs;
|
|
|
|
};
|
|
|
|
|
2008-02-16 12:07:13 +00:00
|
|
|
struct cgit_config {
|
|
|
|
char *agefile;
|
|
|
|
char *cache_root;
|
|
|
|
char *clone_prefix;
|
|
|
|
char *css;
|
|
|
|
char *index_header;
|
|
|
|
char *index_info;
|
|
|
|
char *logo;
|
|
|
|
char *logo_link;
|
|
|
|
char *module_link;
|
|
|
|
char *repo_group;
|
|
|
|
char *robots;
|
|
|
|
char *root_title;
|
|
|
|
char *script_name;
|
|
|
|
char *virtual_root;
|
|
|
|
int cache_dynamic_ttl;
|
|
|
|
int cache_max_create_time;
|
|
|
|
int cache_repo_ttl;
|
|
|
|
int cache_root_ttl;
|
|
|
|
int cache_static_ttl;
|
|
|
|
int enable_index_links;
|
|
|
|
int enable_log_filecount;
|
|
|
|
int enable_log_linecount;
|
|
|
|
int max_commit_count;
|
|
|
|
int max_lock_attempts;
|
|
|
|
int max_msg_len;
|
|
|
|
int max_repodesc_len;
|
|
|
|
int nocache;
|
|
|
|
int renamelimit;
|
|
|
|
int snapshots;
|
|
|
|
int summary_branches;
|
|
|
|
int summary_log;
|
|
|
|
int summary_tags;
|
|
|
|
};
|
|
|
|
|
2008-03-23 23:51:19 +00:00
|
|
|
struct cgit_page {
|
|
|
|
time_t modified;
|
|
|
|
time_t expires;
|
|
|
|
char *mimetype;
|
|
|
|
char *charset;
|
|
|
|
char *filename;
|
|
|
|
char *title;
|
|
|
|
};
|
|
|
|
|
2008-02-16 10:53:40 +00:00
|
|
|
struct cgit_context {
|
|
|
|
struct cgit_query qry;
|
2008-02-16 12:07:13 +00:00
|
|
|
struct cgit_config cfg;
|
2008-02-16 12:56:09 +00:00
|
|
|
struct cgit_repo *repo;
|
2008-03-23 23:51:19 +00:00
|
|
|
struct cgit_page page;
|
2008-02-16 10:53:40 +00:00
|
|
|
};
|
|
|
|
|
2007-06-18 07:42:10 +00:00
|
|
|
extern const char *cgit_version;
|
2006-12-11 15:38:30 +00:00
|
|
|
|
2008-02-16 12:56:09 +00:00
|
|
|
extern struct cgit_repolist cgit_repolist;
|
2008-02-16 10:53:40 +00:00
|
|
|
extern struct cgit_context ctx;
|
2007-05-18 01:00:54 +00:00
|
|
|
extern int cgit_cmd;
|
2007-02-03 14:02:55 +00:00
|
|
|
|
2008-02-16 12:07:13 +00:00
|
|
|
extern void cgit_prepare_context(struct cgit_context *ctx);
|
2008-02-16 12:56:09 +00:00
|
|
|
extern struct cgit_repo *cgit_get_repoinfo(const char *url);
|
2006-12-11 16:25:41 +00:00
|
|
|
extern void cgit_global_config_cb(const char *name, const char *value);
|
|
|
|
extern void cgit_repo_config_cb(const char *name, const char *value);
|
|
|
|
extern void cgit_querystring_cb(const char *name, const char *value);
|
|
|
|
|
2007-02-08 12:53:13 +00:00
|
|
|
extern int chk_zero(int result, char *msg);
|
|
|
|
extern int chk_positive(int result, char *msg);
|
2007-07-20 18:56:43 +00:00
|
|
|
extern int chk_non_negative(int result, char *msg);
|
2007-02-08 12:53:13 +00:00
|
|
|
|
2007-01-04 15:53:03 +00:00
|
|
|
extern int hextoint(char c);
|
2007-06-26 16:04:31 +00:00
|
|
|
extern char *trim_end(const char *str, char c);
|
2007-10-30 09:47:38 +00:00
|
|
|
extern char *strlpart(char *txt, int maxlen);
|
|
|
|
extern char *strrpart(char *txt, int maxlen);
|
2007-01-04 15:53:03 +00:00
|
|
|
|
2007-10-25 07:30:06 +00:00
|
|
|
extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
|
|
|
|
extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
|
|
|
|
int flags, void *cb_data);
|
|
|
|
|
2006-12-16 13:58:20 +00:00
|
|
|
extern void *cgit_free_commitinfo(struct commitinfo *info);
|
2007-05-13 12:21:19 +00:00
|
|
|
|
|
|
|
extern int cgit_diff_files(const unsigned char *old_sha1,
|
|
|
|
const unsigned char *new_sha1,
|
|
|
|
linediff_fn fn);
|
|
|
|
|
2007-05-13 09:24:23 +00:00
|
|
|
extern void cgit_diff_tree(const unsigned char *old_sha1,
|
|
|
|
const unsigned char *new_sha1,
|
2007-10-01 09:42:19 +00:00
|
|
|
filepair_fn fn, const char *prefix);
|
2007-05-13 12:21:19 +00:00
|
|
|
|
2007-05-13 09:24:23 +00:00
|
|
|
extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
|
2006-12-16 13:58:20 +00:00
|
|
|
|
2006-12-09 14:18:17 +00:00
|
|
|
extern char *fmt(const char *format,...);
|
|
|
|
|
|
|
|
extern int cgit_read_config(const char *filename, configfn fn);
|
2006-12-11 15:11:40 +00:00
|
|
|
extern int cgit_parse_query(char *txt, configfn fn);
|
2006-12-15 17:17:36 +00:00
|
|
|
extern struct commitinfo *cgit_parse_commit(struct commit *commit);
|
2007-01-17 00:09:51 +00:00
|
|
|
extern struct taginfo *cgit_parse_tag(struct tag *tag);
|
2007-05-18 01:00:54 +00:00
|
|
|
extern void cgit_parse_url(const char *url);
|
2006-12-09 14:18:17 +00:00
|
|
|
|
2007-01-11 23:24:35 +00:00
|
|
|
extern char *cache_safe_filename(const char *unsafe);
|
2006-12-10 21:31:36 +00:00
|
|
|
extern int cache_lock(struct cacheitem *item);
|
|
|
|
extern int cache_unlock(struct cacheitem *item);
|
2006-12-11 21:53:50 +00:00
|
|
|
extern int cache_cancel_lock(struct cacheitem *item);
|
2006-12-11 08:57:58 +00:00
|
|
|
extern int cache_exist(struct cacheitem *item);
|
2006-12-10 21:31:36 +00:00
|
|
|
extern int cache_expired(struct cacheitem *item);
|
|
|
|
|
2006-12-11 15:48:03 +00:00
|
|
|
extern char *cgit_repourl(const char *reponame);
|
2007-07-21 11:13:40 +00:00
|
|
|
extern char *cgit_fileurl(const char *reponame, const char *pagename,
|
|
|
|
const char *filename, const char *query);
|
2007-05-15 22:58:35 +00:00
|
|
|
extern char *cgit_pageurl(const char *reponame, const char *pagename,
|
2006-12-11 15:48:03 +00:00
|
|
|
const char *query);
|
|
|
|
|
2007-07-21 13:24:07 +00:00
|
|
|
extern const char *cgit_repobasename(const char *reponame);
|
|
|
|
|
2007-06-16 23:23:08 +00:00
|
|
|
extern void cgit_tree_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *rev, char *path);
|
2007-06-17 11:57:51 +00:00
|
|
|
extern void cgit_log_link(char *name, char *title, char *class, char *head,
|
2007-11-03 09:42:37 +00:00
|
|
|
char *rev, char *path, int ofs, char *grep,
|
|
|
|
char *pattern);
|
2007-06-17 12:53:02 +00:00
|
|
|
extern void cgit_commit_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *rev);
|
2007-10-27 08:47:44 +00:00
|
|
|
extern void cgit_refs_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *rev, char *path);
|
2007-07-22 22:11:15 +00:00
|
|
|
extern void cgit_snapshot_link(char *name, char *title, char *class,
|
|
|
|
char *head, char *rev, char *archivename);
|
2007-06-17 16:12:03 +00:00
|
|
|
extern void cgit_diff_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *new_rev, char *old_rev, char *path);
|
2007-06-16 23:23:08 +00:00
|
|
|
|
2007-07-22 21:42:55 +00:00
|
|
|
extern void cgit_object_link(struct object *obj);
|
|
|
|
|
2006-12-11 15:38:30 +00:00
|
|
|
extern void cgit_print_error(char *msg);
|
2007-05-22 21:08:46 +00:00
|
|
|
extern void cgit_print_date(time_t secs, char *format);
|
|
|
|
extern void cgit_print_age(time_t t, time_t max_relative, char *format);
|
2008-03-23 23:51:19 +00:00
|
|
|
extern void cgit_print_http_headers(struct cgit_context *ctx);
|
|
|
|
extern void cgit_print_docstart(struct cgit_context *ctx);
|
2006-12-11 15:38:30 +00:00
|
|
|
extern void cgit_print_docend();
|
2008-03-23 23:51:19 +00:00
|
|
|
extern void cgit_print_pageheader(struct cgit_context *ctx);
|
2008-02-23 21:45:33 +00:00
|
|
|
extern void cgit_print_filemode(unsigned short mode);
|
2007-10-27 08:25:40 +00:00
|
|
|
extern void cgit_print_branches(int maxcount);
|
|
|
|
extern void cgit_print_tags(int maxcount);
|
2006-12-11 15:38:30 +00:00
|
|
|
|
2008-03-24 00:00:36 +00:00
|
|
|
extern void cgit_print_repolist();
|
2006-12-11 16:04:19 +00:00
|
|
|
extern void cgit_print_summary();
|
2007-10-28 14:23:00 +00:00
|
|
|
extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
|
|
|
|
char *pattern, char *path, int pager);
|
2008-03-24 00:00:36 +00:00
|
|
|
extern void cgit_print_blob(const char *hex, char *path);
|
2007-06-16 18:20:42 +00:00
|
|
|
extern void cgit_print_tree(const char *rev, char *path);
|
2007-06-17 16:12:03 +00:00
|
|
|
extern void cgit_print_commit(char *hex);
|
2007-10-27 08:36:53 +00:00
|
|
|
extern void cgit_print_refs();
|
2007-07-22 21:42:55 +00:00
|
|
|
extern void cgit_print_tag(char *revname);
|
2007-10-01 09:46:38 +00:00
|
|
|
extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
|
2008-03-24 00:00:36 +00:00
|
|
|
extern void cgit_print_patch(char *hex);
|
|
|
|
extern void cgit_print_snapshot(const char *head, const char *hex,
|
|
|
|
const char *prefix, const char *filename,
|
|
|
|
int snapshot);
|
2007-07-22 22:11:15 +00:00
|
|
|
extern void cgit_print_snapshot_links(const char *repo, const char *head,
|
|
|
|
const char *hex, int snapshots);
|
2007-07-21 16:00:53 +00:00
|
|
|
extern int cgit_parse_snapshots_mask(const char *str);
|
2006-12-11 15:48:03 +00:00
|
|
|
|
2006-12-09 14:18:17 +00:00
|
|
|
#endif /* CGIT_H */
|