00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 struct _VFSConstructor VFSConstructor;
00040
00046 struct _VFSFile {
00047 gchar *uri;
00048 gpointer handle;
00049 VFSConstructor *base;
00050 gint ref;
00051 };
00052
00059 struct _VFSConstructor {
00061 gchar * uri_id;
00062
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 glong 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_register_transport (VFSConstructor * vtable);
00150
00151 #undef WARN_RETURN
00152
00153 G_END_DECLS
00154
00155 #endif