diff th_ioctx.c @ 735:31bc1ed07cf5

Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2022 12:14:39 +0200
parents 29e44a58bc73
children 8eca15bde07d
line wrap: on
line diff
--- a/th_ioctx.c	Wed Dec 07 11:58:54 2022 +0200
+++ b/th_ioctx.c	Wed Dec 07 12:14:39 2022 +0200
@@ -40,18 +40,18 @@
 
     th_io_init(ctx);
 
-    ctx->allocated = TRUE;
+    ctx->allocated = true;
     ctx->fops = fops;
 
     ctx->filename = th_strdup(filename);
-    ctx->fallocated = TRUE;
+    ctx->fallocated = true;
     if (filename != NULL && ctx->filename == NULL)
         goto err;
 
     if (mode != NULL && (ctx->mode = th_strdup(mode)) == NULL)
         goto err;
 
-    ctx->mallocated = TRUE;
+    ctx->mallocated = true;
 
     return ctx;
 
@@ -95,7 +95,7 @@
     }
     else
     {
-        ctx->mallocated = TRUE;
+        ctx->mallocated = true;
         if ((ctx->mode = th_strdup(mode)) == NULL)
             return THERR_MALLOC;
     }
@@ -122,17 +122,17 @@
 }
 
 
-BOOL th_io_set_handlers(th_ioctx *ctx,
+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))
 {
     if (ctx == NULL)
-        return FALSE;
+        return false;
 
     ctx->error = error;
     ctx->msg = msg;
 
-    return TRUE;
+    return true;
 }
 
 
@@ -240,7 +240,7 @@
 }
 
 
-BOOL thfeof(th_ioctx *ctx)
+bool thfeof(th_ioctx *ctx)
 {
     th_io_update_atime(ctx);
     return ctx->fops->feof(ctx);
@@ -332,25 +332,25 @@
 }
 
 
-BOOL thfread_str(th_ioctx *ctx, void *ptr, const size_t len)
+bool thfread_str(th_ioctx *ctx, void *ptr, const size_t len)
 {
     return thfread(ptr, sizeof(uint8_t), len, ctx) == len;
 }
 
 
-BOOL thfread_u8(th_ioctx *ctx, uint8_t *val)
+bool thfread_u8(th_ioctx *ctx, uint8_t *val)
 {
     return (thfread(val, sizeof(uint8_t), 1, ctx) == 1);
 }
 
 
-BOOL thfwrite_str(th_ioctx *ctx, const void *ptr, const size_t len)
+bool thfwrite_str(th_ioctx *ctx, const void *ptr, const size_t len)
 {
     return thfwrite(ptr, sizeof(uint8_t), len, ctx) == len;
 }
 
 
-BOOL thfwrite_u8(th_ioctx *ctx, const uint8_t val)
+bool thfwrite_u8(th_ioctx *ctx, const uint8_t val)
 {
     return thfwrite(&val, sizeof(uint8_t), 1, ctx) == 1;
 }
@@ -360,21 +360,21 @@
 // File routines for endian-dependant data
 //
 #define TH_DEFINE_FUNC(xname, xtype, xmacro)               \
-BOOL thfread_ ## xname (th_ioctx *ctx, xtype *v)           \
+bool thfread_ ## xname (th_ioctx *ctx, xtype *v)           \
 {                                                          \
     xtype result;                                          \
     if (thfread(&result, sizeof( xtype ), 1, ctx) != 1)    \
-        return FALSE;                                      \
+        return false;                                      \
     *v = TH_ ## xmacro ## _TO_NATIVE (result);             \
-    return TRUE;                                           \
+    return true;                                           \
 }                                                          \
                                                            \
-BOOL thfwrite_ ## xname (th_ioctx *ctx, const xtype v)     \
+bool thfwrite_ ## xname (th_ioctx *ctx, const xtype v)     \
 {                                                          \
     xtype result = TH_NATIVE_TO_ ## xmacro (v);            \
     if (thfwrite(&result, sizeof( xtype ), 1, ctx) != 1)   \
-        return FALSE;                                      \
-    return TRUE;                                           \
+        return false;                                      \
+    return true;                                           \
 }