2006-12-09 15:18:17 +01:00
|
|
|
#ifndef CGIT_H
|
|
|
|
#define CGIT_H
|
|
|
|
|
2007-05-08 22:40:59 +02: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>
|
|
|
|
|
2006-12-10 22:31:36 +01:00
|
|
|
|
2007-05-18 00:50:46 +02:00
|
|
|
/*
|
|
|
|
* The valid cgit repo-commands
|
|
|
|
*/
|
2007-05-18 03:00:54 +02:00
|
|
|
#define CMD_LOG 1
|
|
|
|
#define CMD_COMMIT 2
|
|
|
|
#define CMD_DIFF 3
|
|
|
|
#define CMD_TREE 4
|
2007-06-16 20:20:42 +02:00
|
|
|
#define CMD_BLOB 5
|
|
|
|
#define CMD_SNAPSHOT 6
|
2007-07-22 23:42:55 +02:00
|
|
|
#define CMD_TAG 7
|
2007-10-27 10:36:53 +02:00
|
|
|
#define CMD_REFS 8
|
2007-05-22 23:08:46 +02: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)
|
|
|
|
|
|
|
|
|
2006-12-10 22:31:36 +01:00
|
|
|
typedef void (*configfn)(const char *name, const char *value);
|
2007-05-13 11:24:23 +02:00
|
|
|
typedef void (*filepair_fn)(struct diff_filepair *pair);
|
2007-05-13 14:21:19 +02:00
|
|
|
typedef void (*linediff_fn)(char *line, int len);
|
2006-12-10 22:31:36 +01:00
|
|
|
|
|
|
|
struct cacheitem {
|
|
|
|
char *name;
|
|
|
|
struct stat st;
|
|
|
|
int ttl;
|
|
|
|
int fd;
|
|
|
|
};
|
|
|
|
|
2007-02-03 15:02:55 +01:00
|
|
|
struct repoinfo {
|
|
|
|
char *url;
|
|
|
|
char *name;
|
|
|
|
char *path;
|
|
|
|
char *desc;
|
|
|
|
char *owner;
|
2007-05-16 00:14:51 +02:00
|
|
|
char *defbranch;
|
2007-05-18 22:48:22 +02:00
|
|
|
char *group;
|
2007-05-11 12:12:48 +02:00
|
|
|
char *module_link;
|
2007-05-23 22:46:54 +02:00
|
|
|
char *readme;
|
2007-02-08 14:47:56 +01:00
|
|
|
int snapshots;
|
2007-05-18 13:55:52 +02:00
|
|
|
int enable_log_filecount;
|
|
|
|
int enable_log_linecount;
|
2007-02-03 15:02:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct repolist {
|
|
|
|
int length;
|
|
|
|
int count;
|
|
|
|
struct repoinfo *repos;
|
|
|
|
};
|
|
|
|
|
2006-12-15 18:17:36 +01:00
|
|
|
struct commitinfo {
|
|
|
|
struct commit *commit;
|
|
|
|
char *author;
|
2006-12-16 14:25:41 +01:00
|
|
|
char *author_email;
|
|
|
|
unsigned long author_date;
|
2006-12-15 18:17:36 +01:00
|
|
|
char *committer;
|
2006-12-16 14:25:41 +01:00
|
|
|
char *committer_email;
|
|
|
|
unsigned long committer_date;
|
2006-12-15 18:17:36 +01:00
|
|
|
char *subject;
|
|
|
|
char *msg;
|
|
|
|
};
|
|
|
|
|
2007-01-17 01:09:51 +01:00
|
|
|
struct taginfo {
|
|
|
|
char *tagger;
|
|
|
|
char *tagger_email;
|
|
|
|
int tagger_date;
|
|
|
|
char *msg;
|
|
|
|
};
|
|
|
|
|
2007-10-25 09:30:06 +02: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;
|
|
|
|
};
|
|
|
|
|
2007-06-18 09:42:10 +02:00
|
|
|
extern const char *cgit_version;
|
2006-12-11 16:38:30 +01:00
|
|
|
|
2007-02-03 15:02:55 +01:00
|
|
|
extern struct repolist cgit_repolist;
|
|
|
|
extern struct repoinfo *cgit_repo;
|
2007-05-18 03:00:54 +02:00
|
|
|
extern int cgit_cmd;
|
2007-02-03 15:02:55 +01:00
|
|
|
|
2006-12-10 22:31:36 +01:00
|
|
|
extern char *cgit_root_title;
|
|
|
|
extern char *cgit_css;
|
|
|
|
extern char *cgit_logo;
|
2007-05-19 00:00:25 +02:00
|
|
|
extern char *cgit_index_header;
|
2006-12-10 22:31:36 +01:00
|
|
|
extern char *cgit_logo_link;
|
2007-05-11 12:12:48 +02:00
|
|
|
extern char *cgit_module_link;
|
2007-05-22 23:25:25 +02:00
|
|
|
extern char *cgit_agefile;
|
2006-12-10 22:31:36 +01:00
|
|
|
extern char *cgit_virtual_root;
|
2007-05-15 00:48:31 +02:00
|
|
|
extern char *cgit_script_name;
|
2006-12-10 22:31:36 +01:00
|
|
|
extern char *cgit_cache_root;
|
2007-05-18 22:48:22 +02:00
|
|
|
extern char *cgit_repo_group;
|
2006-12-10 22:31:36 +01:00
|
|
|
|
2006-12-16 13:33:32 +01:00
|
|
|
extern int cgit_nocache;
|
2007-02-08 14:47:56 +01:00
|
|
|
extern int cgit_snapshots;
|
2007-06-19 00:56:40 +02:00
|
|
|
extern int cgit_enable_index_links;
|
2007-05-18 13:55:52 +02:00
|
|
|
extern int cgit_enable_log_filecount;
|
|
|
|
extern int cgit_enable_log_linecount;
|
2006-12-11 12:10:12 +01:00
|
|
|
extern int cgit_max_lock_attempts;
|
2006-12-10 22:31:36 +01:00
|
|
|
extern int cgit_cache_root_ttl;
|
|
|
|
extern int cgit_cache_repo_ttl;
|
|
|
|
extern int cgit_cache_dynamic_ttl;
|
|
|
|
extern int cgit_cache_static_ttl;
|
|
|
|
extern int cgit_cache_max_create_time;
|
2007-05-26 03:33:41 +02:00
|
|
|
extern int cgit_summary_log;
|
2007-10-25 10:40:16 +02:00
|
|
|
extern int cgit_summary_tags;
|
2007-10-27 10:13:42 +02:00
|
|
|
extern int cgit_summary_branches;
|
2006-12-10 22:31:36 +01:00
|
|
|
|
2007-01-28 12:17:03 +01:00
|
|
|
extern int cgit_max_msg_len;
|
2007-05-16 10:45:45 +02:00
|
|
|
extern int cgit_max_repodesc_len;
|
2007-05-13 17:15:06 +02:00
|
|
|
extern int cgit_max_commit_count;
|
2007-01-28 12:17:03 +01:00
|
|
|
|
2006-12-10 22:31:36 +01:00
|
|
|
extern int cgit_query_has_symref;
|
|
|
|
extern int cgit_query_has_sha1;
|
|
|
|
|
|
|
|
extern char *cgit_querystring;
|
|
|
|
extern char *cgit_query_repo;
|
|
|
|
extern char *cgit_query_page;
|
2006-12-28 02:01:49 +01:00
|
|
|
extern char *cgit_query_search;
|
2006-12-10 22:31:36 +01:00
|
|
|
extern char *cgit_query_head;
|
|
|
|
extern char *cgit_query_sha1;
|
2006-12-20 22:48:27 +01:00
|
|
|
extern char *cgit_query_sha2;
|
2007-01-12 00:46:17 +01:00
|
|
|
extern char *cgit_query_path;
|
2007-02-08 13:53:13 +01:00
|
|
|
extern char *cgit_query_name;
|
2006-12-14 00:40:34 +01:00
|
|
|
extern int cgit_query_ofs;
|
2006-12-10 22:31:36 +01:00
|
|
|
|
|
|
|
extern int htmlfd;
|
2006-12-09 15:18:17 +01:00
|
|
|
|
2007-05-18 00:50:46 +02:00
|
|
|
extern int cgit_get_cmd_index(const char *cmd);
|
2007-05-18 00:47:47 +02:00
|
|
|
extern struct repoinfo *cgit_get_repoinfo(const char *url);
|
2006-12-11 17:25:41 +01: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 13:53:13 +01:00
|
|
|
extern int chk_zero(int result, char *msg);
|
|
|
|
extern int chk_positive(int result, char *msg);
|
2007-07-20 20:56:43 +02:00
|
|
|
extern int chk_non_negative(int result, char *msg);
|
2007-02-08 13:53:13 +01:00
|
|
|
|
2007-01-04 16:53:03 +01:00
|
|
|
extern int hextoint(char c);
|
2007-06-26 18:04:31 +02:00
|
|
|
extern char *trim_end(const char *str, char c);
|
2007-01-04 16:53:03 +01:00
|
|
|
|
2007-10-25 09:30:06 +02: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 14:58:20 +01:00
|
|
|
extern void *cgit_free_commitinfo(struct commitinfo *info);
|
2007-05-13 14:21:19 +02:00
|
|
|
|
|
|
|
extern int cgit_diff_files(const unsigned char *old_sha1,
|
|
|
|
const unsigned char *new_sha1,
|
|
|
|
linediff_fn fn);
|
|
|
|
|
2007-05-13 11:24:23 +02:00
|
|
|
extern void cgit_diff_tree(const unsigned char *old_sha1,
|
|
|
|
const unsigned char *new_sha1,
|
2007-10-01 11:42:19 +02:00
|
|
|
filepair_fn fn, const char *prefix);
|
2007-05-13 14:21:19 +02:00
|
|
|
|
2007-05-13 11:24:23 +02:00
|
|
|
extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
|
2006-12-16 14:58:20 +01:00
|
|
|
|
2006-12-09 15:18:17 +01:00
|
|
|
extern char *fmt(const char *format,...);
|
|
|
|
|
|
|
|
extern void html(const char *txt);
|
|
|
|
extern void htmlf(const char *format,...);
|
|
|
|
extern void html_txt(char *txt);
|
2006-12-22 00:58:18 +01:00
|
|
|
extern void html_ntxt(int len, char *txt);
|
2006-12-09 15:18:17 +01:00
|
|
|
extern void html_attr(char *txt);
|
2006-12-28 02:01:49 +01:00
|
|
|
extern void html_hidden(char *name, char *value);
|
2006-12-09 15:18:17 +01:00
|
|
|
extern void html_link_open(char *url, char *title, char *class);
|
|
|
|
extern void html_link_close(void);
|
2006-12-17 23:07:28 +01:00
|
|
|
extern void html_filemode(unsigned short mode);
|
2007-05-18 23:56:10 +02:00
|
|
|
extern int html_include(const char *filename);
|
2006-12-09 15:18:17 +01:00
|
|
|
|
|
|
|
extern int cgit_read_config(const char *filename, configfn fn);
|
2006-12-11 16:11:40 +01:00
|
|
|
extern int cgit_parse_query(char *txt, configfn fn);
|
2006-12-15 18:17:36 +01:00
|
|
|
extern struct commitinfo *cgit_parse_commit(struct commit *commit);
|
2007-01-17 01:09:51 +01:00
|
|
|
extern struct taginfo *cgit_parse_tag(struct tag *tag);
|
2007-05-18 03:00:54 +02:00
|
|
|
extern void cgit_parse_url(const char *url);
|
2006-12-09 15:18:17 +01:00
|
|
|
|
2007-01-12 00:24:35 +01:00
|
|
|
extern char *cache_safe_filename(const char *unsafe);
|
2006-12-10 22:31:36 +01:00
|
|
|
extern int cache_lock(struct cacheitem *item);
|
|
|
|
extern int cache_unlock(struct cacheitem *item);
|
2006-12-11 22:53:50 +01:00
|
|
|
extern int cache_cancel_lock(struct cacheitem *item);
|
2006-12-11 09:57:58 +01:00
|
|
|
extern int cache_exist(struct cacheitem *item);
|
2006-12-10 22:31:36 +01:00
|
|
|
extern int cache_expired(struct cacheitem *item);
|
|
|
|
|
2006-12-11 16:48:03 +01:00
|
|
|
extern char *cgit_repourl(const char *reponame);
|
2007-07-21 13:13:40 +02:00
|
|
|
extern char *cgit_fileurl(const char *reponame, const char *pagename,
|
|
|
|
const char *filename, const char *query);
|
2007-05-16 00:58:35 +02:00
|
|
|
extern char *cgit_pageurl(const char *reponame, const char *pagename,
|
2006-12-11 16:48:03 +01:00
|
|
|
const char *query);
|
|
|
|
|
2007-07-21 15:24:07 +02:00
|
|
|
extern const char *cgit_repobasename(const char *reponame);
|
|
|
|
|
2007-06-17 01:23:08 +02:00
|
|
|
extern void cgit_tree_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *rev, char *path);
|
2007-06-17 13:57:51 +02:00
|
|
|
extern void cgit_log_link(char *name, char *title, char *class, char *head,
|
2007-06-29 20:27:41 +02:00
|
|
|
char *rev, char *path, int ofs);
|
2007-06-17 14:53:02 +02:00
|
|
|
extern void cgit_commit_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *rev);
|
2007-10-27 10:47:44 +02:00
|
|
|
extern void cgit_refs_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *rev, char *path);
|
2007-07-23 00:11:15 +02:00
|
|
|
extern void cgit_snapshot_link(char *name, char *title, char *class,
|
|
|
|
char *head, char *rev, char *archivename);
|
2007-06-17 18:12:03 +02:00
|
|
|
extern void cgit_diff_link(char *name, char *title, char *class, char *head,
|
|
|
|
char *new_rev, char *old_rev, char *path);
|
2007-06-17 01:23:08 +02:00
|
|
|
|
2007-07-22 23:42:55 +02:00
|
|
|
extern void cgit_object_link(struct object *obj);
|
|
|
|
|
2006-12-11 16:38:30 +01:00
|
|
|
extern void cgit_print_error(char *msg);
|
2007-05-22 23:08:46 +02: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);
|
2006-12-11 16:38:30 +01:00
|
|
|
extern void cgit_print_docstart(char *title, struct cacheitem *item);
|
|
|
|
extern void cgit_print_docend();
|
2006-12-28 02:01:49 +01:00
|
|
|
extern void cgit_print_pageheader(char *title, int show_search);
|
2007-05-16 00:58:35 +02:00
|
|
|
extern void cgit_print_snapshot_start(const char *mimetype,
|
|
|
|
const char *filename,
|
2007-02-08 13:53:13 +01:00
|
|
|
struct cacheitem *item);
|
2007-10-27 10:25:40 +02:00
|
|
|
extern void cgit_print_branches(int maxcount);
|
|
|
|
extern void cgit_print_tags(int maxcount);
|
2006-12-11 16:38:30 +01:00
|
|
|
|
2006-12-11 16:48:03 +01:00
|
|
|
extern void cgit_print_repolist(struct cacheitem *item);
|
2006-12-11 17:04:19 +01:00
|
|
|
extern void cgit_print_summary();
|
2007-05-26 03:26:14 +02:00
|
|
|
extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager);
|
2007-05-09 00:48:09 +02:00
|
|
|
extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
|
2007-06-16 20:20:42 +02:00
|
|
|
extern void cgit_print_tree(const char *rev, char *path);
|
2007-06-17 18:12:03 +02:00
|
|
|
extern void cgit_print_commit(char *hex);
|
2007-10-27 10:36:53 +02:00
|
|
|
extern void cgit_print_refs();
|
2007-07-22 23:42:55 +02:00
|
|
|
extern void cgit_print_tag(char *revname);
|
2007-10-01 11:46:38 +02:00
|
|
|
extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
|
2007-07-23 00:11:15 +02:00
|
|
|
extern void cgit_print_snapshot(struct cacheitem *item, const char *head,
|
|
|
|
const char *hex, const char *prefix,
|
|
|
|
const char *filename, int snapshot);
|
|
|
|
extern void cgit_print_snapshot_links(const char *repo, const char *head,
|
|
|
|
const char *hex, int snapshots);
|
2007-07-21 18:00:53 +02:00
|
|
|
extern int cgit_parse_snapshots_mask(const char *str);
|
2006-12-11 16:48:03 +01:00
|
|
|
|
2006-12-09 15:18:17 +01:00
|
|
|
#endif /* CGIT_H */
|