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 */
EXPORT int64_t vfs_fwrite(const void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
Writes to a VFS stream.
Definition: vfs.c:215
bool_t vfs_fget_le64(uint64_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 64-bit Little Endian value from the stream into native endian format.
Definition: vfs_common.c:238
bool_t vfs_fget_le32(uint32_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 32-bit Little Endian value from the stream into native endian format.
Definition: vfs_common.c:222
bool_t vfs_fget_be32(uint32_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 32-bit Big Endian value from the stream into native endian format.
Definition: vfs_common.c:271
EXPORT bool_t vfs_feof(VFSFile *file)
Returns whether or not the VFS stream has reached EOF.
Definition: vfs.c:333
bool_t vfs_fput_be32(uint32_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
Definition: vfs_common.c:360
int64_t(* vfs_ftell_impl)(VFSFile *file)
A function pointer which points to a ftell implementation.
Definition: vfs.h:75
bool_t vfs_fput_be16(uint16_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 16-bit native endian value into the stream as a Big Endian value.
Definition: vfs_common.c:346
EXPORT int64_t vfs_ftell(VFSFile *file)
Returns the current position in the VFS stream&#39;s buffer.
Definition: vfs.c:314
const char filename
Definition: misc-api.h:85
bool_t vfs_fget_le16(uint16_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 16-bit Little Endian value from the stream into native endian format.
Definition: vfs_common.c:206
EXPORT int vfs_fclose(VFSFile *file)
Closes a VFS stream and destroys a VFSFile object.
Definition: vfs.c:164
EXPORT bool_t vfs_is_streaming(VFSFile *file)
Tests if a file is associated to streaming.
Definition: vfs.c:485
const char PluginHandle decoder const char PluginHandle decoder const char PluginHandle decoder void const PreferencesWidget int
Definition: misc-api.h:103
EXPORT VFSFile * vfs_new(const char *path, VFSConstructor *vtable, void *handle)
Definition: vfs.c:93
bool_t vfs_fget_be16(uint16_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 16-bit Big Endian value from the stream into native endian format.
Definition: vfs_common.c:255
int format
Definition: audio.c:132
int(* vfs_getc_impl)(VFSFile *stream)
A function pointer which points to a getc implementation.
Definition: vfs.h:66
bool_t vfs_fput_le16(uint16_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 16-bit native endian value into the stream as a Little Endian value.
Definition: vfs_common.c:304
int64_t(* vfs_fsize_impl)(VFSFile *file)
A function pointer which points to a fsize implementation.
Definition: vfs.h:81
EXPORT int vfs_ftruncate(VFSFile *file, int64_t length)
Truncates a VFS stream to a certain size.
Definition: vfs.c:352
int(* vfs_fseek_impl)(VFSFile *file, int64_t offset, int whence)
A function pointer which points to a fseek implementation.
Definition: vfs.h:71
Index Index bool_t
Definition: playlist-api.h:122
EXPORT const char * vfs_get_filename(VFSFile *file)
Definition: vfs.c:103
int(* vfs_fclose_impl)(VFSFile *file)
A function pointer which points to a fclose implementation.
Definition: vfs.h:56
EXPORT int vfs_fseek(VFSFile *file, int64_t offset, int whence)
Performs a seek in given VFS stream.
Definition: vfs.c:277
int64_t(* vfs_fread_impl)(void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
A function pointer which points to a fread implementation.
Definition: vfs.h:59
bool_t vfs_fput_le64(uint64_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
Definition: vfs_common.c:332
VFSConstructor objects contain the base vtables used for extrapolating a VFS stream.
Definition: vfs.h:52
EXPORT int64_t vfs_fread(void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
Reads from a VFS stream.
Definition: vfs.c:193
static bool_t verbose
Definition: vfs.c:59
EXPORT void vfs_set_lookup_func(VFSConstructor *(*func)(const char *scheme))
Definition: vfs.c:54
int64_t(* vfs_fwrite_impl)(const void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
A function pointer which points to a fwrite implementation.
Definition: vfs.h:62
EXPORT void * vfs_get_handle(VFSFile *file)
Definition: vfs.c:108
int(* vfs_ungetc_impl)(int c, VFSFile *stream)
A function pointer which points to an ungetc implementation.
Definition: vfs.h:68
EXPORT int vfs_ungetc(int c, VFSFile *file)
Pushes a character back to the VFS stream.
Definition: vfs.c:253
func
Definition: plugins-api.h:41
bool_t vfs_fput_be64(uint64_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
Definition: vfs_common.c:374
EXPORT bool_t vfs_is_writeable(const char *path)
Tests if a file is writeable.
Definition: vfs.c:455
bool_t(* vfs_feof_impl)(VFSFile *file)
A function pointer which points to a feof implementation.
Definition: vfs.h:77
EXPORT VFSFile * vfs_fopen(const char *path, const char *mode)
Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.
Definition: vfs.c:122
bool_t vfs_fput_le32(uint32_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
Definition: vfs_common.c:318
void vfs_file_get_contents(const char *filename, void **buf, int64_t *size)
Gets contents of the file into a buffer.
Definition: vfs_common.c:149
EXPORT char * vfs_get_metadata(VFSFile *file, const char *field)
Returns metadata about the stream.
Definition: vfs.c:388
int(* vfs_ftruncate_impl)(VFSFile *file, int64_t length)
A function pointer which points to a ftruncate implementation.
Definition: vfs.h:79
VFSFile objects describe an opened VFS stream, basically being similar in purpose as stdio FILE ...
Definition: vfs.c:39
EXPORT bool_t vfs_is_remote(const char *path)
Tests if a path is remote uri.
Definition: vfs.c:474
EXPORT void vfs_set_verbose(bool_t set)
Definition: vfs.c:61
EXPORT void vfs_rewind(VFSFile *file)
Rewinds a VFS stream.
Definition: vfs.c:297
EXPORT int vfs_getc(VFSFile *file)
Reads a character from a VFS stream.
Definition: vfs.c:235
char * vfs_fgets(char *s, int n, VFSFile *stream) WARN_RETURN
Reads a string of characters from a stream, ending in newline or EOF.
Definition: vfs_common.c:63
void(* vfs_rewind_impl)(VFSFile *file)
function pointer which points to a rewind implementation.
Definition: vfs.h:73
struct @17::@18::@20 s
EXPORT int64_t vfs_fsize(VFSFile *file)
Returns size of the file.
Definition: vfs.c:368
bool_t vfs_fget_be64(uint64_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 64-bit Big Endian value from the stream into native endian format.
Definition: vfs_common.c:287
EXPORT bool_t vfs_file_test(const char *path, int test)
Wrapper for g_file_test().
Definition: vfs.c:406
int vfs_fprintf(VFSFile *stream, char const *format,...) __attribute__((__format__(__printf__
#define WARN_RETURN
Definition: vfs.h:90