diff th_ioctx.h @ 771:c17eadc60c3d

Rename th_ioctx struct to th_ioctx_t, for consistency. Breaks API.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 20 Feb 2023 23:33:45 +0200
parents 8eca15bde07d
children 1959ba53e9dc
line wrap: on
line diff
--- a/th_ioctx.h	Sun Feb 12 14:08:09 2023 +0200
+++ b/th_ioctx.h	Mon Feb 20 23:33:45 2023 +0200
@@ -22,13 +22,13 @@
 //
 // Typedefs and structures
 //
-struct th_ioctx;
-struct th_ioctx_ops;
+struct th_ioctx_t;
+struct th_ioctx_t_ops;
 
 
 /** I/O context structure
  */
-typedef struct th_ioctx
+typedef struct th_ioctx_t
 {
     char *filename;     ///< Context filename, if any. May be NULL.
     bool fn_allocated;  ///< true if filename is allocated, false if "const"
@@ -53,118 +53,118 @@
     bool   memWrite;    ///< true = memory can be written to / expanded etc. false = no
 
     // Message functions
-    void (*error)(struct th_ioctx *ctx, const int err, const char *msg);
-    void (*msg)(struct th_ioctx *ctx, const int level, const char *msg);
+    void (*error)(struct th_ioctx_t *ctx, const int err, const char *msg);
+    void (*msg)(struct th_ioctx_t *ctx, const int level, const char *msg);
 
-    const struct th_ioctx_ops *fops; ///< Pointer to I/O ops struct to be used with this context
-} th_ioctx;
+    const struct th_ioctx_t_ops *fops; ///< Pointer to I/O ops struct to be used with this context
+} th_ioctx_t;
 
 
-typedef struct th_ioctx_ops
+typedef struct th_ioctx_t_ops
 {
     char    *name;                       ///< Name of this I/O ops definition
 
-    int     (*fopen)(th_ioctx *ctx);
-    void    (*fclose)(th_ioctx *ctx);
+    int     (*fopen)(th_ioctx_t *ctx);
+    void    (*fclose)(th_ioctx_t *ctx);
 
-    int     (*freset)(th_ioctx *ctx);
-    int     (*ferror)(th_ioctx *ctx);
-    int     (*fseek)(th_ioctx *ctx, const off_t, const int whence);
-    off_t   (*fsize)(th_ioctx *ctx);
-    off_t   (*ftell)(th_ioctx *ctx);
-    bool    (*feof)(th_ioctx *ctx);
-    int     (*fgetc)(th_ioctx *ctx);
-    int     (*fputc)(int, th_ioctx *ctx);
-    size_t  (*fread)(void *ptr, const size_t, const size_t, th_ioctx *ctx);
-    size_t  (*fwrite)(const void *ptr, const size_t, const size_t, th_ioctx *ctx);
+    int     (*freset)(th_ioctx_t *ctx);
+    int     (*ferror)(th_ioctx_t *ctx);
+    int     (*fseek)(th_ioctx_t *ctx, const off_t, const int whence);
+    off_t   (*fsize)(th_ioctx_t *ctx);
+    off_t   (*ftell)(th_ioctx_t *ctx);
+    bool    (*feof)(th_ioctx_t *ctx);
+    int     (*fgetc)(th_ioctx_t *ctx);
+    int     (*fputc)(int, th_ioctx_t *ctx);
+    size_t  (*fread)(void *ptr, const size_t, const size_t, th_ioctx_t *ctx);
+    size_t  (*fwrite)(const void *ptr, const size_t, const size_t, th_ioctx_t *ctx);
 
-    char *  (*fgets)(char *str, int size, th_ioctx *ctx);
-    int     (*fputs)(const char *str, th_ioctx *ctx);
-    int     (*vfprintf)(th_ioctx *ctx, const char *fmt, va_list ap);
+    char *  (*fgets)(char *str, int size, th_ioctx_t *ctx);
+    int     (*fputs)(const char *str, th_ioctx_t *ctx);
+    int     (*vfprintf)(th_ioctx_t *ctx, const char *fmt, va_list ap);
 
-} th_ioctx_ops;
+} th_ioctx_t_ops;
 
 
 //
 // Some basic iops
 //
-extern const th_ioctx_ops th_stdio_io_ops, th_mem_io_ops;
+extern const th_ioctx_t_ops th_stdio_io_ops, th_mem_io_ops;
 
 
 
 //
 // I/O context management functions
 //
-th_ioctx *   th_io_new(const th_ioctx_ops *fops, const char *filename, const char *mode);
-int          th_io_fopen(th_ioctx **pctx, const th_ioctx_ops *fops, const char *filename, const char *mode);
-int          th_io_reopen(th_ioctx *ctx, const char *mode);
-void         th_io_close(th_ioctx *ctx);
+th_ioctx_t *   th_io_new(const th_ioctx_t_ops *fops, const char *filename, const char *mode);
+int          th_io_fopen(th_ioctx_t **pctx, const th_ioctx_t_ops *fops, const char *filename, const char *mode);
+int          th_io_reopen(th_ioctx_t *ctx, const char *mode);
+void         th_io_close(th_ioctx_t *ctx);
 
-void         th_io_init_stdio(th_ioctx *ctx, FILE *fh);
+void         th_io_init_stdio(th_ioctx_t *ctx, FILE *fh);
 
-bool         th_io_set_handlers(th_ioctx *ctx,
-             void (*error)(th_ioctx *, const int, const char *msg),
-             void (*msg)(th_ioctx *, const int, const char *msg));
+bool         th_io_set_handlers(th_ioctx_t *ctx,
+             void (*error)(th_ioctx_t *, const int, const char *msg),
+             void (*msg)(th_ioctx_t *, const int, const char *msg));
 
-int          th_io_error_v(th_ioctx *ctx, const int err, const char *fmt, va_list ap);
-void         th_io_msg_v(th_ioctx *ctx, const int level, const char *fmt, va_list ap);
-int          th_io_error(th_ioctx *ctx, const int err, const char *fmt, ...)
+int          th_io_error_v(th_ioctx_t *ctx, const int err, const char *fmt, va_list ap);
+void         th_io_msg_v(th_ioctx_t *ctx, const int level, const char *fmt, va_list ap);
+int          th_io_error(th_ioctx_t *ctx, const int err, const char *fmt, ...)
              TH_ATTR_PRINTF_FMT(3, 4);
-void         th_io_msg(th_ioctx *ctx, const int level, const char *fmt, ...)
+void         th_io_msg(th_ioctx_t *ctx, const int level, const char *fmt, ...)
              TH_ATTR_PRINTF_FMT(3, 4);
 
 
 //
 // Basic I/O operations
 //
-int          thfopen(th_ioctx *ctx);
-void         thfclose(th_ioctx *ctx);
+int          thfopen(th_ioctx_t *ctx);
+void         thfclose(th_ioctx_t *ctx);
 
-int          thfreset(th_ioctx *ctx);
-int          thferror(th_ioctx *ctx);
-int          thfseek(th_ioctx *ctx, const off_t, const int whence);
-off_t        thfsize(th_ioctx *ctx);
-off_t        thftell(th_ioctx *ctx);
-bool         thfeof(th_ioctx *ctx);
-int          thfgetc(th_ioctx *ctx);
-int          thfputc(int ch, th_ioctx *ctx);
-size_t       thfread(void *ptr, const size_t, const size_t, th_ioctx *ctx);
-size_t       thfwrite(const void *, const size_t, const size_t, th_ioctx *ctx);
-char *       thfgets(char *ptr, int size, th_ioctx *ctx);
-int          thfputs(const char *ptr, th_ioctx *ctx);
-int          thvfprintf(th_ioctx *ctx, const char *fmt, va_list ap);
-int          thfprintf(th_ioctx *ctx, const char *fmt, ...)
+int          thfreset(th_ioctx_t *ctx);
+int          thferror(th_ioctx_t *ctx);
+int          thfseek(th_ioctx_t *ctx, const off_t, const int whence);
+off_t        thfsize(th_ioctx_t *ctx);
+off_t        thftell(th_ioctx_t *ctx);
+bool         thfeof(th_ioctx_t *ctx);
+int          thfgetc(th_ioctx_t *ctx);
+int          thfputc(int ch, th_ioctx_t *ctx);
+size_t       thfread(void *ptr, const size_t, const size_t, th_ioctx_t *ctx);
+size_t       thfwrite(const void *, const size_t, const size_t, th_ioctx_t *ctx);
+char *       thfgets(char *ptr, int size, th_ioctx_t *ctx);
+int          thfputs(const char *ptr, th_ioctx_t *ctx);
+int          thvfprintf(th_ioctx_t *ctx, const char *fmt, va_list ap);
+int          thfprintf(th_ioctx_t *ctx, const char *fmt, ...)
              TH_ATTR_PRINTF_FMT(2, 3);
 
-bool         thfread_str(th_ioctx *ctx, void *ptr, const size_t len);
-bool         thfread_u8(th_ioctx *ctx, uint8_t *);
-bool         thfwrite_str(th_ioctx *ctx, const void *ptr, const size_t len);
-bool         thfwrite_u8(th_ioctx *ctx, const uint8_t);
+bool         thfread_str(th_ioctx_t *ctx, void *ptr, const size_t len);
+bool         thfread_u8(th_ioctx_t *ctx, uint8_t *);
+bool         thfwrite_str(th_ioctx_t *ctx, const void *ptr, const size_t len);
+bool         thfwrite_u8(th_ioctx_t *ctx, const uint8_t);
 
 
 //
 // Endian-handling file read/write routines
 //
-bool         thfwrite_ne16(th_ioctx *ctx, const uint16_t v);
-bool         thfwrite_ne32(th_ioctx *ctx, const uint32_t v);
-bool         thfwrite_ne64(th_ioctx *ctx, const uint64_t v);
-bool         thfread_ne16(th_ioctx *ctx, uint16_t *v);
-bool         thfread_ne32(th_ioctx *ctx, uint32_t *v);
-bool         thfread_ne64(th_ioctx *ctx, uint64_t *v);
+bool         thfwrite_ne16(th_ioctx_t *ctx, const uint16_t v);
+bool         thfwrite_ne32(th_ioctx_t *ctx, const uint32_t v);
+bool         thfwrite_ne64(th_ioctx_t *ctx, const uint64_t v);
+bool         thfread_ne16(th_ioctx_t *ctx, uint16_t *v);
+bool         thfread_ne32(th_ioctx_t *ctx, uint32_t *v);
+bool         thfread_ne64(th_ioctx_t *ctx, uint64_t *v);
 
-bool         thfwrite_le16(th_ioctx *ctx, const uint16_t v);
-bool         thfwrite_le32(th_ioctx *ctx, const uint32_t v);
-bool         thfwrite_le64(th_ioctx *ctx, const uint64_t v);
-bool         thfread_le16(th_ioctx *ctx, uint16_t *v);
-bool         thfread_le32(th_ioctx *ctx, uint32_t *v);
-bool         thfread_le64(th_ioctx *ctx, uint64_t *v);
+bool         thfwrite_le16(th_ioctx_t *ctx, const uint16_t v);
+bool         thfwrite_le32(th_ioctx_t *ctx, const uint32_t v);
+bool         thfwrite_le64(th_ioctx_t *ctx, const uint64_t v);
+bool         thfread_le16(th_ioctx_t *ctx, uint16_t *v);
+bool         thfread_le32(th_ioctx_t *ctx, uint32_t *v);
+bool         thfread_le64(th_ioctx_t *ctx, uint64_t *v);
 
-bool         thfwrite_be16(th_ioctx *ctx, const uint16_t v);
-bool         thfwrite_be32(th_ioctx *ctx, const uint32_t v);
-bool         thfwrite_be64(th_ioctx *ctx, const uint64_t v);
-bool         thfread_be16(th_ioctx *ctx, uint16_t *v);
-bool         thfread_be32(th_ioctx *ctx, uint32_t *v);
-bool         thfread_be64(th_ioctx *ctx, uint64_t *v);
+bool         thfwrite_be16(th_ioctx_t *ctx, const uint16_t v);
+bool         thfwrite_be32(th_ioctx_t *ctx, const uint32_t v);
+bool         thfwrite_be64(th_ioctx_t *ctx, const uint64_t v);
+bool         thfread_be16(th_ioctx_t *ctx, uint16_t *v);
+bool         thfread_be32(th_ioctx_t *ctx, uint32_t *v);
+bool         thfread_be64(th_ioctx_t *ctx, uint64_t *v);
 
 
 #ifdef __cplusplus