diff th_config.c @ 457:85fa3d333556

Actually, revert the boolean changes .. meh.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Jan 2018 23:09:29 +0200
parents efd33accdc81
children ff3ebe22f6c5
line wrap: on
line diff
--- 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);
 }