Functions

vfs_common.c File Reference

Common code for various VFS-stream related operations. More...

#include "vfs.h"
#include <string.h>
#include <stdlib.h>
#include <glib/gprintf.h>

Go to the source code of this file.

Functions

gint vfs_fputc (gint c, VFSFile *stream)
 Writes a character to a stream.
gchar * vfs_fgets (gchar *s, gint n, VFSFile *stream)
 Reads a string of characters from a stream, ending in newline or EOF.
gint vfs_fputs (const gchar *s, VFSFile *stream)
 Writes a string to a VFS stream.
gint vfs_vfprintf (VFSFile *stream, gchar const *format, va_list args)
 Writes a formatted string to a VFS stream via a va_list of args.
gint vfs_fprintf (VFSFile *stream, gchar const *format,...)
 Writes a formatted string to a VFS stream.
void vfs_file_get_contents (const gchar *filename, void **buf, gint64 *size)
 Gets contents of the file into a buffer.
gboolean vfs_fget_le16 (guint16 *value, VFSFile *stream)
 Reads an unsigned 16-bit Little Endian value from the stream into native endian format.
gboolean vfs_fget_le32 (guint32 *value, VFSFile *stream)
 Reads an unsigned 32-bit Little Endian value from the stream into native endian format.
gboolean vfs_fget_le64 (guint64 *value, VFSFile *stream)
 Reads an unsigned 64-bit Little Endian value from the stream into native endian format.
gboolean vfs_fget_be16 (guint16 *value, VFSFile *stream)
 Reads an unsigned 16-bit Big Endian value from the stream into native endian format.
gboolean vfs_fget_be32 (guint32 *value, VFSFile *stream)
 Reads an unsigned 32-bit Big Endian value from the stream into native endian format.
gboolean vfs_fget_be64 (guint64 *value, VFSFile *stream)
 Reads an unsigned 64-bit Big Endian value from the stream into native endian format.
gboolean vfs_fput_le16 (guint16 value, VFSFile *stream)
 Writes an unsigned 16-bit native endian value into the stream as a Little Endian value.
gboolean vfs_fput_le32 (guint32 value, VFSFile *stream)
 Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_le64 (guint64 value, VFSFile *stream)
 Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_be16 (guint16 value, VFSFile *stream)
 Writes an unsigned 16-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_be32 (guint32 value, VFSFile *stream)
 Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
gboolean vfs_fput_be64 (guint64 value, VFSFile *stream)
 Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.

Detailed Description

Common code for various VFS-stream related operations.

Routines for string reading and writing and functions for reading and writing endianess-dependant integer values.

Definition in file vfs_common.c.


Function Documentation

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

Referenced by vfs_async_file_get_contents_worker().

gint vfs_fprintf ( VFSFile stream,
gchar const *  format,
  ... 
)

Writes a formatted string to a VFS stream.

Parameters:
stream A VFSFile object representing the stream.
format A printf-style format string.
... Optional list of arguments.
Returns:
The amount of bytes written.

Definition at line 119 of file vfs_common.c.

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:
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 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:
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 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:
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 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:
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 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:
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 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:
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 323 of file vfs_common.c.

gint vfs_fputc ( gint  c,
VFSFile stream 
)

Writes a character to a stream.

Parameters:
c A character to write to the stream.
stream A VFSFile object representing the stream.
Returns:
The character on success, or EOF.

Definition at line 35 of file vfs_common.c.

gint vfs_fputs ( const gchar *  s,
VFSFile stream 
)

Writes a string to a VFS stream.

Parameters:
s A string to write to the stream.
stream A VFSFile object representing the stream.
Returns:
The amount of bytes written.

Definition at line 86 of file vfs_common.c.

Referenced by vfs_vfprintf().

gint vfs_vfprintf ( VFSFile stream,
gchar const *  format,
va_list  args 
)

Writes a formatted string to a VFS stream via a va_list of args.

Parameters:
stream A VFSFile object representing the stream.
format A printf-style format string.
args A va_list of args to use.
Returns:
value The amount of bytes written.

Definition at line 101 of file vfs_common.c.

Referenced by vfs_fprintf().