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  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions, and the following disclaimer in the documentation
14  * provided with the distribution.
15  *
16  * This software is provided "as is" and without any warranty, express or
17  * implied. In no event shall the authors be liable for any damages arising from
18  * the use of this software.
19  */
27 #ifndef LIBAUDCORE_VFS_H
28 #define LIBAUDCORE_VFS_H
29 
30 #include <stdint.h>
31 
32 #include <libaudcore/core.h>
33 
34 /* equivalent to G_FILE_TEST_XXX */
35 #define VFS_IS_REGULAR (1 << 0)
36 #define VFS_IS_SYMLINK (1 << 1)
37 #define VFS_IS_DIR (1 << 2)
38 #define VFS_IS_EXECUTABLE (1 << 3)
39 #define VFS_EXISTS (1 << 4)
40 
42 typedef struct _VFSFile VFSFile;
44 typedef const struct _VFSConstructor VFSConstructor;
45 
54  void * (* vfs_fopen_impl) (const char * filename, const char * mode);
56  int (* vfs_fclose_impl) (VFSFile * file);
57 
59  int64_t (* vfs_fread_impl) (void * ptr, int64_t size, int64_t nmemb, VFSFile *
60  file);
62  int64_t (* vfs_fwrite_impl) (const void * ptr, int64_t size, int64_t nmemb,
63  VFSFile * file);
64 
66  int (* vfs_getc_impl) (VFSFile * stream);
68  int (* vfs_ungetc_impl) (int c, VFSFile * stream);
69 
71  int (* vfs_fseek_impl) (VFSFile * file, int64_t offset, int whence);
73  void (* vfs_rewind_impl) (VFSFile * file);
75  int64_t (* vfs_ftell_impl) (VFSFile * file);
79  int (* vfs_ftruncate_impl) (VFSFile * file, int64_t length);
81  int64_t (* vfs_fsize_impl) (VFSFile * file);
82 
84  char * (* vfs_get_metadata_impl) (VFSFile * file, const char * field);
85 };
86 
87 #ifdef __GNUC__
88 #define WARN_RETURN __attribute__ ((warn_unused_result))
89 #else
90 #define WARN_RETURN
91 #endif
92 
93 VFSFile * vfs_new (const char * path, VFSConstructor * vtable, void * handle) WARN_RETURN;
94 const char * vfs_get_filename (VFSFile * file) WARN_RETURN;
95 void * vfs_get_handle (VFSFile * file) WARN_RETURN;
96 
97 VFSFile * vfs_fopen (const char * path, const char * mode) WARN_RETURN;
98 int vfs_fclose (VFSFile * file);
99 
100 int64_t vfs_fread (void * ptr, int64_t size, int64_t nmemb, VFSFile * file)
101  WARN_RETURN;
102 int64_t vfs_fwrite (const void * ptr, int64_t size, int64_t nmemb, VFSFile * file)
103  WARN_RETURN;
104 
105 int vfs_getc (VFSFile * stream) WARN_RETURN;
106 int vfs_ungetc (int c, VFSFile * stream) WARN_RETURN;
107 char * vfs_fgets (char * s, int n, VFSFile * stream) WARN_RETURN;
109 int vfs_fprintf (VFSFile * stream, char const * format, ...) __attribute__
110  ((__format__ (__printf__, 2, 3)));
111 
112 int vfs_fseek (VFSFile * file, int64_t offset, int whence) WARN_RETURN;
113 void vfs_rewind (VFSFile * file);
114 int64_t vfs_ftell (VFSFile * file) WARN_RETURN;
115 int64_t vfs_fsize (VFSFile * file) WARN_RETURN;
116 int vfs_ftruncate (VFSFile * file, int64_t length) WARN_RETURN;
117 
118 bool_t vfs_fget_le16 (uint16_t * value, VFSFile * stream) WARN_RETURN;
119 bool_t vfs_fget_le32 (uint32_t * value, VFSFile * stream) WARN_RETURN;
120 bool_t vfs_fget_le64 (uint64_t * value, VFSFile * stream) WARN_RETURN;
121 bool_t vfs_fget_be16 (uint16_t * value, VFSFile * stream) WARN_RETURN;
122 bool_t vfs_fget_be32 (uint32_t * value, VFSFile * stream) WARN_RETURN;
123 bool_t vfs_fget_be64 (uint64_t * value, VFSFile * stream) WARN_RETURN;
124 
125 bool_t vfs_fput_le16 (uint16_t value, VFSFile * stream) WARN_RETURN;
126 bool_t vfs_fput_le32 (uint32_t value, VFSFile * stream) WARN_RETURN;
127 bool_t vfs_fput_le64 (uint64_t value, VFSFile * stream) WARN_RETURN;
128 bool_t vfs_fput_be16 (uint16_t value, VFSFile * stream) WARN_RETURN;
129 bool_t vfs_fput_be32 (uint32_t value, VFSFile * stream) WARN_RETURN;
130 bool_t vfs_fput_be64 (uint64_t value, VFSFile * stream) WARN_RETURN;
131 
132 bool_t vfs_is_streaming (VFSFile * file) WARN_RETURN;
133 char * vfs_get_metadata (VFSFile * file, const char * field) WARN_RETURN;
134 
135 bool_t vfs_file_test (const char * path, int test) WARN_RETURN;
136 bool_t vfs_is_writeable (const char * path) WARN_RETURN;
137 bool_t vfs_is_remote (const char * path) WARN_RETURN;
138 
139 void vfs_file_get_contents (const char * filename, void * * buf, int64_t *
140  size);
141 
142 void vfs_set_lookup_func (VFSConstructor * (* func) (const char * scheme));
144 
145 #undef WARN_RETURN
146 
147 #endif /* LIBAUDCORE_VFS_H */