]> git.cameronkatri.com Git - cgit.git/blob - cgit.h
Make snapshot feature configurable
[cgit.git] / cgit.h
1 #ifndef CGIT_H
2 #define CGIT_H
3
4 #include "git.h"
5 #include <openssl/sha.h>
6 #include <ctype.h>
7 #include <sched.h>
8
9 typedef void (*configfn)(const char *name, const char *value);
10
11 struct cacheitem {
12 char *name;
13 struct stat st;
14 int ttl;
15 int fd;
16 };
17
18 struct repoinfo {
19 char *url;
20 char *name;
21 char *path;
22 char *desc;
23 char *owner;
24 int snapshots;
25 };
26
27 struct repolist {
28 int length;
29 int count;
30 struct repoinfo *repos;
31 };
32
33 struct commitinfo {
34 struct commit *commit;
35 char *author;
36 char *author_email;
37 unsigned long author_date;
38 char *committer;
39 char *committer_email;
40 unsigned long committer_date;
41 char *subject;
42 char *msg;
43 };
44
45 struct taginfo {
46 char *tagger;
47 char *tagger_email;
48 int tagger_date;
49 char *msg;
50 };
51
52 extern const char cgit_version[];
53
54 extern struct repolist cgit_repolist;
55 extern struct repoinfo *cgit_repo;
56
57 extern char *cgit_root_title;
58 extern char *cgit_css;
59 extern char *cgit_logo;
60 extern char *cgit_logo_link;
61 extern char *cgit_virtual_root;
62 extern char *cgit_cache_root;
63
64 extern int cgit_nocache;
65 extern int cgit_snapshots;
66 extern int cgit_max_lock_attempts;
67 extern int cgit_cache_root_ttl;
68 extern int cgit_cache_repo_ttl;
69 extern int cgit_cache_dynamic_ttl;
70 extern int cgit_cache_static_ttl;
71 extern int cgit_cache_max_create_time;
72
73 extern int cgit_max_msg_len;
74
75 extern char *cgit_repo_name;
76 extern char *cgit_repo_desc;
77 extern char *cgit_repo_owner;
78
79 extern int cgit_query_has_symref;
80 extern int cgit_query_has_sha1;
81
82 extern char *cgit_querystring;
83 extern char *cgit_query_repo;
84 extern char *cgit_query_page;
85 extern char *cgit_query_search;
86 extern char *cgit_query_head;
87 extern char *cgit_query_sha1;
88 extern char *cgit_query_sha2;
89 extern char *cgit_query_path;
90 extern char *cgit_query_name;
91 extern int cgit_query_ofs;
92
93 extern int htmlfd;
94
95 extern void cgit_global_config_cb(const char *name, const char *value);
96 extern void cgit_repo_config_cb(const char *name, const char *value);
97 extern void cgit_querystring_cb(const char *name, const char *value);
98
99 extern int chk_zero(int result, char *msg);
100 extern int chk_positive(int result, char *msg);
101
102 extern int hextoint(char c);
103
104 extern void *cgit_free_commitinfo(struct commitinfo *info);
105
106 extern char *fmt(const char *format,...);
107
108 extern void html(const char *txt);
109 extern void htmlf(const char *format,...);
110 extern void html_txt(char *txt);
111 extern void html_ntxt(int len, char *txt);
112 extern void html_attr(char *txt);
113 extern void html_hidden(char *name, char *value);
114 extern void html_link_open(char *url, char *title, char *class);
115 extern void html_link_close(void);
116 extern void html_filemode(unsigned short mode);
117
118 extern int cgit_read_config(const char *filename, configfn fn);
119 extern int cgit_parse_query(char *txt, configfn fn);
120 extern struct commitinfo *cgit_parse_commit(struct commit *commit);
121 extern struct taginfo *cgit_parse_tag(struct tag *tag);
122
123 extern char *cache_safe_filename(const char *unsafe);
124 extern int cache_lock(struct cacheitem *item);
125 extern int cache_unlock(struct cacheitem *item);
126 extern int cache_cancel_lock(struct cacheitem *item);
127 extern int cache_exist(struct cacheitem *item);
128 extern int cache_expired(struct cacheitem *item);
129
130 extern char *cgit_repourl(const char *reponame);
131 extern char *cgit_pageurl(const char *reponame, const char *pagename,
132 const char *query);
133
134 extern void cgit_print_error(char *msg);
135 extern void cgit_print_date(unsigned long secs);
136 extern void cgit_print_docstart(char *title, struct cacheitem *item);
137 extern void cgit_print_docend();
138 extern void cgit_print_pageheader(char *title, int show_search);
139 extern void cgit_print_snapshot_start(const char *mimetype,
140 const char *filename,
141 struct cacheitem *item);
142
143 extern void cgit_print_repolist(struct cacheitem *item);
144 extern void cgit_print_summary();
145 extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep);
146 extern void cgit_print_view(const char *hex);
147 extern void cgit_print_tree(const char *hex, char *path);
148 extern void cgit_print_commit(const char *hex);
149 extern void cgit_print_diff(const char *old_hex, const char *new_hex);
150 extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
151 const char *format, const char *prefix,
152 const char *filename);
153
154 #endif /* CGIT_H */