]> git.cameronkatri.com Git - cgit.git/blob - cgit.h
Merge branch 'stable'
[cgit.git] / cgit.h
1 #ifndef CGIT_H
2 #define CGIT_H
3
4
5 #include <git-compat-util.h>
6 #include <cache.h>
7 #include <grep.h>
8 #include <object.h>
9 #include <tree.h>
10 #include <commit.h>
11 #include <tag.h>
12 #include <diff.h>
13 #include <diffcore.h>
14 #include <refs.h>
15 #include <revision.h>
16 #include <log-tree.h>
17 #include <archive.h>
18 #include <xdiff/xdiff.h>
19
20
21 /*
22 * The valid cgit repo-commands
23 */
24 #define CMD_LOG 1
25 #define CMD_COMMIT 2
26 #define CMD_DIFF 3
27 #define CMD_TREE 4
28 #define CMD_BLOB 5
29 #define CMD_SNAPSHOT 6
30 #define CMD_TAG 7
31 #define CMD_REFS 8
32
33 /*
34 * Dateformats used on misc. pages
35 */
36 #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
37 #define FMT_SHORTDATE "%Y-%m-%d"
38
39
40 /*
41 * Limits used for relative dates
42 */
43 #define TM_MIN 60
44 #define TM_HOUR (TM_MIN * 60)
45 #define TM_DAY (TM_HOUR * 24)
46 #define TM_WEEK (TM_DAY * 7)
47 #define TM_YEAR (TM_DAY * 365)
48 #define TM_MONTH (TM_YEAR / 12.0)
49
50
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);
54
55 struct cacheitem {
56 char *name;
57 struct stat st;
58 int ttl;
59 int fd;
60 };
61
62 struct repoinfo {
63 char *url;
64 char *name;
65 char *path;
66 char *desc;
67 char *owner;
68 char *defbranch;
69 char *group;
70 char *module_link;
71 char *readme;
72 int snapshots;
73 int enable_log_filecount;
74 int enable_log_linecount;
75 };
76
77 struct repolist {
78 int length;
79 int count;
80 struct repoinfo *repos;
81 };
82
83 struct commitinfo {
84 struct commit *commit;
85 char *author;
86 char *author_email;
87 unsigned long author_date;
88 char *committer;
89 char *committer_email;
90 unsigned long committer_date;
91 char *subject;
92 char *msg;
93 };
94
95 struct taginfo {
96 char *tagger;
97 char *tagger_email;
98 int tagger_date;
99 char *msg;
100 };
101
102 struct refinfo {
103 const char *refname;
104 struct object *object;
105 union {
106 struct taginfo *tag;
107 struct commitinfo *commit;
108 };
109 };
110
111 struct reflist {
112 struct refinfo **refs;
113 int alloc;
114 int count;
115 };
116
117 extern const char *cgit_version;
118
119 extern struct repolist cgit_repolist;
120 extern struct repoinfo *cgit_repo;
121 extern int cgit_cmd;
122
123 extern char *cgit_root_title;
124 extern char *cgit_css;
125 extern char *cgit_logo;
126 extern char *cgit_index_header;
127 extern char *cgit_logo_link;
128 extern char *cgit_module_link;
129 extern char *cgit_agefile;
130 extern char *cgit_virtual_root;
131 extern char *cgit_script_name;
132 extern char *cgit_cache_root;
133 extern char *cgit_repo_group;
134
135 extern int cgit_nocache;
136 extern int cgit_snapshots;
137 extern int cgit_enable_index_links;
138 extern int cgit_enable_log_filecount;
139 extern int cgit_enable_log_linecount;
140 extern int cgit_max_lock_attempts;
141 extern int cgit_cache_root_ttl;
142 extern int cgit_cache_repo_ttl;
143 extern int cgit_cache_dynamic_ttl;
144 extern int cgit_cache_static_ttl;
145 extern int cgit_cache_max_create_time;
146 extern int cgit_summary_log;
147 extern int cgit_summary_tags;
148 extern int cgit_summary_branches;
149
150 extern int cgit_max_msg_len;
151 extern int cgit_max_repodesc_len;
152 extern int cgit_max_commit_count;
153
154 extern int cgit_query_has_symref;
155 extern int cgit_query_has_sha1;
156
157 extern char *cgit_querystring;
158 extern char *cgit_query_repo;
159 extern char *cgit_query_page;
160 extern char *cgit_query_search;
161 extern char *cgit_query_head;
162 extern char *cgit_query_sha1;
163 extern char *cgit_query_sha2;
164 extern char *cgit_query_path;
165 extern char *cgit_query_name;
166 extern int cgit_query_ofs;
167
168 extern int htmlfd;
169
170 extern int cgit_get_cmd_index(const char *cmd);
171 extern struct repoinfo *cgit_get_repoinfo(const char *url);
172 extern void cgit_global_config_cb(const char *name, const char *value);
173 extern void cgit_repo_config_cb(const char *name, const char *value);
174 extern void cgit_querystring_cb(const char *name, const char *value);
175
176 extern int chk_zero(int result, char *msg);
177 extern int chk_positive(int result, char *msg);
178 extern int chk_non_negative(int result, char *msg);
179
180 extern int hextoint(char c);
181 extern char *trim_end(const char *str, char c);
182
183 extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
184 extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
185 int flags, void *cb_data);
186
187 extern void *cgit_free_commitinfo(struct commitinfo *info);
188
189 extern int cgit_diff_files(const unsigned char *old_sha1,
190 const unsigned char *new_sha1,
191 linediff_fn fn);
192
193 extern void cgit_diff_tree(const unsigned char *old_sha1,
194 const unsigned char *new_sha1,
195 filepair_fn fn, const char *prefix);
196
197 extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
198
199 extern char *fmt(const char *format,...);
200
201 extern void html(const char *txt);
202 extern void htmlf(const char *format,...);
203 extern void html_txt(char *txt);
204 extern void html_ntxt(int len, char *txt);
205 extern void html_attr(char *txt);
206 extern void html_hidden(char *name, char *value);
207 extern void html_link_open(char *url, char *title, char *class);
208 extern void html_link_close(void);
209 extern void html_filemode(unsigned short mode);
210 extern int html_include(const char *filename);
211
212 extern int cgit_read_config(const char *filename, configfn fn);
213 extern int cgit_parse_query(char *txt, configfn fn);
214 extern struct commitinfo *cgit_parse_commit(struct commit *commit);
215 extern struct taginfo *cgit_parse_tag(struct tag *tag);
216 extern void cgit_parse_url(const char *url);
217
218 extern char *cache_safe_filename(const char *unsafe);
219 extern int cache_lock(struct cacheitem *item);
220 extern int cache_unlock(struct cacheitem *item);
221 extern int cache_cancel_lock(struct cacheitem *item);
222 extern int cache_exist(struct cacheitem *item);
223 extern int cache_expired(struct cacheitem *item);
224
225 extern char *cgit_repourl(const char *reponame);
226 extern char *cgit_fileurl(const char *reponame, const char *pagename,
227 const char *filename, const char *query);
228 extern char *cgit_pageurl(const char *reponame, const char *pagename,
229 const char *query);
230
231 extern const char *cgit_repobasename(const char *reponame);
232
233 extern void cgit_tree_link(char *name, char *title, char *class, char *head,
234 char *rev, char *path);
235 extern void cgit_log_link(char *name, char *title, char *class, char *head,
236 char *rev, char *path, int ofs);
237 extern void cgit_commit_link(char *name, char *title, char *class, char *head,
238 char *rev);
239 extern void cgit_refs_link(char *name, char *title, char *class, char *head,
240 char *rev, char *path);
241 extern void cgit_snapshot_link(char *name, char *title, char *class,
242 char *head, char *rev, char *archivename);
243 extern void cgit_diff_link(char *name, char *title, char *class, char *head,
244 char *new_rev, char *old_rev, char *path);
245
246 extern void cgit_object_link(struct object *obj);
247
248 extern void cgit_print_error(char *msg);
249 extern void cgit_print_date(time_t secs, char *format);
250 extern void cgit_print_age(time_t t, time_t max_relative, char *format);
251 extern void cgit_print_docstart(char *title, struct cacheitem *item);
252 extern void cgit_print_docend();
253 extern void cgit_print_pageheader(char *title, int show_search);
254 extern void cgit_print_snapshot_start(const char *mimetype,
255 const char *filename,
256 struct cacheitem *item);
257 extern void cgit_print_branches(int maxcount);
258 extern void cgit_print_tags(int maxcount);
259
260 extern void cgit_print_repolist(struct cacheitem *item);
261 extern void cgit_print_summary();
262 extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager);
263 extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
264 extern void cgit_print_tree(const char *rev, char *path);
265 extern void cgit_print_commit(char *hex);
266 extern void cgit_print_refs();
267 extern void cgit_print_tag(char *revname);
268 extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
269 extern void cgit_print_snapshot(struct cacheitem *item, const char *head,
270 const char *hex, const char *prefix,
271 const char *filename, int snapshot);
272 extern void cgit_print_snapshot_links(const char *repo, const char *head,
273 const char *hex, int snapshots);
274 extern int cgit_parse_snapshots_mask(const char *str);
275
276 #endif /* CGIT_H */