Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
vfs.h
Go to the documentation of this file.
1 /*
2  * vfs.h
3  * Copyright 2006-2011 William Pitcock, Daniel Barkalow, Ralf Ertzinger,
4  * Yoshiki Yazawa, Matti Hämäläinen, and John Lindgren
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; under version 3 of the License.
9  *
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 General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses>.
17  *
18  * The Audacious team does not consider modular code linking to
19  * Audacious or using our public API to be a derived work.
20  */
28 #ifndef LIBAUDCORE_VFS_H
29 #define LIBAUDCORE_VFS_H
30 
31 #include <stdint.h>
32 
33 #include <libaudcore/core.h>
34 
36 typedef struct _VFSFile VFSFile;
38 typedef const struct _VFSConstructor VFSConstructor;
39 
48  void * (* vfs_fopen_impl) (const char * filename, const char * mode);
50  int (* vfs_fclose_impl) (VFSFile * file);
51 
53  int64_t (* vfs_fread_impl) (void * ptr, int64_t size, int64_t nmemb, VFSFile *
54  file);
56  int64_t (* vfs_fwrite_impl) (const void * ptr, int64_t size, int64_t nmemb,
57  VFSFile * file);
58 
60  int (* vfs_getc_impl) (VFSFile * stream);
62  int (* vfs_ungetc_impl) (int c, VFSFile * stream);
63 
65  int (* vfs_fseek_impl) (VFSFile * file, int64_t offset, int whence);
67  void (* vfs_rewind_impl) (VFSFile * file);
69  int64_t (* vfs_ftell_impl) (VFSFile * file);
73  int (* vfs_ftruncate_impl) (VFSFile * file, int64_t length);
75  int64_t (* vfs_fsize_impl) (VFSFile * file);
76 
78  char * (* vfs_get_metadata_impl) (VFSFile * file, const char * field);
79 };
80 
81 #ifdef __GNUC__
82 #define WARN_RETURN __attribute__ ((warn_unused_result))
83 #else
84 #define WARN_RETURN
85 #endif
86 
87 VFSFile * vfs_new (const char * path, VFSConstructor * vtable, void * handle) WARN_RETURN;
88 const char * vfs_get_filename (VFSFile * file) WARN_RETURN;
89 void * vfs_get_handle (VFSFile * file) WARN_RETURN;
90 
91 VFSFile * vfs_fopen (const char * path, const char * mode) WARN_RETURN;
92 int vfs_fclose (VFSFile * file);
93 
94 int64_t vfs_fread (void * ptr, int64_t size, int64_t nmemb, VFSFile * file)
96 int64_t vfs_fwrite (const void * ptr, int64_t size, int64_t nmemb, VFSFile * file)
98 
99 int vfs_getc (VFSFile * stream) WARN_RETURN;
100 int vfs_ungetc (int c, VFSFile * stream) WARN_RETURN;
101 char * vfs_fgets (char * s, int n, VFSFile * stream) WARN_RETURN;
103 int vfs_fprintf (VFSFile * stream, char const * format, ...) __attribute__
104  ((__format__ (__printf__, 2, 3)));
105 
106 int vfs_fseek (VFSFile * file, int64_t offset, int whence) WARN_RETURN;
107 void vfs_rewind (VFSFile * file);
108 int64_t vfs_ftell (VFSFile * file) WARN_RETURN;
109 int64_t vfs_fsize (VFSFile * file) WARN_RETURN;
110 int vfs_ftruncate (VFSFile * file, int64_t length) WARN_RETURN;
111 
112 bool_t vfs_fget_le16 (uint16_t * value, VFSFile * stream) WARN_RETURN;
113 bool_t vfs_fget_le32 (uint32_t * value, VFSFile * stream) WARN_RETURN;
114 bool_t vfs_fget_le64 (uint64_t * value, VFSFile * stream) WARN_RETURN;
115 bool_t vfs_fget_be16 (uint16_t * value, VFSFile * stream) WARN_RETURN;
116 bool_t vfs_fget_be32 (uint32_t * value, VFSFile * stream) WARN_RETURN;
117 bool_t vfs_fget_be64 (uint64_t * value, VFSFile * stream) WARN_RETURN;
118 
119 bool_t vfs_fput_le16 (uint16_t value, VFSFile * stream) WARN_RETURN;
120 bool_t vfs_fput_le32 (uint32_t value, VFSFile * stream) WARN_RETURN;
121 bool_t vfs_fput_le64 (uint64_t value, VFSFile * stream) WARN_RETURN;
122 bool_t vfs_fput_be16 (uint16_t value, VFSFile * stream) WARN_RETURN;
123 bool_t vfs_fput_be32 (uint32_t value, VFSFile * stream) WARN_RETURN;
124 bool_t vfs_fput_be64 (uint64_t value, VFSFile * stream) WARN_RETURN;
125 
126 bool_t vfs_is_streaming (VFSFile * file) WARN_RETURN;
127 char * vfs_get_metadata (VFSFile * file, const char * field) WARN_RETURN;
128 
129 bool_t vfs_file_test (const char * path, int test) WARN_RETURN;
130 bool_t vfs_is_writeable (const char * path) WARN_RETURN;
131 bool_t vfs_is_remote (const char * path) WARN_RETURN;
132 
133 void vfs_file_get_contents (const char * filename, void * * buf, int64_t *
134  size);
135 
136 void vfs_set_lookup_func (VFSConstructor * (* func) (const char * scheme));
138 
139 #undef WARN_RETURN
140 
141 #endif /* LIBAUDCORE_VFS_H */