X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcconfig.c;h=93e27d2d3560ac655a6300e1c34662e444124ef6;hb=40f8443d8d3a6577336ee66d18e04d9ac4d956bb;hp=2066f95719ed0531315ffaebdc7bb2e9d8c36346;hpb=ecb19b3983b3e74bc4aaa82277abd125c53c3623;p=silc.git diff --git a/lib/silcutil/silcconfig.c b/lib/silcutil/silcconfig.c index 2066f957..93e27d2d 100644 --- a/lib/silcutil/silcconfig.c +++ b/lib/silcutil/silcconfig.c @@ -8,8 +8,7 @@ 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +18,7 @@ */ /* $Id$ */ -#include "silcincludes.h" +#include "silc.h" /* limit debug logging verbosity */ #if 0 @@ -48,7 +47,7 @@ struct SilcConfigFileObject { char *p; /* the Parser poitner */ SilcUInt32 len; /* fixed length of the whole file */ SilcUInt32 line; /* current parsing line, strictly linked to p */ - bool included; /* wether this file is main or included */ + SilcBool included; /* wether this file is main or included */ }; /* We need the entity to base our block-style parsing on */ @@ -95,7 +94,7 @@ char *silc_config_strerror(int errnum) static void my_trim_spaces(SilcConfigFile *file) { register char *r = file->p; - while (isspace(*r)) + while ((*r != '\0' && *r != EOF) && isspace(*r)) if (*r++ == '\n') file->line++; file->p = r; } @@ -103,8 +102,8 @@ static void my_trim_spaces(SilcConfigFile *file) static void my_skip_line(SilcConfigFile *file) { register char *r = file->p; - while (*r && (*r != '\n') && (*r != '\r')) r++; - file->p = (*r ? r + 1 : r); + while ((*r != '\0' && *r != EOF) && (*r != '\n') && (*r != '\r')) r++; + file->p = ((*r != '\0' && *r != EOF) ? r + 1 : r); file->line++; } /* Obtains a text token from the current position until first separator. @@ -178,7 +177,7 @@ static void *silc_config_marshall(SilcConfigType type, const char *val) { void *pt; int val_int; - bool val_bool; + SilcBool val_boolean; char *val_tmp; SilcUInt32 val_size; @@ -186,16 +185,16 @@ static void *silc_config_marshall(SilcConfigType type, const char *val) case SILC_CONFIG_ARG_TOGGLE: if (!strcasecmp(val, "yes") || !strcasecmp(val, "true") || !strcasecmp(val, "on") || !strcasecmp(val, "1")) { - val_bool = TRUE; + val_boolean = TRUE; } else if (!strcasecmp(val, "no") || !strcasecmp(val, "false") || !strcasecmp(val, "off") || !strcasecmp(val, "0")) { - val_bool = FALSE; + val_boolean = FALSE; } else return NULL; - pt = silc_calloc(1, sizeof(val_bool)); - *(bool *)pt = (bool) val_bool; + pt = silc_calloc(1, sizeof(val_boolean)); + *(SilcBool *)pt = (SilcBool) val_boolean; return pt; case SILC_CONFIG_ARG_INT: val_int = (int) strtol(val, &val_tmp, 0); @@ -355,7 +354,7 @@ char *silc_config_read_current_line(SilcConfigFile *file) /* (Private) destroy a SilcConfigEntity */ -static void silc_config_destroy(SilcConfigEntity ent, bool destroy_opts) +static void silc_config_destroy(SilcConfigEntity ent, SilcBool destroy_opts) { SilcConfigOption *oldopt, *nextopt; SILC_CONFIG_DEBUG(("Freeing config entity [ent=0x%x] [opts=0x%x]", @@ -381,7 +380,7 @@ static void silc_config_destroy(SilcConfigEntity ent, bool destroy_opts) /* Registers a new option in the specified entity. * Returns TRUE on success, FALSE if already registered. */ -bool silc_config_register(SilcConfigEntity ent, const char *name, +SilcBool silc_config_register(SilcConfigEntity ent, const char *name, SilcConfigType type, SilcConfigCallback cb, const SilcConfigTable *subtable, void *context) { @@ -425,7 +424,7 @@ bool silc_config_register(SilcConfigEntity ent, const char *name, /* Register a new option table in the specified config entity */ -bool silc_config_register_table(SilcConfigEntity ent, +SilcBool silc_config_register_table(SilcConfigEntity ent, const SilcConfigTable table[], void *context) { int i;