Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$
vfs.h
Go to the documentation of this file.
00001 /*
00002  * Audacious
00003  * Copyright (c) 2006-2010 Audacious team
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; under version 3 of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses>.
00016  *
00017  * The Audacious team does not consider modular code linking to
00018  * Audacious or using our public API to be a derived work.
00019  */
00027 #ifndef AUDACIOUS_VFS_H
00028 #define AUDACIOUS_VFS_H
00029 
00030 #include <glib.h>
00031 #include <stdio.h>
00032 #include <sys/types.h>
00033 
00034 G_BEGIN_DECLS
00035 
00037 typedef struct _VFSFile VFSFile;
00039 typedef const struct _VFSConstructor VFSConstructor;
00040 
00041 #define VFS_SIG ('V' | ('F' << 8) | ('S' << 16))
00042 
00048 struct _VFSFile {
00049     gchar *uri;             
00050     gpointer handle;        
00051     VFSConstructor *base;   
00052     gint ref;               
00053     gint sig;               
00054 };
00055 
00062 struct _VFSConstructor {
00064     VFSFile * (* vfs_fopen_impl) (const gchar * filename, const gchar * mode);
00066     gint (* vfs_fclose_impl) (VFSFile * file);
00067 
00069     gint64 (* vfs_fread_impl) (void * ptr, gint64 size, gint64 nmemb, VFSFile *
00070      file);
00072     gint64 (* vfs_fwrite_impl) (const void * ptr, gint64 size, gint64 nmemb,
00073      VFSFile * file);
00074 
00076     gint (* vfs_getc_impl) (VFSFile * stream);
00078     gint (* vfs_ungetc_impl) (gint c, VFSFile * stream);
00079 
00081     gint (* vfs_fseek_impl) (VFSFile * file, gint64 offset, gint whence);
00083     void (* vfs_rewind_impl) (VFSFile * file);
00085     gint64 (* vfs_ftell_impl) (VFSFile * file);
00087     gboolean (* vfs_feof_impl) (VFSFile * file);
00089     gint (* vfs_ftruncate_impl) (VFSFile * file, gint64 length);
00091     gint64 (* vfs_fsize_impl) (VFSFile * file);
00092 
00094     gchar * (* vfs_get_metadata_impl) (VFSFile * file, const gchar * field);
00095 };
00096 
00097 #ifdef __GNUC__
00098 #define WARN_RETURN __attribute__ ((warn_unused_result))
00099 #else
00100 #define WARN_RETURN
00101 #endif
00102 
00103 VFSFile * vfs_fopen (const gchar * path, const gchar * mode) WARN_RETURN;
00104 VFSFile * vfs_dup (VFSFile * in) WARN_RETURN;
00105 gint vfs_fclose (VFSFile * file);
00106 
00107 gint64 vfs_fread (void * ptr, gint64 size, gint64 nmemb, VFSFile * file)
00108  WARN_RETURN;
00109 gint64 vfs_fwrite (const void * ptr, gint64 size, gint64 nmemb, VFSFile * file)
00110  WARN_RETURN;
00111 
00112 gint vfs_getc (VFSFile * stream) WARN_RETURN;
00113 gint vfs_ungetc (gint c, VFSFile * stream) WARN_RETURN;
00114 gchar * vfs_fgets (gchar * s, gint n, VFSFile * stream) WARN_RETURN;
00115 gboolean vfs_feof (VFSFile * file) WARN_RETURN;
00116 gint vfs_fprintf (VFSFile * stream, gchar const * format, ...) __attribute__
00117  ((__format__ (__printf__, 2, 3)));
00118 
00119 gint vfs_fseek (VFSFile * file, gint64 offset, gint whence) WARN_RETURN;
00120 void vfs_rewind (VFSFile * file);
00121 gint64 vfs_ftell (VFSFile * file) WARN_RETURN;
00122 gint64 vfs_fsize (VFSFile * file) WARN_RETURN;
00123 gint vfs_ftruncate (VFSFile * file, gint64 length) WARN_RETURN;
00124 
00125 gboolean vfs_fget_le16 (guint16 * value, VFSFile * stream) WARN_RETURN;
00126 gboolean vfs_fget_le32 (guint32 * value, VFSFile * stream) WARN_RETURN;
00127 gboolean vfs_fget_le64 (guint64 * value, VFSFile * stream) WARN_RETURN;
00128 gboolean vfs_fget_be16 (guint16 * value, VFSFile * stream) WARN_RETURN;
00129 gboolean vfs_fget_be32 (guint32 * value, VFSFile * stream) WARN_RETURN;
00130 gboolean vfs_fget_be64 (guint64 * value, VFSFile * stream) WARN_RETURN;
00131 
00132 gboolean vfs_fput_le16 (guint16 value, VFSFile * stream) WARN_RETURN;
00133 gboolean vfs_fput_le32 (guint32 value, VFSFile * stream) WARN_RETURN;
00134 gboolean vfs_fput_le64 (guint64 value, VFSFile * stream) WARN_RETURN;
00135 gboolean vfs_fput_be16 (guint16 value, VFSFile * stream) WARN_RETURN;
00136 gboolean vfs_fput_be32 (guint32 value, VFSFile * stream) WARN_RETURN;
00137 gboolean vfs_fput_be64 (guint64 value, VFSFile * stream) WARN_RETURN;
00138 
00139 gboolean vfs_is_streaming (VFSFile * file) WARN_RETURN;
00140 gchar * vfs_get_metadata (VFSFile * file, const gchar * field) WARN_RETURN;
00141 
00142 gboolean vfs_file_test (const gchar * path, GFileTest test) WARN_RETURN;
00143 gboolean vfs_is_writeable (const gchar * path) WARN_RETURN;
00144 gboolean vfs_is_remote (const gchar * path) WARN_RETURN;
00145 
00146 void vfs_file_get_contents (const gchar * filename, void * * buf, gint64 *
00147  size);
00148 
00149 void vfs_set_lookup_func (VFSConstructor * (* func) (const gchar * scheme));
00150 void vfs_set_verbose (gboolean verbose);
00151 
00152 #undef WARN_RETURN
00153 
00154 G_END_DECLS
00155 
00156 #endif /* AUDACIOUS_VFS_H */