Mercurial > hg > th-libs
diff th_ioctx.c @ 453:efd33accdc81
Break backwards compatibility by renaming BOOL, TRUE and FALSE to lowercase.
Introduce optional but default use of stdbool.h.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Jan 2018 22:56:03 +0200 |
parents | 1b3472ba7b23 |
children | 347bfd3e017e |
line wrap: on
line diff
--- a/th_ioctx.c Wed Oct 25 22:32:07 2017 +0300 +++ b/th_ioctx.c Tue Jan 02 22:56:03 2018 +0200 @@ -78,17 +78,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; } @@ -176,7 +176,7 @@ } -BOOL thfeof(th_ioctx *ctx) +bool thfeof(th_ioctx *ctx) { ctx->atime = time(NULL); return ctx->fops->feof(ctx); @@ -268,25 +268,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); } @@ -296,21 +296,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; \ } @@ -405,7 +405,7 @@ } -static BOOL th_stdio_feof(th_ioctx *ctx) +static bool th_stdio_feof(th_ioctx *ctx) { return feof(CTX_FH); }