annotate th_ioctx.h @ 686:dfc2c9f0577f

Add functions thfopen(ctx) and thfclose(ctx) to th_ioctx.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Mar 2020 00:16:30 +0200
parents 927772fb0745
children a622d21833e1
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 /*
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
2 * Simple I/O abstraction and context handling layer
67
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
553
3a852e9f70a6 Bump copyright years.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
4 * (C) Copyright 2012-2020 Tecnic Software productions (TNSP)
67
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 */
653
3c9205d52376 Doxygen fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 650
diff changeset
8 /// @file
3c9205d52376 Doxygen fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 650
diff changeset
9 /// @brief Simple I/O abstraction and context handling layer
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #ifndef TH_IOCTX_H
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #define TH_IOCTX_H
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #include "th_util.h"
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
14 #include <time.h>
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
92
40568456eb5b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
16
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #ifdef __cplusplus
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 extern "C" {
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 #endif
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
616
594f197f7005 Slight improvements to the almost non-existing Doxygen documentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 577
diff changeset
22 //
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
23 // Typedefs and structures
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
24 //
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
25 struct th_ioctx;
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
26 struct th_ioctx_ops;
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
27
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
28
436
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
29 /** I/O context structure
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
30 */
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
31 typedef struct th_ioctx
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 {
436
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
33 char *filename; ///< Context filename, if any. May be NULL.
650
24cbab6e88c6 Remove th_io_free(), merge the functionality to th_io_close(). Add flags
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
34 BOOL fallocated; ///< TRUE if filename is allocated, FALSE if "const"
436
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
35 char *mode; ///< Context's stdio open "mode", may also be NULL.
650
24cbab6e88c6 Remove th_io_free(), merge the functionality to th_io_close(). Add flags
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
36 BOOL mallocated; ///< TRUE if mode string is allocated, FALSE if "const"
24cbab6e88c6 Remove th_io_free(), merge the functionality to th_io_close(). Add flags
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
37 BOOL allocated; ///< TRUE if this structure has been allocated
24cbab6e88c6 Remove th_io_free(), merge the functionality to th_io_close(). Add flags
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
38
436
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
39 void *data; ///< Internal data
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
40 time_t atime; ///< Last access time
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
41 int64_t size; ///< Size in bytes
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
42 int status; ///< Status
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
43 size_t line; ///< Line number
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
675
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
45 // Mem data
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
46 size_t maxSize; ///< Maximum size (0 = no limit)
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
47 size_t memSize; ///< Size of data
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
48 size_t memAlloc; ///< Amount allocated
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
49 size_t minAlloc; ///< Minimum allocation increase (0 = default)
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
50 off_t memOffset; ///< Current offset in data
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
51 uint8_t *memData; ///< Pointer to data
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
52
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
53 // Message functions
477
96d137a6b392 Improve ioctx API. This breaks backwards compatibility of th_io_fopen().
Matti Hamalainen <ccr@tnsp.org>
parents: 457
diff changeset
54 void (*error)(struct th_ioctx *ctx, const int err, const char *msg);
96d137a6b392 Improve ioctx API. This breaks backwards compatibility of th_io_fopen().
Matti Hamalainen <ccr@tnsp.org>
parents: 457
diff changeset
55 void (*msg)(struct th_ioctx *ctx, const int level, const char *msg);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
56
436
9148bc3fa838 Begin adding Doxygen documentation for some things. Very rudimentary, and
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
57 const struct th_ioctx_ops *fops; ///< Pointer to I/O ops struct to be used with this context
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
58 } th_ioctx;
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
59
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
60
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
61 typedef struct th_ioctx_ops
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
62 {
616
594f197f7005 Slight improvements to the almost non-existing Doxygen documentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 577
diff changeset
63 char *name; ///< Name of this I/O ops definition
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
64
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
65 int (*fopen)(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
66 void (*fclose)(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
67
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
68 int (*freset)(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
69 int (*ferror)(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
70 int (*fseek)(th_ioctx *ctx, const off_t, const int whence);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
71 off_t (*fsize)(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
72 off_t (*ftell)(th_ioctx *ctx);
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
73 BOOL (*feof)(th_ioctx *ctx);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
74 int (*fgetc)(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
75 int (*fputc)(int, th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
76 size_t (*fread)(void *ptr, const size_t, const size_t, th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
77 size_t (*fwrite)(const void *ptr, const size_t, const size_t, th_ioctx *ctx);
208
3635415a2d03 More work on th_ioctx stuff and wrappers.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
78
3635415a2d03 More work on th_ioctx stuff and wrappers.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
79 char * (*fgets)(char *str, int size, th_ioctx *ctx);
3635415a2d03 More work on th_ioctx stuff and wrappers.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
80 int (*fputs)(const char *str, th_ioctx *ctx);
3635415a2d03 More work on th_ioctx stuff and wrappers.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
81 int (*vfprintf)(th_ioctx *ctx, const char *fmt, va_list ap);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
82
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
83 } th_ioctx_ops;
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
84
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
85
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
86 //
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
87 // Some basic iops
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
88 //
675
fb4093ad1f7b Add MemIO ioctx functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 653
diff changeset
89 extern const th_ioctx_ops th_stdio_io_ops, th_mem_io_ops;
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
90
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
93 //
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
94 // I/O context management functions
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
95 //
209
462b837ea492 Change io context API. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
96 th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename);
462b837ea492 Change io context API. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
97 int th_io_open(th_ioctx *ctx, const char *mode);
477
96d137a6b392 Improve ioctx API. This breaks backwards compatibility of th_io_fopen().
Matti Hamalainen <ccr@tnsp.org>
parents: 457
diff changeset
98 int th_io_fopen(th_ioctx **pctx, const th_ioctx_ops *fops, const char *filename, const char *mode);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
99 void th_io_close(th_ioctx *ctx);
650
24cbab6e88c6 Remove th_io_free(), merge the functionality to th_io_close(). Add flags
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
100
24cbab6e88c6 Remove th_io_free(), merge the functionality to th_io_close(). Add flags
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
101 void th_io_init_stdio(th_ioctx *ctx, FILE *fh);
72
43df05a632cb Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 67
diff changeset
102
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
103 BOOL th_io_set_handlers(th_ioctx *ctx,
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
104 void (*error)(th_ioctx *, const int, const char *msg),
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
105 void (*msg)(th_ioctx *, const int, const char *msg));
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
106
519
e1b15fb56ddf Change return value of th_io_error() and th_io_error_v() to int, and return the error code.
Matti Hamalainen <ccr@tnsp.org>
parents: 481
diff changeset
107 int th_io_error_v(th_ioctx *ctx, const int err, const char *fmt, va_list ap);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
108 void th_io_msg_v(th_ioctx *ctx, const int level, const char *fmt, va_list ap);
570
262411458cde Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
109 int th_io_error(th_ioctx *ctx, const int err, const char *fmt, ...)
577
70d44ba005ac Define a helper macro for __attribute__ ((__format__ (__printf__, 2, 3)))
Matti Hamalainen <ccr@tnsp.org>
parents: 570
diff changeset
110 TH_ATTR_PRINTF_FMT(3, 4);
570
262411458cde Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
111 void th_io_msg(th_ioctx *ctx, const int level, const char *fmt, ...)
577
70d44ba005ac Define a helper macro for __attribute__ ((__format__ (__printf__, 2, 3)))
Matti Hamalainen <ccr@tnsp.org>
parents: 570
diff changeset
112 TH_ATTR_PRINTF_FMT(3, 4);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
113
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
115 //
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
116 // Basic I/O operations
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
117 //
686
dfc2c9f0577f Add functions thfopen(ctx) and thfclose(ctx) to th_ioctx.
Matti Hamalainen <ccr@tnsp.org>
parents: 677
diff changeset
118 int thfopen(th_ioctx *ctx);
dfc2c9f0577f Add functions thfopen(ctx) and thfclose(ctx) to th_ioctx.
Matti Hamalainen <ccr@tnsp.org>
parents: 677
diff changeset
119 void thfclose(th_ioctx *ctx);
dfc2c9f0577f Add functions thfopen(ctx) and thfclose(ctx) to th_ioctx.
Matti Hamalainen <ccr@tnsp.org>
parents: 677
diff changeset
120
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
121 int thfreset(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
122 int thferror(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
123 int thfseek(th_ioctx *ctx, const off_t, const int whence);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
124 off_t thfsize(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
125 off_t thftell(th_ioctx *ctx);
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
126 BOOL thfeof(th_ioctx *ctx);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
127 int thfgetc(th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
128 int thfputc(int ch, th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
129 size_t thfread(void *ptr, const size_t, const size_t, th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
130 size_t thfwrite(const void *, const size_t, const size_t, th_ioctx *ctx);
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
131 char * thfgets(char *ptr, int size, th_ioctx *ctx);
208
3635415a2d03 More work on th_ioctx stuff and wrappers.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
132 int thfputs(const char *ptr, th_ioctx *ctx);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
133 int thvfprintf(th_ioctx *ctx, const char *fmt, va_list ap);
570
262411458cde Add __attribute__(__format__ ..) specifiers for functions that use printf() style format specifiers.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
134 int thfprintf(th_ioctx *ctx, const char *fmt, ...)
577
70d44ba005ac Define a helper macro for __attribute__ ((__format__ (__printf__, 2, 3)))
Matti Hamalainen <ccr@tnsp.org>
parents: 570
diff changeset
135 TH_ATTR_PRINTF_FMT(2, 3);
72
43df05a632cb Break I/O context API, add function pointers to init/open/new functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 67
diff changeset
136
677
927772fb0745 Oops, fix the return type of thfread_str() and thfwrite_str().
Matti Hamalainen <ccr@tnsp.org>
parents: 675
diff changeset
137 BOOL thfread_str(th_ioctx *ctx, void *ptr, const size_t len);
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
138 BOOL thfread_u8(th_ioctx *ctx, uint8_t *);
677
927772fb0745 Oops, fix the return type of thfread_str() and thfwrite_str().
Matti Hamalainen <ccr@tnsp.org>
parents: 675
diff changeset
139 BOOL thfwrite_str(th_ioctx *ctx, const void *ptr, const size_t len);
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
140 BOOL thfwrite_u8(th_ioctx *ctx, const uint8_t);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
141
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
142
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
143 //
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
144 // Endian-handling file read/write routines
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
145 //
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
146 BOOL thfwrite_ne16(th_ioctx *ctx, const uint16_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
147 BOOL thfwrite_ne32(th_ioctx *ctx, const uint32_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
148 BOOL thfwrite_ne64(th_ioctx *ctx, const uint64_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
149 BOOL thfread_ne16(th_ioctx *ctx, uint16_t *v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
150 BOOL thfread_ne32(th_ioctx *ctx, uint32_t *v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
151 BOOL thfread_ne64(th_ioctx *ctx, uint64_t *v);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
152
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
153 BOOL thfwrite_le16(th_ioctx *ctx, const uint16_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
154 BOOL thfwrite_le32(th_ioctx *ctx, const uint32_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
155 BOOL thfwrite_le64(th_ioctx *ctx, const uint64_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
156 BOOL thfread_le16(th_ioctx *ctx, uint16_t *v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
157 BOOL thfread_le32(th_ioctx *ctx, uint32_t *v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
158 BOOL thfread_le64(th_ioctx *ctx, uint64_t *v);
202
b392293047da Refactor I/O contexts. Breaks API and all that.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
159
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
160 BOOL thfwrite_be16(th_ioctx *ctx, const uint16_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
161 BOOL thfwrite_be32(th_ioctx *ctx, const uint32_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
162 BOOL thfwrite_be64(th_ioctx *ctx, const uint64_t v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
163 BOOL thfread_be16(th_ioctx *ctx, uint16_t *v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
164 BOOL thfread_be32(th_ioctx *ctx, uint32_t *v);
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
165 BOOL thfread_be64(th_ioctx *ctx, uint64_t *v);
67
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 #ifdef __cplusplus
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 }
d94af48cef7b Added new module, a simple I/O context helper.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 #endif
129
aa2d608fb3f3 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
171 #endif // TH_IOCTX_H