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...

Defines

#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.


Define 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:
file A VFSFile object to destroy.
Returns:
-1 on failure, 0 on success.

Definition at line 165 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, whether or not the VFS stream is at EOF. Otherwise, FALSE.

Definition at line 334 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:
value Pointer to the variable to read the value into.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 256 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:
value Pointer to the variable to read the value into.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 272 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:
value Pointer to the variable to read the value into.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 288 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:
value Pointer to the variable to read the value into.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 207 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:
value Pointer to the variable to read the value into.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 223 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:
value Pointer to the variable to read the value into.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 239 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:
s A buffer to put the string in.
n The amount of characters to read.
stream A VFSFile object representing the stream.
Returns:
The string on success, or NULL.

Definition at line 64 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:
filename URI of the file to read in.
buf Pointer to a pointer variable of buffer.
size Pointer to gsize variable that will hold the amount of read data e.g. filesize.

Definition at line 150 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:
path A path to test.
test A GFileTest to run.
Returns:
The result of g_file_test().

Definition at line 407 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:
path The path or URI to open.
mode The preferred access privileges (not guaranteed).
Returns:
On success, a VFSFile object representing the stream.

Definition at line 123 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:
value Value to write into the stream.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 347 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:
value Value to write into the stream.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 361 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:
value Value to write into the stream.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 375 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:
value Value to write into the stream.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 305 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:
value Value to write into the stream.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 319 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:
value Value to write into the stream.
stream A VFSFile object representing the stream.
Returns:
TRUE if read was succesful, FALSE if there was an error.

Definition at line 333 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:
ptr A pointer to the destination buffer.
size The size of each element to read.
nmemb The number of elements to read.
file VFSFile object that represents the VFS stream.
Returns:
The number of elements succesfully read.

Definition at line 194 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:
file VFSFile object that represents the VFS stream.
offset The offset to seek to.
whence Type of the seek: SEEK_CUR, SEEK_SET or SEEK_END.
Returns:
On success, 0. Otherwise, -1.

Definition at line 278 of file vfs.c.

Referenced by import_winamp_eqf(), and probe_func().

int64_t vfs_fsize ( VFSFile file  ) 

Returns size of the file.

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

Definition at line 369 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, the current position. Otherwise, -1.

Definition at line 315 of file vfs.c.

int vfs_ftruncate ( VFSFile file,
int64_t  length 
)

Truncates a VFS stream to a certain size.

Parameters:
file VFSFile object that represents the VFS stream.
length The length to truncate at.
Returns:
On success, 0. Otherwise, -1.

Definition at line 353 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:
ptr A const pointer to the source buffer.
size The size of each element to write.
nmemb The number of elements to write.
file VFSFile object that represents the VFS stream.
Returns:
The number of elements succesfully written.

Definition at line 216 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 104 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:
file VFSFile object that represents the VFS stream.
field The string constant field name to get.
Returns:
On success, a copy of the value of the field. Otherwise, NULL.

Definition at line 389 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, a character. Otherwise, EOF.

Definition at line 236 of file vfs.c.

Referenced by vfs_fgets().

bool_t vfs_is_remote ( const char *  path  ) 

Tests if a path is remote uri.

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

Definition at line 450 of file vfs.c.

Referenced by check_opened().

bool_t vfs_is_streaming ( VFSFile file  ) 

Tests if a file is associated to streaming.

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

Definition at line 461 of file vfs.c.

bool_t vfs_is_writeable ( const char *  path  ) 

Tests if a file is writeable.

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

Definition at line 431 of file vfs.c.

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

Definition at line 94 of file vfs.c.

Referenced by probe_buffer_new(), and vfs_fopen().

void vfs_rewind ( VFSFile file  ) 

Rewinds a VFS stream.

Parameters:
file VFSFile object that represents the VFS stream.

Definition at line 298 of file vfs.c.

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

Definition at line 55 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

void vfs_set_verbose ( bool_t  verbose  ) 

Definition at line 62 of file vfs.c.

Referenced by init_two().

int vfs_ungetc ( int  c,
VFSFile file 
)

Pushes a character back to the VFS stream.

Parameters:
c The character to push back.
file VFSFile object that represents the VFS stream.
Returns:
On success, 0. Otherwise, EOF.

Definition at line 254 of file vfs.c.


Generated on 3 Feb 2012 for Audacious by  doxygen 1.6.1