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
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Go to the documentation of this file.
2 * MIO, an I/O abstraction layer replicating C file I/O API.
3 * Copyright (C) 2010 Colomban Wendling <>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
21#ifndef MIO_H
22#define MIO_H
24#ifndef QUALIFIER
25#include "general.h" /* must always come first */
27#include "gcc-attr.h"
30#include <stdio.h>
31#include <stdarg.h>
35 * MIOType:
36 * @MIO_TYPE_FILE: #MIO object works on a file
37 * @MIO_TYPE_MEMORY: #MIO object works in-memory
38 *
39 * Existing implementations.
40 */
46typedef enum _MIOType MIOType;
47typedef struct _MIO MIO;
48typedef struct _MIOPos MIOPos;
51 * MIOReallocFunc:
52 * @ptr: Pointer to the memory to resize
53 * @size: New size of the memory pointed by @ptr
54 *
55 * A function following the realloc() semantic.
56 *
57 * Returns: A pointer to the start of the new memory, or %NULL on failure.
58 */
59typedef void *(* MIOReallocFunc) (void * ptr, size_t size);
62 * MIOFOpenFunc:
63 * @filename: The filename to open
64 * @mode: fopen() modes for opening @filename
65 *
66 * A function following the fclose() semantic, used to close a #FILE
67 * object.
68 *
69 * Returns: A new #FILE object, or %NULL on failure
70 */
71typedef FILE *(* MIOFOpenFunc) (const char *filename, const char *mode);
74 * MIOFCloseFunc:
75 * @fp: An opened #FILE object
76 *
77 * A function following the fclose() semantic, used to close a #FILE
78 * object.
79 *
80 * Returns: 0 on success, EOF otherwise.
81 */
82typedef int (* MIOFCloseFunc) (FILE *fp);
85 * MIODestroyNotify:
86 * @data: Data element being destroyed
87 *
88 * Specifies the type of function which is called when a data element is
89 * destroyed. It is passed the pointer to the data element and should free any
90 * memory and resources allocated for it.
91 */
92typedef void (*MIODestroyNotify) (void *data);
95 * MIOPos:
96 *
97 * An object representing the state of a #MIO stream. This object can be
98 * statically allocated but all its fields are private and should not be
99 * accessed directly.
100 */
101struct _MIOPos {
102 /*< private >*/
104#ifdef MIO_DEBUG
105 void *tag;
107 union {
108 fpos_t file;
109 size_t mem;
115MIO *mio_new_file (const char *filename, const char *mode);
116MIO *mio_new_file_full (const char *filename,
117 const char *mode,
118 MIOFOpenFunc open_func,
119 MIOFCloseFunc close_func);
120MIO *mio_new_fp (FILE *fp, MIOFCloseFunc close_func);
121MIO *mio_new_memory (unsigned char *data,
122 size_t size,
123 MIOReallocFunc realloc_func,
124 MIODestroyNotify free_func);
126MIO *mio_new_mio (MIO *base, long start, long size);
127MIO *mio_ref (MIO *mio);
129int mio_unref (MIO *mio);
130FILE *mio_file_get_fp (MIO *mio);
131unsigned char *mio_memory_get_data (MIO *mio, size_t *size);
132size_t mio_read (MIO *mio,
133 void *ptr,
134 size_t size,
135 size_t nmemb);
136size_t mio_write (MIO *mio,
137 const void *ptr,
138 size_t size,
139 size_t nmemb);
140int mio_getc (MIO *mio);
141char *mio_gets (MIO *mio, char *s, size_t size);
142int mio_ungetc (MIO *mio, int ch);
143int mio_putc (MIO *mio, int c);
144int mio_puts (MIO *mio, const char *s);
146int mio_vprintf (MIO *mio, const char *format, va_list ap) CTAGS_ATTR_PRINTF (2, 0);
147int mio_printf (MIO *mio, const char *format, ...) CTAGS_ATTR_PRINTF (2, 3);
149void mio_clearerr (MIO *mio);
150int mio_eof (MIO *mio);
151int mio_error (MIO *mio);
152int mio_seek (MIO *mio, long offset, int whence);
153long mio_tell (MIO *mio);
154void mio_rewind (MIO *mio);
155int mio_getpos (MIO *mio, MIOPos *pos);
156int mio_setpos (MIO *mio, MIOPos *pos);
157int mio_flush (MIO *mio);
159void mio_attach_user_data (MIO *mio, void *user_data, MIODestroyNotify user_data_free_func);
160void *mio_get_user_data (MIO *mio);
162int mio_try_resize (MIO *mio, size_t new_size);
164#endif /* MIO_H */
GeanyBuildCommand ** ptr
Definition: build.c:2679
gint pos
Definition: editor.c:87
#define CTAGS_ATTR_PRINTF(s, f)
Definition: gcc-attr.h:23
CobolFormat format
Definition: geany_cobol.c:137
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 ...
Definition: mio.c:457
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 th...
Definition: mio.c:259
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 ...
Definition: mio.c:689
int mio_getc(MIO *mio)
mio_getc: @mio: A MIO object
Definition: mio.c:884
long mio_tell(MIO *mio)
mio_tell: @mio: A MIO object
Definition: mio.c:1174
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 ...
Definition: mio.c:234
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 t...
Definition: mio.c:800
void mio_clearerr(MIO *mio)
mio_clearerr: @mio: A MIO object
Definition: mio.c:1030
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.
Definition: mio.c:1101
int mio_eof(MIO *mio)
mio_eof: @mio: A MIO object
Definition: mio.c:1052
MIOType: @MIO_TYPE_FILE: MIO object works on a file @MIO_TYPE_MEMORY: MIO object works in-memory.
Definition: mio.h:41
Definition: mio.h:43
Definition: mio.h:42
void * mio_get_user_data(MIO *mio)
mio_get_user_data: @mio: A MIO object
Definition: mio.c:1372
int mio_try_resize(MIO *mio, size_t new_size)
Definition: mio.c:652
int mio_getpos(MIO *mio, MIOPos *pos)
mio_getpos: @mio: A MIO stream @pos: (out): A MIOPos object to fill-in
Definition: mio.c:1235
int mio_flush(MIO *mio)
mio_flush: @mio: A MIO object
Definition: mio.c:1335
void(* MIODestroyNotify)(void *data)
MIODestroyNotify: @data: Data element being destroyed.
Definition: mio.h:92
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 @mod...
Definition: mio.c:186
int mio_error(MIO *mio)
mio_error: @mio: A MIO object
Definition: mio.c:1074
void mio_rewind(MIO *mio)
mio_rewind: @mio: A MIO object
Definition: mio.c:1208
FILE * mio_file_get_fp(MIO *mio)
mio_file_get_fp: @mio: A MIO object
Definition: mio.c:432
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 byt...
Definition: mio.c:967
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 fu...
Definition: mio.c:316
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: t...
Definition: mio.c:364
int mio_printf(MIO *mio, const char *format,...)
mio_printf: @mio: A MIO object @format: A print format string ...: Arguments of the format
Definition: mio.c:863
int mio_puts(MIO *mio, const char *s)
mio_puts: @mio: A MIO object @s: The string to write
Definition: mio.c:762
void *(* MIOReallocFunc)(void *ptr, size_t size)
MIOReallocFunc: @ptr: Pointer to the memory to resize @size: New size of the memory pointed by @ptr.
Definition: mio.h:59
MIO * mio_ref(MIO *mio)
mio_ref: @mio: A MIO object
Definition: mio.c:413
int mio_ungetc(MIO *mio, int ch)
mio_ungetc: @mio: A MIO object @ch: Character to put back in the stream
Definition: mio.c:931
FILE *(* MIOFOpenFunc)(const char *filename, const char *mode)
MIOFOpenFunc: @filename: The filename to open @mode: fopen() modes for opening @filename.
Definition: mio.h:71
enum _MIOType MIOType
Definition: mio.h:46
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 ea...
Definition: mio.c:536
int mio_putc(MIO *mio, int c)
mio_putc: @mio: A MIO object : The character to write
Definition: mio.c:729
int(* MIOFCloseFunc)(FILE *fp)
MIOFCloseFunc: @fp: An opened #FILE object.
Definition: mio.h:82
int mio_unref(MIO *mio)
mio_unref: @mio: A MIO object
Definition: mio.c:480
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_fun...
Definition: mio.c:1356
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...
Definition: mio.c:1287
const gchar filename[]
Definition: stash-example.c:4
Definition: mio.h:101
size_t mem
Definition: mio.h:109
union _MIOPos::@16 impl
fpos_t file
Definition: mio.h:108
MIOType type
Definition: mio.h:103
Definition: mio.c:136