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

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

#include <glib.h>
#include <stdio.h>
#include <sys/types.h>

Go to the source code of this file.

Classes

struct  VFSFile
 VFSFile objects describe an opened VFS stream, basically being similar in purpose as stdio FILE More...
struct  VFSConstructor
 VFSConstructor objects contain the base vtables used for extrapolating a VFS stream. More...

Defines

#define VFS_SIG   ('V' | ('F' << 8) | ('S' << 16))
#define WARN_RETURN

Functions

VFSFilevfs_fopen (const gchar *path, const gchar *mode) WARN_RETURN
 Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.
VFSFilevfs_dup (VFSFile *in) WARN_RETURN
 Increments the amount of references that are using this FD.
gint vfs_fclose (VFSFile *file)
 Closes a VFS stream and destroys a VFSFile object.
gint64 vfs_fread (void *ptr, gint64 size, gint64 nmemb, VFSFile *file) WARN_RETURN
 Reads from a VFS stream.
gint64 vfs_fwrite (const void *ptr, gint64 size, gint64 nmemb, VFSFile *file) WARN_RETURN
 Writes to a VFS stream.
gint vfs_getc (VFSFile *stream) WARN_RETURN
 Reads a character from a VFS stream.
gint vfs_ungetc (gint c, VFSFile *stream) WARN_RETURN
 Pushes a character back to the VFS stream.
gchar * vfs_fgets (gchar *s, gint n, VFSFile *stream) WARN_RETURN
 Reads a string of characters from a stream, ending in newline or EOF.
gboolean vfs_feof (VFSFile *file) WARN_RETURN
 Returns whether or not the VFS stream has reached EOF.
gint vfs_fprintf (VFSFile *stream, gchar const *format,...) __attribute__((__format__(__printf__
gint gint vfs_fseek (VFSFile *file, gint64 offset, gint whence) WARN_RETURN
 Performs a seek in given VFS stream.
void vfs_rewind (VFSFile *file)
 Rewinds a VFS stream.
gint64 vfs_ftell (VFSFile *file) WARN_RETURN
 Returns the current position in the VFS stream's buffer.
gint64 vfs_fsize (VFSFile *file) WARN_RETURN
 Returns size of the file.
gint vfs_ftruncate (VFSFile *file, gint64 length) WARN_RETURN
 Truncates a VFS stream to a certain size.
gboolean vfs_fget_le16 (guint16 *value, VFSFile *stream) WARN_RETURN
 Reads an unsigned 16-bit Little Endian value from the stream into native endian format.
gboolean vfs_fget_le32 (guint32 *value, VFSFile *stream) WARN_RETURN
 Reads an unsigned 32-bit Little Endian value from the stream into native endian format.
gboolean vfs_fget_le64 (guint64 *value, VFSFile *stream) WARN_RETURN
 Reads an unsigned 64-bit Little Endian value from the stream into native endian format.
gboolean vfs_fget_be16 (guint16 *value, VFSFile *stream) WARN_RETURN
 Reads an unsigned 16-bit Big Endian value from the stream into native endian format.
gboolean vfs_fget_be32 (guint32 *value, VFSFile *stream) WARN_RETURN
 Reads an unsigned 32-bit Big Endian value from the stream into native endian format.
gboolean vfs_fget_be64 (guint64 *value, VFSFile *stream) WARN_RETURN
 Reads an unsigned 64-bit Big Endian value from the stream into native endian format.
gboolean vfs_fput_le16 (guint16 value, VFSFile *stream) WARN_RETURN
 Writes an unsigned 16-bit native endian value into the stream as a Little Endian value.
gboolean vfs_fput_le32 (guint32 value, VFSFile *stream) WARN_RETURN
 Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_le64 (guint64 value, VFSFile *stream) WARN_RETURN
 Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_be16 (guint16 value, VFSFile *stream) WARN_RETURN
 Writes an unsigned 16-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_be32 (guint32 value, VFSFile *stream) WARN_RETURN
 Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_be64 (guint64 value, VFSFile *stream) WARN_RETURN
 Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
gboolean vfs_is_streaming (VFSFile *file) WARN_RETURN
 Tests if a file is associated to streaming.
gchar * vfs_get_metadata (VFSFile *file, const gchar *field) WARN_RETURN
 Returns metadata about the stream.
gboolean vfs_file_test (const gchar *path, GFileTest test) WARN_RETURN
 Wrapper for g_file_test().
gboolean vfs_is_writeable (const gchar *path) WARN_RETURN
 Tests if a file is writeable.
gboolean vfs_is_remote (const gchar *path) WARN_RETURN
 Tests if a path is remote uri.
void vfs_file_get_contents (const gchar *filename, void **buf, gint64 *size)
 Gets contents of the file into a buffer.
void vfs_set_lookup_func (VFSConstructor *(*func)(const gchar *scheme))
void vfs_set_verbose (gboolean 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 VFS_SIG   ('V' | ('F' << 8) | ('S' << 16))
#define WARN_RETURN

Definition at line 100 of file vfs.h.


Function Documentation

VFSFile* vfs_dup ( VFSFile in)

Increments the amount of references that are using this FD.

References are removed by calling vfs_fclose on the handle returned from this function. If the amount of references reaches zero, then the file will be closed.

Parameters:
inThe VFSFile handle to mark as duplicated.
Returns:
VFSFile handle, which is same as given input.

Definition at line 422 of file vfs.c.

gint vfs_fclose ( VFSFile file)
gboolean 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 302 of file vfs.c.

Referenced by buffered_file_vfs_feof_impl(), and probe_buffer_feof().

gboolean vfs_fget_be16 ( guint16 *  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 246 of file vfs_common.c.

gboolean vfs_fget_be32 ( guint32 *  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 262 of file vfs_common.c.

gboolean vfs_fget_be64 ( guint64 *  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 278 of file vfs_common.c.

gboolean vfs_fget_le16 ( guint16 *  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 197 of file vfs_common.c.

gboolean vfs_fget_le32 ( guint32 *  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 213 of file vfs_common.c.

gboolean vfs_fget_le64 ( guint64 *  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 229 of file vfs_common.c.

gchar* vfs_fgets ( gchar *  s,
gint  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 54 of file vfs_common.c.

void vfs_file_get_contents ( const gchar *  filename,
void **  buf,
gint64 *  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 140 of file vfs_common.c.

Referenced by vfs_async_file_get_contents_worker().

gboolean vfs_file_test ( const gchar *  path,
GFileTest  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 375 of file vfs.c.

Referenced by add_generic(), and playlist_remove_failed().

VFSFile* vfs_fopen ( const gchar *  path,
const gchar *  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 88 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(), vfs_buffered_file_new_from_uri(), and vfs_file_get_contents().

gint vfs_fprintf ( VFSFile stream,
gchar const *  format,
  ... 
)
gboolean vfs_fput_be16 ( guint16  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 337 of file vfs_common.c.

gboolean vfs_fput_be32 ( guint32  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 351 of file vfs_common.c.

gboolean vfs_fput_be64 ( guint64  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 365 of file vfs_common.c.

gboolean vfs_fput_le16 ( guint16  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 295 of file vfs_common.c.

gboolean vfs_fput_le32 ( guint32  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 309 of file vfs_common.c.

gboolean vfs_fput_le64 ( guint64  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 323 of file vfs_common.c.

gint64 vfs_fread ( void *  ptr,
gint64  size,
gint64  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 162 of file vfs.c.

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

gint gint vfs_fseek ( VFSFile file,
gint64  offset,
gint  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 246 of file vfs.c.

Referenced by buffered_file_vfs_fread_impl(), buffered_file_vfs_fseek_impl(), buffered_file_vfs_getc_impl(), import_winamp_eqf(), and probe_func().

gint64 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 337 of file vfs.c.

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

gint64 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 283 of file vfs.c.

Referenced by buffered_file_vfs_fread_impl(), buffered_file_vfs_fseek_impl(), buffered_file_vfs_ftell_impl(), and buffered_file_vfs_getc_impl().

gint vfs_ftruncate ( VFSFile file,
gint64  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 321 of file vfs.c.

gint64 vfs_fwrite ( const void *  ptr,
gint64  size,
gint64  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 184 of file vfs.c.

Referenced by buffered_file_vfs_fwrite_impl(), 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().

gchar* vfs_get_metadata ( VFSFile file,
const gchar *  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 357 of file vfs.c.

Referenced by buffered_file_vfs_metadata_impl(), probe_buffer_get_metadata(), and probe_by_mime().

gint 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 204 of file vfs.c.

Referenced by buffered_file_vfs_getc_impl(), and vfs_fgets().

gboolean vfs_is_remote ( const gchar *  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 438 of file vfs.c.

Referenced by check_opened().

gboolean 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 450 of file vfs.c.

gboolean vfs_is_writeable ( const gchar *  path)

Tests if a file is writeable.

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

Definition at line 399 of file vfs.c.

void vfs_rewind ( VFSFile file)

Rewinds a VFS stream.

Parameters:
fileVFSFile object that represents the VFS stream.

Definition at line 266 of file vfs.c.

Referenced by buffered_file_vfs_rewind_impl(), and vfs_buffered_file_new_from_uri().

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

Definition at line 40 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

void vfs_set_verbose ( gboolean  verbose)

Definition at line 47 of file vfs.c.

Referenced by init_two().

gint vfs_ungetc ( gint  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 222 of file vfs.c.