4daec0d08a4583e68f0a964259940f09a48cde38
[assman] / src / assman.h
1 #ifndef ASSMAN_H_
2 #define ASSMAN_H_
3
4 #include <stdlib.h>
5
6 #ifndef ASSMAN_IMPL_H_
7 typedef void ass_file;
8 #endif
9
10 struct ass_fileops {
11         void *udata;
12         void *(*open)(const char *fname, void *udata);
13         void (*close)(void *fp, void *udata);
14         long (*seek)(void *fp, long offs, int whence, void *udata);
15         long (*read)(void *fp, void *buf, long size, void *udata);
16 };
17
18 /* options (ass_set_option/ass_get_option) */
19 enum {
20         ASS_OPEN_FALLTHROUGH    /* try all matching handlers if the first fails to open the file */
21 };
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 void ass_set_option(int opt, int val);
28 int ass_get_option(int opt);
29
30 /* add a handler for a specific path prefixes. 0 matches every path */
31 int ass_add_path(const char *prefix, const char *path);
32 int ass_add_archive(const char *prefix, const char *arfile);
33 int ass_add_url(const char *prefix, const char *url);
34 int ass_add_user(const char *prefix, struct ass_fileops *cb);
35 void ass_clear(void);
36
37 ass_file *ass_fopen(const char *fname, const char *mode);
38 void ass_fclose(ass_file *fp);
39 long ass_fseek(ass_file *fp, long offs, int whence);
40 long ass_ftell(ass_file *fp);
41
42 size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp);
43
44 /* convenience functions, derived from the above */
45 int ass_fgetc(ass_file *fp);
46 char *ass_fgets(char *s, int size, ass_file *fp);
47
48 #ifdef __cplusplus
49 }
50 #endif
51
52
53 #endif  /* ASSMAN_H_ */