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