changeset 170:8e69e07e5aac

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 19 Feb 2015 15:57:38 +0200
parents a2cd862315c5
children 9a1353862520
files th_config.c th_config.h
diffstat 2 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/th_config.c	Wed Feb 18 21:13:52 2015 +0200
+++ b/th_config.c	Thu Feb 19 15:57:38 2015 +0200
@@ -63,7 +63,7 @@
 
 /* Add integer type setting into give configuration
  */
-int th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *itemData, int itemDef)
+int th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *itemData, int defValue)
 {
     th_cfgitem_t *node;
 
@@ -71,14 +71,14 @@
     if (node == NULL)
         return -1;
 
-    *itemData = itemDef;
+    *itemData = defValue;
 
     return 0;
 }
 
 
 int th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name,
-                        int *itemData, int itemDef)
+                        int *itemData, int defValue)
 {
     th_cfgitem_t *node;
 
@@ -86,7 +86,7 @@
     if (node == NULL)
         return -1;
 
-    *itemData = itemDef;
+    *itemData = defValue;
 
     return 0;
 }
@@ -95,7 +95,7 @@
 /* Add unsigned integer type setting into give configuration
  */
 int th_cfg_add_uint(th_cfgitem_t **cfg, const char *name,
-                    unsigned int *itemData, unsigned int itemDef)
+                    unsigned int *itemData, unsigned int defValue)
 {
     th_cfgitem_t *node;
 
@@ -103,7 +103,7 @@
     if (node == NULL)
         return -1;
 
-    *itemData = itemDef;
+    *itemData = defValue;
 
     return 0;
 }
@@ -112,7 +112,7 @@
 /* Add strint type setting into given configuration
  */
 int th_cfg_add_string(th_cfgitem_t **cfg, const char *name,
-                      char **itemData, char *itemDef)
+                      char **itemData, char *defValue)
 {
     th_cfgitem_t *node;
 
@@ -120,7 +120,7 @@
     if (node == NULL)
         return -1;
 
-    *itemData = th_strdup(itemDef);
+    *itemData = th_strdup(defValue);
 
     return 0;
 }
@@ -129,7 +129,7 @@
 /* Add boolean type setting into given configuration
  */
 int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name,
-                    BOOL *itemData, BOOL itemDef)
+                    BOOL *itemData, BOOL defValue)
 {
     th_cfgitem_t *node;
 
@@ -137,7 +137,7 @@
     if (node == NULL)
         return -1;
 
-    *itemData = itemDef;
+    *itemData = defValue;
 
     return 0;
 }
@@ -198,7 +198,7 @@
     PM_KEYNAME,
     PM_KEYSET,
     PM_STRING,
-    PM_INT,
+    PM_NUMERIC,
     PM_BOOL,
     PM_SECTION,
     PM_ARRAY
@@ -371,7 +371,8 @@
 
                     case ITEM_INT:
                     case ITEM_UINT:
-                        nextMode = PM_INT;
+                    case ITEM_FLOAT:
+                        nextMode = PM_NUMERIC;
                         break;
 
                     case ITEM_BOOL:
@@ -539,7 +540,7 @@
             c = -1;
             break;
 
-        case PM_INT:
+        case PM_NUMERIC:
             // Integer parsing mode
             if (isStart && item->type == ITEM_UINT && c == '-')
             {
@@ -583,7 +584,7 @@
             {
                 // Error! Unexpected character.
                 th_ioctx_error(ctx, -1,
-                    "Unexpected character '%c' for integer setting '%s'.",
+                    "Unexpected character '%c' for numeric setting '%s'.",
                     c, item->name);
                 parseMode = PM_ERROR;
             }
--- a/th_config.h	Wed Feb 18 21:13:52 2015 +0200
+++ b/th_config.h	Thu Feb 19 15:57:38 2015 +0200
@@ -61,12 +61,13 @@
 int     th_cfg_add_section(th_cfgitem_t **cfg, const char *name, th_cfgitem_t *data);
 int     th_cfg_add_comment(th_cfgitem_t **cfg, const char *comment);
 
-int     th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *data, int itemDef);
-int     th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int itemDef);
-int     th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **data, char *itemDef);
-int     th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL itemDef);
-int     th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float itemDef);
-int     th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int itemDef);
+int     th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *data, int defValue);
+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_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);
 
 th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type);