gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1621 - in GNUnet/src: conf include util


From: durner
Subject: [GNUnet-SVN] r1621 - in GNUnet/src: conf include util
Date: Sat, 6 Aug 2005 12:17:02 -0700 (PDT)

Author: durner
Date: 2005-08-06 12:16:56 -0700 (Sat, 06 Aug 2005)
New Revision: 1621

Modified:
   GNUnet/src/conf/confdata.c
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/util/configuration.c
Log:
don't treat empty settings as NEW

Modified: GNUnet/src/conf/confdata.c
===================================================================
--- GNUnet/src/conf/confdata.c  2005-08-06 11:32:08 UTC (rev 1620)
+++ GNUnet/src/conf/confdata.c  2005-08-06 19:16:56 UTC (rev 1621)
@@ -1,8 +1,24 @@
 /*
- * Copyright (C) 2002 Roman Zippel <address@hidden>
- * Released under the terms of the GNU GPL v2.0.
- */
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
 
+     GNUnet 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, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+
 /**
  * @file conf/confdata.c
  * @brief GNUnet Setup
@@ -10,6 +26,10 @@
  * @author Nils Durner
  */
 
+/*
+ * Originally Copyright (C) 2002 Roman Zippel <address@hidden>
+ */
+
 #include <sys/stat.h>
 #include <ctype.h>
 #include <stdio.h>
@@ -194,8 +214,11 @@
          sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
                sym->flags &= ~SYMBOL_VALID;
                
-               val = getConfigurationString(sym->sect, sym->name);
-               if (val) {
+               if (isConfigurationItemSet(sym->sect, sym->name)) {
+               val = getConfigurationString(sym->sect, sym->name);             
        
+               if (!val)
+                       val = STRDUP("");
+               
                switch (sym->type) {
                        case S_TRISTATE:
                                if (*val == 'm') {

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2005-08-06 11:32:08 UTC (rev 1620)
+++ GNUnet/src/include/gnunet_util.h    2005-08-06 19:16:56 UTC (rev 1621)
@@ -751,6 +751,12 @@
                                int count);
 
 /**
+ * @brief Check if a setting was specified in a .conf file
+ * @return YES or NO
+ */
+int isConfigurationItemSet(const char *section, const char *option);
+
+/**
  * Start the cron jobs.
  */
 void startCron(void);

Modified: GNUnet/src/util/configuration.c
===================================================================
--- GNUnet/src/util/configuration.c     2005-08-06 11:32:08 UTC (rev 1620)
+++ GNUnet/src/util/configuration.c     2005-08-06 19:16:56 UTC (rev 1621)
@@ -245,6 +245,31 @@
   return NULL;
 }
 
+/**
+ * @brief Checks if a setting exists
+ * @return YES or NO
+ */
+static int cfg_exists(const char *sec,
+                                               const char *ent)
+{
+       struct CFG_ENTRIES *e = NULL;
+       int i;
+
+       if(c)
+               for(i = 0; i < c->sec_count; i++)
+                       if(0 == strcasecmp(c->sec_names[i], sec))
+                               e = c->sec_entries[i];
+                               
+       if(NULL == e)
+               return NO;
+               
+       for(i = 0; i < e->ent_count; i++)
+               if(0 == strcasecmp(e->ent_names[i], ent))
+                       return YES;
+               
+       return NO;
+}
+
 static int cfg_get_signed_int(const char *sec,
                              const char *ent) {
   char *val;
@@ -634,6 +659,33 @@
 }
 
 /**
+ * @brief Check if a setting was specified in a .conf file
+ * @return YES or NO
+ */
+int isConfigurationItemSet(const char *section, const char *option)
+{
+       UserConf *pos;
+       int found = NO;
+
+       GNUNET_ASSERT((section != NULL) && (option != NULL));
+       MUTEX_LOCK(&configLock);
+       pos = userconfig;
+       while(pos != NULL) {
+               if((strcmp(section, pos->section) == 0) &&
+                        (strcmp(option, pos->option) == 0)) {
+                               found = YES;
+                               break;
+               }
+               pos = pos->next;
+       }
+
+       if (! found && parseConfigInit == YES)
+               found = cfg_exists(section, option);
+
+       return found;
+}
+
+/**
  * Check if a string in the configuration matches a given value.  This
  * method should be preferred over getConfigurationString since this
  * method can avoid making a copy of the configuration string that





reply via email to

[Prev in Thread] Current Thread [Next in Thread]