diff th_config.c @ 129:aa2d608fb3f3

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 22 Jun 2014 07:23:54 +0300
parents 0ac59c798773
children 51eec969b07a
line wrap: on
line diff
--- a/th_config.c	Sun Jun 22 07:06:46 2014 +0300
+++ b/th_config.c	Sun Jun 22 07:23:54 2014 +0300
@@ -44,17 +44,17 @@
     if (cfg == NULL)
         return NULL;
 
-    /* Allocate new item */
+    // Allocate new item
     node = (th_cfgitem_t *) th_malloc0(sizeof(th_cfgitem_t));
     if (node == NULL)
         return NULL;
 
-    /* Set values */
+    // Set values
     node->type = type;
     node->v.data = data;
     node->name = th_strdup(name);
 
-    /* Insert into linked list */
+    // Insert into linked list
     if (*cfg != NULL)
     {
         node->prev = (*cfg)->prev;
@@ -226,7 +226,7 @@
     int c, parseMode, prevMode, nextMode, tmpCh;
     BOOL isFound, isStart, isError, validError;
 
-    /* Initialize values */
+    // Initialize values
     tmpCh = 0;
     strPos = 0;
     c = -1;
@@ -236,12 +236,12 @@
     if ((tmpStr = th_malloc(SET_MAX_BUF + 1)) == NULL)
         goto out;
 
-    /* Parse the configuration */
+    // Parse the configuration
     while (parseMode != PM_EOF && parseMode != PM_ERROR)
     {
         if (c == -1)
         {
-            /* Get next character */
+            // Get next character
             switch (c = fgetc(ctx->fp))
             {
             case EOF:
@@ -262,10 +262,10 @@
         switch (parseMode)
         {
         case PM_COMMENT:
-            /* Comment parsing mode */
+            // Comment parsing mode
             if (c == '\n')
             {
-                /* End of line, end of comment */
+                // End of line, end of comment
                 parseMode = prevMode;
                 prevMode = PM_COMMENT;
             }
@@ -273,7 +273,7 @@
             break;
 
         case PM_NORMAL:
-            /* Normal parsing mode */
+            // Normal parsing mode
             if (c == '#')
             {
                 prevMode = parseMode;
@@ -287,7 +287,7 @@
             else if (c == '}')
             {
                 if (nesting > 0)
-                    /* Check for validation errors */
+                    // Check for validation errors
                     goto out;
                 else
                 {
@@ -298,42 +298,42 @@
             }
             else if (th_isalpha(c))
             {
-                /* Start of key name found */
+                // Start of key name found
                 prevMode = parseMode;
                 parseMode = PM_KEYNAME;
                 strPos = 0;
             }
             else
             {
-                /* Error! Invalid character found */
+                // Error! Invalid character found
                 th_ioctx_error(ctx, -1, "Unexpected character '%c'.\n", c);
                 parseMode = PM_ERROR;
             }
             break;
 
         case PM_KEYNAME:
-            /* Configuration KEY name parsing mode */
+            // Configuration KEY name parsing mode
             if (c == '#')
             {
-                /* Start of comment */
+                // Start of comment
                 prevMode = parseMode;
                 parseMode = PM_COMMENT;
                 c = -1;
             }
             else if (th_iscrlf(c) || th_isspace(c) || c == '=')
             {
-                /* End of key name */
+                // End of key name
                 prevMode = parseMode;
                 parseMode = PM_NEXT;
                 nextMode = PM_KEYSET;
             }
             else if (th_isalnum(c) || c == '_')
             {
-                /* Add to key name string */
+                // Add to key name string
                 VADDCH(c)
                 else
                 {
-                    /* Error! Key name string too long! */
+                    // Error! Key name string too long!
                     th_ioctx_error(ctx, -1, "Config key name too long!");
                     parseMode = PM_ERROR;
                 }
@@ -341,7 +341,7 @@
             }
             else
             {
-                /* Error! Invalid character found */
+                // Error! Invalid character found
                 tmpStr[strPos] = 0;
                 th_ioctx_error(ctx, -1,
                     "Unexpected character '%c' in key name '%s'.\n",
@@ -353,7 +353,7 @@
         case PM_KEYSET:
             if (c == '=')
             {
-                /* Find key from configuration */
+                // Find key from configuration
                 tmpStr[strPos] = 0;
                 isFound = FALSE;
                 item = cfg;
@@ -365,10 +365,10 @@
                         item = item->next;
                 }
 
-                /* Check if key was found */
+                // Check if key was found
                 if (isFound)
                 {
-                    /* Okay, set next mode */
+                    // Okay, set next mode
                     switch (item->type)
                     {
                     case ITEM_HEX_TRIPLET:
@@ -401,7 +401,7 @@
                 }
                 else
                 {
-                    /* Error! No configuration key by this name found */
+                    // Error! No configuration key by this name found
                     th_ioctx_error(ctx, -1,
                         "No such configuration setting ('%s')\n",
                         tmpStr);
@@ -412,7 +412,7 @@
             }
             else
             {
-                /* Error! '=' expected! */
+                // Error! '=' expected!
                 th_ioctx_error(ctx, -1,
                     "Unexpected character '%c', assignation '=' was expected.\n",
                     c);
@@ -421,21 +421,21 @@
             break;
 
         case PM_NEXT:
-            /* Search next item parsing mode */
+            // Search next item parsing mode
             if (c == '#')
             {
-                /* Start of comment */
+                // Start of comment
                 prevMode = parseMode;
                 parseMode = PM_COMMENT;
             }
             else if (th_isspace(c) || th_iscrlf(c))
             {
-                /* Ignore whitespaces and linechanges */
+                // Ignore whitespaces and linechanges
                 c = -1;
             }
             else
             {
-                /* Next item found */
+                // Next item found
                 prevMode = parseMode;
                 parseMode = nextMode;
             }
@@ -473,10 +473,10 @@
             break;
 
         case PM_SECTION:
-            /* Section parsing mode */
+            // Section parsing mode
             if (c != '{')
             {
-                /* Error! Section start '{' expected! */
+                // Error! Section start '{' expected!
                 th_ioctx_error(ctx, -1,
                     "Unexpected character '%c', section start '{' was expected.\n",
                     c);
@@ -499,17 +499,17 @@
             break;
 
         case PM_STRING:
-            /* String parsing mode */
+            // String parsing mode
             if (isStart)
             {
-                /* Start of string, get delimiter */
+                // Start of string, get delimiter
                 tmpCh = c;
                 isStart = FALSE;
                 strPos = 0;
             }
             else if (c == tmpCh)
             {
-                /* End of string, set the value */
+                // End of string, set the value
                 tmpStr[strPos] = 0;
 
                 switch (item->type)
@@ -535,11 +535,11 @@
             }
             else
             {
-                /* Add character to string */
+                // Add character to string
                 VADDCH(c)
                 else
                 {
-                    /* Error! String too long! */
+                    // Error! String too long!
                     th_ioctx_error(ctx, -1,
                         "String too long! Maximum is %d characters.",
                         SET_MAX_BUF);
@@ -551,10 +551,10 @@
             break;
 
         case PM_INT:
-            /* Integer parsing mode */
+            // Integer parsing mode
             if (isStart && item->type == ITEM_UINT && c == '-')
             {
-                /* Error! Negative values not allowed for unsigned ints */
+                // Error! Negative values not allowed for unsigned ints
                 th_ioctx_error(ctx, -1,
                     "Negative value specified for %s, unsigned value expected.",
                     item->name);
@@ -574,7 +574,7 @@
             }
             else if (VISEND(c))
             {
-                /* End of integer parsing mode */
+                // End of integer parsing mode
                 tmpStr[strPos] = 0;
                 switch (item->type)
                 {
@@ -592,7 +592,7 @@
             }
             else
             {
-                /* Error! Unexpected character. */
+                // Error! Unexpected character.
                 th_ioctx_error(ctx, -1,
                     "Unexpected character '%c' for integer setting '%s'.",
                     c, item->name);
@@ -601,7 +601,7 @@
 
             if (isError)
             {
-                /* Error! String too long! */
+                // Error! String too long!
                 th_ioctx_error(ctx, -1,
                     "String too long! Maximum is %d characters.",
                     SET_MAX_BUF);
@@ -613,7 +613,7 @@
             break;
 
         case PM_BOOL:
-            /* Boolean parsing mode */
+            // Boolean parsing mode
             if (isStart)
             {
                 tmpCh = c;
@@ -623,7 +623,7 @@
             {
                 BOOL tmpBool = FALSE;
 
-                /* End of boolean parsing */
+                // End of boolean parsing
                 switch (tmpCh)
                 {
                 case 'Y':
@@ -669,11 +669,11 @@
 out:
     th_free(tmpStr);
 
-    /* Check for validation errors */
+    // Check for validation errors
     if (validError)
         return 1;
 
-    /* Return result */
+    // Return result
     if (parseMode == PM_ERROR)
         return -2;
     else