geany
1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
![]() ![]() |
Go to the source code of this file.
Classes | |
struct | _MIOPos |
MIOPos: More... | |
Typedefs | |
typedef enum _MIOType | MIOType |
typedef struct _MIO | MIO |
typedef struct _MIOPos | MIOPos |
typedef void *(* | MIOReallocFunc) (void *ptr, size_t size) |
MIOReallocFunc: @ptr: Pointer to the memory to resize @size: New size of the memory pointed by @ptr. More... | |
typedef FILE *(* | MIOFOpenFunc) (const char *filename, const char *mode) |
MIOFOpenFunc: @filename: The filename to open @mode: fopen() modes for opening @filename. More... | |
typedef int(* | MIOFCloseFunc) (FILE *fp) |
MIOFCloseFunc: @fp: An opened #FILE object. More... | |
typedef void(* | MIODestroyNotify) (void *data) |
MIODestroyNotify: @data: Data element being destroyed. More... | |
Enumerations | |
enum | _MIOType { MIO_TYPE_FILE , MIO_TYPE_MEMORY } |
MIOType: @MIO_TYPE_FILE: MIO object works on a file @MIO_TYPE_MEMORY: MIO object works in-memory. More... | |
Functions | |
MIO * | mio_new_file (const char *filename, const char *mode) |
mio_new_file: @filename: Filename to open, same as the fopen()'s first argument @mode: Mode in which open the file, fopen()'s second argument More... | |
MIO * | mio_new_file_full (const char *filename, const char *mode, MIOFOpenFunc open_func, MIOFCloseFunc close_func) |
mio_new_file_full: @filename: Filename to open, passed as-is to @open_func as the first argument @mode: Mode in which open the file, passed as-is to @open_func as the second argument @open_func: A function with the fopen() semantic to use to open the file @close_func: A function with the fclose() semantic to close the file when the MIO object is destroyed, or NULL not to close the #FILE object More... | |
MIO * | mio_new_fp (FILE *fp, MIOFCloseFunc close_func) |
mio_new_fp: @fp: An opened #FILE object @close_func: (allow-none): Function used to close @fp when the MIO object gets destroyed, or NULL not to close the #FILE object More... | |
MIO * | mio_new_memory (unsigned char *data, size_t size, MIOReallocFunc realloc_func, MIODestroyNotify free_func) |
mio_new_memory: @data: Initial data (may be NULL) @size: Length of @data in bytes @realloc_func: A function with the realloc() semantic used to grow the buffer, or NULL to disable buffer growing @free_func: A function with the free() semantic to destroy the data together with the object, or NULL not to destroy the data More... | |
MIO * | mio_new_mio (MIO *base, long start, long size) |
mio_new_mio: @base: The original mio @start: stream offset of the @base where new mio starts @size: the length of the data copied from @base to new mio More... | |
MIO * | mio_ref (MIO *mio) |
mio_ref: @mio: A MIO object More... | |
int | mio_unref (MIO *mio) |
mio_unref: @mio: A MIO object More... | |
FILE * | mio_file_get_fp (MIO *mio) |
mio_file_get_fp: @mio: A MIO object More... | |
unsigned char * | mio_memory_get_data (MIO *mio, size_t *size) |
mio_memory_get_data: @mio: A MIO object @size: (allow-none) (out): Return location for the length of the returned memory, or NULL More... | |
size_t | mio_read (MIO *mio, void *ptr, size_t size, size_t nmemb) |
mio_read: @mio: A MIO object @ptr: Pointer to the memory to fill with the read data @size: Size of each block to read @nmemb: Number o blocks to read More... | |
size_t | mio_write (MIO *mio, const void *ptr, size_t size, size_t nmemb) |
mio_write: @mio: A MIO object @ptr: Pointer to the memory to write on the stream @size: Size of each block to write @nmemb: Number of block to write More... | |
int | mio_getc (MIO *mio) |
mio_getc: @mio: A MIO object More... | |
char * | mio_gets (MIO *mio, char *s, size_t size) |
mio_gets: @mio: A MIO object @s: A string to fill with the read data @size: The maximum number of bytes to read More... | |
int | mio_ungetc (MIO *mio, int ch) |
mio_ungetc: @mio: A MIO object @ch: Character to put back in the stream More... | |
int | mio_putc (MIO *mio, int c) |
mio_putc: @mio: A MIO object : The character to write More... | |
int | mio_puts (MIO *mio, const char *s) |
mio_puts: @mio: A MIO object @s: The string to write More... | |
int | mio_vprintf (MIO *mio, const char *format, va_list ap) |
mio_vprintf: @mio: A MIO object @format: A printf format string @ap: The variadic argument list for the format More... | |
int | mio_printf (MIO *mio, const char *format,...) |
mio_printf: @mio: A MIO object @format: A print format string ...: Arguments of the format More... | |
void | mio_clearerr (MIO *mio) |
mio_clearerr: @mio: A MIO object More... | |
int | mio_eof (MIO *mio) |
mio_eof: @mio: A MIO object More... | |
int | mio_error (MIO *mio) |
mio_error: @mio: A MIO object More... | |
int | mio_seek (MIO *mio, long offset, int whence) |
mio_seek: @mio: A MIO object @offset: Offset of the new place, from @whence @whence: Move origin. More... | |
long | mio_tell (MIO *mio) |
mio_tell: @mio: A MIO object More... | |
void | mio_rewind (MIO *mio) |
mio_rewind: @mio: A MIO object More... | |
int | mio_getpos (MIO *mio, MIOPos *pos) |
mio_getpos: @mio: A MIO stream @pos: (out): A MIOPos object to fill-in More... | |
int | mio_setpos (MIO *mio, MIOPos *pos) |
mio_setpos: @mio: A MIO object @pos: (in): A MIOPos object filled-in by a previous call of mio_getpos() on the same stream More... | |
int | mio_flush (MIO *mio) |
mio_flush: @mio: A MIO object More... | |
void | mio_attach_user_data (MIO *mio, void *user_data, MIODestroyNotify user_data_free_func) |
mio_attach_user_data: @mio: A MIO object @user_data: a pointer to any data object @user_data_free_func: a call back function to destroy the data object passed as @user_data More... | |
void * | mio_get_user_data (MIO *mio) |
mio_get_user_data: @mio: A MIO object More... | |
int | mio_try_resize (MIO *mio, size_t new_size) |
typedef void(* MIODestroyNotify) (void *data) |
typedef int(* MIOFCloseFunc) (FILE *fp) |
typedef FILE *(* MIOFOpenFunc) (const char *filename, const char *mode) |
typedef void *(* MIOReallocFunc) (void *ptr, size_t size) |
enum _MIOType |
void mio_attach_user_data | ( | MIO * | mio, |
void * | user_data, | ||
MIODestroyNotify | user_data_free_func | ||
) |
mio_attach_user_data: @mio: A MIO object @user_data: a pointer to any data object @user_data_free_func: a call back function to destroy the data object passed as @user_data
Attach any data object to a MIO object. Attached data can be got with mio_get_user_data(). The attached data is destroyed when new data is attached to the MIO object, or #the MIO object itself is destroyed. For destroying the data @user_data_free_func is used.
Definition at line 1356 of file mio.c.
References _MIOUserData::d, _MIOUserData::f, and _MIO::udata.
void mio_clearerr | ( | MIO * | mio | ) |
mio_clearerr: @mio: A MIO object
Clears the error and end-of-stream indicators of a MIO stream. This function behaves the same as clearerr().
Definition at line 1030 of file mio.c.
References AssertNotReached, _MIO::eof, _MIO::error, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, and _MIO::type.
Referenced by readLineFromBypass().
int mio_eof | ( | MIO * | mio | ) |
mio_eof: @mio: A MIO object
Checks whether the end-of-stream indicator of a MIO stream is set. This function behaves the same as feof().
Returns: A non-null value if the stream reached its end, 0 otherwise.
Definition at line 1052 of file mio.c.
References AssertNotReached, _MIO::eof, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, and _MIO::type.
Referenced by internalSortTags(), readLine(), and stringListNewFromFile().
int mio_error | ( | MIO * | mio | ) |
mio_error: @mio: A MIO object
Checks whether the error indicator of a MIO stream is set. This function behaves the same as ferror().
Returns: A non-null value if the stream have an error set, 0 otherwise.
Definition at line 1074 of file mio.c.
References AssertNotReached, _MIO::error, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, and _MIO::type.
Referenced by abort_if_ferror().
FILE * mio_file_get_fp | ( | MIO * | mio | ) |
mio_file_get_fp: @mio: A MIO object
Gets the underlying #FILE object associated with a MIO file stream.
<warning>
The returned object may become invalid after a call to mio_unref() if the stream was configured to close the file when destroyed.
</warning>
Returns: The underlying #FILE object of the given stream, or NULL if the stream is not a file stream.
Definition at line 432 of file mio.c.
References _MIO::file, _MIO::fp, _MIO::impl, MIO_TYPE_FILE, NULL, and _MIO::type.
int mio_flush | ( | MIO * | mio | ) |
mio_flush: @mio: A MIO object
Forces a write of all user-space buffered data for the given output or update stream via the stream's underlying write function. Only applicable when using FILE back-end.
Returns: 0 on success, error code otherwise.
Definition at line 1335 of file mio.c.
References _MIO::file, _MIO::fp, _MIO::impl, MIO_TYPE_FILE, and _MIO::type.
Referenced by closeTagFile(), writeSortedTags(), and writeTagEntry().
void * mio_get_user_data | ( | MIO * | mio | ) |
mio_get_user_data: @mio: A MIO object
Returns: user data attached with mio_attach_user_data() to a MIO object.
Definition at line 1372 of file mio.c.
References _MIOUserData::d, and _MIO::udata.
Referenced by getInputFileUserData().
int mio_getc | ( | MIO * | mio | ) |
mio_getc: @mio: A MIO object
Gets the current character from a MIO stream. This function behaves the same as fgetc().
Returns: The read character as a #int, or EOF on error.
Definition at line 884 of file mio.c.
References AssertNotReached, _MIO::buf, _MIO::eof, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, _MIO::size, _MIO::type, and _MIO::ungetch.
Referenced by catFile(), checkUTF8BOM(), rewindInputFile(), and updateSortedFlag().
mio_getpos: @mio: A MIO stream @pos: (out): A MIOPos object to fill-in
Stores the current position (and maybe other informations about the stream state) of a MIO stream in order to restore it later with mio_setpos(). This function behaves the same as fgetpos().
Returns: 0 on success, -1 otherwise, in which case errno is set to indicate the error.
Definition at line 1235 of file mio.c.
References AssertNotReached, errno, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, pos, and _MIO::type.
Referenced by iFileGetLine(), openInputFile(), readLineFromBypass(), resetInputFile(), tagFilePosition(), updatePseudoTags(), and updateSortedFlag().
char * mio_gets | ( | MIO * | mio, |
char * | s, | ||
size_t | size | ||
) |
mio_gets: @mio: A MIO object @s: A string to fill with the read data @size: The maximum number of bytes to read
Reads a string from a MIO stream, stopping after the first new-line character or at the end of the stream. This function behaves the same as fgets().
Returns: @s on success, NULL otherwise.
Definition at line 967 of file mio.c.
References AssertNotReached, _MIO::buf, _MIO::eof, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, NULL, _MIO::pos, pos, _MIO::size, _MIO::type, and _MIO::ungetch.
Referenced by readLine(), and selectByLines().
unsigned char * mio_memory_get_data | ( | MIO * | mio, |
size_t * | size | ||
) |
mio_memory_get_data: @mio: A MIO object @size: (allow-none) (out): Return location for the length of the returned memory, or NULL
Gets the underlying memory buffer associated with a MIO memory stream.
<warning>
The returned pointer and size may become invalid after a successful write on the stream or after a call to mio_unref() if the stream was configured to free the memory when destroyed.
</warning>
Returns: The memory buffer of the given MIO stream, or NULL if the stream is not a memory stream.
Definition at line 457 of file mio.c.
References _MIO::buf, _MIO::impl, _MIO::mem, MIO_TYPE_MEMORY, NULL, ptr, _MIO::size, and _MIO::type.
Referenced by getInputFileData(), openInputFile(), and pushNarrowedInputStream().
MIO * mio_new_file | ( | const char * | filename, |
const char * | mode | ||
) |
mio_new_file: @filename: Filename to open, same as the fopen()'s first argument @mode: Mode in which open the file, fopen()'s second argument
Creates a new MIO object working on a file from a filename; wrapping fopen(). This function simply calls mio_new_file_full() with the libc's fopen() and fclose() functions.
Free-function: mio_unref()
Returns: A new MIO on success, or NULL on failure.
Definition at line 234 of file mio.c.
References filename, and mio_new_file_full().
Referenced by copyFile(), getMio(), internalSortTagFile(), isTagFile(), openTagFile(), processTagRegexOption(), stringListNewFromFile(), and writeSortedTags().
MIO * mio_new_file_full | ( | const char * | filename, |
const char * | mode, | ||
MIOFOpenFunc | open_func, | ||
MIOFCloseFunc | close_func | ||
) |
mio_new_file_full: @filename: Filename to open, passed as-is to @open_func as the first argument @mode: Mode in which open the file, passed as-is to @open_func as the second argument @open_func: A function with the fopen() semantic to use to open the file @close_func: A function with the fclose() semantic to close the file when the MIO object is destroyed, or NULL not to close the #FILE object
Creates a new MIO object working on a file, from a filename and an opening function. See also mio_new_file().
This function is generally overkill and mio_new_file() should often be used instead, but it allows to specify a custom function to open a file, as well as a close function. The former is useful e.g. if you need to wrap fopen() for some reason (like filename encoding conversion for example), and the latter allows you both to match your custom open function and to choose whether the underlying #FILE object should or not be closed when mio_unref() is called on the returned object.
Free-function: mio_unref()
Returns: A new MIO on success, or NULL on failure.
Definition at line 186 of file mio.c.
References _MIO::close_func, _MIOUserData::d, eFree(), _MIOUserData::f, _MIO::file, filename, _MIO::fp, _MIO::impl, MIO_TYPE_FILE, NULL, _MIO::refcount, _MIO::type, _MIO::udata, and xMalloc.
Referenced by mio_new_file().
MIO * mio_new_fp | ( | FILE * | fp, |
MIOFCloseFunc | close_func | ||
) |
mio_new_fp: @fp: An opened #FILE object @close_func: (allow-none): Function used to close @fp when the MIO object gets destroyed, or NULL not to close the #FILE object
Creates a new MIO object working on a file, from an already opened #FILE object.
<title>Typical use of this function</title> <programlisting> MIO *mio = mio_new_fp (fp, fclose); </programlisting>
Free-function: mio_unref()
Returns: A new MIO on success or NULL on failure.
Definition at line 259 of file mio.c.
References _MIO::close_func, _MIOUserData::d, _MIOUserData::f, _MIO::file, _MIO::fp, _MIO::impl, MIO_TYPE_FILE, NULL, _MIO::refcount, _MIO::type, _MIO::udata, and xMalloc.
Referenced by tempFile(), and writeSortedTags().
MIO * mio_new_memory | ( | unsigned char * | data, |
size_t | size, | ||
MIOReallocFunc | realloc_func, | ||
MIODestroyNotify | free_func | ||
) |
mio_new_memory: @data: Initial data (may be NULL) @size: Length of @data in bytes @realloc_func: A function with the realloc() semantic used to grow the buffer, or NULL to disable buffer growing @free_func: A function with the free() semantic to destroy the data together with the object, or NULL not to destroy the data
Creates a new MIO object working on memory.
To allow the buffer to grow, you must provide a @realloc_func, otherwise trying to write after the end of the current data will fail.
If you want the buffer to be freed together with the MIO object, you must give a @free_func; otherwise the data will still live after MIO object termination.
<title>Basic creation of a non-growable, freeable MIO object</title> <programlisting> MIO *mio = mio_new_memory (data, size, NULL, g_free); </programlisting>
<title>Basic creation of an empty growable and freeable MIO object</title> <programlisting> MIO *mio = mio_new_memory (NULL, 0, g_try_realloc, g_free); </programlisting>
Free-function: mio_unref()
Returns: A new MIO on success, or NULL on failure.
Definition at line 316 of file mio.c.
References _MIO::allocated_size, _MIO::buf, _MIOUserData::d, _MIO::eof, _MIO::error, _MIOUserData::f, _MIO::free_func, _MIO::impl, _MIO::mem, MIO_TYPE_MEMORY, NULL, _MIO::pos, _MIO::realloc_func, _MIO::refcount, _MIO::size, _MIO::type, _MIO::udata, _MIO::ungetch, and xMalloc.
Referenced by getMio(), mio_new_mio(), openTagFile(), and parseRawBuffer().
mio_new_mio: @base: The original mio @start: stream offset of the @base where new mio starts @size: the length of the data copied from @base to new mio
Creates a new MIO object by copying data from existing MIO (@base). The range for copying is given with @start and @size. Copying data at the range from @start to the end of @base is done if -1 is given as @size.
If @size is larger than the length from @start to the end of @base, NULL is returned.
The function doesn't move the file position of @base.
Free-function: mio_unref()
Definition at line 364 of file mio.c.
References Assert, eFree(), eFreeNoNullCheck(), eRealloc(), mio_new_memory(), mio_read(), mio_seek(), mio_tell(), NULL, and xMalloc.
Referenced by pushNarrowedInputStream().
int mio_printf | ( | MIO * | mio, |
const char * | format, | ||
... | |||
) |
mio_printf: @mio: A MIO object @format: A print format string ...: Arguments of the format
Writes a formatted string to a MIO stream. This function behaves the same as fprintf().
Returns: The number of bytes written to the stream, or a negative value on failure.
Definition at line 863 of file mio.c.
References format, and mio_vprintf().
Referenced by addExtensionFields(), addParserFields(), endEtagsFile(), printTagField(), renderExtensionFieldMaybe(), writeCtagsEntry(), writeCtagsPtagEntry(), writeEtagsEntry(), writeEtagsIncludes(), and writeLineNumberEntry().
int mio_putc | ( | MIO * | mio, |
int | c | ||
) |
mio_putc: @mio: A MIO object : The character to write
Writes a character to a MIO stream. This function behaves the same as fputc().
Returns: The written character, or EOF on error.
Definition at line 729 of file mio.c.
References AssertNotReached, _MIO::buf, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, mem_try_ensure_space(), MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, and _MIO::type.
Referenced by updateSortedFlag(), writeSortedTags(), and writeXrefEntry().
int mio_puts | ( | MIO * | mio, |
const char * | s | ||
) |
mio_puts: @mio: A MIO object @s: The string to write
Writes a string to a MIO object. This function behaves the same as fputs().
Returns: A non-negative integer on success or EOF on failure.
Definition at line 762 of file mio.c.
References AssertNotReached, _MIO::buf, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, mem_try_ensure_space(), MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, and _MIO::type.
Referenced by endEtagsFile(), printLiteral(), printTagField(), writeCtagsEntry(), and writeSortedTags().
size_t mio_read | ( | MIO * | mio, |
void * | ptr_, | ||
size_t | size, | ||
size_t | nmemb | ||
) |
mio_read: @mio: A MIO object @ptr: Pointer to the memory to fill with the read data @size: Size of each block to read @nmemb: Number o blocks to read
Reads raw data from a MIO stream. This function behave the same as fread().
Returns: The number of actually read blocks. If an error occurs or if the end of the stream is reached, the return value may be smaller than the requested block count, or even 0. This function doesn't distinguish between end-of-stream and an error, you should then use mio_eof() and mio_error() to determine which occurred.
Definition at line 536 of file mio.c.
References AssertNotReached, _MIO::buf, _MIO::eof, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, ptr, _MIO::size, _MIO::type, and _MIO::ungetch.
Referenced by copyBytes(), and mio_new_mio().
mio_ref: @mio: A MIO object
Increments the reference counter of a MIO.
Returns: passed @mio.
Definition at line 413 of file mio.c.
References _MIO::refcount.
Referenced by getFileLanguageForRequestInternal(), and openInputFile().
void mio_rewind | ( | MIO * | mio | ) |
mio_rewind: @mio: A MIO object
Resets the cursor position to 0, and also the end-of-stream and the error indicators of a MIO stream. See also mio_seek() and mio_clearerr().
Definition at line 1208 of file mio.c.
References AssertNotReached, _MIO::eof, _MIO::error, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, _MIO::type, and _MIO::ungetch.
Referenced by checkUTF8BOM(), endEtagsFile(), getFileLanguageForRequestInternal(), openInputFile(), rewindInputFile(), and tasteLanguage().
int mio_seek | ( | MIO * | mio, |
long | offset, | ||
int | whence | ||
) |
mio_seek: @mio: A MIO object @offset: Offset of the new place, from @whence @whence: Move origin.
SEEK_SET moves relative to the start of the stream, SEEK_CUR from the current position and SEEK_SET from the end of the stream.
Sets the cursor position on a MIO stream. This functions behaves the same as fseek(). See also mio_tell() and mio_setpos().
Returns: 0 on success, -1 otherwise, in which case errno should be set to indicate the error.
Definition at line 1101 of file mio.c.
References AssertNotReached, _MIO::eof, errno, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, _MIO::size, _MIO::type, and _MIO::ungetch.
Referenced by catFile(), closeTagFile(), extractEmacsModeLanguageAtEOF(), internalSortTagFile(), mio_new_mio(), and pushNarrowedInputStream().
mio_setpos: @mio: A MIO object @pos: (in): A MIOPos object filled-in by a previous call of mio_getpos() on the same stream
Restores the position and state indicators of a MIO stream previously saved by mio_getpos().
<warning>
The MIOPos object must have been initialized by a previous call to mio_getpos() on the same stream.
</warning>
Returns: 0 on success, -1 otherwise, in which case errno is set to indicate the error.
Definition at line 1287 of file mio.c.
References AssertNotReached, errno, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, pos, _MIO::size, _MIO::type, and _MIO::ungetch.
Referenced by pushNarrowedInputStream(), readLineFromBypass(), setTagFilePosition(), and updateSortedFlag().
long mio_tell | ( | MIO * | mio | ) |
mio_tell: @mio: A MIO object
Gets the current cursor position of a MIO stream. This function behaves the same as ftell().
Returns: The current offset from the start of the stream, or -1 or error, in which case errno is set to indicate the error.
Definition at line 1174 of file mio.c.
References AssertNotReached, errno, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, and _MIO::type.
Referenced by closeTagFile(), iFileGetLine(), mio_new_mio(), openInputFile(), pushNarrowedInputStream(), readLineFromBypass(), and resetInputFile().
int mio_try_resize | ( | MIO * | mio, |
size_t | new_size | ||
) |
int mio_ungetc | ( | MIO * | mio, |
int | ch | ||
) |
mio_ungetc: @mio: A MIO object @ch: Character to put back in the stream
Puts a character back in a MIO stream. This function behaves the sames as ungetc().
<warning>
It is only guaranteed that one character can be but back at a time, even if the implementation may allow more.
</warning> <warning>
Using this function while the stream cursor is at offset 0 is not guaranteed to function properly. As the C99 standard says, it is "an obsolescent feature".
</warning>
Returns: The character put back, or EOF on error.
Definition at line 931 of file mio.c.
References AssertNotReached, _MIO::eof, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, _MIO::type, and _MIO::ungetch.
int mio_unref | ( | MIO * | mio | ) |
mio_unref: @mio: A MIO object
Decrements the reference counter of a MIO and destroys the MIO object if its counter becomes 0.
Returns: Error code obtained from the registered MIOFCloseFunc or 0 on success.
Definition at line 480 of file mio.c.
References _MIO::allocated_size, AssertNotReached, _MIO::buf, _MIO::close_func, _MIOUserData::d, eFree(), _MIO::eof, _MIO::error, _MIOUserData::f, _MIO::file, _MIO::fp, _MIO::free_func, _MIO::impl, _MIO::mem, MIO_TYPE_FILE, MIO_TYPE_MEMORY, NULL, _MIO::pos, _MIO::realloc_func, _MIO::refcount, _MIO::size, _MIO::type, and _MIO::udata.
Referenced by closeInputFile(), closeTagFile(), copyFile(), endEtagsFile(), failedSort(), internalSortTagFile(), isTagFile(), openInputFile(), openTagFile(), parseFileWithMio(), parseRawBuffer(), popNarrowedInputStream(), processTagRegexOption(), replacementTruncate(), stringListNewFromFile(), and writeSortedTags().
int mio_vprintf | ( | MIO * | mio, |
const char * | format, | ||
va_list | ap | ||
) |
mio_vprintf: @mio: A MIO object @format: A printf format string @ap: The variadic argument list for the format
Writes a formatted string into a MIO stream. This function behaves the same as vfprintf().
Returns: The number of bytes written in the stream, or a negative value on failure.
Definition at line 800 of file mio.c.
References AssertNotReached, _MIO::buf, dummy, _MIO::file, format, _MIO::fp, _MIO::impl, MAX, _MIO::mem, mem_try_ensure_space(), MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, _MIO::size, _MIO::type, and va_copy.
Referenced by mio_printf().
size_t mio_write | ( | MIO * | mio, |
const void * | ptr, | ||
size_t | size, | ||
size_t | nmemb | ||
) |
mio_write: @mio: A MIO object @ptr: Pointer to the memory to write on the stream @size: Size of each block to write @nmemb: Number of block to write
Writes raw data to a MIO stream. This function behaves the same as fwrite().
Returns: The number of blocks actually written to the stream. This might be smaller than the requested count if a write error occurs.
Definition at line 689 of file mio.c.
References AssertNotReached, _MIO::buf, _MIO::file, _MIO::fp, _MIO::impl, _MIO::mem, mem_try_ensure_space(), MIO_TYPE_FILE, MIO_TYPE_MEMORY, _MIO::pos, ptr, and _MIO::type.
Referenced by copyBytes().