Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
Classes | Macros | 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 WARN_RETURN

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.
int vfs_fclose (VFSFile *file)
 Closes a VFS stream and destroys a VFSFile object.
int64_t vfs_fread (void *ptr, int64_t size, int64_t nmemb, VFSFile *file) WARN_RETURN
 Reads from a VFS stream.
int64_t vfs_fwrite (const void *ptr, int64_t size, int64_t nmemb, VFSFile *file) WARN_RETURN
 Writes to a VFS stream.
int vfs_getc (VFSFile *stream) WARN_RETURN
 Reads a character from a VFS stream.
int vfs_ungetc (int c, VFSFile *stream) WARN_RETURN
 Pushes a character back to the VFS stream.
char * vfs_fgets (char *s, int n, VFSFile *stream) WARN_RETURN
 Reads a string of characters from a stream, ending in newline or EOF.
bool_t vfs_feof (VFSFile *file) WARN_RETURN
 Returns whether or not the VFS stream has reached EOF.
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.
void vfs_rewind (VFSFile *file)
 Rewinds a VFS stream.
int64_t vfs_ftell (VFSFile *file) WARN_RETURN
 Returns the current position in the VFS stream's buffer.
int64_t vfs_fsize (VFSFile *file) WARN_RETURN
 Returns size of the file.
int vfs_ftruncate (VFSFile *file, int64_t length) WARN_RETURN
 Truncates a VFS stream to a certain size.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
bool_t vfs_is_streaming (VFSFile *file) WARN_RETURN
 Tests if a file is associated to streaming.
char * vfs_get_metadata (VFSFile *file, const char *field) WARN_RETURN
 Returns metadata about the stream.
bool_t vfs_file_test (const char *path, int test) WARN_RETURN
 Wrapper for g_file_test().
bool_t vfs_is_writeable (const char *path) WARN_RETURN
 Tests if a file is writeable.
bool_t vfs_is_remote (const char *path) WARN_RETURN
 Tests if a path is remote uri.
void vfs_file_get_contents (const char *filename, void **buf, int64_t *size)
 Gets contents of the file into a buffer.
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 WARN_RETURN

Definition at line 84 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 167 of file vfs.c.

Referenced by file_find_decoder(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_thread(), 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 336 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 257 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 273 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 289 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 208 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 224 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 240 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 65 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 151 of file vfs_common.c.

Referenced by art_get_data(), 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 409 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 125 of file vfs.c.

Referenced by check_opened(), 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 348 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 362 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 376 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 306 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 320 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 334 of file vfs_common.c.

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 196 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 280 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 371 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 317 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 355 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 218 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 106 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 391 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 238 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 452 of file vfs.c.

Referenced by check_opened().

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 463 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 433 of file vfs.c.

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

Definition at line 96 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 300 of file vfs.c.

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

Definition at line 57 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

void vfs_set_verbose ( bool_t  verbose)

Definition at line 64 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 256 of file vfs.c.