gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3153 - in GNUnet/src: include server transports util/confi


From: grothoff
Subject: [GNUnet-SVN] r3153 - in GNUnet/src: include server transports util/config
Date: Sat, 29 Jul 2006 01:04:49 -0700 (PDT)

Author: grothoff
Date: 2006-07-29 01:04:48 -0700 (Sat, 29 Jul 2006)
New Revision: 3153

Modified:
   GNUnet/src/include/gnunet_util_config.h
   GNUnet/src/server/gnunetd.c
   GNUnet/src/transports/nat.c
   GNUnet/src/util/config/config.c
Log:
better yesno

Modified: GNUnet/src/include/gnunet_util_config.h
===================================================================
--- GNUnet/src/include/gnunet_util_config.h     2006-07-29 07:56:57 UTC (rev 
3152)
+++ GNUnet/src/include/gnunet_util_config.h     2006-07-29 08:04:48 UTC (rev 
3153)
@@ -129,6 +129,19 @@
                                      const char ** value);
 
 /**
+ * Get a configuration value that should be in a set of
+ * "YES" or "NO".
+ *
+ * @param def default value (use indicated by return value;
+ *        will NOT be aliased, maybe NULL)
+ * @return YES, NO or SYSERR
+ */
+int GC_get_configuration_value_yesno(struct GC_Configuration * cfg,
+                                    const char * section,
+                                    const char * option,
+                                    int def);
+
+/**
  * Set a configuration value that should be a number.
  * @return 0 on success, -1 on error (i.e. out of memory,
  *   or update refused by registered callback)

Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2006-07-29 07:56:57 UTC (rev 3152)
+++ GNUnet/src/server/gnunetd.c 2006-07-29 08:04:48 UTC (rev 3153)
@@ -100,11 +100,13 @@
   struct SignalHandlerContext * shc_hup;
   int filedes[2]; /* pipe between client and parent */
 
-  if (NO == debug_flag()) {
-    if (OK != detachFromTerminal(ectx,
-                                filedes))
-      return SYSERR;
-  }
+  if ( (NO == GC_get_configuration_value_yesno(cfg,
+                                              "GNUNETD",
+                                              "DEBUG",
+                                              NO)) &&
+       (OK != os_terminal_detach(ectx,
+                                filedes)) )
+    return SYSERR;
   mon = os_network_monitor_create(ectx,
                                  cfg);
   cron = cron_create(ectx);
@@ -117,8 +119,9 @@
   loadApplicationModules();
   writePIDFile(ectx, cfg);
   if (NO == debug_flag())
-    detachFromTerminalComplete(ectx,
-                              filedes);
+    os_terminal_detach_complete(ectx,
+                               filedes,
+                               YES);
   cron_start(cron);
   enableCoreProcessing();
   waitForSignalHandler(ectx);  
@@ -149,7 +152,7 @@
                 "not daemonize and error messages will "
                 "be written to stderr instead of a logfile"), 
     0, &gnunet_getopt_configure_set_option, "GNUNETD:DEBUG" },
-  COMMAND_LINE_OPTION_HELP(_("Starts the gnunetd daemon.")), /* -h */
+  COMMAND_LINE_OPTION_HELP(gettext_noop("Starts the gnunetd daemon.")), /* -h 
*/
   COMMAND_LINE_OPTION_HOSTNAME, /* -H */
   COMMAND_LINE_OPTION_LOGGING, /* -L */
   { 'p', "padding", "PADDING", gettext_noop(""), 1,

Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2006-07-29 07:56:57 UTC (rev 3152)
+++ GNUnet/src/transports/nat.c 2006-07-29 08:04:48 UTC (rev 3153)
@@ -65,13 +65,10 @@
        (ntohs(helo->header.type) != p2p_PROTO_hello) ) {
     return SYSERR; /* obviously invalid */
   } else {
-    if ( (-1 != GC_get_configuration_value_choice(coreAPI->cfg,
-                                                 "NAT",
-                                                 "LIMITED",
-                                                 yesno,
-                                                 "NO",
-                                                 &value)) &&
-        (value == "YES") ) {
+    if (YES == GC_get_configuration_value_yesno(coreAPI->cfg,
+                                               "NAT",
+                                               "LIMITED",
+                                               NO)) {
       /* if WE are a NAT and this is not our hello,
         it is invalid since NAT-to-NAT is not possible! */
       if (0 == memcmp(&coreAPI->myIdentity->hashPubKey,
@@ -97,15 +94,11 @@
   const char * value;
   P2P_hello_MESSAGE * msg;
 
-  if (! ( (-1 != GC_get_configuration_value_choice(coreAPI->cfg,
-                                               "NAT",
-                                               "LIMITED",
-                                               yesno,
-                                               "NO",
-                                               &value)) &&
-         (value == "YES") ) )
+  if (NO == GC_get_configuration_value_yesno(coreAPI->cfg,
+                                            "NAT",
+                                            "LIMITED",
+                                            NO))
     return NULL;
-
   msg = MALLOC(sizeof(P2P_hello_MESSAGE) + sizeof(HostAddress));
   msg->senderAddressSize = htons(sizeof(HostAddress));
   msg->protocol          = htons(NAT_PROTOCOL_NUMBER);

Modified: GNUnet/src/util/config/config.c
===================================================================
--- GNUnet/src/util/config/config.c     2006-07-29 07:56:57 UTC (rev 3152)
+++ GNUnet/src/util/config/config.c     2006-07-29 08:04:48 UTC (rev 3153)
@@ -77,7 +77,36 @@
   return cfg->write_configuration(cfg, filename);
 }
 
+
 /**
+ * Get a configuration value that should be in a set of
+ * "YES" or "NO".
+ *
+ * @param def default value (use indicated by return value;
+ *        will NOT be aliased, maybe NULL)
+ * @return YES, NO or SYSERR
+ */
+int GC_get_configuration_value_yesno(struct GC_Configuration * cfg,
+                                    const char * section,
+                                    const char * option,
+                                    int def) {
+  static const char * yesno[] = { "YES" , "NO", NULL };
+  const char * val;
+  int ret;
+
+  ret = GC_get_configuration_value_choice(cfg,
+                                         section,
+                                         option,
+                                         def == YES ? "YES" : "NO",
+                                         &val);
+  if (ret == -1)
+    return SYSERR;
+  if (ret == yesno[0])
+    return YES;
+  return NO;
+}
+
+/**
  * Get a configuration value that should be a number.
  * @param min minimal legal value
  * @param max maximal legal value





reply via email to

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