changeset 457:85fa3d333556

Actually, revert the boolean changes .. meh.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Jan 2018 23:09:29 +0200
parents 1bf886fa9db5
children 694c85f4e354
files Makefile Makefile.w32 tests.c th_args.c th_args.h th_config.c th_config.h th_datastruct.c th_datastruct.h th_file.c th_file.h th_ioctx.c th_ioctx.h th_network.c th_network.h th_printf1.c th_string.c th_string.h th_strmatch.c th_types.h th_util.c
diffstat 21 files changed, 304 insertions(+), 309 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Jan 02 22:57:47 2018 +0200
+++ b/Makefile	Tue Jan 02 23:09:29 2018 +0200
@@ -18,7 +18,6 @@
 CFLAGS += -DHAVE_STDINT_H
 #CFLAGS += -DHAVE_SYS_TYPES_H
 CFLAGS += -DHAVE_INTTYPES_H
-CFLAGS += -DHAVE_STDBOOL_H
 
 
 ###
--- a/Makefile.w32	Tue Jan 02 22:57:47 2018 +0200
+++ b/Makefile.w32	Tue Jan 02 23:09:29 2018 +0200
@@ -11,7 +11,7 @@
 
 # Compiler flags and linker flags
 CFLAGS += -DHAVE_STRING_H -DTH_BYTEORDER=TH_LITTLE_ENDIAN -mconsole
-CFLAGS += -DHAVE_STDBOOL_H
+
 
 
 ###
--- a/tests.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/tests.c	Tue Jan 02 23:09:29 2018 +0200
@@ -23,7 +23,7 @@
 typedef struct
 {
     char *header, *res;
-    bool shown;
+    BOOL shown;
 } test_ctx;
 
 
@@ -47,21 +47,21 @@
 static const int arg_nopts = sizeof(arg_opts) / sizeof(arg_opts[0]);
 
 
-bool tprintv(const int level, const char *fmt, va_list ap)
+BOOL tprintv(const int level, const char *fmt, va_list ap)
 {
     if (level <= th_verbosityLevel)
     {
         vfprintf(stdout, fmt, ap);
-        return true;
+        return TRUE;
     }
     else
-        return false;
+        return FALSE;
 }
 
 
-bool tprint(const int level, const char *fmt, ...)
+BOOL tprint(const int level, const char *fmt, ...)
 {
-    bool retv;
+    BOOL retv;
     va_list ap;
     va_start(ap, fmt);
     retv = tprintv(level, fmt, ap);
@@ -77,7 +77,7 @@
 }
 
 
-bool arg_handle_opt(const int optN, char *optArg, char *currArg)
+BOOL arg_handle_opt(const int optN, char *optArg, char *currArg)
 {
     switch (optN)
     {
@@ -92,7 +92,7 @@
 
     case 2:
         {
-            bool ret = true;
+            BOOL ret = TRUE;
             char *pos, *pstr, *next;
             pos = pstr = th_strdup(optArg);
             memset(sets_enabled, 0, sizeof(sets_enabled));
@@ -111,7 +111,7 @@
                     else
                     {
                         THERR("Invalid test number #%d, out of range [%d .. %d]\n", val, 1, SET_MAX_TESTS);
-                        ret = false;
+                        ret = FALSE;
                     }
                     th_free(tmp);
                 }
@@ -130,10 +130,10 @@
 
     default:
         THERR("Unknown option '%s'.\n", currArg);
-        return false;
+        return FALSE;
     }
 
-    return true;
+    return TRUE;
 }
 
 
@@ -167,19 +167,19 @@
 }
 
 
-void test_result_msg_v(test_ctx *ctx, bool check, const char *fmt, va_list ap)
+void test_result_msg_v(test_ctx *ctx, BOOL check, const char *fmt, va_list ap)
 {
     if (check)
     {
         if (!ctx->shown && tprint(2, "%s: OK\n", ctx->header))
-            ctx->shown = true;
+            ctx->shown = TRUE;
 
         tests_passed++;
     }
     else
     {
         if (!ctx->shown && tprint(0, "%s: FAIL\n", ctx->header))
-            ctx->shown = true;
+            ctx->shown = TRUE;
 
         if (fmt != NULL)
         {
@@ -194,7 +194,7 @@
 }
 
 
-bool test_result_msg(test_ctx *ctx, bool check, const char *fmt, ...)
+BOOL test_result_msg(test_ctx *ctx, BOOL check, const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
@@ -204,7 +204,7 @@
 }
 
 
-bool test_result(test_ctx *ctx, bool check)
+BOOL test_result(test_ctx *ctx, BOOL check)
 {
     test_result_msg_v(ctx, check, NULL, NULL);
     return check;
@@ -275,7 +275,7 @@
 }
 
 
-bool test_set_start(const char *str)
+BOOL test_set_start(const char *str)
 {
     if (sets_enabled[sets_total++])
     {
@@ -286,10 +286,10 @@
             "======================================================\n",
             sets_total, str);
 
-        return true;
+        return TRUE;
     }
     else
-        return false;
+        return FALSE;
 }
 
 
@@ -444,52 +444,52 @@
     //
     if (test_set_start("String matching #1"))
     {
-        TEST2(th_strcasecmp, "aSdFq", "asdfq", true);
-        TEST2(th_strcasecmp, "aSdFq", "asFfq", false);
-        TEST2(th_strcasecmp, "abcde", "abcde", true);
-        TEST2(th_strcasecmp, "öäå", "öäå", true);
-        TEST2(th_strcasecmp, "aöäå", "aöäå", true);
+        TEST2(th_strcasecmp, "aSdFq", "asdfq", TRUE);
+        TEST2(th_strcasecmp, "aSdFq", "asFfq", FALSE);
+        TEST2(th_strcasecmp, "abcde", "abcde", TRUE);
+        TEST2(th_strcasecmp, "öäå", "öäå", TRUE);
+        TEST2(th_strcasecmp, "aöäå", "aöäå", TRUE);
     }
 
     if (test_set_start("String matching #2"))
     {
-        TEST3(th_strncasecmp, "aSdFq", "asFfqB", 4, false);
-        TEST3(th_strncasecmp, "aSdFq", "asFfqQ", 2, true);
-        TEST3(th_strncasecmp, "aSdFq", "asDfq", 3, true);
-        TEST3(th_strncasecmp, "aSdFq", "asDfq", 2, true);
-        TEST3(th_strncasecmp, "aSdFq", "asDfq", 0, true);
-        TEST3(th_strncasecmp, "aSdFq", "QsDfq", 0, true);
-        TEST3(th_strncasecmp, "aSdFq", "QsDfq", 1, false);
+        TEST3(th_strncasecmp, "aSdFq", "asFfqB", 4, FALSE);
+        TEST3(th_strncasecmp, "aSdFq", "asFfqQ", 2, TRUE);
+        TEST3(th_strncasecmp, "aSdFq", "asDfq", 3, TRUE);
+        TEST3(th_strncasecmp, "aSdFq", "asDfq", 2, TRUE);
+        TEST3(th_strncasecmp, "aSdFq", "asDfq", 0, TRUE);
+        TEST3(th_strncasecmp, "aSdFq", "QsDfq", 0, TRUE);
+        TEST3(th_strncasecmp, "aSdFq", "QsDfq", 1, FALSE);
     }
 
     if (test_set_start("String matching #3"))
     {
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "*lol", true);
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "*lo*", true);
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "*lo", false);
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "abba", false);
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "*bba*", true);
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "abba*", true);
-        TEST2B(th_strmatch, "abba ABBAkukka lol", "abbak*", false);
-        TEST2B(th_strmatch, "abba ABBAöökukka lol", "*abbaö?", false);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "*lol", TRUE);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "*lo*", TRUE);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "*lo", FALSE);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "abba", FALSE);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "*bba*", TRUE);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "abba*", TRUE);
+        TEST2B(th_strmatch, "abba ABBAkukka lol", "abbak*", FALSE);
+        TEST2B(th_strmatch, "abba ABBAöökukka lol", "*abbaö?", FALSE);
     }
 
     if (test_set_start("String matching #4"))
     {
-        TEST2B(th_strcasematch, "abba ABBAkukka lol", "abbak*", false);
-        TEST2B(th_strcasematch, "abba ABBAkukka lol", "*abbak*", true);
-        TEST2B(th_strcasematch, "abba ABBAkukka lol", "*ab?ak*", true);
-        TEST2B(th_strcasematch, "abba ABBAkukka lol", "*abbak?", false);
-        TEST2B(th_strcasematch, "abba ABBAkukka lol", "?bba?abba*", true);
+        TEST2B(th_strcasematch, "abba ABBAkukka lol", "abbak*", FALSE);
+        TEST2B(th_strcasematch, "abba ABBAkukka lol", "*abbak*", TRUE);
+        TEST2B(th_strcasematch, "abba ABBAkukka lol", "*ab?ak*", TRUE);
+        TEST2B(th_strcasematch, "abba ABBAkukka lol", "*abbak?", FALSE);
+        TEST2B(th_strcasematch, "abba ABBAkukka lol", "?bba?abba*", TRUE);
     }
 
     // Tests that test for things that do not work correctly yet
     // Unicode / multibyte UTF-8 causes problems here
     if (test_set_start("Invalid"))
     {
-        TEST2(th_strcasecmp, "ÖÄÅ", "öäå", false); // SHOULD match
-        TEST3(th_strncasecmp, "Aäöå", "aöå", 2, true); // should NOT match
-        TEST2B(th_strmatch, "öriÖRI! lol", "?ri?RI!*", false); // should match
+        TEST2(th_strcasecmp, "ÖÄÅ", "öäå", FALSE); // SHOULD match
+        TEST3(th_strncasecmp, "Aäöå", "aöå", 2, TRUE); // should NOT match
+        TEST2B(th_strmatch, "öriÖRI! lol", "?ri?RI!*", FALSE); // should match
     }
 
     //
--- a/th_args.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_args.c	Tue Jan 02 23:09:29 2018 +0200
@@ -23,15 +23,15 @@
  * @param opts options list array
  * @param nopts number of elements in options list array
  * @param handle_option function pointer to callback that handles option arguments
- * @param doProcess if true, actually handle the argument, aka call the handle_option() function. if false, only validity of options are checked.
- * @param isLong true if the option is a --long-format one
+ * @param doProcess if TRUE, actually handle the argument, aka call the handle_option() function. if FALSE, only validity of options are checked.
+ * @param isLong TRUE if the option is a --long-format one
  */
-static bool th_args_process_opt(
+static BOOL th_args_process_opt(
     char *currArg, int *argIndex,
     int argc, char *argv[],
     const th_optarg opts[], int nopts,
-    bool (*handle_option)(int id, char *, char *),
-    bool doProcess, bool isLong)
+    BOOL (*handle_option)(int id, char *, char *),
+    BOOL doProcess, BOOL isLong)
 {
     const th_optarg *opt = NULL;
     char *optArg = NULL;
@@ -85,13 +85,13 @@
                 THERR("Option '%s%s' requires an argument.\n",
                     isLong ? "--" : "-",
                     currArg);
-                return false;
+                return FALSE;
             }
         }
 
         // Option was given succesfully, try to process it
         if (doProcess && !handle_option(opt->id, optArg, currArg))
-            return false;
+            return FALSE;
     }
     else
     {
@@ -100,10 +100,10 @@
             isLong ? "--" : "-",
             currArg);
 
-        return false;
+        return FALSE;
     }
 
-    return true;
+    return TRUE;
 }
 
 
@@ -118,15 +118,15 @@
  * @param handle_option callback function
  * @param handle_other callback function
  * @param flags processing flags
- * @return return true if all is well
+ * @return return TRUE if all is well
  */
-bool th_args_process(int argc, char *argv[],
+BOOL th_args_process(int argc, char *argv[],
      const th_optarg *opts, const int nopts,
-     bool(*handle_option)(int id, char *, char *),
-     bool(*handle_other)(char *), const int flags)
+     BOOL(*handle_option)(int id, char *, char *),
+     BOOL(*handle_other)(char *), const int flags)
 {
     int argIndex, handleFlags = flags & OPTH_ONLY_MASK;
-    bool optionsOK = true, endOfOptions = false;
+    BOOL optionsOK = TRUE, endOfOptions = FALSE;
 
     for (argIndex = 1; argIndex < argc; argIndex++)
     {
@@ -134,8 +134,8 @@
         if (*str == '-' && !endOfOptions)
         {
             // Should we process options?
-            bool doProcess = (handleFlags & OPTH_ONLY_OPTS) || handleFlags == 0;
-            bool isLong;
+            BOOL doProcess = (handleFlags & OPTH_ONLY_OPTS) || handleFlags == 0;
+            BOOL isLong;
 
             str++;
             if (*str == '-')
@@ -144,19 +144,19 @@
                 str++;
                 if (*str == 0)
                 {
-                    endOfOptions = true;
+                    endOfOptions = TRUE;
                     continue;
                 }
 
                 // We have a long option
-                isLong = true;
+                isLong = TRUE;
             }
             else
-                isLong = false;
+                isLong = FALSE;
 
             if (!th_args_process_opt(str, &argIndex, argc, argv,
                 opts, nopts, handle_option, doProcess, isLong))
-                optionsOK = false;
+                optionsOK = FALSE;
         }
         else
         if (handleFlags == OPTH_ONLY_OTHER || handleFlags == 0)
@@ -166,13 +166,13 @@
                 (handle_other != NULL && !handle_other(str)))
             {
                 THERR("Invalid argument '%s'\n", str);
-                optionsOK = false;
+                optionsOK = FALSE;
             }
         }
 
         // Check if we bail out on invalid argument
         if (!optionsOK && (flags & OPTH_BAILOUT))
-            return false;
+            return FALSE;
     }
 
     return optionsOK;
--- a/th_args.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_args.h	Tue Jan 02 23:09:29 2018 +0200
@@ -43,10 +43,10 @@
 } th_optarg;
 
 
-bool th_args_process(int argc, char *argv[],
+BOOL th_args_process(int argc, char *argv[],
      const th_optarg *opts, const int nopts,
-     bool (*handle_option)(int id, char *, char *),
-     bool (*handle_other)(char *), const int flags);
+     BOOL (*handle_option)(int id, char *, char *),
+     BOOL (*handle_other)(char *), const int flags);
 
 void th_args_help(FILE *, const th_optarg *opts,
      const int nopts, const int flags);
--- a/th_config.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_config.c	Tue Jan 02 23:09:29 2018 +0200
@@ -129,11 +129,11 @@
 /* Add boolean type setting into given configuration
  */
 int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name,
-                    bool *itemData, bool defValue)
+                    BOOL *itemData, BOOL defValue)
 {
     th_cfgitem_t *node;
 
-    node = th_cfg_add(cfg, name, ITEM_bool, (void *) itemData);
+    node = th_cfg_add(cfg, name, ITEM_BOOL, (void *) itemData);
     if (node == NULL)
         return -1;
 
@@ -199,7 +199,7 @@
     PM_KEYSET,
     PM_STRING,
     PM_NUMERIC,
-    PM_bool,
+    PM_BOOL,
     PM_SECTION,
     PM_ARRAY
 };
@@ -213,13 +213,13 @@
     char *tmpStr = NULL;
     size_t strPos;
     int c, parseMode, prevMode, nextMode, tmpCh;
-    bool isFound, isStart, isError, validError, fpSet;
+    BOOL isFound, isStart, isError, validError, fpSet;
 
     // Initialize values
     tmpCh = 0;
     strPos = 0;
     c = -1;
-    fpSet = isFound = isStart = isError = validError = false;
+    fpSet = isFound = isStart = isError = validError = FALSE;
     nextMode = prevMode = parseMode = PM_IDLE;
 
     if ((tmpStr = th_malloc(SET_MAX_BUF + 1)) == NULL)
@@ -345,12 +345,12 @@
             {
                 // Find key from configuration
                 tmpStr[strPos] = 0;
-                isFound = false;
+                isFound = FALSE;
                 item = cfg;
                 while (item != NULL && !isFound)
                 {
                     if (item->name != NULL && strcmp(item->name, tmpStr) == 0)
-                        isFound = true;
+                        isFound = TRUE;
                     else
                         item = (th_cfgitem_t *) item->node.next;
                 }
@@ -376,8 +376,8 @@
                         nextMode = PM_NUMERIC;
                         break;
 
-                    case ITEM_bool:
-                        nextMode = PM_bool;
+                    case ITEM_BOOL:
+                        nextMode = PM_BOOL;
                         break;
 
                     case ITEM_SECTION:
@@ -387,8 +387,8 @@
 
                     prevMode = parseMode;
                     parseMode = PM_NEXT;
-                    isStart = true;
-                    fpSet = false;
+                    isStart = TRUE;
+                    fpSet = FALSE;
                     strPos = 0;
                 }
                 else
@@ -450,7 +450,7 @@
                 {
                 case ITEM_STRING_LIST:
                     c = -1;
-                    isStart = true;
+                    isStart = TRUE;
                     prevMode = parseMode;
                     parseMode = PM_NEXT;
                     nextMode = PM_STRING;
@@ -479,7 +479,7 @@
                 int res = th_cfg_read_sect(ctx, item->v.section, nesting + 1);
                 c = -1;
                 if (res > 0)
-                    validError = true;
+                    validError = TRUE;
                 else if (res < 0)
                     parseMode = PM_ERROR;
                 else
@@ -496,7 +496,7 @@
             {
                 // Start of string, get delimiter
                 tmpCh = c;
-                isStart = false;
+                isStart = FALSE;
                 strPos = 0;
             }
             else if (c == tmpCh)
@@ -556,31 +556,31 @@
             {
                 VADDCH(c)
                 else
-                isError = true;
+                isError = TRUE;
             }
             else if (isStart && item->type == ITEM_FLOAT && c == '.')
             {
-                fpSet = true;
+                fpSet = TRUE;
                 VADDCH('0')
                 else
-                isError = true;
+                isError = TRUE;
 
                 VADDCH(c)
                 else
-                isError = true;
+                isError = TRUE;
             }
             else if (item->type == ITEM_FLOAT && c == '.' && !fpSet)
             {
-                fpSet = true;
+                fpSet = TRUE;
                 VADDCH(c)
                 else
-                isError = true;
+                isError = TRUE;
             }
             else if (th_isdigit(c))
             {
                 VADDCH(c)
                 else
-                isError = true;
+                isError = TRUE;
             }
             else if (VISEND(c))
             {
@@ -622,15 +622,15 @@
                 parseMode = PM_ERROR;
             }
 
-            isStart = false;
+            isStart = FALSE;
             c = -1;
             break;
 
-        case PM_bool:
+        case PM_BOOL:
             // Boolean parsing mode
             if (isStart)
             {
-                isStart = false;
+                isStart = FALSE;
                 strPos = 0;
             }
 
@@ -638,12 +638,12 @@
             {
                 VADDCH(c)
                 else
-                isError = true;
+                isError = TRUE;
             }
             else
             if (VISEND(c))
             {
-                bool tmpBool;
+                BOOL tmpBool;
                 tmpStr[strPos] = 0;
                 isError = !th_get_boolean(tmpStr, &tmpBool);
                 if (!isError)
@@ -781,7 +781,7 @@
                     return -5;
                 break;
 
-            case ITEM_bool:
+            case ITEM_BOOL:
                 if (thfprintf(ctx, "%s = %s\n", item->name,
                     *(item->v.val_bool) ? "yes" : "no") < 0)
                     return -6;
@@ -830,17 +830,17 @@
  * Name MUST be defined. Section can be NULL and type -1,
  * first matching item will be returned.
  */
-static th_cfgitem_t *th_cfg_find_do(th_cfgitem_t *item, bool *sect, const char *section, const char *name, const int type)
+static th_cfgitem_t *th_cfg_find_do(th_cfgitem_t *item, BOOL *sect, const char *section, const char *name, const int type)
 {
     while (item != NULL)
     {
-        bool match = true;
+        BOOL match = TRUE;
 
         if (item->type == ITEM_SECTION)
         {
             // Check section name if set
             if (section != NULL && strcmp(section, item->name) == 0)
-                *sect = true;
+                *sect = TRUE;
 
             // Recurse to sub-section
             th_cfgitem_t *tmp = th_cfg_find_do(item->v.section, sect, section, name, type);
@@ -850,11 +850,11 @@
         else
         // Has type check been set, and does it match?
         if (type != -1 && item->type != type)
-            match = false;
+            match = FALSE;
         else
         // Check name (not section name, tho)
         if (strcmp(name, item->name) != 0)
-            match = false;
+            match = FALSE;
 
         // Do we have a match?
         if (*sect && match)
@@ -867,10 +867,10 @@
 
 th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type)
 {
-    bool sect = false;
+    BOOL sect = FALSE;
 
     if (section == NULL)
-        sect = true;
+        sect = TRUE;
 
     return th_cfg_find_do(cfg, &sect, section, name, type);
 }
--- a/th_config.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_config.h	Tue Jan 02 23:09:29 2018 +0200
@@ -25,7 +25,7 @@
     ITEM_STRING,
     ITEM_INT,
     ITEM_UINT,
-    ITEM_bool,
+    ITEM_BOOL,
     ITEM_FLOAT,
     ITEM_HEX_TRIPLET,
 
@@ -44,7 +44,7 @@
         int *val_int;
         unsigned int *val_uint;
         char **val_str;
-        bool *val_bool;
+        BOOL *val_bool;
         float *val_float;
 
         void *data;
@@ -67,7 +67,7 @@
 int     th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int defValue);
 int     th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float defValue);
 int     th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **data, char *defValue);
-int     th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, bool *data, bool defValue);
+int     th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL defValue);
 int     th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float defValue);
 int     th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int defValue);
 int     th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, th_llist_t **list);
--- a/th_datastruct.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_datastruct.c	Tue Jan 02 23:09:29 2018 +0200
@@ -335,16 +335,16 @@
 }
 
 
-bool th_ringbuf_grow(th_ringbuf_t *buf, const size_t n)
+BOOL th_ringbuf_grow(th_ringbuf_t *buf, const size_t n)
 {
     buf->data = (char **) th_realloc(buf->data, (buf->size + n) * sizeof(char *));
     if (buf->data != NULL)
     {
         memset(buf->data + buf->size, 0, sizeof(char *) * n);
         buf->size += n;
-        return true;
+        return TRUE;
     } else
-        return false;
+        return FALSE;
 }
 
 
@@ -400,7 +400,7 @@
         return NULL;
 
     th_growbuf_init(buf, mingrow);
-    buf->allocated = true;
+    buf->allocated = TRUE;
 
     return buf;
 }
@@ -415,132 +415,132 @@
 }
 
 
-bool th_growbuf_grow(th_growbuf_t *buf, const size_t grow)
+BOOL th_growbuf_grow(th_growbuf_t *buf, const size_t grow)
 {
     if (buf == NULL)
-        return false;
+        return FALSE;
 
     if (buf->data == NULL || buf->len + grow >= buf->size)
     {
         buf->size += grow + (buf->mingrow > 0 ? buf->mingrow : TH_BUFGROW);
         buf->data = (uint8_t *) th_realloc(buf->data, buf->size);
         if (buf->data == NULL)
-            return false;
+            return FALSE;
     }
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_puts(th_growbuf_t *buf, const char *str, bool eos)
+BOOL th_growbuf_puts(th_growbuf_t *buf, const char *str, BOOL eos)
 {
     size_t slen;
     if (str == NULL)
-        return false;
+        return FALSE;
 
     slen = strlen(str);
     if (!th_growbuf_grow(buf, slen + 1))
-        return false;
+        return FALSE;
 
     memcpy(buf->data + buf->len, str, slen + 1);
     buf->len += eos ? (slen + 1) : slen;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_putch(th_growbuf_t *buf, const char ch)
+BOOL th_growbuf_putch(th_growbuf_t *buf, const char ch)
 {
     if (!th_growbuf_grow(buf, sizeof(char)))
-        return false;
+        return FALSE;
 
     buf->data[buf->len++] = (uint8_t) ch;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len)
+BOOL th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len)
 {
     if (s == NULL)
-        return false;
+        return FALSE;
 
     if (!th_growbuf_grow(buf, len + 1))
-        return false;
+        return FALSE;
 
     memcpy(buf->data + buf->len, s, len + 1);
     buf->len += len;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val)
+BOOL th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val)
 {
     if (!th_growbuf_grow(buf, sizeof(uint8_t)))
-        return false;
+        return FALSE;
 
     buf->data[buf->len++] = val;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val)
+BOOL th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val)
 {
     if (!th_growbuf_grow(buf, sizeof(uint16_t)))
-        return false;
+        return FALSE;
 
     buf->data[buf->len++] = (val >> 8) & 0xff;
     buf->data[buf->len++] = val & 0xff;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val)
+BOOL th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val)
 {
     if (!th_growbuf_grow(buf, sizeof(uint16_t)))
-        return false;
+        return FALSE;
 
     buf->data[buf->len++] = val & 0xff;
     buf->data[buf->len++] = (val >> 8) & 0xff;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val)
+BOOL th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val)
 {
     if (!th_growbuf_grow(buf, sizeof(uint32_t)))
-        return false;
+        return FALSE;
 
     buf->data[buf->len++] = (val >> 24) & 0xff;
     buf->data[buf->len++] = (val >> 16) & 0xff;
     buf->data[buf->len++] = (val >> 8) & 0xff;
     buf->data[buf->len++] = val & 0xff;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val)
+BOOL th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val)
 {
     if (!th_growbuf_grow(buf, sizeof(uint32_t)))
-        return false;
+        return FALSE;
 
     buf->data[buf->len++] = val & 0xff;
     buf->data[buf->len++] = (val >> 8) & 0xff;
     buf->data[buf->len++] = (val >> 16) & 0xff;
     buf->data[buf->len++] = (val >> 24) & 0xff;
 
-    return true;
+    return TRUE;
 }
 
 
 /*
  * Simple legacy string growing buffer
  */
-bool th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, size_t grow)
+BOOL th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, size_t grow)
 {
     if (*buf == NULL)
         *bufsize = *len = 0;
@@ -550,52 +550,52 @@
         *bufsize += grow + TH_BUFGROW;
         *buf = th_realloc(*buf, *bufsize);
         if (*buf == NULL)
-            return false;
+            return FALSE;
     }
-    return true;
+    return TRUE;
 }
 
 
-bool th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch)
+BOOL th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch)
 {
     if (!th_strbuf_grow(buf, bufsize, len, 1))
-        return false;
+        return FALSE;
 
     (*buf)[*len] = ch;
     (*len)++;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen)
+BOOL th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen)
 {
     if (str == NULL)
-        return false;
+        return FALSE;
 
     if (!th_strbuf_grow(buf, bufsize, len, slen + 1))
-        return false;
+        return FALSE;
 
     memcpy(*buf + *len, str, slen);
     (*len) += slen;
     *(buf + *len + slen) = 0;
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str)
+BOOL th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str)
 {
     size_t slen;
     if (str == NULL)
-        return false;
+        return FALSE;
 
     slen = strlen(str);
     if (!th_strbuf_grow(buf, bufsize, len, slen + 1))
-        return false;
+        return FALSE;
 
     memcpy(*buf + *len, str, slen + 1);
     (*len) += slen;
 
-    return true;
+    return TRUE;
 }
--- a/th_datastruct.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_datastruct.h	Tue Jan 02 23:09:29 2018 +0200
@@ -60,7 +60,7 @@
 } th_ringbuf_t;
 
 th_ringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *));
-bool         th_ringbuf_grow(th_ringbuf_t *buf, const size_t n);
+BOOL         th_ringbuf_grow(th_ringbuf_t *buf, const size_t n);
 void         th_ringbuf_free(th_ringbuf_t *buf);
 void         th_ringbuf_add(th_ringbuf_t *buf, void *ptr);
 
@@ -72,7 +72,7 @@
 
 typedef struct
 {
-    bool allocated;
+    BOOL allocated;
     uint8_t *data;
     size_t size, len, mingrow;
 } th_growbuf_t;
@@ -80,10 +80,10 @@
 
 /* Simple growing string buffer
  */
-bool    th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, const size_t grow);
-bool    th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch);
-bool    th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen);
-bool    th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str);
+BOOL    th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, const size_t grow);
+BOOL    th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch);
+BOOL    th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen);
+BOOL    th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str);
 
 
 /* Growing byte buffer
@@ -94,15 +94,15 @@
 void    th_growbuf_free(th_growbuf_t *buf);
 
 
-bool    th_growbuf_grow(th_growbuf_t *buf, const size_t grow);
-bool    th_growbuf_puts(th_growbuf_t *buf, const char *str, bool eos);
-bool    th_growbuf_putch(th_growbuf_t *buf, const char ch);
-bool    th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len);
-bool    th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val);
-bool    th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val);
-bool    th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val);
-bool    th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val);
-bool    th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val);
+BOOL    th_growbuf_grow(th_growbuf_t *buf, const size_t grow);
+BOOL    th_growbuf_puts(th_growbuf_t *buf, const char *str, BOOL eos);
+BOOL    th_growbuf_putch(th_growbuf_t *buf, const char ch);
+BOOL    th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len);
+BOOL    th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val);
+BOOL    th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val);
+BOOL    th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val);
+BOOL    th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val);
+BOOL    th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val);
 
 
 #ifdef __cplusplus
--- a/th_file.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_file.c	Tue Jan 02 23:09:29 2018 +0200
@@ -69,7 +69,7 @@
 }
 
 
-bool th_stat_path(const char *path, int *flags)
+BOOL th_stat_path(const char *path, int *flags)
 {
     *flags = 0;
 
@@ -83,22 +83,22 @@
     uid_t id = geteuid();
     struct stat sb;
     if (stat(path, &sb) < 0)
-        return false;
+        return FALSE;
 
     *flags |= S_ISDIR(sb.st_mode) ? TH_IS_DIR : 0;
     *flags |= (id == sb.st_uid && (sb.st_mode & S_IWUSR)) ? TH_IS_WRITABLE : 0;
     *flags |= (id == sb.st_uid && (sb.st_mode & S_IRUSR)) ? TH_IS_READABLE : 0;
 #endif
 
-    return true;
+    return TRUE;
 }
 
 
-bool th_mkdir_path(const char *cpath, int mode)
+BOOL th_mkdir_path(const char *cpath, int mode)
 {
     char save, *path = th_strdup(cpath);
     size_t start = 0, end;
-    bool res = false;
+    BOOL res = FALSE;
 
     // If mode is 0, default to something sensible
     if (mode == 0)
@@ -120,7 +120,7 @@
         if (path[start] != 0)
         {
             int flags;
-            bool exists = th_stat_path(path, &flags);
+            BOOL exists = th_stat_path(path, &flags);
             if (exists && (flags & TH_IS_DIR) == 0)
                 goto error;
 
@@ -141,7 +141,7 @@
         start = end + 1;
     } while (save != 0);
 
-    res = true;
+    res = TRUE;
 
 error:
     th_free(path);
--- a/th_file.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_file.h	Tue Jan 02 23:09:29 2018 +0200
@@ -39,8 +39,8 @@
 char *  th_get_home_dir();
 char *  th_get_config_dir(const char *name);
 
-bool    th_stat_path(const char *path, int *flags);
-bool    th_mkdir_path(const char *cpath, int mode);
+BOOL    th_stat_path(const char *path, int *flags);
+BOOL    th_mkdir_path(const char *cpath, int mode);
 
 
 #ifdef __cplusplus
--- a/th_ioctx.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_ioctx.c	Tue Jan 02 23:09:29 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);
 }
--- a/th_ioctx.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_ioctx.h	Tue Jan 02 23:09:29 2018 +0200
@@ -54,7 +54,7 @@
     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);
+    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);
@@ -83,7 +83,7 @@
 void         th_io_close(th_ioctx *ctx);
 void         th_io_free(th_ioctx *ctx);
 
-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));
 
@@ -101,7 +101,7 @@
 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);
+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);
@@ -111,35 +111,35 @@
 int          thvfprintf(th_ioctx *ctx, const char *fmt, va_list ap);
 int          thfprintf(th_ioctx *ctx, const char *fmt, ...);
 
-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);
+int          thfread_str(th_ioctx *ctx, void *ptr, const size_t len);
+BOOL         thfread_u8(th_ioctx *ctx, uint8_t *);
+int          thfwrite_str(th_ioctx *ctx, const void *ptr, const size_t len);
+BOOL         thfwrite_u8(th_ioctx *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 *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_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 *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_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 *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);
 
 
 #ifdef __cplusplus
--- a/th_network.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_network.c	Tue Jan 02 23:09:29 2018 +0200
@@ -10,7 +10,7 @@
 #include <errno.h>
 
 
-static bool th_network_inited = false;
+static BOOL th_network_inited = FALSE;
 static th_llist_t *th_conn_list = NULL;
 
 
@@ -114,14 +114,14 @@
 }
 
 
-bool th_base_conn_init(th_base_conn_t *base, ssize_t bufsize)
+BOOL th_base_conn_init(th_base_conn_t *base, ssize_t bufsize)
 {
     // Allocate connection data buffer
     base->bufsize = (bufsize <= 0) ? TH_CONNBUF_SIZE : bufsize;
     if ((base->buf = th_malloc(base->bufsize)) == NULL)
-        return false;
+        return FALSE;
 
-    return true;
+    return TRUE;
 }
 
 
@@ -150,17 +150,17 @@
 }
 
 
-static bool th_get_addr(struct in_addr *addr, struct hostent *hst)
+static BOOL th_get_addr(struct in_addr *addr, struct hostent *hst)
 {
     if (hst != NULL)
     {
         *addr = *(struct in_addr *) (hst->h_addr_list[0]);
-        return true;
+        return TRUE;
     }
     else
     {
         addr->s_addr = 0;
-        return false;
+        return FALSE;
     }
 }
 
@@ -320,9 +320,9 @@
             goto out;
     }
 
-    th_growbuf_puts(&buf, conn->proxy.userid, true);
+    th_growbuf_puts(&buf, conn->proxy.userid, TRUE);
     if (conn->proxy.addr_type == TH_PROXY_ADDR_DOMAIN)
-        th_growbuf_puts(&buf, host, true);
+        th_growbuf_puts(&buf, host, TRUE);
 
     // Send request
     if ((err = th_conn_proxy_send(conn, &buf)) != THERR_OK)
@@ -464,9 +464,9 @@
 
         th_growbuf_put_u8(&buf, 0x01);
         th_growbuf_put_u8(&buf, strlen(conn->proxy.userid));
-        th_growbuf_puts(&buf, conn->proxy.userid, false);
+        th_growbuf_puts(&buf, conn->proxy.userid, FALSE);
         th_growbuf_put_u8(&buf, strlen(conn->proxy.passwd));
-        th_growbuf_puts(&buf, conn->proxy.passwd, false);
+        th_growbuf_puts(&buf, conn->proxy.passwd, FALSE);
 
         // Send request
         if ((err = th_conn_proxy_send(conn, &buf)) != THERR_OK)
@@ -828,10 +828,10 @@
 }
 
 
-bool th_conn_check(th_conn_t *conn)
+BOOL th_conn_check(th_conn_t *conn)
 {
     if (conn == NULL)
-        return false;
+        return FALSE;
 
     return conn->err == 0 && conn->status == TH_CONN_OPEN;
 }
@@ -850,7 +850,7 @@
     }
 #endif
 
-    th_network_inited = true;
+    th_network_inited = TRUE;
 
     th_conn_list = NULL;
 
@@ -876,25 +876,25 @@
 #endif
     }
 
-    th_network_inited = false;
+    th_network_inited = FALSE;
 }
 
 
-bool th_conn_buf_check(th_conn_t *conn, size_t n)
+BOOL th_conn_buf_check(th_conn_t *conn, size_t n)
 {
     return conn && (conn->base.ptr + n <= conn->base.in_ptr);
 }
 
 
-bool th_conn_buf_skip(th_conn_t *conn, size_t n)
+BOOL th_conn_buf_skip(th_conn_t *conn, size_t n)
 {
     if (th_conn_buf_check(conn, n))
     {
         conn->base.ptr += n;
-        return true;
+        return TRUE;
     }
     else
-        return false;
+        return FALSE;
 }
 
 
--- a/th_network.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_network.h	Tue Jan 02 23:09:29 2018 +0200
@@ -16,7 +16,7 @@
 
 
 #ifdef TH_PLAT_WINDOWS
-#    define __OBJC_bool // A nasty hack
+#    define __OBJC_BOOL // A nasty hack
 #    include <windows.h>
 #    include <winsock.h>
 typedef uint16_t in_port_t;
@@ -157,11 +157,11 @@
 int         th_conn_pull(th_conn_t *);
 int         th_conn_send_buf(th_conn_t *, const void *buf, const size_t len);
 int         th_conn_send_growbuf(th_conn_t *, th_growbuf_t *buf);
-bool        th_conn_check(th_conn_t *);
+BOOL        th_conn_check(th_conn_t *);
 
 
-bool        th_conn_buf_check(th_conn_t *conn, size_t n);
-bool        th_conn_buf_skip(th_conn_t *conn, size_t n);
+BOOL        th_conn_buf_check(th_conn_t *conn, size_t n);
+BOOL        th_conn_buf_skip(th_conn_t *conn, size_t n);
 int         th_conn_buf_strncmp(th_conn_t *conn, const char *str, const size_t n);
 int         th_conn_buf_strcmp(th_conn_t *conn, const char *str);
 char *      th_conn_buf_strstr(th_conn_t *conn, const char *str);
--- a/th_printf1.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_printf1.c	Tue Jan 02 23:09:29 2018 +0200
@@ -8,8 +8,8 @@
 
 
 int TH_PFUNC_NAME (char *buf, const int len, int *pos,
-    TH_PFUNC_TYPE_S pval, const int f_radix, const bool f_upcase,
-    const bool f_unsig, bool *f_neg)
+    TH_PFUNC_TYPE_S pval, const int f_radix, const BOOL f_upcase,
+    const BOOL f_unsig, BOOL *f_neg)
 #ifdef TH_PFUNC_HEADER
 ;
 #else
@@ -20,11 +20,11 @@
     // Check for negative value
     if (!f_unsig && pval < 0)
     {
-        *f_neg = true;
+        *f_neg = TRUE;
         pval = -pval;
     }
     else
-        *f_neg = false;
+        *f_neg = FALSE;
 
     // Render the value to a string in buf (reversed)
     TH_PFUNC_TYPE_U val = pval;
--- a/th_string.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_string.c	Tue Jan 02 23:09:29 2018 +0200
@@ -200,7 +200,7 @@
 
 int th_vprintf_put_int_format(th_vprintf_ctx *ctx, th_vprintf_putch vputch,
     char *buf, int f_flags, int f_width, int f_prec, int f_len, int vret,
-    bool f_neg, bool f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags))
+    BOOL f_neg, BOOL f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags))
 {
     int ret = 0, nwidth, nprec;
     char f_sign, *f_altstr;
@@ -297,11 +297,11 @@
 
 int th_vprintf_put_int(th_vprintf_ctx *ctx, th_vprintf_putch vputch,
     va_list ap, const int f_radix, int f_flags, int f_width, int f_prec,
-    const bool f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags))
+    const BOOL f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags))
 {
     char buf[64];
     int f_len = 0, vret;
-    bool f_neg = false;
+    BOOL f_neg = FALSE;
 
     if (f_flags & TH_PF_LONGLONG)
     {
@@ -364,7 +364,7 @@
     memcpy(&val, &pval, sizeof(int64_t));
 
     // We have sign, exponent and mantissa
-    bool f_sign    = (val >> 63) & 0x01;
+    BOOL f_sign    = (val >> 63) & 0x01;
     int64_t d_exp  = (val >> 52) & 0x7ff;
     uint64_t d_man = val & 0x0fffffffffffff;
 
@@ -408,7 +408,7 @@
         else
         {
             int f_width = -1, f_prec = -1, f_flags = 0;
-            bool end = false;
+            BOOL end = FALSE;
 
             fmt++;
 
@@ -442,7 +442,7 @@
                         break;
 
                     default:
-                        end = true;
+                        end = TRUE;
                         break;
                 }
                 if (!end) fmt++;
@@ -525,7 +525,7 @@
                     break;
 
                 case 'o':
-                    if ((ret = th_vprintf_put_int(ctx, vputch, ap, 8, f_flags, f_width, f_prec, true, th_vprintf_altfmt_oct)) == EOF)
+                    if ((ret = th_vprintf_put_int(ctx, vputch, ap, 8, f_flags, f_width, f_prec, TRUE, th_vprintf_altfmt_oct)) == EOF)
                         goto out;
                     break;
 
@@ -540,7 +540,7 @@
                 case 'X':
                     if (*fmt == 'X')
                         f_flags |= TH_PF_UPCASE;
-                    if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, true, th_vprintf_altfmt_hex)) == EOF)
+                    if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_vprintf_altfmt_hex)) == EOF)
                         goto out;
                     break;
 
@@ -554,7 +554,7 @@
                     f_flags |= TH_PF_LONGLONG;
 #endif
                     f_flags |= TH_PF_ALT | TH_PF_POINTER;
-                    if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, true, th_vprintf_altfmt_hex)) == EOF)
+                    if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_vprintf_altfmt_hex)) == EOF)
                         goto out;
                     break;
 
@@ -990,15 +990,15 @@
 }
 
 
-bool th_get_boolean(const char *str, bool *value)
+BOOL th_get_boolean(const char *str, BOOL *value)
 {
     if (!th_strcasecmp(str, "yes") ||
         !th_strcasecmp(str, "on") ||
         !th_strcasecmp(str, "true") ||
         !th_strcasecmp(str, "1"))
     {
-        *value = true;
-        return true;
+        *value = TRUE;
+        return TRUE;
     }
     else
     if (!th_strcasecmp(str, "no") ||
@@ -1006,11 +1006,11 @@
         !th_strcasecmp(str, "false") ||
         !th_strcasecmp(str, "0"))
     {
-        *value = false;
-        return true;
+        *value = FALSE;
+        return TRUE;
     }
     else
-        return false;
+        return FALSE;
 }
 
 
@@ -1024,14 +1024,14 @@
 void th_print_wrap(FILE *fh, const char *str, int spad, int rpad, int width)
 {
     size_t pos = 0;
-    bool first = true;
+    BOOL first = TRUE;
 
     while (str[pos])
     {
         // Pre-pad line
         int linelen = first ? spad : rpad;
         th_pad(fh, first ? 0 : rpad);
-        first = false;
+        first = FALSE;
 
         // Skip whitespace at line start
         while (th_isspace(str[pos]) || str[pos] == '\n') pos++;
--- a/th_string.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_string.h	Tue Jan 02 23:09:29 2018 +0200
@@ -123,10 +123,10 @@
         const char *str, int f_flags, const int f_width, const int f_prec);
 int 	th_vprintf_put_int(th_vprintf_ctx *ctx, th_vprintf_putch vputch,
         va_list ap, const int f_radix, int f_flags, int f_width, int f_prec,
-        const bool f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags));
+        const BOOL f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags));
 int	 th_vprintf_put_int_format(th_vprintf_ctx *ctx, th_vprintf_putch vputch,
         char *buf, int f_flags, int f_width, int f_prec, int f_len, int vret,
-        bool f_neg, bool f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags));
+        BOOL f_neg, BOOL f_unsig, char *(f_alt)(const char *buf, const size_t blen, const int vret, const int flags));
 
 char *  th_vprintf_altfmt_oct(const char *buf, const size_t len, const int vret, const int flags);
 char *  th_vprintf_altfmt_hex(const char *buf, const size_t len, const int vret, const int flags);
@@ -152,11 +152,11 @@
 const char    *th_findsep(const char *, size_t *, char);
 const char    *th_findseporspace(const char *, size_t *, char);
 
-bool    th_strmatch(const char *haystack, const char *pattern);
-bool    th_strcasematch(const char *haystack, const char *pattern);
+BOOL    th_strmatch(const char *haystack, const char *pattern);
+BOOL    th_strcasematch(const char *haystack, const char *pattern);
 
 int     th_get_hex_triplet(const char *str);
-bool    th_get_boolean(const char *str, bool *value);
+BOOL    th_get_boolean(const char *str, BOOL *value);
 
 void    th_print_wrap(FILE *fh, const char *str, int spad, int rpad, int width);
 
--- a/th_strmatch.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_strmatch.c	Tue Jan 02 23:09:29 2018 +0200
@@ -6,14 +6,14 @@
  * Please read file 'COPYING' for information on license and distribution.
  */
 
-bool TH_STRMATCH_FUNC (const char *haystack, const char *pattern)
+BOOL TH_STRMATCH_FUNC (const char *haystack, const char *pattern)
 {
-    bool matched = true, any = false, end = false;
+    BOOL matched = TRUE, any = FALSE, end = FALSE;
     const char *tmp = NULL;
 
     // Check given pattern and string
     if (haystack == NULL || pattern == NULL)
-        return false;
+        return FALSE;
 
     // Start comparision
     while (matched && !end)
@@ -27,14 +27,14 @@
             haystack++;
         }
         else
-            matched = false;
+            matched = FALSE;
         break;
 
     case '*':
         pattern++;
         if (!*pattern || *pattern == '?')
-            end = true;
-        any = true;
+            end = TRUE;
+        any = TRUE;
         tmp = pattern;
         break;
 
@@ -44,21 +44,21 @@
             if (*haystack)
                 haystack++;
             else
-                end = true;
+                end = TRUE;
         }
         else
         if (*haystack)
         {
             if (tmp)
             {
-                any = true;
+                any = TRUE;
                 pattern = tmp;
             }
             else
-                matched = false;
+                matched = FALSE;
         }
         else
-            end = true;
+            end = TRUE;
         break;
 
     default:
@@ -66,13 +66,13 @@
         {
             if (TH_STRMATCH_COLLATE(*pattern) == TH_STRMATCH_COLLATE(*haystack))
             {
-                any = false;
+                any = FALSE;
             }
             else
             if (*haystack)
                 haystack++;
             else
-                matched = false;
+                matched = FALSE;
         }
         else
         {
@@ -86,15 +86,15 @@
             else
             if (tmp)
             {
-                any = true;
+                any = TRUE;
                 pattern = tmp;
             }
             else
-                matched = false;
+                matched = FALSE;
         }
 
         if (!*haystack && !*pattern)
-            end = true;
+            end = TRUE;
 
         break;
     }
--- a/th_types.h	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_types.h	Tue Jan 02 23:09:29 2018 +0200
@@ -24,11 +24,6 @@
 #  endif
 #endif
 
-#ifdef HAVE_STDBOOL_H
-#  define HAVE_BOOL 1
-#  include <stdbool.h>
-#endif
-
 #ifdef HAVE_INTTYPES_H
 #  include <inttypes.h>
 #endif
@@ -176,15 +171,16 @@
 
 /* Define a boolean type, if needed
  */
-#ifndef HAVE_BOOL
-#  if !defined(false) && !defined(true) && !defined(bool)
-typedef enum { false = 0, true = 1 } bool;
-#  endif
-#  ifndef bool
-#    define bool int
-#  endif
+#if !defined(FALSE) && !defined(TRUE) && !defined(BOOL)
+typedef enum { FALSE = 0, TRUE = 1 } BOOL;
+#endif
 
-#endif // !HAVE_BOOL
-
+#ifndef BOOL
+#    ifdef bool
+#        define BOOL bool
+#    else
+#        define BOOL int
+#    endif
+#endif
 
 #endif // TH_TYPES_H
--- a/th_util.c	Tue Jan 02 22:57:47 2018 +0200
+++ b/th_util.c	Tue Jan 02 23:09:29 2018 +0200
@@ -12,7 +12,7 @@
 
 /* Default settings
  */
-static bool    th_initialized = false;
+static BOOL    th_initialized = FALSE;
 int            th_verbosityLevel = 2;
 char           *th_prog_name = NULL,
                *th_prog_desc = NULL,
@@ -40,7 +40,7 @@
     else
         th_prog_license = TH_PROG_LICENSE;
 
-    th_initialized = true;
+    th_initialized = TRUE;
 }
 
 
@@ -86,7 +86,7 @@
  */
 void THERR_V(const char *fmt, va_list ap)
 {
-    assert(th_initialized == true);
+    assert(th_initialized == TRUE);
 
     fprintf(stderr, "%s: ", th_prog_name);
     vfprintf(stderr, fmt, ap);
@@ -95,7 +95,7 @@
 
 void THMSG_V(int level, const char *fmt, va_list ap)
 {
-    assert(th_initialized == true);
+    assert(th_initialized == TRUE);
 
     if (th_verbosityLevel >= level)
     {
@@ -107,7 +107,7 @@
 
 void THPRINT_V(int level, const char *fmt, va_list ap)
 {
-    assert(th_initialized == true);
+    assert(th_initialized == TRUE);
 
     if (th_verbosityLevel >= level)
     {
@@ -119,7 +119,7 @@
 void THERR(const char *fmt, ...)
 {
     va_list ap;
-    assert(th_initialized == true);
+    assert(th_initialized == TRUE);
 
     va_start(ap, fmt);
     THERR_V(fmt, ap);
@@ -130,7 +130,7 @@
 void THMSG(int level, const char *fmt, ...)
 {
     va_list ap;
-    assert(th_initialized == true);
+    assert(th_initialized == TRUE);
 
     va_start(ap, fmt);
     THMSG_V(level, fmt, ap);
@@ -141,7 +141,7 @@
 void THPRINT(int level, const char *fmt, ...)
 {
     va_list ap;
-    assert(th_initialized == true);
+    assert(th_initialized == TRUE);
 
     va_start(ap, fmt);
     THPRINT_V(level, fmt, ap);