author | Lars Hjemli <hjemli@gmail.com> | 2009-08-18 15:17:41 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-08-18 15:22:14 (UTC) |
commit | e16f1783346a090e4ea1194dcaae7f03e813f6a2 (patch) (unidiff) | |
tree | 268f5ba231895ba3a63071497764c64d44733da5 /cgit.h | |
parent | 523c133e2e5f7089a3d18ac23f2074b60991a7f0 (diff) | |
download | cgit-e16f1783346a090e4ea1194dcaae7f03e813f6a2.zip cgit-e16f1783346a090e4ea1194dcaae7f03e813f6a2.tar.gz cgit-e16f1783346a090e4ea1194dcaae7f03e813f6a2.tar.bz2 |
Add and use a common readfile() function
This function is used to read the full content of a textfile into a
newly allocated buffer (with zerotermination).
It replaces the earlier readfile() in scan-tree.c (which was rather
error-prone[1]), and is reused by read_agefile() in ui-repolist.c.
1: No checks for EINTR and EAGAIN, fixed-size buffer
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -222,66 +222,67 @@ struct cgit_environment { | |||
222 | 222 | ||
223 | struct cgit_context { | 223 | struct cgit_context { |
224 | struct cgit_environment env; | 224 | struct cgit_environment env; |
225 | struct cgit_query qry; | 225 | struct cgit_query qry; |
226 | struct cgit_config cfg; | 226 | struct cgit_config cfg; |
227 | struct cgit_repo *repo; | 227 | struct cgit_repo *repo; |
228 | struct cgit_page page; | 228 | struct cgit_page page; |
229 | }; | 229 | }; |
230 | 230 | ||
231 | struct cgit_snapshot_format { | 231 | struct cgit_snapshot_format { |
232 | const char *suffix; | 232 | const char *suffix; |
233 | const char *mimetype; | 233 | const char *mimetype; |
234 | write_archive_fn_t write_func; | 234 | write_archive_fn_t write_func; |
235 | int bit; | 235 | int bit; |
236 | }; | 236 | }; |
237 | 237 | ||
238 | extern const char *cgit_version; | 238 | extern const char *cgit_version; |
239 | 239 | ||
240 | extern struct cgit_repolist cgit_repolist; | 240 | extern struct cgit_repolist cgit_repolist; |
241 | extern struct cgit_context ctx; | 241 | extern struct cgit_context ctx; |
242 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; | 242 | extern const struct cgit_snapshot_format cgit_snapshot_formats[]; |
243 | 243 | ||
244 | extern struct cgit_repo *cgit_add_repo(const char *url); | 244 | extern struct cgit_repo *cgit_add_repo(const char *url); |
245 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); | 245 | extern struct cgit_repo *cgit_get_repoinfo(const char *url); |
246 | extern void cgit_repo_config_cb(const char *name, const char *value); | 246 | extern void cgit_repo_config_cb(const char *name, const char *value); |
247 | 247 | ||
248 | extern int chk_zero(int result, char *msg); | 248 | extern int chk_zero(int result, char *msg); |
249 | extern int chk_positive(int result, char *msg); | 249 | extern int chk_positive(int result, char *msg); |
250 | extern int chk_non_negative(int result, char *msg); | 250 | extern int chk_non_negative(int result, char *msg); |
251 | 251 | ||
252 | extern char *trim_end(const char *str, char c); | 252 | extern char *trim_end(const char *str, char c); |
253 | extern char *strlpart(char *txt, int maxlen); | 253 | extern char *strlpart(char *txt, int maxlen); |
254 | extern char *strrpart(char *txt, int maxlen); | 254 | extern char *strrpart(char *txt, int maxlen); |
255 | 255 | ||
256 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 256 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
257 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 257 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
258 | int flags, void *cb_data); | 258 | int flags, void *cb_data); |
259 | 259 | ||
260 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 260 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
261 | 261 | ||
262 | extern int cgit_diff_files(const unsigned char *old_sha1, | 262 | extern int cgit_diff_files(const unsigned char *old_sha1, |
263 | const unsigned char *new_sha1, | 263 | const unsigned char *new_sha1, |
264 | unsigned long *old_size, unsigned long *new_size, | 264 | unsigned long *old_size, unsigned long *new_size, |
265 | int *binary, linediff_fn fn); | 265 | int *binary, linediff_fn fn); |
266 | 266 | ||
267 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 267 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
268 | const unsigned char *new_sha1, | 268 | const unsigned char *new_sha1, |
269 | filepair_fn fn, const char *prefix); | 269 | filepair_fn fn, const char *prefix); |
270 | 270 | ||
271 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 271 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
272 | 272 | ||
273 | extern char *fmt(const char *format,...); | 273 | extern char *fmt(const char *format,...); |
274 | 274 | ||
275 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 275 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
276 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 276 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
277 | extern void cgit_parse_url(const char *url); | 277 | extern void cgit_parse_url(const char *url); |
278 | 278 | ||
279 | extern const char *cgit_repobasename(const char *reponame); | 279 | extern const char *cgit_repobasename(const char *reponame); |
280 | 280 | ||
281 | extern int cgit_parse_snapshots_mask(const char *str); | 281 | extern int cgit_parse_snapshots_mask(const char *str); |
282 | 282 | ||
283 | extern int cgit_open_filter(struct cgit_filter *filter); | 283 | extern int cgit_open_filter(struct cgit_filter *filter); |
284 | extern int cgit_close_filter(struct cgit_filter *filter); | 284 | extern int cgit_close_filter(struct cgit_filter *filter); |
285 | 285 | ||
286 | extern int readfile(const char *path, char **buf, size_t *size); | ||
286 | 287 | ||
287 | #endif /* CGIT_H */ | 288 | #endif /* CGIT_H */ |