Mercurial > hg > th-libs
comparison th_ioctx.h @ 650:24cbab6e88c6
Remove th_io_free(), merge the functionality to th_io_close(). Add flags
allocation for certain elements and/of the th_ioctx structure itself.
Add helper function th_io_init_stdio(th_ioctx *ctx, FILE *fh) for
initializing th_ioctx with stdio fops and given file handle.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 25 Jan 2020 13:05:11 +0200 |
parents | 594f197f7005 |
children | 3c9205d52376 |
comparison
equal
deleted
inserted
replaced
649:2c9260f5cf44 | 650:24cbab6e88c6 |
---|---|
27 /** I/O context structure | 27 /** I/O context structure |
28 */ | 28 */ |
29 typedef struct th_ioctx | 29 typedef struct th_ioctx |
30 { | 30 { |
31 char *filename; ///< Context filename, if any. May be NULL. | 31 char *filename; ///< Context filename, if any. May be NULL. |
32 BOOL fallocated; ///< TRUE if filename is allocated, FALSE if "const" | |
32 char *mode; ///< Context's stdio open "mode", may also be NULL. | 33 char *mode; ///< Context's stdio open "mode", may also be NULL. |
34 BOOL mallocated; ///< TRUE if mode string is allocated, FALSE if "const" | |
35 BOOL allocated; ///< TRUE if this structure has been allocated | |
36 | |
33 void *data; ///< Internal data | 37 void *data; ///< Internal data |
34 time_t atime; ///< Last access time | 38 time_t atime; ///< Last access time |
35 int64_t size; ///< Size in bytes | 39 int64_t size; ///< Size in bytes |
36 int status; ///< Status | 40 int status; ///< Status |
37 size_t line; ///< Line number | 41 size_t line; ///< Line number |
80 // | 84 // |
81 th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename); | 85 th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename); |
82 int th_io_open(th_ioctx *ctx, const char *mode); | 86 int th_io_open(th_ioctx *ctx, const char *mode); |
83 int th_io_fopen(th_ioctx **pctx, const th_ioctx_ops *fops, const char *filename, const char *mode); | 87 int th_io_fopen(th_ioctx **pctx, const th_ioctx_ops *fops, const char *filename, const char *mode); |
84 void th_io_close(th_ioctx *ctx); | 88 void th_io_close(th_ioctx *ctx); |
85 void th_io_free(th_ioctx *ctx); | 89 |
90 void th_io_init_stdio(th_ioctx *ctx, FILE *fh); | |
86 | 91 |
87 BOOL th_io_set_handlers(th_ioctx *ctx, | 92 BOOL th_io_set_handlers(th_ioctx *ctx, |
88 void (*error)(th_ioctx *, const int, const char *msg), | 93 void (*error)(th_ioctx *, const int, const char *msg), |
89 void (*msg)(th_ioctx *, const int, const char *msg)); | 94 void (*msg)(th_ioctx *, const int, const char *msg)); |
90 | 95 |