annotate th_ioctx.h @ 67:d94af48cef7b

Added new module, a simple I/O context helper.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 15 Nov 2012 19:21:14 +0200
parents
children 43df05a632cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 BOOL th_ioctx_init(th_ioctx_t *ctx, const char *filename);
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 BOOL th_ioctx_open(th_ioctx_t *ctx, const char *filename, const char *mode);
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 void th_ioctx_close(th_ioctx_t *ctx);
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 void th_ioctx_error(th_ioctx_t *ctx, const int err, const char *fmt, ...);
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 th_ioctx_t * th_ioctx_new(const char *filename);
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 void th_ioctx_free(th_ioctx_t *ctx);
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #ifdef __cplusplus
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 }
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 #endif
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 #endif /* TH_IOCTX_H */