gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1660 - in GNUnet: contrib src/conf src/util


From: grothoff
Subject: [GNUnet-SVN] r1660 - in GNUnet: contrib src/conf src/util
Date: Sat, 13 Aug 2005 22:49:08 -0700 (PDT)

Author: grothoff
Date: 2005-08-13 22:49:03 -0700 (Sat, 13 Aug 2005)
New Revision: 1660

Added:
   GNUnet/src/conf/conf.h
   GNUnet/src/conf/confdata.h
   GNUnet/src/conf/gconf.h
   GNUnet/src/conf/mconf.h
   GNUnet/src/conf/recreate.h
   GNUnet/src/conf/wizard.h
   GNUnet/src/conf/wizard_curs.h
   GNUnet/src/conf/zconf_tab.h
Removed:
   GNUnet/contrib/config.in
Modified:
   GNUnet/contrib/Makefile.am
   GNUnet/contrib/config-client.in
   GNUnet/contrib/config-daemon.in
   GNUnet/src/conf/Makefile.am
   GNUnet/src/conf/conf.c
   GNUnet/src/conf/confdata.c
   GNUnet/src/conf/gconf.c
   GNUnet/src/conf/gnunet-setup.c
   GNUnet/src/conf/lkc.h
   GNUnet/src/conf/lkc_defs.h
   GNUnet/src/conf/lkc_proto.h
   GNUnet/src/conf/mconf.c
   GNUnet/src/conf/recreate.c
   GNUnet/src/conf/wizard.c
   GNUnet/src/conf/wizard_callbacks.c
   GNUnet/src/conf/wizard_curs.c
   GNUnet/src/util/configuration.c
Log:
working on conf

Modified: GNUnet/contrib/Makefile.am
===================================================================
--- GNUnet/contrib/Makefile.am  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/contrib/Makefile.am  2005-08-14 05:49:03 UTC (rev 1660)
@@ -3,7 +3,6 @@
 endif
 
 pkgdata_DATA = \
- config.in \
  config-client.in \
  config-daemon.in
 

Modified: GNUnet/contrib/config-client.in
===================================================================
--- GNUnet/contrib/config-client.in     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/contrib/config-client.in     2005-08-14 05:49:03 UTC (rev 1660)
@@ -2,24 +2,6 @@
 
 menu "User specific configuration" ""
 menu "Meta-configuration" "Meta"
-  config config-client.in_CONF_DEF_DIR
-  string "Default configuration directory"
-  depends on RARE-CLIENT
-  default "~/.gnunet/"
-  help
-       This is the directory where gnunet-setup will store the configuration
-       file by default.
-       Default: config-client.in_CONF_DEF_DIR                  = ~/.gnunet/
-  
-  config config-client.in_CONF_DEF_FILE
-  string "Default configuration file"
-  depends on RARE-CLIENT
-  default "gnunet.conf"
-  help
-       This is the filename under which gnunet-setup will store the 
configuration
-       by default.
-       Default: config-client.in_CONF_DEF_FILE         = gnunet.conf
-
   config ADVANCED-CLIENT
   bool "Show options for advanced users"
   

Modified: GNUnet/contrib/config-daemon.in
===================================================================
--- GNUnet/contrib/config-daemon.in     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/contrib/config-daemon.in     2005-08-14 05:49:03 UTC (rev 1660)
@@ -2,24 +2,6 @@
 
 menu "Server configuration" ""
 menu "Meta-configuration" "Meta"
-  config config-daemon.in_CONF_DEF_DIR
-  string "Default configuration directory"
-  depends on RARE
-  default "/etc/"
-  help
-       This is the directory where gnunet-setup will store the configuration
-       file by default.
-       Default: config-daemon.in_CONF_DEF_DIR                  = /etc/
-  
-  config config-daemon.in_CONF_DEF_FILE
-  string "Default configuration file"
-  depends on RARE
-  default "gnunetd.conf"
-  help
-       This is the filename under which gnunet-setup will store the 
configuration
-       by default.
-       Default: config-daemon.in_CONF_DEF_FILE         = gnunetd.conf
-
   config EXPERIMENTAL
   bool "Prompt for development and/or incomplete code"
   help

Deleted: GNUnet/contrib/config.in
===================================================================
--- GNUnet/contrib/config.in    2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/contrib/config.in    2005-08-14 05:49:03 UTC (rev 1660)
@@ -1,4 +0,0 @@
-mainmenu "GNUnet user configuration"
-
-source "$DATADIR/config-daemon.in"
-source "$DATADIR/config-client.in"

Modified: GNUnet/src/conf/Makefile.am
===================================================================
--- GNUnet/src/conf/Makefile.am 2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/Makefile.am 2005-08-14 05:49:03 UTC (rev 1660)
@@ -36,7 +36,7 @@
 
 if HAVE_CURSES
 mconf_src = \
-  mconf.c \
+  mconf.c mconf.h \
   mconf_checklist.c \
   mconf_colors.h \
   mconf_dialog.h \
@@ -46,7 +46,7 @@
   mconf_textbox.c \
   mconf_util.c \
   mconf_yesno.c \
-  wizard_curs.c
+  wizard_curs.c wizard_curs.h
 endif
 
 if HAVE_GTK
@@ -58,22 +58,22 @@
    gconf_support.h \
    gconf_interface.c \
    gconf_support.c \
-   gconf.c \
+   gconf.c gconf.h \
    images.c 
-   
+
  gbasic_src = \
    wizard_callbacks.h \
    wizard_interface.h \
    wizard_support.h \
    wizard_callbacks.c \
    wizard_interface.c \
-   wizard.c
+   wizard.c wizard.h
 endif
 
 
 gnunet_setup_SOURCES = \
- conf.c \
- confdata.c \
+ conf.c conf.h \
+ confdata.c confdata.h \
  expr.c \
  expr.h \
  lkc.h \

Modified: GNUnet/src/conf/conf.c
===================================================================
--- GNUnet/src/conf/conf.c      2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/conf.c      2005-08-14 05:49:03 UTC (rev 1660)
@@ -1,4 +1,23 @@
 /*
+     This file is part of GNUnet.
+     (C) 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.
+*/
+/*
  * Copyright (C) 2002 Roman Zippel <address@hidden>
  * Released under the terms of the GNU GPL v2.0.
  */
@@ -13,6 +32,8 @@
 #define LKC_DIRECT_LINK
 #include "lkc.h"
 
+#include "confdata.h"
+
 static void conf(struct menu *menu);
 static void check_conf(struct menu *menu);
 
@@ -482,95 +503,32 @@
                check_conf(child);
 }
 
-int conf_main(int ac, char **av)
+int conf_main()
 {
-       int i = 1;
-       struct stat tmpstat;
-
-       if (ac > i && av[i][0] == '-') {
-               switch (av[i++][1]) {
-               case 'o':
-                       input_mode = ask_new;
-                       break;
-               case 's':
-                       input_mode = ask_silent;
-                       valid_stdin = isatty(0) && isatty(1) && isatty(2);
-                       break;
-               case 'd':
-                       input_mode = set_default;
-                       break;
-               case 'D':
-                       input_mode = set_default;
-                       defconfig_file = av[i++];
-                       if (!defconfig_file) {
-                               printf("%s: No default config file specified\n",
-                                       av[0]);
-                               exit(1);
-                       }
-                       break;
-               case 'n':
-                       input_mode = set_no;
-                       break;
-               case 'm':
-                       input_mode = set_mod;
-                       break;
-               case 'y':
-                       input_mode = set_yes;
-                       break;
-               case 'r':
-                       input_mode = set_random;
-                       srand(time(NULL));
-                       break;
-               case 'h':
-               case '?':
-                       printf("%s [-o|-s] config\n", av[0]);
-                       exit(0);
-               }
-       }
-
-       conf_parse(DATADIR"/config.in");
+  char * filename;
   
-       switch (input_mode) {
-       case set_default:
-               if (!defconfig_file)
-                       defconfig_file = conf_get_default_confname();
-               if (conf_read(defconfig_file)) {
-                       printf("***\n"
-                               "*** Can't find default configuration \"%s\"!\n"
-                               "***\n", defconfig_file);
-                       exit(1);
-               }
-               break;
-       case ask_silent:
-               if (STAT("/etc/GNUnet/.config", &tmpstat)) {
-                       printf("***\n"
-                               "*** You have not yet configured GNUnet!\n"
-                               "***\n"
-                               "*** Please run some configurator (e.g.\n"
-                               "*** \"gnunet-setup menuconfig\" or 
\"gnunet-setup gconfig\").\n"
-                               "***\n");
-                       exit(1);
-               }
-       case ask_all:
-       case ask_new:
-               conf_read(NULL);
-               break;
-       default:
-               break;
-       }
-
-       if (input_mode != ask_silent) {
-               rootEntry = &rootmenu;
-               conf(&rootmenu);
-               if (input_mode == ask_all) {
-                       input_mode = ask_silent;
-                       valid_stdin = 1;
-               }
-       }
-       do {
-               conf_cnt = 0;
-               check_conf(&rootmenu);
-       } while (conf_cnt);
-       conf_write();
-       return 0;
+  filename = getConfigurationString("GNUNET-SETUP",
+                                   "FILENAME");
+  conf_read(filename);
+  input_mode = ask_all; /* for now */
+  rootEntry = &rootmenu;
+  conf(&rootmenu);  
+  do {
+    conf_cnt = 0;
+    check_conf(&rootmenu);
+  } while (conf_cnt);
+   
+  if (conf_write(filename)) {
+    printf(_("Unable to save configuration file '%s': %s.\n"), 
+          filename,
+          STRERROR(errno));
+    FREE(filename);
+    return 1;
+  }
+  else {
+    printf(_("Configuration file '%s' created.\n"),
+          filename);
+    FREE(filename);
+    return 0;
+  }
 }

Added: GNUnet/src/conf/conf.h
===================================================================
--- GNUnet/src/conf/conf.h      2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/conf.h      2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/conf.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef CONF_H
+#define CONF_H
+
+int conf_main(void);
+
+#endif

Modified: GNUnet/src/conf/confdata.c
===================================================================
--- GNUnet/src/conf/confdata.c  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/confdata.c  2005-08-14 05:49:03 UTC (rev 1660)
@@ -44,518 +44,223 @@
 #include "platform.h"
 #include "gnunet_util.h"
 
-const char conf_def_filename[] = "gnunet.conf";
-
-const char conf_defname[] = "defconfig";
-
-const char *conf_confnames[] = {
-                               ".config",
-        "/tmp/.config",
-        "/etc/gnunet.conf",
-                               conf_defname,
-                               NULL,
-};
-
-static char *conf_expand_value(const char *in)
-{
-       struct symbol *sym;
-       const char *src;
-       static char res_value[SYMBOL_MAXLENGTH];
-       char *dst, name[SYMBOL_MAXLENGTH];
-
-       res_value[0] = 0;
-       dst = name;
-       while ((src = strchr(in, '$'))) {
-               strncat(res_value, in, src - in);
-               src++;
-               dst = name;
-               while (isalnum(*src) || *src == '_')
-                       *dst++ = *src++;
-               *dst = 0;
-               sym = sym_lookup(name, "X", 0);
-               sym_calc_value(sym);
-               strcat(res_value, sym_get_string_value(sym));
-               in = src;
-       }
-       strcat(res_value, in);
-
-       return res_value;
-}
-
-char *conf_get_default_confname(void)
-{
-       struct stat buf;
-       static char fullname[PATH_MAX+1];
-       char *env, *name;
-
-       name = conf_expand_value(conf_defname);
-       env = getenv(SRCTREE);
-       if (env) {
-               sprintf(fullname, "%s/%s", env, name);
-               if (!STAT(fullname, &buf))
-                       return fullname;
-       }
-       return name;
-}
-
-void extract_setting(char *line, char **setting, char *sect)
-{
-       int idx = 0;
-       while ((!(line[idx] == '!' || line[idx] == 0)) &&
-               idx <= 250)
-       {
-               sect[idx] = line[idx];
-               idx++;
-       }
-       if (! line[idx])
-       {
-               strcpy(sect, "GENERAL");
-               idx = 0;
-       }
-       else
-               sect[idx] = 0;
-
-       if(idx)
-               idx++;
-
-       *setting = line + idx;
-}
-
-/**
- * @brief Set default for GNUNETD_HOME if needed
- */
-void checkGNUNETDHome(struct symbol *sym)
-{
-       if (strcmp(sym->name, "GNUNETD_HOME") == 0)
-       {
-               const char *val;
-               
-               sym_calc_value_ext(sym, 1);
-               val = sym_get_string_value(sym);
-               
-               /* only empty if gnunet-setup is run for the first time */
-               if (!val || !strlen(val))
-               {
-                       /* GNUNETD_HOME isn't set yet. Let's choose a sane 
default */
-                       struct stat buf;
-                       int var = 0;
-                       if (STAT("/var/lib/GNUnet", &buf) != 0)
-                       {
-                               /* /var/lib/GNUnet doesn't exist. Do we have 
write permissions to /var? */
-                               if (ACCESS("/var", W_OK) == 0)
-                                       var = 1;
-                       }
-                       else
-                       {
-                               /* /var/lib/GNUnet is there, do we have write 
permissions? */
-                               if (ACCESS("/var/lib/GNUnet", W_OK) == 0)
-                                       var = 1;
-                       }
-                       
-                       sym_set_string_value(sym, var ? "/var/lib/GNUnet" : 
"~/.gnunet");
-               }
-       }
-}
-
 int conf_read(const char *name)
 {
-       char *val;
-       struct symbol *sym;
-       struct property *prop;
-       struct expr *e;
-       int i = 0;
+  char *val;
+  struct symbol *sym;
+  struct property *prop;
+  struct expr *e;
+  int i = 0;
+  
+  GNUNET_ASSERT(name != NULL);
+  setConfigurationString("FILES",
+                        "gnunet.conf",
+                        name);
+  readConfigFile(name);        
+  
+  for_all_symbols(i, sym) {
+    sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
+    sym->flags &= ~SYMBOL_VALID;
+    
+    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') {
+         sym->user.tri = mod;
+         sym->flags &= ~SYMBOL_NEW;
+         break;
+       }
+      case S_BOOLEAN:
+       sym->user.tri = (*val == 'Y') ? yes : no;
+       sym->flags &= ~SYMBOL_NEW;
+       break;
+      case S_STRING:
+      case S_INT:
+      case S_HEX:
+       if (sym->user.val)
+         free(sym->user.val);
        
-       if (! name) {
-               /* Read default config files as defined in the templates */
-               if (! name && file_list) {
-                       struct file *f;
-                       i = 1;
-                       
-                       /* Go through the list of used template files */
-                       for (f = file_list; f; f = f->next) {
-                               char *path, *fn, *key;
-                               struct symbol *defFile;
-                               
-                               path = f->name;
-                               fn = path + strlen(path);
-                               
-                               /* Get filename without path */
-                               while(*fn != '/' && *fn != '\\' && fn != path)
-                                       fn--;
-                               if (fn != path)
-                                       fn++;
-                               
-                               /* Query default config file */
-                               key = malloc(strlen(fn) + 16);
-                               sprintf(key, "%s_CONF_DEF_DIR", fn);
-                               sym = sym_find(key, "Meta");
-                               if (sym) {
-                                       sprintf(key, "%s_CONF_DEF_FILE", fn);
-                                       defFile = sym_find(key, "Meta");
-                                       if (defFile) {
-                                               char *path, *file, c;
-                                               int pathLen;
-                                               
-                                               sym_calc_value_ext(sym, 1);
-                                               sym_calc_value_ext(defFile, 1);
-                                               path = (char *) 
sym_get_string_value(sym);
-                                               file = (char *) 
sym_get_string_value(defFile);                                  
-                                               
-                                               pathLen = strlen(path);
-                                               key = realloc(key, pathLen + 
strlen(file) + 2);
-                                               strcpy(key, path);
-                                               c = key[pathLen-1];
-                                               if (c != '\\' && c != '/')
-                                                       strcat(key, 
DIR_SEPARATOR_STR);
-                                               strcat(key, file);
-                                               setConfigurationString("FILES",
-                                                                      
"gnunet.conf",
-                                                                      key);
-                                               
setConfigurationString("GNUNETD", "_MAGIC_",
-                                                       strcmp(fn, 
"config-daemon.in") == 0 ? "YES" : "NO");
-                                               readConfigFile(key);
-                                       }
-                               }
-                               free(key);
-                       }
-               }
-
-               /* Read global default files (only if necessary) */
-               if (!i) {
-                       const char **names = conf_confnames;
-                       
-                       while ( (name = *names++)) {
-                         name = conf_expand_value(name); 
-                         if (0 == ACCESS(name, R_OK)) {
-                           setConfigurationString("FILES",
-                                                  "gnunet.conf",
-                                                  name);
-                           readConfigFile(name);
-                           i = 1;
-                           break;
-                         }
-                       }
-               }
+       if (sym_string_valid(sym, val)) {
+         sym->user.val = STRDUP(val);
+         sym->flags &= ~SYMBOL_NEW;
        }
        else {
-               i = 1;
-               setConfigurationString("FILES",
-                                      "gnunet.conf",
-                                      name);
-               readConfigFile(name);
+         LOG(LOG_ERROR,
+             _("%s: symbol value '%s' invalid for %s\n"), 
+             name, 
+             val,
+             sym->name);
+         sym->user.val = NULL;
+         sym->flags |= SYMBOL_NEW;
        }
-
-       if (!i)
-               return 1;
        
-       for_all_symbols(i, sym) {
-         sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
-               sym->flags &= ~SYMBOL_VALID;
-
-               checkGNUNETDHome(sym);
-               
-               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') {
-                                       sym->user.tri = mod;
-                                       sym->flags &= ~SYMBOL_NEW;
-                                       break;
-                               }
-                       case S_BOOLEAN:
-                               sym->user.tri = (*val == 'Y') ? yes : no;
-                               sym->flags &= ~SYMBOL_NEW;
-                               break;
-                       case S_STRING:
-                       case S_INT:
-                       case S_HEX:
-                               if (sym->user.val)
-                                       free(sym->user.val);
-  
-                               if (sym_string_valid(sym, val)) {
-                                       sym->user.val = strdup(val);
-                                       sym->flags &= ~SYMBOL_NEW;
-                               }
-                               else {
-                                       fprintf(stderr, "%s: symbol value '%s' 
invalid for %s\n", name, val, sym->name);
-                                       exit(1);
-                               }
-
-                               if (!sym_string_within_range(sym, val))
-                                       sym->flags |= SYMBOL_NEW;
-
-                               break;
-                       default:
-                       sym->user.val = NULL;
-                       sym->user.tri = no;
-                       
-               }
-               
-               if (sym && sym_is_choice_value(sym)) {
-                       struct symbol *cs = 
prop_get_symbol(sym_get_choice_prop(sym));
-                       switch (sym->user.tri) {
-                       case no:
-                               break;
-                       case mod:
-                               if (cs->user.tri == yes)
-                                       /* warn? */;
-                               break;
-                       case yes:
-                               if (cs->user.tri != no)
-                                       /* warn? */;
-                               cs->user.val = sym;
-                               break;
-                       }
-                       cs->user.tri = E_OR(cs->user.tri, sym->user.tri);
-                       cs->flags &= ~SYMBOL_NEW;
-               }
-
-               sym_calc_value(sym);
-               if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
-                       if (sym->visible == no)
-                               sym->flags |= SYMBOL_NEW;
-               }
-               if (!sym_is_choice(sym))
-                       continue;
-               prop = sym_get_choice_prop(sym);
-               for (e = prop->expr; e; e = e->left.expr)
-                       if (e->right.sym->visible != no)
-                               sym->flags |= e->right.sym->flags & SYMBOL_NEW;
-               FREE(val);
-               }
-       }
+       if (!sym_string_within_range(sym, val))
+         sym->flags |= SYMBOL_NEW;
        
-       sym_change_count = 1;
-
-       return 0;
+       break;
+      default:
+       sym->user.val = NULL;
+       sym->user.tri = no;
+       
+      }
+      
+      if (sym && sym_is_choice_value(sym)) {
+       struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
+       switch (sym->user.tri) {
+       case no:
+         break;
+       case mod:
+         if (cs->user.tri == yes)
+           /* warn? */;
+         break;
+       case yes:
+         if (cs->user.tri != no)
+           /* warn? */;
+         cs->user.val = sym;
+         break;
+       }
+       cs->user.tri = E_OR(cs->user.tri, sym->user.tri);
+       cs->flags &= ~SYMBOL_NEW;
+      }
+      
+      sym_calc_value(sym);
+      if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
+       if (sym->visible == no)
+         sym->flags |= SYMBOL_NEW;
+      }
+      if (!sym_is_choice(sym))
+       continue;
+      prop = sym_get_choice_prop(sym);
+      for (e = prop->expr; e; e = e->left.expr)
+       if (e->right.sym->visible != no)
+         sym->flags |= e->right.sym->flags & SYMBOL_NEW;
+      FREE(val);
+    }
+  }
+  
+  sym_change_count = 1;
+  
+  return 0;
 }
 
-int conf_write()
+int conf_write(const char * filename)
 {
-       FILE *out = NULL;
-       struct symbol *sym;
-       struct menu *menu;
-       const char *basename;
-       char dirname[128], tmpname[128], newname[128];
-       int type;
-       const char *str;
-       const char *cur_tmpl = NULL;
-       char **tempfiles = NULL;
-       int num_tempfiles = 0;
-       int idx;
-       char *tmp;
-
+  FILE *out = NULL;
+  struct symbol *sym;
+  struct menu *menu;
+  int type;
+  const char *str;
+  
   sym_clear_all_valid();
 
-       menu = rootmenu.list;
-       while (menu) {
-
-               sym = menu->sym;
-               
-               if (!sym) {
-
-                       str = menu_get_prompt(menu);
-                       if (str && strlen(str) > 0) {                   
-                               /* First of all, we have to determine where to 
write the menu's settings to.
-                                * There are two possibilites:
-                                *      1. There's a setting 
$prefix_CONF_DEF_FILE that defines the file
-                                *               (this is useful if independent 
.in files with different
-                                *     destination files are included 
together). $prefix is the name
-                                *     of the template file.
-                                *  2. We use conf_def_filename. */
-                               if (!out || (cur_tmpl == NULL || 
strcmp(cur_tmpl, menu->file->name) != 0)) {
-                                       char key[251];
-                                       struct symbol *fn_sym;
-                                       int registered;
-                                       char *prefix;
-                                       struct stat stat_cf;
-                                       int exists;
-                                       
-                                       /* This setting's destination file is 
different from the previous
-                                        * one's. */
-                                       if (out)
-                                               fclose(out);
-                                       
-                                       cur_tmpl = menu->file->name;
-                                       prefix = (char *) cur_tmpl + 
strlen(cur_tmpl);
-                                       while(*prefix != '/' && *prefix != '\\')
-                                               prefix--;
-                                       prefix++;
-                                       
-                                       /* Determine destination */
-                                       SNPRINTF(key, 250, "%s_CONF_DEF_FILE", 
prefix);
-                                       fn_sym = sym_find(key, "Meta");
-                                       
-                                       if (! fn_sym) {
-                                               /* Default filename */
-                                               strncpy(newname, 
conf_def_filename, 127);
-                                               newname[127] = 0;
-                                               basename = conf_def_filename;
-                                               strcpy(dirname, "/etc/");
-                                       }
-                                       else
-                                       {
-                                               sym_calc_value_ext(fn_sym, 1);
-               
-                                               dirname[0] = 0;
-                                               basename = 
sym_get_string_value(fn_sym);
-                                       
-                                               if (! dirname[0]) {
-                                                       SNPRINTF(key, 250, 
"%s_CONF_DEF_DIR", prefix);
-                                                       fn_sym = sym_find(key, 
"Meta");
-                                                       
-                                                       if (fn_sym) {
-                                                               
sym_calc_value_ext(fn_sym, 1);
-                                                               strcpy(dirname, 
sym_get_string_value(fn_sym));
-                                                       }
-                                                       else
-                                                               strcpy(dirname, 
"/etc/");
-                                               }
-                                       }
-                                       
-                                       tmp = expandFileName(dirname);
-                                       strlcpy(dirname, tmp, 128);
-                                       free(tmp);
-                                       
-                                       /* Create a temporary filename */
-                                       sprintf(newname,
-                                               "%s%s-%u.tmp",
-                                               dirname,
-                                               basename,
-                                               (unsigned int) getpid());
-               
-                                       exists = STAT(newname, &stat_cf);
-                                       
-                                       out = FOPEN(newname, "a");
-                                       
-                                       if (!out)
-                                               return 1;
-               
-                                       if (exists == -1)
-                                         fprintf(out, "#%s"
-                                                                        "# 
Automatically generated by gnunet-setup%s"
-                                                                        "#%s", 
NEWLINE, NEWLINE, NEWLINE);
-               
-                                       /* Save the temporary filename to 
rename it later */
-                                       registered = 0;
-                                       for (idx=0; idx < num_tempfiles; idx++) 
{
-                                               if (strcmp(tempfiles[idx], 
newname) == 0)
-                                                       registered = 1;
-                                       }
-                                       if (! registered) {
-                                               if (num_tempfiles == 0)
-                                                       tempfiles = 
malloc(sizeof(char **));
-                                               else
-                                                       tempfiles = 
realloc(tempfiles, (num_tempfiles + 1) * sizeof(char **));
-                                               tempfiles[num_tempfiles] = 
strdup(newname);
-                                               num_tempfiles++;
-                                       }
-                               }
-
-                               fprintf(out, "%s"
-                                       "#%s"
-                                       "# %s%s"
-                                       "#%s", NEWLINE, NEWLINE, str, NEWLINE, 
NEWLINE);
-                       }
-                       if (menu->section && strlen(menu->section) > 0)
-                               fprintf(out, "[%s]%s", menu->section, NEWLINE);
-               } else if (!(sym->flags & SYMBOL_CHOICE)) {
-                       sym_calc_value_ext(sym, 1);
-                       sym->flags &= ~SYMBOL_WRITE;
-                       type = sym->type;
-                       if (type == S_TRISTATE) {
-                               sym_calc_value_ext(modules_sym, 1);
-                               if (modules_sym->curr.tri == no)
-                                       type = S_BOOLEAN;
-                       }
-                       switch (type) {
-                       case S_BOOLEAN:
-                       case S_TRISTATE:
-                               switch (sym_get_tristate_value(sym)) {
-                               case no:
-                                       fprintf(out, "%s = NO", sym->name);
-                                       break;
-                               case mod:
-                                       fprintf(out, "%s = m", sym->name);
-                                       break;
-                               case yes:
-                                       fprintf(out, "%s = YES", sym->name);
-                                       break;
-                               }
-                               break;
-                       case S_STRING:
-        fprintf(out, "%s = \"%s\"", sym->name, sym_get_string_value(sym));
-                               break;
-                       case S_HEX:
-                               str = sym_get_string_value(sym);
-                               if (str[0] != '0' || (str[1] != 'x' && str[1] 
!= 'X')) {
-                                       fprintf(out, "%s = 0x%s", sym->name, 
str);
-                                       break;
-                               }
-                       case S_INT:
-                               fprintf(out, "%s = %s", sym->name, 
sym_get_string_value(sym));
-                               break;
-                       }
-                       fprintf(out, "%s", NEWLINE);
-               }
-
-               if (menu->list) {
-                       menu = menu->list;
-                       continue;
-               }
-               if (menu->next)
-                       menu = menu->next;
-               else while ((menu = menu->parent)) {
-                       if (menu->next) {
-                               menu = menu->next;
-                               break;
-                       }
-               }
+  out = FOPEN(filename, "w+");   
+  if (NULL == out)     
+    return 1;
+  fprintf(out, 
+         "#%s"
+         "# Automatically generated by gnunet-setup%s"
+         "#%s", 
+         NEWLINE, 
+         NEWLINE, 
+         NEWLINE); 
+  menu = rootmenu.list;
+  while (menu) {   
+    sym = menu->sym;
+    if (!sym) {      
+      str = menu_get_prompt(menu);
+      if (str && strlen(str) > 0) {                    
+       fprintf(out, 
+               "%s"
+               "#%s"
+               "# %s%s"
+               "#%s", 
+               NEWLINE,
+               NEWLINE,
+               str, 
+               NEWLINE, 
+               NEWLINE);
+      }
+      if (menu->section && strlen(menu->section) > 0)
+       fprintf(out, 
+               "[%s]%s",
+               menu->section, 
+               NEWLINE);
+    } else if (!(sym->flags & SYMBOL_CHOICE)) {
+      sym_calc_value_ext(sym, 1);
+      sym->flags &= ~SYMBOL_WRITE;
+      type = sym->type;
+      if (type == S_TRISTATE) {
+       sym_calc_value_ext(modules_sym, 1);
+       if (modules_sym->curr.tri == no)
+         type = S_BOOLEAN;
+      }
+      switch (type) {
+      case S_BOOLEAN:
+      case S_TRISTATE:
+       switch (sym_get_tristate_value(sym)) {
+       case no:
+         fprintf(out, 
+                 "%s = NO",
+                 sym->name);
+         break;
+       case mod:
+         fprintf(out, 
+                 "%s = m",
+                 sym->name);
+         break;
+       case yes:
+         fprintf(out, 
+                 "%s = YES", 
+                 sym->name);
+         break;
        }
-       
-       if (out)
-               fclose(out);
-       
-       for (idx=0; idx < num_tempfiles; idx++) {
-               char *dstname, *tempfile;
-               int dstlen;
-               
-               /* Get real destination name. The temporary name has the form
-                *              name-pid.tmp */
-               tempfile = tempfiles[idx];
-               dstlen = strlen(tempfile);
-               while (tempfile[dstlen] != '-')
-                       dstlen--;
-               
-               dstname = malloc(dstlen + 1);
-               strncpy(dstname, tempfile, dstlen);
-               dstname[dstlen] = 0;
-               
-               sprintf(tmpname, "%s.old", dstname);
-               UNLINK(tmpname);
-               RENAME(dstname, tmpname);
-
-               if (RENAME(tempfile, dstname)) {
-                       free(dstname);
-                       free(tempfile);
-
-                       return 1;
-               }
-               
-               UNLINK(tempfile);
-               
-               free(dstname);
-               free(tempfile);
+       break;
+      case S_STRING:
+        fprintf(out, 
+               "%s = \"%s\"", 
+               sym->name, 
+               sym_get_string_value(sym));
+       break;
+      case S_HEX:
+       str = sym_get_string_value(sym);
+       if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
+         fprintf(out,
+                 "%s = 0x%s",
+                 sym->name, 
+                 str);
+         break;
        }
-       
-       if (tempfiles)
-               free(tempfiles);
-
-       sym_change_count = 0;
-
-       return 0;
+      case S_INT:
+       fprintf(out, 
+               "%s = %s", 
+               sym->name,
+               sym_get_string_value(sym));
+       break;
+      }
+      fprintf(out, 
+             "%s", 
+             NEWLINE);
+    }    
+    if (menu->list) {
+      menu = menu->list;
+      continue;
+    }
+    if (menu->next)
+      menu = menu->next;
+    else while ((menu = menu->parent)) {
+      if (menu->next) {
+       menu = menu->next;
+       break;
+      }
+    }
+  }
+  
+  fclose(out);
+  sym_change_count = 0;
+  
+  return 0;
 }

Added: GNUnet/src/conf/confdata.h
===================================================================
--- GNUnet/src/conf/confdata.h  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/confdata.h  2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,35 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef CONFDATA_H
+#define CONFDATA_H
+
+int conf_read(const char *name);
+
+int conf_write(const char * filename);
+
+#endif

Modified: GNUnet/src/conf/gconf.c
===================================================================
--- GNUnet/src/conf/gconf.c     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/gconf.c     2005-08-14 05:49:03 UTC (rev 1660)
@@ -36,6 +36,7 @@
 #define ENABLE_NLS 1
 
 #include "lkc.h"
+#include "confdata.h"
 #include "images.c"
 
 #include <gtk/gtk.h>
@@ -733,9 +734,13 @@
 
 void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (conf_write())
-    text_insert_msg("Error", "Unable to save configuration!");
-
+  char * filename;
+  filename = getConfigurationString("GNUNET-SETUP",
+                                   "FILENAME");
+  if (conf_write(filename))
+    text_insert_msg("Error", 
+                   "Unable to save configuration!");
+  FREE(filename);
   config_changed = FALSE;
 }
 
@@ -1659,18 +1664,13 @@
 /* Main */
 
 
-int gconf_main(int ac, char *av[])
+int gconf_main()
 {
-  struct menu *root;
+  char * filename;
 
-#ifndef LKC_DIRECT_LINK
-  kconfig_load();
-#endif
-
   /* GTK stuffs */
   bind_textdomain_codeset(PACKAGE, "UTF-8");
   gtk_set_locale();
-  gtk_init(&ac, &av);
 
   /* add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); */
   /* add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps"); */
@@ -1681,27 +1681,11 @@
   init_left_tree();
   init_right_tree();
 
-  /* Conf stuffs */
-               
-  if (ac > 1 && av[1][0] == '-') {
-    switch (av[1][1]) {
-    case 'a':
-      /* showAll = 1;*/
-      break;
-    case 'h':
-    case '?':
-      printf("%s <config>\n", av[0]);
-      exit(0);
-    }
-  }
-
-       /* This configurator is also called from the wizard configurator.
-        * Check whether the templates are already parsed. */
-       root = menu_get_root_menu(NULL);
-       if (!(root && root->prompt))
-       conf_parse(DATADIR"/config.in");
   fixup_rootmenu(&rootmenu);
-  conf_read(NULL);
+  filename = getConfigurationString("GNUNET-SETUP",
+                                   "FILENAME");
+  conf_read(filename);
+  FREE(filename);
 
   switch (view_mode) {
   case SINGLE_VIEW:

Added: GNUnet/src/conf/gconf.h
===================================================================
--- GNUnet/src/conf/gconf.h     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/gconf.h     2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/gconf.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef GCONF_H
+#define GCONF_H
+
+int gconf_main(void);
+
+#endif

Modified: GNUnet/src/conf/gnunet-setup.c
===================================================================
--- GNUnet/src/conf/gnunet-setup.c      2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/gnunet-setup.c      2005-08-14 05:49:03 UTC (rev 1660)
@@ -22,90 +22,274 @@
  * @file conf/gnunet-setup.c
  * @brief GNUnet Setup
  * @author Nils Durner
+ * @author Christian Grothoff
  */
 
-#include <stdio.h>
-#include <string.h>
+#include "platform.h"
 #include "gnunet_util.h"
-#include "platform.h"
+#include "recreate.h"
+#include "conf.h"
+#include "zconf_tab.h"
 
-static void help() {
-  puts(_("USAGE: gnunet-setup MODULE\n\n"
-       "MODULE\n"
-       " recreate\trecreate configuration files\n"
-       " config\t\ttext-based configuration\n"
-       " menuconfig\ttext-based menu\n"
-       " gconfig\tGTK configuration\n"
-                       " wizard-curses\tBasic text-based graphical 
configuration\n"
-                       " wizard-gtk\tBasic GTK configuration\n\n"));
-}
-
 #if HAVE_CURSES
-int mconf_main(int ac, char **av);
-int wizard_curs_main(int argc, char *argv[]);
+#include "mconf.h"
+#include "wizard_curs.h"
 #endif
 
 #if HAVE_GTK
-int gconf_main(int ac, char *av[]);
-int wizard_main (int argc, char *argv[]);
+#include "gconf.h"
+#include "wizard.h"
+#include <gtk/gtk.h>
 #endif
 
-int conf_main(int ac, char **av);
-int recreate_main(int ac, char **av);
 
+/**
+ * Perform option parsing from the command line.
+ */
+static int parser(int argc,
+                 char * argv[]) {
+  int cont = OK;
+  int c;
+  int daemon = NO;
+  char * filename = NULL;  
+  char * dirname;
+
+  FREENONNULL(setConfigurationString("GNUNETD",
+                                    "LOGFILE",
+                                    NULL));
+  while (1) {
+    int option_index = 0;
+    static struct GNoption long_options[] = {
+      { "config",   1, 0, 'c' }, 
+      { "deamon",   0, 0, 'd' },
+      { "help",     0, 0, 'h' },
+      { "version",  0, 0, 'v' },
+      { "verbose",  0, 0, 'V' },
+      { 0,0,0,0 }
+    };
+
+    c = GNgetopt_long(argc,
+                     argv,
+                     "c:dhvV",
+                     long_options,
+                     &option_index);
+
+    if (c == -1)
+      break;  /* No more flags to process */
+
+    switch(c) {
+    case 'c':
+      filename = expandFileName(GNoptarg);
+      break;
+    case 'd':
+      daemon = YES;
+      break;
+    case 'v':
+      printf("gnunet-setup v%s\n",
+            VERSION);
+      cont = SYSERR;
+      break;
+    case 'V':
+      FREENONNULL(setConfigurationString("GNUNET-SETUP",
+                                        "VERBOSE",
+                                        "YES"));
+      break;
+    case 'h': {
+      static Help help[] = {
+       HELP_CONFIG,
+       { 'd', "daemon", NULL,
+         gettext_noop("generate configuration for gnunetd, the GNUnet daemon") 
},
+       HELP_HELP,
+       HELP_LOGLEVEL,
+       HELP_VERSION,
+        HELP_VERBOSE,
+       HELP_END,
+      };
+      formatHelp("gnunet-daemon [OPTIONS] MODE",
+                _("Tool to setup GNUnet."),
+                help);
+      printf(_("Available MODEs:\n"));
+      printf(_(" config\t\ttext-based configuration\n"));
+#if HAVE_CURSES      
+      printf(_(" menuconfig\ttext-based menu\n"));
+      printf(_(" wizard-curses\tBasic text-based graphical configuration\n"));
+#endif
+#if HAVE_GTK
+      printf(_(" gconfig\tGTK configuration\n"));
+      printf(_(" wizard-gtk\tBasic GTK configuration\n\n"));
+#endif
+      cont = SYSERR;
+      break;
+    }
+    default:
+      LOG(LOG_FAILURE,
+         _("Use --help to get a list of options.\n"));
+      cont = SYSERR;
+    } /* end of parsing commandline */
+  }
+  /* set the 'magic' code that indicates that
+     this process is 'gnunetd' (and not any of
+     the user-tools).  Needed such that we use
+     the right configuration file... */
+  if (daemon) {
+    FREENONNULL(setConfigurationString("GNUNETD",
+                                      "_MAGIC_",
+                                      "YES"));
+    if (filename == NULL) {
+      if (0 == ACCESS("/etc/gnunetd.conf",
+                     W_OK)) 
+       filename = STRDUP("/etc/gnunetd.conf");
+      else {   
+       if (0 == ACCESS("/var/lib",
+                       W_OK))
+         mkdirp("/var/lib/GNUnet");
+       if (0 == ACCESS("/var/lib/GNUnet/gnunetd.conf",
+                       W_OK)) 
+         filename = STRDUP("/var/lib/GNUnet/gnunetd.conf");
+       else {
+         dirname =  expandFileName("~/.gnunet/");
+         mkdirp(dirname);
+         FREE(dirname);
+         filename = expandFileName("~/.gnunet/gnunetd.conf");
+       }
+      }
+    }
+    FREENONNULL(setConfigurationString("FILES",
+                                      "gnunet.conf",
+                                      filename));
+    conf_parse(DATADIR"/config-daemon.in");
+  } else {
+    FREENONNULL(setConfigurationString("GNUNETD",
+                                      "_MAGIC_",
+                                      "NO"));
+    if (filename == NULL) {
+      dirname =  expandFileName("~/.gnunet/");
+      mkdirp(dirname);
+      FREE(dirname);
+      filename = expandFileName("~/.gnunet/gnunet.conf");
+    }
+    FREENONNULL(setConfigurationString("FILES",
+                                      "gnunet.conf",
+                                      filename));
+    conf_parse(DATADIR"/config-client.in");
+  }
+  dirname = STRDUP(filename);
+  while ( ( strlen(dirname) > 0) &&
+         (dirname[strlen(dirname)-1] != DIR_SEPARATOR) )
+    dirname[strlen(dirname)-1] = '\0';
+  if (strlen(dirname) > 0) {
+    dirname[strlen(dirname)-1] = '\0';
+    if (strlen(dirname) > 0)
+      mkdirp(dirname);
+  }
+  if ( (0 != ACCESS(filename,
+                   W_OK)) &&
+       ( (0 == ACCESS(filename,
+                     F_OK)) ||
+        (0 != ACCESS(dirname,
+                     W_OK)) ) ) {
+    errexit(_("gnunet-setup must have write-access to the configuration file 
'%s'\n"),
+           filename);
+  } 
+  FREE(dirname);
+  FREENONNULL(setConfigurationString("GNUNET-SETUP",
+                                    "FILENAME",
+                                    filename));
+  if (GNoptind < argc) 
+    FREENONNULL(setConfigurationString("GNUNET-SETUP",
+                                      "OPERATION",
+                                      argv[GNoptind++]));
+  if (GNoptind < argc) {
+    LOG(LOG_WARNING,
+       _("Invalid arguments: "));
+    while (GNoptind < argc)
+      LOG(LOG_WARNING,
+         "%s ", argv[GNoptind++]);
+    LOG(LOG_FATAL,
+       _("Invalid arguments. Exiting.\n"));
+    FREE(filename);
+    return SYSERR;
+  }
+
+  if (0 != ACCESS(filename,
+                 F_OK))
+    recreate_main();
+  FREE(filename);
+
+
+  return cont;
+}
+
+
+
 int main(int argc,
         char *argv[]) {
-  if (argc < 2) {
-    help();
-    return 0;
+  char * operation;
+
+#if HAVE_GTK
+  gtk_init(&argc, &argv);
+#endif
+  if (OK != initUtil(argc, argv, &parser))
+    return -1;
+  operation = getConfigurationString("GNUNET-SETUP",
+                                    "OPERATION");
+  if (operation == NULL) {
+#if HAVE_GTK
+    operation = STRDUP("gconfig");
+#elif HAVE_CURSES
+    operation = STRDUP("menuconfig");
+#else
+    operation = STRDUP("config");
+#endif    
   }
-
-  initUtil(0, NULL, NULL);
-
-  if (strncmp(argv[1], "config", 6) == 0)
-    conf_main(argc - 1, &argv[1]);
-  else if (strncmp(argv[1], "menuconfig", 10) == 0) {
+  if (strcmp(operation, "config") == 0)
+    conf_main();
+  else if (strcmp(operation, "menuconfig") == 0) {
 #if HAVE_CURSES
-    mconf_main(argc - 1, &argv[1]);
+    mconf_main();
 #else
-    puts("Menuconfig is not available\n");
+    printf(_("menuconfig is not available\n"));
 #endif
   }
-  else if (strncmp(argv[1], "wizard-curses", 13) == 0) {
+  else if (strcmp(operation, "wizard-curses") == 0) {
+    if (! testConfigurationString("GNUNETD",
+                                 "_MAGIC_",
+                                 "YES"))
+      errexit(_("Can only run wizard to configure gnunetd.\n"
+               "Did you forget the '%s' option?\n"),
+             "-d");
 #if HAVE_CURSES
-    wizard_curs_main(argc - 1, &argv[1]);
+    wizard_curs_main();
 #else
-    puts("Wizard-curses is not available\n");
+    printf(_("wizard-curses is not available\n"));
 #endif
-  }
-  else if (strncmp(argv[1], "wizard-gtk", 10) == 0) {
+  } else if (strcmp(operation, "wizard-gtk") == 0) {
+    errexit(_("Can only run wizard to configure gnunetd.\n"
+             "Did you forget the '%s' option?\n"),
+           "-d");
 #if HAVE_GTK
-    wizard_main(argc - 1, &argv[1]);
+    wizard_main();
 #else
-    puts("wizard-gtk is not available\n");
+    printf(_("wizard-gtk is not available\n"));
 #endif
-       }
-  else if (strncmp(argv[1], "gconfig", 7) == 0) {
+  }
+  else if (strcmp(operation, "gconfig") == 0) {
 #if HAVE_GTK
-    gconf_main(argc - 1, &argv[1]);
+    gconf_main();
 #else
-    puts("Gconfig is not available\n");
+    printf(_("gconfig is not available\n"));
 #endif
   }
-  else if (strncmp(argv[1], "recreate", 7) == 0) {
-       if (argc < 3) {
-               puts(_("Please specify a path where the configuration files 
will be "
-                       "stored."));
-               return 1;
-       }
-       recreate_main(argc - 1, &argv[1]);
+  else {
+    printf(_("Unknown operation '%s'\n"),
+          operation);
+    printf(_("Use --help to get a list of options.\n"));
+    FREE(operation);
+    doneUtil();
+    return 1;
   }
-       else {
-    puts("Unknown configurator\n\n");
-    help();
-  }
 
+  FREE(operation);
   doneUtil();
-
   return 0;
 }

Modified: GNUnet/src/conf/lkc.h
===================================================================
--- GNUnet/src/conf/lkc.h       2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/lkc.h       2005-08-14 05:49:03 UTC (rev 1660)
@@ -49,9 +49,6 @@
 
 char *conf_get_default_confname(void);
 
-/* kconfig_load.c */
-void kconfig_load(void);
-
 /* menu.c */
 void menu_init(void);
 void menu_add_menu(void);

Modified: GNUnet/src/conf/lkc_defs.h
===================================================================
--- GNUnet/src/conf/lkc_defs.h  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/lkc_defs.h  2005-08-14 05:49:03 UTC (rev 1660)
@@ -6,11 +6,6 @@
  * @author Nils Durner
  **/
 
-/* confdata.c */
-#define conf_parse (*conf_parse_p)
-#define conf_read (*conf_read_p)
-#define conf_write (*conf_write_p)
-
 /* menu.c */
 #define rootmenu (*rootmenu_p)
 

Modified: GNUnet/src/conf/lkc_proto.h
===================================================================
--- GNUnet/src/conf/lkc_proto.h 2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/lkc_proto.h 2005-08-14 05:49:03 UTC (rev 1660)
@@ -6,11 +6,6 @@
  * @author Nils Durner
  **/
 
-/* confdata.c */
-P(conf_parse,void,(const char *name));
-P(conf_read,int,(const char *name));
-P(conf_write,int,());
-
 /* menu.c */
 P(rootmenu,struct menu,);
 

Modified: GNUnet/src/conf/mconf.c
===================================================================
--- GNUnet/src/conf/mconf.c     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/mconf.c     2005-08-14 05:49:03 UTC (rev 1660)
@@ -48,6 +48,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "mconf.h"
 #include "mconf_dialog.h"
 
 #define LKC_DIRECT_LINK
@@ -776,62 +777,59 @@
        UNLINK("lxdialog.scrltmp");
 }
 
-int mconf_main(int ac, char **av)
+int mconf_main()
 {
        char *mode;
        int stat;
-  struct menu *root;
+  char * filename;
 
-       /* This configurator is also called from the wizard configurator.
-        * Check whether the templates are already parsed. */
-       root = menu_get_root_menu(NULL);
-       if (!(root && root->prompt))
-               conf_parse(DATADIR"/config.in");
+  filename = getConfigurationString("GNUNET-SETUP",
+                                   "FILENAME");
+  conf_read(filename);
+  FREE(filename);
   
-       conf_read(NULL);
-
-       backtitle = malloc(128);
-       strcpy(backtitle, "GNUnet Configuration");
-
-       mode = getenv("MENUCONFIG_MODE");
-       if (mode) {
-               if (!strcasecmp(mode, "single_menu"))
-                       single_menu_mode = 1;
-       }
-
+  backtitle = malloc(128);
+  strcpy(backtitle, "GNUnet Configuration");
+  
+  mode = getenv("MENUCONFIG_MODE");
+  if (mode) {
+    if (!strcasecmp(mode, "single_menu"))
+      single_menu_mode = 1;
+  }
+  
 #ifndef MINGW
-       {
-               struct sigaction sa;
-               sa.sa_handler = winch_handler;
-               sigemptyset(&sa.sa_mask);
-               sa.sa_flags = SA_RESTART;
-               sigaction(SIGWINCH, &sa, NULL);
-       }
-
-       tcgetattr(1, &ios_org);
+  {
+    struct sigaction sa;
+    sa.sa_handler = winch_handler;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_RESTART;
+    sigaction(SIGWINCH, &sa, NULL);
+  }
+  
+  tcgetattr(1, &ios_org);
 #endif
-       atexit(conf_cleanup);
-       init_dialog();
-       
-       init_wsize();
-       conf(&rootmenu);
-
-       do {
-               stat = dialog_yesno(NULL,
-                               "Do you wish to save your new configuration?",
-                               5, 60);
-       } while (stat < 0);
-       end_dialog();
-
-       if (stat == 0) {
-               conf_write(NULL);
-               printf("\n\n"
-                       "*** End of configuration.\n"
-                       "\n\n");
-       } else
-               printf("\n\n"
-                       "Your configuration changes were NOT saved."
-                       "\n\n");
-
-       return 0;
+  atexit(conf_cleanup);
+  init_dialog();
+  
+  init_wsize();
+  conf(&rootmenu);
+  
+  do {
+    stat = dialog_yesno(NULL,
+                       "Do you wish to save your new configuration?",
+                       5, 60);
+  } while (stat < 0);
+  end_dialog();
+  
+  if (stat == 0) {
+    conf_write(NULL);
+    printf("\n\n"
+          "*** End of configuration.\n"
+          "\n\n");
+  } else {
+    printf("\n\n"
+          "Your configuration changes were NOT saved."
+          "\n\n");
+  }
+  return 0;
 }

Added: GNUnet/src/conf/mconf.h
===================================================================
--- GNUnet/src/conf/mconf.h     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/mconf.h     2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/mconf.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef MCONF_H
+#define MCONF_H
+
+int mconf_main(void);
+
+#endif

Modified: GNUnet/src/conf/recreate.c
===================================================================
--- GNUnet/src/conf/recreate.c  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/recreate.c  2005-08-14 05:49:03 UTC (rev 1660)
@@ -19,62 +19,92 @@
 */
 
 /**
- * @file conf/silent.c
+ * @file conf/recreate.c
  * @brief create .conf files from the .in templates
  * @author Nils Durner
  */
 
 #include "gnunet_util.h"
+#include "recreate.h"
+#include "confdata.h"
 
 #define LKC_DIRECT_LINK
 #include "lkc.h"
 
 
-int recreate_main(int ac, char **av) {
+/**
+ * @brief Set reasonable default for GNUNETD_HOME if needed
+ */
+static void checkGNUNETDHome(struct symbol *sym)
+{
+ 
+  if (strcmp(sym->name, "GNUNETD_HOME") == 0)
+    {
+      const char *val;
+      
+      sym_calc_value_ext(sym, 1);
+      val = sym_get_string_value(sym);
+      
+      /* only empty if gnunet-setup is run for the first time */
+      if (!val || !strlen(val))
+       {
+         /* GNUNETD_HOME isn't set yet. Let's choose a sane default */
+         struct stat buf;
+         int var = 0;
+         if (STAT("/var/lib/GNUnet", &buf) != 0)
+           {
+             /* /var/lib/GNUnet doesn't exist. Do we have write permissions to 
/var? */
+             if (ACCESS("/var", W_OK) == 0)
+               var = 1;
+           }
+         else
+           {
+             /* /var/lib/GNUnet is there, do we have write permissions? */
+             if (ACCESS("/var/lib/GNUnet", W_OK) == 0)
+               var = 1;
+           }
+         
+         sym_set_string_value(sym, var ? "/var/lib/GNUnet" : "~/.gnunet");
+       }
+    }
+}
+
+
+int recreate_main() {
   struct symbol *sym;
-  char *dstDir;
-  int dirLen;
+  int i = 0;
+  char * filename;
   
-  dirLen = strlen(av[1]);
-  dstDir = MALLOC(dirLen + 2);
-  strcpy(dstDir, av[1]);
-  if (dstDir[dirLen - 1] != DIR_SEPARATOR)
-    strcat(dstDir, DIR_SEPARATOR_STR);
-  
-  conf_parse(DATADIR"/config.in");
-
+  filename = getConfigurationString("GNUNET-SETUP",
+                                   "FILENAME");
   /* we are setting advanced/rare settings below */
   sym = sym_find("EXPERIMENTAL", "Meta");
-  sym_set_tristate_value(sym, yes);
-  sym = sym_find("ADVANCED", "Meta");
-  sym_set_tristate_value(sym, yes);
-  sym = sym_find("RARE", "Meta");
-  sym_set_tristate_value(sym, yes);
+  if (sym != NULL)
+    sym_set_tristate_value(sym, yes);
+  sym = sym_find("ADVANCED", "Meta"); 
+  if (sym != NULL)
+    sym_set_tristate_value(sym, yes);
+  sym = sym_find("RARE", "Meta"); 
+  if (sym != NULL)
+    sym_set_tristate_value(sym, yes);
 
   /* save new config files to DATADIR */
-  sym = sym_find("config-daemon.in_CONF_DEF_DIR", "Meta");
-  sym_set_string_value(sym, dstDir);
-
-  sym = sym_find("config-daemon.in_CONF_DEF_FILE", "Meta");
-  sym_set_string_value(sym, "gnunet.root");
-
-  sym = sym_find("config-client.in_CONF_DEF_DIR", "Meta");
-  sym_set_string_value(sym, dstDir);
-
-  sym = sym_find("config-client.in_CONF_DEF_FILE", "Meta");
-  sym_set_string_value(sym, "gnunet.user");
-       
-  FREE(dstDir);
-
+  if (testConfigurationString("GNUNETD",
+                             "_MAGIC_",
+                             "YES")) {
+    for_all_symbols(i, sym) 
+      checkGNUNETDHome(sym);
+  }
   /* Write defaults */
-  if (conf_write()) {
-    printf(_("Unable to save configuration files: %s.\n"), STRERROR(errno));
+  if (conf_write(filename)) {
+    printf(_("Unable to save configuration file '%s': %s.\n"), 
+          filename,
+          STRERROR(errno));
+    FREE(filename);
     return 1;
   }
-  else {
-    puts(_("Configuration files (re)created.\n"));
-    return 0;
-  }
+  FREE(filename);
+  return 0;  
 }
 
-/* end of silent.c */
+/* end of recreate.c */

Added: GNUnet/src/conf/recreate.h
===================================================================
--- GNUnet/src/conf/recreate.h  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/recreate.h  2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/recreate.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef RECREATE_H
+#define RECREATE_H
+
+int recreate_main(void);
+
+#endif

Modified: GNUnet/src/conf/wizard.c
===================================================================
--- GNUnet/src/conf/wizard.c    2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/wizard.c    2005-08-14 05:49:03 UTC (rev 1660)
@@ -36,6 +36,10 @@
 #include "wizard_callbacks.h"
 #include "wizard_util.h"
 
+#include "wizard.h"
+#include "gconf.h"
+#include "confdata.h"
+
 GtkWidget *curwnd;
 GtkWidget *cmbNIC;
 
@@ -44,8 +48,6 @@
 char *user_name = NULL, *group_name = NULL;
 static int nic_item_count = 0;
 
-int gconf_main(int ac, char *av[]);
-
 void insert_nic(char *name, int defaultNIC)
 {
  gtk_combo_box_append_text(GTK_COMBO_BOX(cmbNIC), name);
@@ -264,26 +266,27 @@
 }
 
 int
-wizard_main (int argc, char *argv[])
+wizard_main ()
 {
-       struct symbol *sym;
+  struct symbol *sym;
+  char * filename;
        
 #ifdef ENABLE_NLS
-               /* GTK uses UTF-8 encoding */
-               bind_textdomain_codeset(PACKAGE, "UTF-8");
+  /* GTK uses UTF-8 encoding */
+  bind_textdomain_codeset(PACKAGE, "UTF-8");
 #endif
 
 #ifdef WINDOWS
-       FreeConsole();
+  FreeConsole();
 #endif
 
   gtk_set_locale ();
-  gtk_init (&argc, &argv);
-
-       conf_parse(DATADIR"/config.in");
-         
-  conf_read(NULL);
   
+  filename = getConfigurationString("GNUNET-SETUP",
+                                  "FILENAME");
+  conf_read(filename);
+  FREE(filename);
+  
   sym = sym_find("EXPERIMENTAL", "Meta");
   sym_set_tristate_value(sym, yes);
   sym = sym_find("ADVANCED", "Meta");
@@ -296,8 +299,8 @@
 
   gtk_main ();
 
-       if (doOpenEnhConfigurator)
-               gconf_main(argc, argv);
+  if (doOpenEnhConfigurator)
+    gconf_main();
 
   return 0;
 }

Added: GNUnet/src/conf/wizard.h
===================================================================
--- GNUnet/src/conf/wizard.h    2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/wizard.h    2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/wizard.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef WIZARD_H
+#define WIZARD_H
+
+int wizard_main(void);
+
+#endif

Modified: GNUnet/src/conf/wizard_callbacks.c
===================================================================
--- GNUnet/src/conf/wizard_callbacks.c  2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/wizard_callbacks.c  2005-08-14 05:49:03 UTC (rev 1660)
@@ -25,6 +25,7 @@
  */
 
 #include "platform.h"
+#include "confdata.h"
 
 #define LKC_DIRECT_LINK
 #include "lkc.h"
@@ -157,74 +158,26 @@
 int
 save_conf ()
 {
-       struct symbol *sym, *symFile;
-       char *confDir, *confFile, *conf;
-       int fileLen;
+  char * filename;
        
-  /* Check write permission */
-  sym = sym_find("config-daemon.in_CONF_DEF_DIR", "Meta");
-  sym_calc_value_ext(sym, 1);
-  confDir = strdup(sym_get_string_value(sym));
-
-  symFile = sym_find("config-daemon.in_CONF_DEF_FILE", "Meta");
-  sym_calc_value_ext(symFile, 1);
-  confFile = strdup(sym_get_string_value(symFile));
-
-       fileLen = strlen(confFile);
-       conf = malloc(strlen(confDir) + fileLen + 1);
-       strcpy(conf, confDir);
-       strcat(conf, confFile);
-
-       if (ACCESS(conf, W_OK))
-       {
-               conf = realloc(conf, fileLen + 13);
-               strcpy(conf, "/etc/gnunetd.conf");
-               errno = 0;
-               /**
-                * 1. Do we have write permission to /etc/gnunetd.conf?
-                * 2. If it doesn't exists, check for write permission to /etc/
-                */
-               if (ACCESS(conf, W_OK) == 0 ||
-                       (errno == ENOENT && ACCESS("/etc/", W_OK) == 0))
-               {
-                       confDir = strdup("/etc/");
-                       confFile = strdup("gnunetd.conf");
-               }
-               else
-               {
-                       conf = realloc(conf, fileLen + 11);
-                       strcpy(conf, "~/.gnunet/gnunetd.conf");
-                       
-                       confDir = strdup("~/.gnunet/");
-                       confFile = strdup("gnunetd.conf");
-               }                        
-       }
-
-       sym_set_string_value(sym, confDir);
-       sym_set_string_value(symFile, confFile);
-       mkdirp(confDir);
-       free(confDir);
-       free(confFile);
-       
-       if (conf_write())
-       {
-               char *err, *prefix;
-               
-               prefix = _("Unable to save configuration file %s:");
-               
-               err = malloc(strlen(conf) + strlen(prefix) + 1);
-               sprintf(err, prefix, conf);
-               showErr(err, STRERROR(errno));
-               free(err);
-
-               free(conf);
-               
-               return 0;
-       }
-       
-       free(conf);
-       
-       return 1;
+  filename = getConfigurationString("GNUNET-SETUP",
+                                   "FILENAME");
+  if (conf_write(filename)) {
+    char * err;
+    const char * prefix;
+    
+    prefix = _("Unable to save configuration file '%s':");
+    
+    err = malloc(strlen(filename) + strlen(prefix) + 1);
+    sprintf(err, prefix, filename);
+    showErr(err, STRERROR(errno));
+    free(err);
+    
+    free(filename);    
+    return 0;
+  }  
+  free(filename);      
+  return 1;
 }
 
 void

Modified: GNUnet/src/conf/wizard_curs.c
===================================================================
--- GNUnet/src/conf/wizard_curs.c       2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/wizard_curs.c       2005-08-14 05:49:03 UTC (rev 1660)
@@ -31,9 +31,11 @@
 
 #include "mconf_dialog.h"
 #include "wizard_util.h"
+#include "mconf.h"
+#include "wizard_curs.h"
 
+
 extern int cols, rows;
-int mconf_main(int ac, char **av);
 
 static struct dialog_list_item **nic_items;
 static int nic_item_count = 0;
@@ -72,19 +74,21 @@
   item->selected = wiz_is_nic_default(name, defaultNIC);
 }
 
-int wizard_curs_main(int argc, char *argv[])
+int wizard_curs_main()
 {
   void *active_ptr = NULL;
-       int idx, ret, autostart = 0, adv = 0;
-       struct symbol *sym, *symFile;
-       char *defval, *user_name = NULL, *group_name = NULL;
-       char *confDir, *confFile, *conf;
-       int fileLen;
+  int idx, ret, autostart = 0, adv = 0;
+  struct symbol *sym, *symFile;
+  char *defval, *user_name = NULL, *group_name = NULL;
+  char *confDir, *confFile, *conf;
+  int fileLen;
+  char * filename;
 
-       conf_parse(DATADIR"/config.in");
-  
-  conf_read(NULL);
-
+  filename = getConfigurationString("GNUNET-SETUP",
+                                  "FILENAME");
+  conf_read(filename);
+  FREE(filename);
+ 
   sym = sym_find("EXPERIMENTAL", "Meta");
   sym_set_tristate_value(sym, yes);
   sym = sym_find("ADVANCED", "Meta");
@@ -94,295 +98,306 @@
 
   init_dialog();
   init_wsize();
-       dialog_clear();
-
-       if (dialog_msgbox(_("GNUnet configuration"), 
-               _("Welcome to GNUnet!\n\nThis assistant will ask you a few 
basic questions "
-                 "in order to configure GNUnet.\n\nPlease visit our homepage 
at\n\t"
-                 "http://www.gnunet.org\nand join our community at\n\t"
-                 "http://www.gnunet.org/drupal/\n\nHave a lot of fun,\n\nthe 
GNUnet team"),
-               rows, cols - 5, 1) == -1)
-               goto end;
-
-       dialog_clear();
+  dialog_clear();
+  
+  if (dialog_msgbox(_("GNUnet configuration"), 
+                   _("Welcome to GNUnet!\n\nThis assistant will ask you a few 
basic questions "
+                     "in order to configure GNUnet.\n\nPlease visit our 
homepage at\n\t"
+                     "http://gnunet.org/\nand join our community at\n\t"
+                     "http://gnunet.org/drupal/\n\nHave a lot of fun,\n\nthe 
GNUnet team"),
+                   rows, cols - 5, 1) == -1)
+    goto end;
+  
+  dialog_clear();
        
   enumNetworkIfs(insert_nic_curs);
 
-       /* Network interface */
-       if (nic_item_count) {
-               while (true) {
-                       ret = dialog_menu(_("GNUnet configuration"),
-                                                       _("Choose the network 
interface that connects your computer to "
-                                                               "the internet 
from the list below."), rows, cols - 5, 10,
-                                                       0, active_ptr, 
nic_item_count, nic_items);
-                       
-                       if (ret == 2) {
-                               /* Help */
-                               dialog_msgbox(_("Help"), _("The \"Network 
interface\" is the device "
-                                       "that connects your computer to the 
internet. This is usually a modem, "
-                                       "an ISDN card or a network card in case 
you are using DSL."), rows,
-                                       cols - 5, 1);
-                       }
-                       else if (ret <= 1) {
-                               /* Select or Exit */
-       #ifdef MINGW
-                               char nic[21];
-                               char *dst;
-       #else
-                               char *nic;
-       #endif
-                               for(idx = 0; idx < nic_item_count; idx++) {
-                                       
-                                       if (nic_items[idx]->selected) {
-       #ifdef MINGW
-                                               char *src = 
strrchr(nic_items[idx]->name, '-') + 2;
-                                               dst = nic;
-                                               while(*src)
-                                                       *dst++ = *src++;
-                                               dst[-1] = 0;
-       #else
-                                               nic = nic_items[idx]->name;
-       #endif
-                                               sym = sym_lookup("INTERFACE", 
"NETWORK", 0);
-                                               sym_set_string_value(sym, nic);
-                                               sym = sym_lookup("INTERFACES", 
"LOAD", 0);
-                                               sym_set_string_value(sym, nic);
-                                       }
-                                       
-                                       free(nic_items[idx]->name);
-                                       free(nic_items[idx]);
-                               }
-                               free(nic_items);
-                               
-                               break;
-                       }
-               }
-       
-               if (ret == 1 || ret == -1)
-                       goto end;
+  /* Network interface */
+  if (nic_item_count) {
+    while (true) {
+      ret = dialog_menu(_("GNUnet configuration"),
+                       _("Choose the network interface that connects your 
computer to "
+                         "the internet from the list below."), rows, cols - 5, 
10,
+                       0, active_ptr, nic_item_count, nic_items);
+      
+      if (ret == 2) {
+       /* Help */
+       dialog_msgbox(_("Help"), _("The \"Network interface\" is the device "
+                                  "that connects your computer to the 
internet. This is usually a modem, "
+                                  "an ISDN card or a network card in case you 
are using DSL."), rows,
+                     cols - 5, 1);
+      }
+      else if (ret <= 1) {
+       /* Select or Exit */
+#ifdef MINGW
+       char nic[21];
+       char *dst;
+#else
+       char *nic;
+#endif
+       for(idx = 0; idx < nic_item_count; idx++) {
+         
+         if (nic_items[idx]->selected) {
+#ifdef MINGW
+           char *src = strrchr(nic_items[idx]->name, '-') + 2;
+           dst = nic;
+           while(*src)
+             *dst++ = *src++;
+           dst[-1] = 0;
+#else
+           nic = nic_items[idx]->name;
+#endif
+           sym = sym_lookup("INTERFACE", "NETWORK", 0);
+           sym_set_string_value(sym, nic);
+           sym = sym_lookup("INTERFACES", "LOAD", 0);
+           sym_set_string_value(sym, nic);
+         }
+         
+         free(nic_items[idx]->name);
+         free(nic_items[idx]);
        }
-       else {
-               /* We are not root, just ask for the interface */
-               while(true) {
-                       ret = dialog_inputbox(_("GNUnet configuration"), 
_("What is the name of " \
-                               "the network interface that connects your 
computer to the Internet?"),
-                               rows, cols - 5, "eth0");
-                       
-                       if (ret == 1) {
-                               /* Help */
-                               dialog_msgbox(_("Help"), _("The \"Network 
interface\" is the device "
-                                       "that connects your computer to the 
internet. This is usually a modem, "
-                                       "an ISDN card or a network card in case 
you are using DSL."),
-                                       rows, cols - 5, 1);
-                       }
-                       else if (ret <= 0)
-                               break;
-               }
-               
-               if (ret == -1)
-                       goto end;
-
-               sym = sym_lookup("INTERFACE", "NETWORK", 0);
-               sym_set_string_value(sym, dialog_input_result);
-               sym = sym_lookup("INTERFACES", "LOAD", 0);
-               sym_set_string_value(sym, dialog_input_result);
-       }
+       free(nic_items);
        
-       dialog_clear();
-       
-       /* IP address */
-       if ((sym = sym_find("IP", "NETWORK"))) {
-               sym_calc_value_ext(sym, 1);
-               defval = (char *) sym_get_string_value(sym);
-       }
-       else
-               defval = NULL;
-       
-       while(true) {
-               ret = dialog_inputbox(_("GNUnet configuration"), _("What is 
this computer's "
-                       "public IP address or hostname?\n\nIf in doubt, leave 
this empty."),
-                       rows, cols - 5, defval ? defval : "");
-               
-               if (ret == 1) {
-                       /* Help */
-                       dialog_msgbox(_("Help"), _("If your provider always 
assigns the same "
-                               "IP-Address to you (a \"static\" IP-Address), 
enter it into the "
-                               "\"IP-Address\" field. If your IP-Address 
changes every now and then "
-                               "(\"dynamic\" IP-Address) but there's a 
hostname that always points "
-                               "to your actual IP-Address (\"Dynamic DNS\"), 
you can also enter it "
-                               "here.\nIf in doubt, leave the field empty. 
GNUnet will then try to "
-                               "determine your IP-Address."), rows, cols - 5, 
1);
-               }
-               else if (ret <= 0)
-                       break;
-       }
-       
-       if (ret == -1)
-               goto end;
-               
-       sym_set_string_value(sym, dialog_input_result);
-       
-       dialog_clear();
+       break;
+      }
+    }
+    
+    if (ret == 1 || ret == -1)
+      goto end;
+  }
+  else {
+    /* We are not root, just ask for the interface */
+    while(true) {
+      ret = dialog_inputbox(_("GNUnet configuration"), 
+                           _("What is the name of "                    \
+                             "the network interface that connects your 
computer to the Internet?"),
+                           rows, cols - 5, "eth0");
+      
+      if (ret == 1) {
+       /* Help */
+       dialog_msgbox(_("Help"), 
+                     _("The \"Network interface\" is the device "
+                       "that connects your computer to the internet. This is 
usually a modem, "
+                       "an ISDN card or a network card in case you are using 
DSL."),
+                     rows, cols - 5, 1);
+      }
+      else if (ret <= 0)
+       break;
+    }
+    
+    if (ret == -1)
+      goto end;
+    
+    sym = sym_lookup("INTERFACE", "NETWORK", 0);
+    sym_set_string_value(sym, dialog_input_result);
+    sym = sym_lookup("INTERFACES", "LOAD", 0);
+    sym_set_string_value(sym, dialog_input_result);
+  }
+  
+  dialog_clear();
+  
+  /* IP address */
+  if ((sym = sym_find("IP", "NETWORK"))) {
+    sym_calc_value_ext(sym, 1);
+    defval = (char *) sym_get_string_value(sym);
+  }
+  else
+    defval = NULL;
+  
+  while(true) {
+    ret = dialog_inputbox(_("GNUnet configuration"), 
+                         _("What is this computer's "
+                           "public IP address or hostname?\n\nIf in doubt, 
leave this empty."),
+                         rows, cols - 5, defval ? defval : "");
+    
+    if (ret == 1) {
+      /* Help */
+      dialog_msgbox(_("Help"), 
+                   _("If your provider always assigns the same "
+                     "IP-Address to you (a \"static\" IP-Address), enter it 
into the "
+                     "\"IP-Address\" field. If your IP-Address changes every 
now and then "
+                     "(\"dynamic\" IP-Address) but there's a hostname that 
always points "
+                     "to your actual IP-Address (\"Dynamic DNS\"), you can 
also enter it "
+                     "here.\nIf in doubt, leave the field empty. GNUnet will 
then try to "
+                     "determine your IP-Address."), rows, cols - 5, 1);
+    }
+    else if (ret <= 0)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  
+  sym_set_string_value(sym, dialog_input_result);
+  
+  dialog_clear();
+  
+  /* NAT? */
+  sym = sym_find("LIMITED", "NAT");
+  while(true) {
+    ret = dialog_yesno(_("GNUnet configuration"),
+                      _("Is this machine behind "
+                        "NAT?\n\nIf you are connected to the internet through 
another computer "
+                        "doing SNAT, a router or a \"hardware firewall\" and 
other computers "
+                        "on the internet cannot connect to this computer, say 
\"yes\" here. "
+                        "Answer \"no\" on direct connections through modems, 
ISDN cards and "
+                        "DNAT (also known as \"port forwarding\")."), rows, 
cols - 5);
+    
+    if (ret != -2)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  else
+    sym_set_tristate_value(sym, !ret); /* ret is inverted */
+  
+  /* Upstream */
+  if ((sym = sym_find("MAXNETUPBPSTOTAL", "LOAD"))) {
+    sym_calc_value_ext(sym, 1);
+    defval = (char *) sym_get_string_value(sym);
+  }
+  else
+    defval = NULL;
+  
+  while(true) {
+    ret = dialog_inputbox(_("GNUnet configuration"), 
+                         _("How much upstream "
+                           "(Bytes/s) may be used?"), rows, cols - 5, defval ? 
defval : "");
+    
+    if (ret == 1) {
+      /* Help */
+      dialog_msgbox(_("Help"), _("You can limit GNUnet's resource usage "
+                                "here.\n\nThe \"upstream\" is the data channel 
through which data "
+                                "is *sent* to the internet. The limit is 
either the total maximum "
+                                "for this computer or how much GNUnet itself 
is allowed to use. You "
+                                "can specify that later. If you have a 
flatrate, you can set it to "
+                                "the maximum speed of your internet 
connection."), rows, cols - 5, 1);
+    }
+    else if (ret <= 0)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  
+  sym_set_string_value(sym, dialog_input_result);
+  
+  dialog_clear();
+  
+  /* Downstram */
+  if ((sym = sym_find("MAXNETDOWNBPSTOTAL", "LOAD"))) {
+    sym_calc_value_ext(sym, 1);
+    defval = (char *) sym_get_string_value(sym);
+  }
+  else
+    defval = NULL;
+  
+  while(true) {
+    ret = dialog_inputbox(_("GNUnet configuration"), _("How much downstream "
+                                                      "(Bytes/s) may be 
used?"), rows, cols - 5, defval ? defval : "");
+    
+    if (ret == 1) {
+      /* Help */
+      dialog_msgbox(_("Help"), 
+                   _("You can limit GNUnet's resource usage "
+                     "here.\n\nThe \"downstream\" is the data channel through 
which data "
+                     "is *received* from the internet. The limit is either the 
total maximum "
+                     "for this computer or how much GNUnet itself is allowed 
to use. You "
+                     "can specify that later. If you have a flatrate you can 
set it to "
+                     "the maximum speed of your internet connection."), rows, 
cols - 5, 1);
+    }
+    else if (ret <= 0)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  
+  sym_set_string_value(sym, dialog_input_result);
+  
+  dialog_clear();
+  
+  /* Bandwidth allocation */
+  sym = sym_find("BASICLIMITING", "LOAD");
+  while (true) {
+    ret = dialog_yesno(_("GNUnet configuration"), 
+                      _("Share denoted bandwidth "
+                        "with other applications?\n\nSay \"yes\" here, if you 
don't want other "
+                        "network traffic to interfere with GNUnet's operation, 
but still wish to "
+                        "constrain GNUnet's bandwidth usage to values entered 
in the previous "
+                        "steps, or if you can't reliably measure the maximum 
capabilities "
+                        "of your connection. \"No\" can be very useful if 
other applications "
+                        "are causing a lot of traffic on your LAN.  In this 
case, you do not "
+                        "want to limit the traffic that GNUnet can inflict on 
your internet "
+                        "connection whenever your high-speed LAN gets used 
(e.g. by NFS)."),
+                      rows, cols - 5);
+    
+    if (ret != -2)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  else
+    sym_set_tristate_value(sym, !ret); /* ret is inverted */
+  
+  dialog_clear();
+  
+  /* Max CPU */
+  if ((sym = sym_find("MAXCPULOAD", "LOAD"))) {
+    sym_calc_value_ext(sym, 1);
+    defval = (char *) sym_get_string_value(sym);
+  }
+  else
+    defval = NULL;
+  
+  while(true) {
+    ret = dialog_inputbox(_("GNUnet configuration"), 
+                         _("How much CPU (in %) may "
+                           "be used?"), rows, cols - 5, defval ? defval : "");
+    
+    if (ret == 1) {
+      /* Help */
+      dialog_msgbox(_("Help"),
+                   _("You can limit GNUnet's resource usage "
+                     "here.\n\nThis is the percentage of processor time GNUnet 
is allowed "
+                     "to use."), rows, cols - 5, 1);
+    }
+    else if (ret <= 0)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  
+  sym_set_string_value(sym, dialog_input_result);
+  
+  dialog_clear();
+  
+  /* Migration */
+  sym = sym_find("ACTIVEMIGRATION", "FS");
+  while(true) {
+    ret = dialog_yesno(_("GNUnet configuration"), 
+                      _("Store migrated content?"
+                        "\n\nGNUnet is able to store data from other peers in 
your datastore. "
+                        "This is useful if an adversary has access to your 
inserted content and "
+                        "you need to deny that the content is yours. With 
\"content migration\" "
+                        "on, the content could have \"migrated\" over the 
internet to your node"
+                        " without your knowledge.\nIt also helps to spread 
popular content over "
+                        "different peers to enhance availability."), rows, 
cols - 5);
+    
+    if (ret != -2)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  else
+    sym_set_tristate_value(sym, !ret); /* ret is inverted */
 
-       /* NAT? */
-       sym = sym_find("LIMITED", "NAT");
-       while(true) {
-               ret = dialog_yesno(_("GNUnet configuration"), _("Is this 
machine behind "
-                               "NAT?\n\nIf you are connected to the internet 
through another computer "
-                               "doing SNAT, a router or a \"hardware 
firewall\" and other computers "
-                               "on the internet cannot connect to this 
computer, say \"yes\" here. "
-                               "Answer \"no\" on direct connections through 
modems, ISDN cards and "
-                               "DNAT (also known as \"port forwarding\")."), 
rows, cols - 5);
-               
-               if (ret != -2)
-                       break;
-       }
-       
-       if (ret == -1)
-               goto end;
-       else
-               sym_set_tristate_value(sym, !ret); /* ret is inverted */
-       
-       /* Upstream */
-       if ((sym = sym_find("MAXNETUPBPSTOTAL", "LOAD"))) {
-               sym_calc_value_ext(sym, 1);
-               defval = (char *) sym_get_string_value(sym);
-       }
-       else
-               defval = NULL;
-
-       while(true) {
-               ret = dialog_inputbox(_("GNUnet configuration"), _("How much 
upstream "
-                       "(Bytes/s) may be used?"), rows, cols - 5, defval ? 
defval : "");
-               
-               if (ret == 1) {
-                       /* Help */
-                       dialog_msgbox(_("Help"), _("You can limit GNUnet's 
resource usage "
-                               "here.\n\nThe \"upstream\" is the data channel 
through which data "
-                               "is *sent* to the internet. The limit is either 
the total maximum "
-                               "for this computer or how much GNUnet itself is 
allowed to use. You "
-                               "can specify that later. If you have a 
flatrate, you can set it to "
-                               "the maximum speed of your internet 
connection."), rows, cols - 5, 1);
-               }
-               else if (ret <= 0)
-                       break;
-       }
-
-       if (ret == -1)
-               goto end;
-
-       sym_set_string_value(sym, dialog_input_result);
-
        dialog_clear();
 
-       /* Downstram */
-       if ((sym = sym_find("MAXNETDOWNBPSTOTAL", "LOAD"))) {
-               sym_calc_value_ext(sym, 1);
-               defval = (char *) sym_get_string_value(sym);
-       }
-       else
-               defval = NULL;
-
-       while(true) {
-               ret = dialog_inputbox(_("GNUnet configuration"), _("How much 
downstream "
-                       "(Bytes/s) may be used?"), rows, cols - 5, defval ? 
defval : "");
-               
-               if (ret == 1) {
-                       /* Help */
-                       dialog_msgbox(_("Help"), _("You can limit GNUnet's 
resource usage "
-                               "here.\n\nThe \"downstream\" is the data 
channel through which data "
-                               "is *received* from the internet. The limit is 
either the total maximum "
-                               "for this computer or how much GNUnet itself is 
allowed to use. You "
-                               "can specify that later. If you have a flatrate 
you can set it to "
-                               "the maximum speed of your internet 
connection."), rows, cols - 5, 1);
-               }
-               else if (ret <= 0)
-                       break;
-       }
-       
-       if (ret == -1)
-               goto end;
-
-       sym_set_string_value(sym, dialog_input_result);
-
-       dialog_clear();
-
-       /* Bandwidth allocation */
-       sym = sym_find("BASICLIMITING", "LOAD");
-       while (true) {
-               ret = dialog_yesno(_("GNUnet configuration"), _("Share denoted 
bandwidth "
-                               "with other applications?\n\nSay \"yes\" here, 
if you don't want other "
-                               "network traffic to interfere with GNUnet's 
operation, but still wish to "
-                               "constrain GNUnet's bandwidth usage to values 
entered in the previous "
-                               "steps, or if you can't reliably measure the 
maximum capabilities "
-                               "of your connection. \"No\" can be very useful 
if other applications "
-                               "are causing a lot of traffic on your LAN.  In 
this case, you do not "
-                               "want to limit the traffic that GNUnet can 
inflict on your internet "
-                               "connection whenever your high-speed LAN gets 
used (e.g. by NFS)."),
-                               rows, cols - 5);
-               
-               if (ret != -2)
-                       break;
-       }
-       
-       if (ret == -1)
-               goto end;
-       else
-               sym_set_tristate_value(sym, !ret); /* ret is inverted */
-       
-       dialog_clear();
-
-       /* Max CPU */
-       if ((sym = sym_find("MAXCPULOAD", "LOAD"))) {
-               sym_calc_value_ext(sym, 1);
-               defval = (char *) sym_get_string_value(sym);
-       }
-       else
-               defval = NULL;
-
-       while(true) {
-               ret = dialog_inputbox(_("GNUnet configuration"), _("How much 
CPU (in %) may "
-                       "be used?"), rows, cols - 5, defval ? defval : "");
-               
-               if (ret == 1) {
-                       /* Help */
-                       dialog_msgbox(_("Help"), _("You can limit GNUnet's 
resource usage "
-                               "here.\n\nThis is the percentage of processor 
time GNUnet is allowed "
-                               "to use."), rows, cols - 5, 1);
-               }
-               else if (ret <= 0)
-                       break;
-       }
-       
-       if (ret == -1)
-               goto end;
-
-       sym_set_string_value(sym, dialog_input_result);
-       
-       dialog_clear();
-
-       /* Migration */
-       sym = sym_find("ACTIVEMIGRATION", "FS");
-       while(true) {
-               ret = dialog_yesno(_("GNUnet configuration"), _("Store migrated 
content?"
-                               "\n\nGNUnet is able to store data from other 
peers in your datastore. "
-                               "This is useful if an adversary has access to 
your inserted content and "
-                               "you need to deny that the content is yours. 
With \"content migration\" "
-                               "on, the content could have \"migrated\" over 
the internet to your node"
-                               " without your knowledge.\nIt also helps to 
spread popular content over "
-                               "different peers to enhance availability."), 
rows, cols - 5);
-                               
-               if (ret != -2)
-                       break;
-       }
-
-       if (ret == -1)
-               goto end;
-       else
-               sym_set_tristate_value(sym, !ret); /* ret is inverted */
-
-       dialog_clear();
-
        /* Quota */
        if ((sym = sym_find("QUOTA", "FS"))) {
                sym_calc_value_ext(sym, 1);
@@ -604,7 +619,7 @@
        free(group_name);
 
        if (adv) {
-               mconf_main(argc, argv);
+               mconf_main();
        }
 
   return 0;

Added: GNUnet/src/conf/wizard_curs.h
===================================================================
--- GNUnet/src/conf/wizard_curs.h       2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/wizard_curs.h       2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/gconf.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef GCONF_H
+#define GCONF_H
+
+int wizard_curs_main(void);
+
+#endif

Added: GNUnet/src/conf/zconf_tab.h
===================================================================
--- GNUnet/src/conf/zconf_tab.h 2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/conf/zconf_tab.h 2005-08-14 05:49:03 UTC (rev 1660)
@@ -0,0 +1,33 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 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/gconf.h
+ * @brief GNUnet Setup
+ * @author Nils Durner
+ */
+
+#ifndef ZCONF_TAB_H
+#define ZCONF_TAB_H
+
+void conf_parse(const char * filename);
+
+#endif

Modified: GNUnet/src/util/configuration.c
===================================================================
--- GNUnet/src/util/configuration.c     2005-08-14 03:24:42 UTC (rev 1659)
+++ GNUnet/src/util/configuration.c     2005-08-14 05:49:03 UTC (rev 1660)
@@ -506,9 +506,9 @@
     FREE(c);
     /* try generating a configuration file */
     LOG(LOG_WARNING,
-       _("Configuration file '%s' not found.  Run gnunet-setup!"),
+       _("Configuration file '%s' not found.  Run gnunet-setup!\n"),
        expCfgName);
-    errexit(_("Configuration file '%s' not found.  Run gnunet-setup!"),
+    errexit(_("Configuration file '%s' not found.  Run gnunet-setup!\n"),
            expCfgName);
   }
   if (0 == assertIsFile(expCfgName))





reply via email to

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