Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$
vfs.h
Go to the documentation of this file.
00001 /*
00002  * vfs.h
00003  * Copyright 2006-2011 William Pitcock, Daniel Barkalow, Ralf Ertzinger,
00004  *                     Yoshiki Yazawa, Matti Hämäläinen, and John Lindgren
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; under version 3 of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses>.
00017  *
00018  * The Audacious team does not consider modular code linking to
00019  * Audacious or using our public API to be a derived work.
00020  */
00028 #ifndef LIBAUDCORE_VFS_H
00029 #define LIBAUDCORE_VFS_H
00030 
00031 #include <stdint.h>
00032 
00033 #include <libaudcore/core.h>
00034 
00036 typedef struct _VFSFile VFSFile;
00038 typedef const struct _VFSConstructor VFSConstructor;
00039 
00046 struct _VFSConstructor {
00048     void * (* vfs_fopen_impl) (const char * filename, const char * mode);
00050     int (* vfs_fclose_impl) (VFSFile * file);
00051 
00053     int64_t (* vfs_fread_impl) (void * ptr, int64_t size, int64_t nmemb, VFSFile *
00054      file);
00056     int64_t (* vfs_fwrite_impl) (const void * ptr, int64_t size, int64_t nmemb,
00057      VFSFile * file);
00058 
00060     int (* vfs_getc_impl) (VFSFile * stream);
00062     int (* vfs_ungetc_impl) (int c, VFSFile * stream);
00063 
00065     int (* vfs_fseek_impl) (VFSFile * file, int64_t offset, int whence);
00067     void (* vfs_rewind_impl) (VFSFile * file);
00069     int64_t (* vfs_ftell_impl) (VFSFile * file);
00071     bool_t (* vfs_feof_impl) (VFSFile * file);
00073     int (* vfs_ftruncate_impl) (VFSFile * file, int64_t length);
00075     int64_t (* vfs_fsize_impl) (VFSFile * file);
00076 
00078     char * (* vfs_get_metadata_impl) (VFSFile * file, const char * field);
00079 };
00080 
00081 #ifdef __GNUC__
00082 #define WARN_RETURN __attribute__ ((warn_unused_result))
00083 #else
00084 #define WARN_RETURN
00085 #endif
00086 
00087 VFSFile * vfs_new (const char * path, VFSConstructor * vtable, void * handle) WARN_RETURN;
00088 const char * vfs_get_filename (VFSFile * file) WARN_RETURN;
00089 void * vfs_get_handle (VFSFile * file) WARN_RETURN;
00090 
00091 VFSFile * vfs_fopen (const char * path, const char * mode) WARN_RETURN;
00092 int vfs_fclose (VFSFile * file);
00093 
00094 int64_t vfs_fread (void * ptr, int64_t size, int64_t nmemb, VFSFile * file)
00095  WARN_RETURN;
00096 int64_t vfs_fwrite (const void * ptr, int64_t size, int64_t nmemb, VFSFile * file)
00097  WARN_RETURN;
00098 
00099 int vfs_getc (VFSFile * stream) WARN_RETURN;
00100 int vfs_ungetc (int c, VFSFile * stream) WARN_RETURN;
00101 char * vfs_fgets (char * s, int n, VFSFile * stream) WARN_RETURN;
00102 bool_t vfs_feof (VFSFile * file) WARN_RETURN;
00103 int vfs_fprintf (VFSFile * stream, char const * format, ...) __attribute__
00104  ((__format__ (__printf__, 2, 3)));
00105 
00106 int vfs_fseek (VFSFile * file, int64_t offset, int whence) WARN_RETURN;
00107 void vfs_rewind (VFSFile * file);
00108 int64_t vfs_ftell (VFSFile * file) WARN_RETURN;
00109 int64_t vfs_fsize (VFSFile * file) WARN_RETURN;
00110 int vfs_ftruncate (VFSFile * file, int64_t length) WARN_RETURN;
00111 
00112 bool_t vfs_fget_le16 (uint16_t * value, VFSFile * stream) WARN_RETURN;
00113 bool_t vfs_fget_le32 (uint32_t * value, VFSFile * stream) WARN_RETURN;
00114 bool_t vfs_fget_le64 (uint64_t * value, VFSFile * stream) WARN_RETURN;
00115 bool_t vfs_fget_be16 (uint16_t * value, VFSFile * stream) WARN_RETURN;
00116 bool_t vfs_fget_be32 (uint32_t * value, VFSFile * stream) WARN_RETURN;
00117 bool_t vfs_fget_be64 (uint64_t * value, VFSFile * stream) WARN_RETURN;
00118 
00119 bool_t vfs_fput_le16 (uint16_t value, VFSFile * stream) WARN_RETURN;
00120 bool_t vfs_fput_le32 (uint32_t value, VFSFile * stream) WARN_RETURN;
00121 bool_t vfs_fput_le64 (uint64_t value, VFSFile * stream) WARN_RETURN;
00122 bool_t vfs_fput_be16 (uint16_t value, VFSFile * stream) WARN_RETURN;
00123 bool_t vfs_fput_be32 (uint32_t value, VFSFile * stream) WARN_RETURN;
00124 bool_t vfs_fput_be64 (uint64_t value, VFSFile * stream) WARN_RETURN;
00125 
00126 bool_t vfs_is_streaming (VFSFile * file) WARN_RETURN;
00127 char * vfs_get_metadata (VFSFile * file, const char * field) WARN_RETURN;
00128 
00129 bool_t vfs_file_test (const char * path, int test) WARN_RETURN;
00130 bool_t vfs_is_writeable (const char * path) WARN_RETURN;
00131 bool_t vfs_is_remote (const char * path) WARN_RETURN;
00132 
00133 void vfs_file_get_contents (const char * filename, void * * buf, int64_t *
00134  size);
00135 
00136 void vfs_set_lookup_func (VFSConstructor * (* func) (const char * scheme));
00137 void vfs_set_verbose (bool_t verbose);
00138 
00139 #undef WARN_RETURN
00140 
00141 #endif /* LIBAUDCORE_VFS_H */