Mercurial > hg > th-libs
annotate th_ioctx.h @ 72:43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 15 Nov 2012 19:52:09 +0200 |
parents | d94af48cef7b |
children | 40568456eb5b |
rev | line source |
---|---|
67
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Standard I/O context helpers |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * (C) Copyright 2012 Tecnic Software productions (TNSP) |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #ifndef TH_IOCTX_H |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #define TH_IOCTX_H |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 #include "th_util.h" |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 #include <stdio.h> |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 #ifdef __cplusplus |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 extern "C" { |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 #endif |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 /* Simple STD I/O contexts |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 */ |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 typedef struct _th_ioctx_t |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 { |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 BOOL allocated; |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 char *filename; |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 FILE *fp; |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 size_t line; |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 void (*error)(struct _th_ioctx_t *, const int, const char *msg); |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 void (*msg)(struct _th_ioctx_t *, const char *msg); |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 } th_ioctx_t; |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
72
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
33 BOOL th_ioctx_init(th_ioctx_t *ctx, const char *filename, |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
34 void (*error)(struct _th_ioctx_t *, const int, const char *msg), |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
35 void (*msg)(struct _th_ioctx_t *, const char *msg)); |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
36 |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
37 BOOL th_ioctx_open(th_ioctx_t *ctx, const char *filename, const char *mode, |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
38 void (*error)(struct _th_ioctx_t *, const int, const char *msg), |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
39 void (*msg)(struct _th_ioctx_t *, const char *msg)); |
67
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 |
72
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
41 void th_ioctx_close(th_ioctx_t *ctx); |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
42 void th_ioctx_error(th_ioctx_t *ctx, const int err, const char *fmt, ...); |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
43 |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
44 th_ioctx_t * th_ioctx_new(const char *filename, |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
45 void (*error)(struct _th_ioctx_t *, const int, const char *msg), |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
46 void (*msg)(struct _th_ioctx_t *, const char *msg)); |
43df05a632cb
Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
47 void th_ioctx_free(th_ioctx_t *ctx); |
67
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 #ifdef __cplusplus |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 } |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 #endif |
d94af48cef7b
Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 #endif /* TH_IOCTX_H */ |