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>
|
2013-03-02 12:32:12 +00:00
|
|
|
#include <argv-array.h>
|
2007-05-08 20:40:59 +00:00
|
|
|
#include <refs.h>
|
|
|
|
#include <revision.h>
|
|
|
|
#include <log-tree.h>
|
|
|
|
#include <archive.h>
|
2009-02-13 19:43:30 +00:00
|
|
|
#include <string-list.h>
|
2009-01-31 09:40:40 +00:00
|
|
|
#include <xdiff-interface.h>
|
2007-05-08 20:40:59 +00:00
|
|
|
#include <xdiff/xdiff.h>
|
2007-11-05 21:27:43 +00:00
|
|
|
#include <utf8.h>
|
2010-07-29 14:32:30 +00:00
|
|
|
#include <notes.h>
|
2010-11-15 17:39:50 +00:00
|
|
|
#include <graph.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
|
|
|
|
*/
|
2008-08-01 12:54:38 +00:00
|
|
|
#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
|
2007-05-22 21:08:46 +00:00
|
|
|
#define FMT_SHORTDATE "%Y-%m-%d"
|
2008-05-21 06:17:54 +00:00
|
|
|
#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
|
2007-05-22 21:08:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
2011-03-23 10:57:41 +00:00
|
|
|
typedef enum {
|
|
|
|
ABOUT, COMMIT, SOURCE
|
|
|
|
} filter_type;
|
|
|
|
|
2009-08-09 11:22:00 +00:00
|
|
|
struct cgit_filter {
|
|
|
|
char *cmd;
|
|
|
|
char **argv;
|
2014-01-12 17:13:50 +00:00
|
|
|
int extra_args;
|
2009-08-09 11:22:00 +00:00
|
|
|
int old_stdout;
|
|
|
|
int pipe_fh[2];
|
|
|
|
int pid;
|
|
|
|
};
|
|
|
|
|
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-11 10:12:48 +00:00
|
|
|
char *module_link;
|
2013-05-26 13:20:02 +00:00
|
|
|
struct string_list readme;
|
2009-08-23 20:58:39 +00:00
|
|
|
char *section;
|
2007-12-03 00:49:38 +00:00
|
|
|
char *clone_url;
|
2010-12-23 11:47:54 +00:00
|
|
|
char *logo;
|
|
|
|
char *logo_link;
|
2007-02-08 13:47:56 +00:00
|
|
|
int snapshots;
|
2010-11-15 17:39:50 +00:00
|
|
|
int enable_commit_graph;
|
2007-05-18 11:55:52 +00:00
|
|
|
int enable_log_filecount;
|
|
|
|
int enable_log_linecount;
|
2009-11-07 18:10:58 +00:00
|
|
|
int enable_remote_branches;
|
2010-02-27 12:12:55 +00:00
|
|
|
int enable_subject_links;
|
2008-12-07 12:17:21 +00:00
|
|
|
int max_stats;
|
2013-04-08 14:57:12 +00:00
|
|
|
int branch_sort;
|
2012-10-13 14:10:30 +00:00
|
|
|
int commit_sort;
|
2008-11-29 15:46:37 +00:00
|
|
|
time_t mtime;
|
2009-08-09 11:27:21 +00:00
|
|
|
struct cgit_filter *about_filter;
|
2009-08-09 11:22:00 +00:00
|
|
|
struct cgit_filter *commit_filter;
|
|
|
|
struct cgit_filter *source_filter;
|
2011-06-15 08:04:13 +00:00
|
|
|
struct string_list submodules;
|
2007-02-03 14:02:55 +00:00
|
|
|
};
|
|
|
|
|
2009-08-23 22:04:58 +00:00
|
|
|
typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
|
|
|
|
const char *value);
|
|
|
|
|
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;
|
2008-09-14 07:45:37 +00:00
|
|
|
unsigned long tagger_date;
|
2007-01-17 00:09:51 +00:00
|
|
|
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;
|
2012-01-03 16:02:14 +00:00
|
|
|
int has_ssdiff;
|
2008-02-16 10:53:40 +00:00
|
|
|
char *raw;
|
|
|
|
char *repo;
|
|
|
|
char *page;
|
|
|
|
char *search;
|
|
|
|
char *grep;
|
|
|
|
char *head;
|
|
|
|
char *sha1;
|
|
|
|
char *sha2;
|
|
|
|
char *path;
|
|
|
|
char *name;
|
2008-06-24 21:42:32 +00:00
|
|
|
char *mimetype;
|
2008-08-09 19:11:41 +00:00
|
|
|
char *url;
|
2008-12-06 16:38:19 +00:00
|
|
|
char *period;
|
2008-02-16 10:53:40 +00:00
|
|
|
int ofs;
|
2008-10-11 17:05:50 +00:00
|
|
|
int nohead;
|
2008-11-25 14:25:35 +00:00
|
|
|
char *sort;
|
2008-11-29 17:39:41 +00:00
|
|
|
int showmsg;
|
2009-09-14 18:19:02 +00:00
|
|
|
int ssdiff;
|
2010-02-04 00:31:17 +00:00
|
|
|
int show_all;
|
2010-06-10 18:15:27 +00:00
|
|
|
int context;
|
2010-06-24 15:52:57 +00:00
|
|
|
int ignorews;
|
2010-06-09 23:09:26 +00:00
|
|
|
char *vpath;
|
2008-02-16 10:53:40 +00:00
|
|
|
};
|
|
|
|
|
2008-02-16 12:07:13 +00:00
|
|
|
struct cgit_config {
|
|
|
|
char *agefile;
|
|
|
|
char *cache_root;
|
|
|
|
char *clone_prefix;
|
2011-06-06 20:49:13 +00:00
|
|
|
char *clone_url;
|
2008-02-16 12:07:13 +00:00
|
|
|
char *css;
|
2008-07-19 18:40:30 +00:00
|
|
|
char *favicon;
|
2008-06-26 11:53:30 +00:00
|
|
|
char *footer;
|
2009-03-15 04:11:54 +00:00
|
|
|
char *head_include;
|
2009-01-29 20:27:39 +00:00
|
|
|
char *header;
|
2008-02-16 12:07:13 +00:00
|
|
|
char *index_header;
|
|
|
|
char *index_info;
|
|
|
|
char *logo;
|
|
|
|
char *logo_link;
|
2011-07-19 08:51:58 +00:00
|
|
|
char *mimetype_file;
|
2008-02-16 12:07:13 +00:00
|
|
|
char *module_link;
|
2010-07-29 15:52:29 +00:00
|
|
|
char *project_list;
|
2013-05-26 13:20:02 +00:00
|
|
|
struct string_list readme;
|
2008-02-16 12:07:13 +00:00
|
|
|
char *robots;
|
|
|
|
char *root_title;
|
2008-04-28 22:55:34 +00:00
|
|
|
char *root_desc;
|
2008-04-28 23:06:30 +00:00
|
|
|
char *root_readme;
|
2008-02-16 12:07:13 +00:00
|
|
|
char *script_name;
|
2009-08-23 20:58:39 +00:00
|
|
|
char *section;
|
2012-10-16 21:32:40 +00:00
|
|
|
char *repository_sort;
|
2013-04-01 18:03:34 +00:00
|
|
|
char *virtual_root; /* Always ends with '/'. */
|
2010-11-08 18:41:13 +00:00
|
|
|
char *strict_export;
|
2008-04-28 09:32:42 +00:00
|
|
|
int cache_size;
|
2008-02-16 12:07:13 +00:00
|
|
|
int cache_dynamic_ttl;
|
|
|
|
int cache_max_create_time;
|
|
|
|
int cache_repo_ttl;
|
|
|
|
int cache_root_ttl;
|
2009-08-20 15:41:54 +00:00
|
|
|
int cache_scanrc_ttl;
|
2008-02-16 12:07:13 +00:00
|
|
|
int cache_static_ttl;
|
2013-05-28 14:33:30 +00:00
|
|
|
int cache_about_ttl;
|
2012-07-12 17:13:39 +00:00
|
|
|
int case_sensitive_sort;
|
2009-07-25 10:25:06 +00:00
|
|
|
int embedded;
|
2009-08-24 06:53:21 +00:00
|
|
|
int enable_filter_overrides;
|
2011-01-12 18:06:07 +00:00
|
|
|
int enable_http_clone;
|
2008-02-16 12:07:13 +00:00
|
|
|
int enable_index_links;
|
2013-02-01 09:59:13 +00:00
|
|
|
int enable_index_owner;
|
2010-11-15 17:39:50 +00:00
|
|
|
int enable_commit_graph;
|
2008-02-16 12:07:13 +00:00
|
|
|
int enable_log_filecount;
|
|
|
|
int enable_log_linecount;
|
2009-11-07 18:10:58 +00:00
|
|
|
int enable_remote_branches;
|
2010-02-27 12:12:55 +00:00
|
|
|
int enable_subject_links;
|
2009-08-21 12:26:52 +00:00
|
|
|
int enable_tree_linenumbers;
|
2012-10-09 10:56:14 +00:00
|
|
|
int enable_git_config;
|
2008-08-01 12:54:38 +00:00
|
|
|
int local_time;
|
2010-02-05 00:08:16 +00:00
|
|
|
int max_atom_items;
|
2008-05-03 08:54:39 +00:00
|
|
|
int max_repo_count;
|
2008-02-16 12:07:13 +00:00
|
|
|
int max_commit_count;
|
|
|
|
int max_lock_attempts;
|
|
|
|
int max_msg_len;
|
|
|
|
int max_repodesc_len;
|
2009-11-28 02:44:33 +00:00
|
|
|
int max_blob_size;
|
2008-12-07 12:17:21 +00:00
|
|
|
int max_stats;
|
2008-02-16 12:07:13 +00:00
|
|
|
int nocache;
|
2009-08-07 12:05:17 +00:00
|
|
|
int noplainemail;
|
2009-07-25 10:25:06 +00:00
|
|
|
int noheader;
|
2008-02-16 12:07:13 +00:00
|
|
|
int renamelimit;
|
2010-07-29 17:47:50 +00:00
|
|
|
int remove_suffix;
|
2010-11-15 19:41:00 +00:00
|
|
|
int scan_hidden_path;
|
2010-08-21 13:44:09 +00:00
|
|
|
int section_from_path;
|
2008-02-16 12:07:13 +00:00
|
|
|
int snapshots;
|
2012-10-09 18:53:29 +00:00
|
|
|
int section_sort;
|
2008-02-16 12:07:13 +00:00
|
|
|
int summary_branches;
|
|
|
|
int summary_log;
|
|
|
|
int summary_tags;
|
2009-09-14 18:19:02 +00:00
|
|
|
int ssdiff;
|
2013-04-08 14:57:12 +00:00
|
|
|
int branch_sort;
|
2012-10-13 14:10:30 +00:00
|
|
|
int commit_sort;
|
2009-02-13 19:43:30 +00:00
|
|
|
struct string_list mimetypes;
|
2009-08-09 11:27:21 +00:00
|
|
|
struct cgit_filter *about_filter;
|
2009-07-31 15:42:57 +00:00
|
|
|
struct cgit_filter *commit_filter;
|
2009-07-31 14:55:27 +00:00
|
|
|
struct cgit_filter *source_filter;
|
2008-02-16 12:07:13 +00:00
|
|
|
};
|
|
|
|
|
2008-03-23 23:51:19 +00:00
|
|
|
struct cgit_page {
|
|
|
|
time_t modified;
|
|
|
|
time_t expires;
|
2008-08-06 08:53:50 +00:00
|
|
|
size_t size;
|
2013-04-07 11:46:45 +00:00
|
|
|
const char *mimetype;
|
|
|
|
const char *charset;
|
|
|
|
const char *filename;
|
|
|
|
const char *etag;
|
|
|
|
const char *title;
|
2009-06-07 18:43:08 +00:00
|
|
|
int status;
|
2013-04-07 11:46:45 +00:00
|
|
|
const char *statusmsg;
|
2008-03-23 23:51:19 +00:00
|
|
|
};
|
|
|
|
|
2009-08-10 06:21:09 +00:00
|
|
|
struct cgit_environment {
|
2013-04-01 15:11:14 +00:00
|
|
|
const char *cgit_config;
|
|
|
|
const char *http_host;
|
|
|
|
const char *https;
|
|
|
|
const char *no_http;
|
|
|
|
const char *path_info;
|
|
|
|
const char *query_string;
|
|
|
|
const char *request_method;
|
|
|
|
const char *script_name;
|
|
|
|
const char *server_name;
|
|
|
|
const char *server_port;
|
2009-08-10 06:21:09 +00:00
|
|
|
};
|
|
|
|
|
2008-02-16 10:53:40 +00:00
|
|
|
struct cgit_context {
|
2009-08-10 06:21:09 +00:00
|
|
|
struct cgit_environment env;
|
2008-02-16 10:53:40 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2013-03-02 12:32:12 +00:00
|
|
|
typedef int (*write_archive_fn_t)(const char *, const char *);
|
|
|
|
|
2008-03-24 15:00:27 +00:00
|
|
|
struct cgit_snapshot_format {
|
|
|
|
const char *suffix;
|
|
|
|
const char *mimetype;
|
|
|
|
write_archive_fn_t write_func;
|
|
|
|
int bit;
|
|
|
|
};
|
|
|
|
|
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;
|
2008-03-24 15:00:27 +00:00
|
|
|
extern const struct cgit_snapshot_format cgit_snapshot_formats[];
|
2007-02-03 14:02:55 +00:00
|
|
|
|
2012-10-09 10:56:14 +00:00
|
|
|
extern char *cgit_default_repo_desc;
|
2008-03-24 16:26:08 +00:00
|
|
|
extern struct cgit_repo *cgit_add_repo(const char *url);
|
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_repo_config_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-06-26 16:04:31 +00:00
|
|
|
extern char *trim_end(const char *str, char c);
|
2013-04-01 18:03:34 +00:00
|
|
|
extern char *ensure_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
|
|
|
|
2013-04-07 13:03:47 +00:00
|
|
|
extern void strbuf_ensure_end(struct strbuf *sb, char c);
|
|
|
|
|
2007-10-25 07:30:06 +00:00
|
|
|
extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
|
2013-03-04 12:25:33 +00:00
|
|
|
extern void cgit_free_reflist_inner(struct reflist *list);
|
2007-10-25 07:30:06 +00:00
|
|
|
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,
|
2009-01-31 09:40:40 +00:00
|
|
|
unsigned long *old_size, unsigned long *new_size,
|
2010-06-24 15:52:57 +00:00
|
|
|
int *binary, int context, int ignorews,
|
|
|
|
linediff_fn fn);
|
2007-05-13 12:21:19 +00:00
|
|
|
|
2007-05-13 09:24:23 +00:00
|
|
|
extern void cgit_diff_tree(const unsigned char *old_sha1,
|
|
|
|
const unsigned char *new_sha1,
|
2010-06-24 15:52:57 +00:00
|
|
|
filepair_fn fn, const char *prefix, int ignorews);
|
2007-05-13 12:21:19 +00:00
|
|
|
|
2010-09-30 18:15:14 +00:00
|
|
|
extern void cgit_diff_commit(struct commit *commit, filepair_fn fn,
|
|
|
|
const char *prefix);
|
2006-12-16 13:58:20 +00:00
|
|
|
|
2010-09-04 15:09:57 +00:00
|
|
|
__attribute__((format (printf,1,2)))
|
2006-12-09 14:18:17 +00:00
|
|
|
extern char *fmt(const char *format,...);
|
|
|
|
|
2013-04-07 13:40:50 +00:00
|
|
|
__attribute__((format (printf,1,2)))
|
|
|
|
extern char *fmtalloc(const char *format,...);
|
|
|
|
|
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-07-21 13:24:07 +00:00
|
|
|
extern const char *cgit_repobasename(const char *reponame);
|
|
|
|
|
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
|
|
|
|
2014-01-12 17:13:50 +00:00
|
|
|
extern int cgit_open_filter(struct cgit_filter *filter, ...);
|
2009-07-31 15:38:38 +00:00
|
|
|
extern int cgit_close_filter(struct cgit_filter *filter);
|
2014-01-10 04:19:05 +00:00
|
|
|
extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype);
|
2009-07-31 15:38:38 +00:00
|
|
|
|
2011-06-06 19:29:58 +00:00
|
|
|
extern void cgit_prepare_repo_env(struct cgit_repo * repo);
|
|
|
|
|
2009-08-18 15:17:41 +00:00
|
|
|
extern int readfile(const char *path, char **buf, size_t *size);
|
2008-04-13 10:42:27 +00:00
|
|
|
|
2010-03-21 23:09:43 +00:00
|
|
|
extern char *expand_macros(const char *txt);
|
|
|
|
|
2006-12-09 14:18:17 +00:00
|
|
|
#endif /* CGIT_H */
|