Added SILC Thread Queue API
[silc.git] / lib / silcutil / silcconfig.c
index 697aae14adf39ec9a89bf10979757bda538d2016..55524a32077ce3919cac0be5edfbe353dc7d6b08 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Giovanni Giacobbi <giovanni@giacobbi.net>
 
-  Copyright (C) 2002 - 2003 Giovanni Giacobbi
+  Copyright (C) 2002 - 2007 Giovanni Giacobbi
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
 */
 /* $Id$ */
 
-#include "silcincludes.h"
+#include "silc.h"
 
 /* limit debug logging verbosity */
 #if 0
@@ -94,10 +94,11 @@ char *silc_config_strerror(int errnum)
 static void my_trim_spaces(SilcConfigFile *file)
 {
   register char *r = file->p;
-  while ((*r != '\0' && *r != EOF) && isspace(*r))
+  while ((*r != '\0' && *r != EOF) && isspace((int)*r))
     if (*r++ == '\n') file->line++;
   file->p = r;
 }
+
 /* Skips the current line until newline (lf or cr) */
 static void my_skip_line(SilcConfigFile *file)
 {
@@ -106,6 +107,7 @@ static void my_skip_line(SilcConfigFile *file)
   file->p = ((*r != '\0' && *r != EOF) ? r + 1 : r);
   file->line++;
 }
+
 /* Obtains a text token from the current position until first separator.
  * a separator is any non alphanumeric character nor "_" or "-" */
 static char *my_next_token(SilcConfigFile *file, char *to)
@@ -113,12 +115,13 @@ static char *my_next_token(SilcConfigFile *file, char *to)
   register char *o;
   my_trim_spaces(file);
   o = file->p;
-  while (isalnum(*o) || (*o == '_') || (*o == '-'))
+  while (isalnum((int)*o) || (*o == '_') || (*o == '-'))
     *to++ = *o++;
   *to = '\0';
   file->p = o;
   return to;
 }
+
 /* Obtains a string from the current position. The only difference from
  * next_token() is that quoted-strings are also accepted */
 static char *my_get_string(SilcConfigFile *file, char *to)
@@ -146,7 +149,8 @@ static char *my_get_string(SilcConfigFile *file, char *to)
   /* we don't need quote parsing, fall-back to token extractor */
   my_next_token(file, to);
   return to;
-};
+}
+
 /* Skips all comment lines and spaces lines until first useful character */
 static void my_skip_comments(SilcConfigFile *file)
 {
@@ -171,6 +175,7 @@ static SilcConfigOption *silc_config_find_option(SilcConfigEntity ent,
   }
   return NULL;
 }
+
 /* Converts a string in the type specified. returns a dynamically
  * allocated pointer. */
 static void *silc_config_marshall(SilcConfigType type, const char *val)
@@ -208,7 +213,7 @@ static void *silc_config_marshall(SilcConfigType type, const char *val)
       if (val == val_tmp)
        return NULL; /* really wrong, there must be at least one digit */
       /* Search for a designator */
-      switch (tolower(val_tmp[0])) {
+      switch (tolower((int)val_tmp[0])) {
        case '\0': /* None */
          break;
        case 'k': /* Kilobytes */
@@ -258,7 +263,7 @@ SilcConfigFile *silc_config_open(const char *configfile)
   SilcUInt32 filelen;
   SilcConfigFile *ret;
 
-  if (!(buffer = silc_file_readfile(configfile, &filelen)))
+  if (!(buffer = silc_file_readfile(configfile, &filelen, NULL)))
     return NULL;
 
   ret = silc_calloc(1, sizeof(*ret));
@@ -295,7 +300,7 @@ SilcConfigEntity silc_config_init(SilcConfigFile *file)
   ret = silc_calloc(1, sizeof(*ret));
   ret->file = file;
   return ret;
-};
+}
 
 /* Returns the original filename of the object file */