Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
Classes | Macros | Typedefs | Functions
vfs.h File Reference

Main API header for accessing Audacious VFS functionality. More...

#include <stdint.h>
#include <libaudcore/core.h>

Go to the source code of this file.

Classes

struct  _VFSConstructor
 VFSConstructor objects contain the base vtables used for extrapolating a VFS stream. More...
 

Macros

#define VFS_IS_REGULAR   (1 << 0)
 
#define VFS_IS_SYMLINK   (1 << 1)
 
#define VFS_IS_DIR   (1 << 2)
 
#define VFS_IS_EXECUTABLE   (1 << 3)
 
#define VFS_EXISTS   (1 << 4)
 
#define WARN_RETURN
 

Typedefs

typedef const struct
_VFSConstructor 
VFSConstructor
 

Functions

VFSFilevfs_new (const char *path, VFSConstructor *vtable, void *handle) WARN_RETURN
 
const char * vfs_get_filename (VFSFile *file) WARN_RETURN
 
void * vfs_get_handle (VFSFile *file) WARN_RETURN
 
VFSFilevfs_fopen (const char *path, const char *mode) WARN_RETURN
 Opens a stream from a VFS transport using one of the registered VFSConstructor handlers. More...
 
int vfs_fclose (VFSFile *file)
 Closes a VFS stream and destroys a VFSFile object. More...
 
int64_t vfs_fread (void *ptr, int64_t size, int64_t nmemb, VFSFile *file) WARN_RETURN
 Reads from a VFS stream. More...
 
int64_t vfs_fwrite (const void *ptr, int64_t size, int64_t nmemb, VFSFile *file) WARN_RETURN
 Writes to a VFS stream. More...
 
int vfs_getc (VFSFile *stream) WARN_RETURN
 Reads a character from a VFS stream. More...
 
int vfs_ungetc (int c, VFSFile *stream) WARN_RETURN
 Pushes a character back to the VFS stream. More...
 
char * vfs_fgets (char *s, int n, VFSFile *stream) WARN_RETURN
 Reads a string of characters from a stream, ending in newline or EOF. More...
 
int vfs_fputs (const char *s, VFSFile *stream) WARN_RETURN
 Writes a string to a VFS stream. More...
 
bool_t vfs_feof (VFSFile *file) WARN_RETURN
 Returns whether or not the VFS stream has reached EOF. More...
 
int vfs_fprintf (VFSFile *stream, char const *format,...) __attribute__((__format__(__printf__
 
int int vfs_fseek (VFSFile *file, int64_t offset, int whence) WARN_RETURN
 Performs a seek in given VFS stream. More...
 
void vfs_rewind (VFSFile *file)
 Rewinds a VFS stream. More...
 
int64_t vfs_ftell (VFSFile *file) WARN_RETURN
 Returns the current position in the VFS stream's buffer. More...
 
int64_t vfs_fsize (VFSFile *file) WARN_RETURN
 Returns size of the file. More...
 
int vfs_ftruncate (VFSFile *file, int64_t length) WARN_RETURN
 Truncates a VFS stream to a certain size. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool_t vfs_is_streaming (VFSFile *file) WARN_RETURN
 Tests if a file is associated to streaming. More...
 
char * vfs_get_metadata (VFSFile *file, const char *field) WARN_RETURN
 Returns metadata about the stream. More...
 
bool_t vfs_file_test (const char *path, int test) WARN_RETURN
 Wrapper for g_file_test(). More...
 
bool_t vfs_is_writeable (const char *path) WARN_RETURN
 Tests if a file is writeable. More...
 
bool_t vfs_is_remote (const char *path) WARN_RETURN
 Tests if a path is remote uri. More...
 
void vfs_file_get_contents (const char *filename, void **buf, int64_t *size)
 Gets contents of the file into a buffer. More...
 
void vfs_set_lookup_func (VFSConstructor *(*func)(const char *scheme))
 
void vfs_set_verbose (bool_t verbose)
 

Detailed Description

Main API header for accessing Audacious VFS functionality.

Provides functions for VFS transport registration and file access.

Definition in file vfs.h.

Macro Definition Documentation

#define VFS_EXISTS   (1 << 4)

Definition at line 39 of file vfs.h.

Referenced by vfs_file_test().

#define VFS_IS_DIR   (1 << 2)

Definition at line 37 of file vfs.h.

Referenced by vfs_file_test().

#define VFS_IS_EXECUTABLE   (1 << 3)

Definition at line 38 of file vfs.h.

Referenced by vfs_file_test().

#define VFS_IS_REGULAR   (1 << 0)

Definition at line 35 of file vfs.h.

Referenced by vfs_file_test().

#define VFS_IS_SYMLINK   (1 << 1)

Definition at line 36 of file vfs.h.

Referenced by vfs_file_test().

#define WARN_RETURN

Definition at line 90 of file vfs.h.

Typedef Documentation

typedef const struct _VFSConstructor VFSConstructor

Definition at line 44 of file vfs.h.

Function Documentation

int vfs_fclose ( VFSFile file)

Closes a VFS stream and destroys a VFSFile object.

Parameters
fileA VFSFile object to destroy.
Returns
-1 on failure, 0 on success.

Definition at line 164 of file vfs.c.

Referenced by file_find_decoder(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_cleanup(), playlist_load(), playlist_save(), probe_buffer_fclose(), save_preset_file(), and vfs_file_get_contents().

bool_t vfs_feof ( VFSFile file)

Returns whether or not the VFS stream has reached EOF.

Parameters
fileVFSFile object that represents the VFS stream.
Returns
On success, whether or not the VFS stream is at EOF. Otherwise, FALSE.

Definition at line 333 of file vfs.c.

Referenced by probe_buffer_feof().

bool_t vfs_fget_be16 ( uint16_t *  value,
VFSFile stream 
)

Reads an unsigned 16-bit Big Endian value from the stream into native endian format.

Parameters
valuePointer to the variable to read the value into.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 255 of file vfs_common.c.

bool_t vfs_fget_be32 ( uint32_t *  value,
VFSFile stream 
)

Reads an unsigned 32-bit Big Endian value from the stream into native endian format.

Parameters
valuePointer to the variable to read the value into.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 271 of file vfs_common.c.

bool_t vfs_fget_be64 ( uint64_t *  value,
VFSFile stream 
)

Reads an unsigned 64-bit Big Endian value from the stream into native endian format.

Parameters
valuePointer to the variable to read the value into.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 287 of file vfs_common.c.

bool_t vfs_fget_le16 ( uint16_t *  value,
VFSFile stream 
)

Reads an unsigned 16-bit Little Endian value from the stream into native endian format.

Parameters
valuePointer to the variable to read the value into.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 206 of file vfs_common.c.

bool_t vfs_fget_le32 ( uint32_t *  value,
VFSFile stream 
)

Reads an unsigned 32-bit Little Endian value from the stream into native endian format.

Parameters
valuePointer to the variable to read the value into.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 222 of file vfs_common.c.

bool_t vfs_fget_le64 ( uint64_t *  value,
VFSFile stream 
)

Reads an unsigned 64-bit Little Endian value from the stream into native endian format.

Parameters
valuePointer to the variable to read the value into.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 238 of file vfs_common.c.

char* vfs_fgets ( char *  s,
int  n,
VFSFile stream 
)

Reads a string of characters from a stream, ending in newline or EOF.

Parameters
sA buffer to put the string in.
nThe amount of characters to read.
streamA VFSFile object representing the stream.
Returns
The string on success, or NULL.

Definition at line 63 of file vfs_common.c.

void vfs_file_get_contents ( const char *  filename,
void **  buf,
int64_t *  size 
)

Gets contents of the file into a buffer.

Buffer of filesize bytes is allocated by this function as necessary.

Parameters
filenameURI of the file to read in.
bufPointer to a pointer variable of buffer.
sizePointer to gsize variable that will hold the amount of read data e.g. filesize.

Definition at line 149 of file vfs_common.c.

Referenced by art_get_data_real(), and vfs_async_file_get_contents_worker().

bool_t vfs_file_test ( const char *  path,
int  test 
)

Wrapper for g_file_test().

Parameters
pathA path to test.
testA GFileTest to run.
Returns
The result of g_file_test().

Definition at line 406 of file vfs.c.

Referenced by add_generic(), and playlist_remove_failed().

VFSFile* vfs_fopen ( const char *  path,
const char *  mode 
)

Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.

Parameters
pathThe path or URI to open.
modeThe preferred access privileges (not guaranteed).
Returns
On success, a VFSFile object representing the stream.

Definition at line 122 of file vfs.c.

Referenced by file_read_image(), file_read_tuple(), file_write_tuple(), playback_thread(), playlist_load(), playlist_save(), probe_buffer_new(), save_preset_file(), and vfs_file_get_contents().

int vfs_fprintf ( VFSFile stream,
char const *  format,
  ... 
)
bool_t vfs_fput_be16 ( uint16_t  value,
VFSFile stream 
)

Writes an unsigned 16-bit native endian value into the stream as a Big Endian value.

Parameters
valueValue to write into the stream.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 346 of file vfs_common.c.

bool_t vfs_fput_be32 ( uint32_t  value,
VFSFile stream 
)

Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.

Parameters
valueValue to write into the stream.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 360 of file vfs_common.c.

bool_t vfs_fput_be64 ( uint64_t  value,
VFSFile stream 
)

Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.

Parameters
valueValue to write into the stream.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 374 of file vfs_common.c.

bool_t vfs_fput_le16 ( uint16_t  value,
VFSFile stream 
)

Writes an unsigned 16-bit native endian value into the stream as a Little Endian value.

Parameters
valueValue to write into the stream.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 304 of file vfs_common.c.

bool_t vfs_fput_le32 ( uint32_t  value,
VFSFile stream 
)

Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.

Parameters
valueValue to write into the stream.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 318 of file vfs_common.c.

bool_t vfs_fput_le64 ( uint64_t  value,
VFSFile stream 
)

Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.

Parameters
valueValue to write into the stream.
streamA VFSFile object representing the stream.
Returns
TRUE if read was succesful, FALSE if there was an error.

Definition at line 332 of file vfs_common.c.

int vfs_fputs ( const char *  s,
VFSFile stream 
)

Writes a string to a VFS stream.

Parameters
sA string to write to the stream.
streamA VFSFile object representing the stream.
Returns
The amount of bytes written.

Definition at line 95 of file vfs_common.c.

Referenced by vfs_vfprintf().

int64_t vfs_fread ( void *  ptr,
int64_t  size,
int64_t  nmemb,
VFSFile file 
)

Reads from a VFS stream.

Parameters
ptrA pointer to the destination buffer.
sizeThe size of each element to read.
nmembThe number of elements to read.
fileVFSFile object that represents the VFS stream.
Returns
The number of elements succesfully read.

Definition at line 193 of file vfs.c.

Referenced by import_winamp_eqf(), increase_buffer(), vfs_fget_be16(), vfs_fget_be32(), vfs_fget_be64(), vfs_fget_le16(), vfs_fget_le32(), vfs_fget_le64(), and vfs_file_get_contents().

int int vfs_fseek ( VFSFile file,
int64_t  offset,
int  whence 
)

Performs a seek in given VFS stream.

Standard C-style values of whence can be used to indicate desired action.

  • SEEK_CUR seeks relative to current stream position.
  • SEEK_SET seeks to given absolute position (relative to stream beginning).
  • SEEK_END sets stream position to current file end.
Parameters
fileVFSFile object that represents the VFS stream.
offsetThe offset to seek to.
whenceType of the seek: SEEK_CUR, SEEK_SET or SEEK_END.
Returns
On success, 0. Otherwise, -1.

Definition at line 277 of file vfs.c.

Referenced by import_winamp_eqf(), and probe_func().

int64_t vfs_fsize ( VFSFile file)

Returns size of the file.

Parameters
fileVFSFile object that represents the VFS stream.
Returns
On success, the size of the file in bytes. Otherwise, -1.

Definition at line 368 of file vfs.c.

Referenced by probe_buffer_fsize(), vfs_file_get_contents(), and vfs_is_streaming().

int64_t vfs_ftell ( VFSFile file)

Returns the current position in the VFS stream's buffer.

Parameters
fileVFSFile object that represents the VFS stream.
Returns
On success, the current position. Otherwise, -1.

Definition at line 314 of file vfs.c.

int vfs_ftruncate ( VFSFile file,
int64_t  length 
)

Truncates a VFS stream to a certain size.

Parameters
fileVFSFile object that represents the VFS stream.
lengthThe length to truncate at.
Returns
On success, 0. Otherwise, -1.

Definition at line 352 of file vfs.c.

int64_t vfs_fwrite ( const void *  ptr,
int64_t  size,
int64_t  nmemb,
VFSFile file 
)

Writes to a VFS stream.

Parameters
ptrA const pointer to the source buffer.
sizeThe size of each element to write.
nmembThe number of elements to write.
fileVFSFile object that represents the VFS stream.
Returns
The number of elements succesfully written.

Definition at line 215 of file vfs.c.

Referenced by save_preset_file(), vfs_fput_be16(), vfs_fput_be32(), vfs_fput_be64(), vfs_fput_le16(), vfs_fput_le32(), vfs_fput_le64(), vfs_fputc(), and vfs_fputs().

const char* vfs_get_filename ( VFSFile file)

Definition at line 103 of file vfs.c.

Referenced by import_winamp_eqf().

void* vfs_get_handle ( VFSFile file)
char* vfs_get_metadata ( VFSFile file,
const char *  field 
)

Returns metadata about the stream.

Parameters
fileVFSFile object that represents the VFS stream.
fieldThe string constant field name to get.
Returns
On success, a copy of the value of the field. Otherwise, NULL.

Definition at line 388 of file vfs.c.

Referenced by probe_buffer_get_metadata(), and probe_by_mime().

int vfs_getc ( VFSFile file)

Reads a character from a VFS stream.

Parameters
fileVFSFile object that represents the VFS stream.
Returns
On success, a character. Otherwise, EOF.

Definition at line 235 of file vfs.c.

Referenced by vfs_fgets().

bool_t vfs_is_remote ( const char *  path)

Tests if a path is remote uri.

Parameters
pathA path to test.
Returns
TRUE if the file is remote, otherwise FALSE.

Definition at line 475 of file vfs.c.

bool_t vfs_is_streaming ( VFSFile file)

Tests if a file is associated to streaming.

Parameters
fileA VFSFile object to test.
Returns
TRUE if the file is streaming, otherwise FALSE.

Definition at line 486 of file vfs.c.

bool_t vfs_is_writeable ( const char *  path)

Tests if a file is writeable.

Parameters
pathA path to test.
Returns
TRUE if the file is writeable, otherwise FALSE.

Definition at line 456 of file vfs.c.

VFSFile* vfs_new ( const char *  path,
VFSConstructor vtable,
void *  handle 
)

Definition at line 93 of file vfs.c.

Referenced by probe_buffer_new(), and vfs_fopen().

void vfs_rewind ( VFSFile file)

Rewinds a VFS stream.

Parameters
fileVFSFile object that represents the VFS stream.

Definition at line 297 of file vfs.c.

Referenced by playback_thread().

void vfs_set_lookup_func ( VFSConstructor *(*)(const char *scheme)  func)

Definition at line 54 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

void vfs_set_verbose ( bool_t  verbose)

Definition at line 61 of file vfs.c.

Referenced by init_two().

int vfs_ungetc ( int  c,
VFSFile file 
)

Pushes a character back to the VFS stream.

Parameters
cThe character to push back.
fileVFSFile object that represents the VFS stream.
Returns
On success, 0. Otherwise, EOF.

Definition at line 253 of file vfs.c.