2 assfile - library for accessing assets with an fopen/fread-like interface
3 Copyright (C) 2018 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
23 #ifndef ASSFILE_IMPL_H_
24 typedef void ass_file;
29 void *(*open)(const char *fname, void *udata);
30 void (*close)(void *fp, void *udata);
31 long (*seek)(void *fp, long offs, int whence, void *udata);
32 long (*read)(void *fp, void *buf, long size, void *udata);
35 /* options (ass_set_option/ass_get_option) */
37 ASS_OPEN_FALLTHROUGH /* try all matching handlers if the first fails to open the file */
46 void ass_set_option(int opt, int val);
47 int ass_get_option(int opt);
49 /* add a handler for a specific path prefixes. 0 matches every path */
50 int ass_add_path(const char *prefix, const char *path);
51 int ass_add_archive(const char *prefix, const char *arfile);
52 int ass_add_url(const char *prefix, const char *url);
53 int ass_add_user(const char *prefix, struct ass_fileops *cb);
56 ass_file *ass_fopen(const char *fname, const char *mode);
57 void ass_fclose(ass_file *fp);
58 long ass_fseek(ass_file *fp, long offs, int whence);
59 long ass_ftell(ass_file *fp);
61 size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp);
63 /* convenience functions, derived from the above */
64 int ass_fgetc(ass_file *fp);
65 char *ass_fgets(char *s, int size, ass_file *fp);
72 #endif /* ASSFILE_H_ */