[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3250 - in GNUnet: . src/include src/server src/setup src/u
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3250 - in GNUnet: . src/include src/server src/setup src/util/config src/util/config_impl |
Date: |
Fri, 18 Aug 2006 18:02:33 -0700 (PDT) |
Author: grothoff
Date: 2006-08-18 18:02:21 -0700 (Fri, 18 Aug 2006)
New Revision: 3250
Modified:
GNUnet/src/include/gnunet_util_config.h
GNUnet/src/include/gnunet_util_config_impl.h
GNUnet/src/server/gnunetd.c
GNUnet/src/setup/Makefile.am
GNUnet/src/setup/conf.c
GNUnet/src/setup/conf.h
GNUnet/src/setup/confdata.c
GNUnet/src/setup/confdata.h
GNUnet/src/setup/gconf.h
GNUnet/src/setup/gnunet-setup.c
GNUnet/src/setup/lex.zconf.c
GNUnet/src/setup/recreate.c
GNUnet/src/setup/recreate.h
GNUnet/src/setup/symbol.c
GNUnet/src/setup/wizard_util.c
GNUnet/src/setup/zconf_tab.c
GNUnet/src/util/config/config.c
GNUnet/src/util/config_impl/impl.c
GNUnet/todo
Log:
making gnunet-setup binary compile (not plugins)
Modified: GNUnet/src/include/gnunet_util_config.h
===================================================================
--- GNUnet/src/include/gnunet_util_config.h 2006-08-19 00:07:16 UTC (rev
3249)
+++ GNUnet/src/include/gnunet_util_config.h 2006-08-19 01:02:21 UTC (rev
3250)
@@ -158,6 +158,18 @@
int def);
/**
+ * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
+ * where either in the current section or globally FOO is set to
+ * DIRECTORY.
+
+ * @param old string to $-expand (will be freed!)
+ * @return $-expanded string
+ */
+char * GC_configuration_expand_dollar(struct GC_Configuration * cfg,
+ const char * section,
+ char * old);
+
+/**
* Set a configuration value that should be a number.
* @return 0 on success, -1 on error (i.e. out of memory,
* or update refused by registered callback)
Modified: GNUnet/src/include/gnunet_util_config_impl.h
===================================================================
--- GNUnet/src/include/gnunet_util_config_impl.h 2006-08-19 00:07:16 UTC
(rev 3249)
+++ GNUnet/src/include/gnunet_util_config_impl.h 2006-08-19 01:02:21 UTC
(rev 3250)
@@ -86,7 +86,20 @@
int (*write_configuration)(struct GC_Configuration * cfg,
const char * filename);
+
/**
+ * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
+ * where either in the current section or globally FOO is set to
+ * DIRECTORY.
+ *
+ * @param old string to $-expand (will be freed!)
+ * @return $-expanded string
+ */
+ char * (*configuration_expand_dollar)(struct GC_Configuration * cfg,
+ const char * section,
+ char * old);
+
+ /**
* Get a configuration value that should be a number.
* @param min minimal legal value
* @param max maximal legal value
Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/server/gnunetd.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -51,11 +51,11 @@
char * filename;
filename = NULL;
- if (-1 == GC_get_configuration_value_string(cfg,
- "GNUNET",
- "CONFIGFILE",
- DEFAULT_DAEMON_CONFIG_FILE,
- &filename)) {
+ if (-1 == GC_get_configuration_value_filename(cfg,
+ "GNUNET",
+ "CONFIGFILE",
+ DEFAULT_DAEMON_CONFIG_FILE,
+ &filename)) {
GE_BREAK(NULL, 0); /* should never happen */
return;
}
Modified: GNUnet/src/setup/Makefile.am
===================================================================
--- GNUnet/src/setup/Makefile.am 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/Makefile.am 2006-08-19 01:02:21 UTC (rev 3250)
@@ -28,6 +28,7 @@
lib_LTLIBRARIES = libgnunetsetup.la
plugin_LTLIBRARIES = \
+ libgnunetsetup_text.la \
$(curses_libs) \
$(gtk_libs)
@@ -59,7 +60,6 @@
sed < $(srcdir)/lkc_proto.h > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
libgnunetsetup_la_SOURCES = \
- conf.c conf.h \
confdata.c confdata.h \
expr.c \
expr.h \
@@ -73,7 +73,9 @@
wizard_util.h
libgnunetsetup_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
libgnunetsetup_la_LDFLAGS = \
-export-dynamic
@@ -100,6 +102,18 @@
$(top_builddir)/src/util/libgnunetutil.la \
libgnunetsetup.la
+
+libgnunetsetup_text_la_SOURCES = \
+ conf.c conf.h
+
+libgnunetsetup_text_la_LDFLAGS = \
+ -export-dynamic -avoid-version -module
+
+libgnunetsetup_text_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ libgnunetsetup.la
+
+
libgnunetsetup_gtk_la_SOURCES = \
gconf.c gconf.h \
glade_support.h glade_support.c \
Modified: GNUnet/src/setup/conf.c
===================================================================
--- GNUnet/src/setup/conf.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/conf.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -503,8 +503,9 @@
check_conf(child);
}
-int conf_main()
-{
+int conf_main(int argc,
+ char **argv,
+ void * lib) {
char * filename;
filename = getConfigurationString("GNUNET-SETUP",
Modified: GNUnet/src/setup/conf.h
===================================================================
--- GNUnet/src/setup/conf.h 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/conf.h 2006-08-19 01:02:21 UTC (rev 3250)
@@ -21,13 +21,15 @@
/**
* @file conf/conf.h
- * @brief GNUnet Setup
+ * @brief GNUnet text mode Setup
* @author Nils Durner
*/
#ifndef CONF_H
#define CONF_H
-int conf_main(void);
+int conf_main(int argc,
+ char **argv,
+ void * lib);
#endif
Modified: GNUnet/src/setup/confdata.c
===================================================================
--- GNUnet/src/setup/confdata.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/confdata.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -44,7 +44,8 @@
#include "platform.h"
#include "gnunet_util.h"
-int conf_read(const char *name)
+int conf_read(struct GE_Context * ectx,
+ struct GC_Configuration * cfg)
{
char *val;
struct symbol *sym;
@@ -52,21 +53,15 @@
struct expr *e;
int i = 0;
- GE_ASSERT(ectx, name != NULL);
- FREENONNULL(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("");
-
+ if (0 == GC_get_configuration_value_string(cfg,
+ sym->sect,
+ sym->name,
+ NULL,
+ &val)) {
switch (sym->type) {
case S_TRISTATE:
if (*val == 'm') {
@@ -89,11 +84,11 @@
sym->flags &= ~SYMBOL_NEW;
}
else {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("%s: symbol value `%s' invalid for %s\n"),
- name,
- val,
- sym->name);
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Symbol value `%s' invalid for %s\n"),
+ val,
+ sym->name);
sym->user.val = NULL;
sym->flags |= SYMBOL_NEW;
}
Modified: GNUnet/src/setup/confdata.h
===================================================================
--- GNUnet/src/setup/confdata.h 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/confdata.h 2006-08-19 01:02:21 UTC (rev 3250)
@@ -28,7 +28,12 @@
#ifndef CONFDATA_H
#define CONFDATA_H
-int conf_read(const char *name);
+/**
+ * Convert the configuration specified in "cfg"
+ * into the internal configuration of the conf module.
+ */
+int conf_read(struct GE_Context * ectx,
+ struct GC_Configuration * cfg);
int conf_write(const char * filename);
Modified: GNUnet/src/setup/gconf.h
===================================================================
--- GNUnet/src/setup/gconf.h 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/gconf.h 2006-08-19 01:02:21 UTC (rev 3250)
@@ -28,7 +28,9 @@
#ifndef GNUNET_SETUP_GCONF_H
#define GNUNET_SETUP_GCONF_H
-int gconf_main(int argc, char **argv, void * lib);
+int gconf_main(int argc,
+ char **argv,
+ void * lib);
void gconf_main_post_init(void * lib);
Modified: GNUnet/src/setup/gnunet-setup.c
===================================================================
--- GNUnet/src/setup/gnunet-setup.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/gnunet-setup.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2001, 2002, 2005, 2006 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
@@ -19,7 +19,7 @@
*/
/**
- * @file conf/gnunet-setup.c
+ * @file setup/gnunet-setup.c
* @brief GNUnet Setup
* @author Nils Durner
* @author Christian Grothoff
@@ -27,269 +27,210 @@
#include "platform.h"
#include "gnunet_util.h"
+#include "gnunet_directories.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_error_loggers.h"
+
#include "recreate.h"
-#include "conf.h"
#include "zconf_tab.h"
+static int config_daemon;
+static struct GE_Context * ectx;
+
+struct GC_Configuration * cfg;
+
/**
- * Perform option parsing from the command line.
+ * All gnunet-setup command line options
*/
-static int parser(int argc, char *argv[])
-{
- int cont = OK;
- int c;
- int daemon = NO;
- char *filename = NULL;
- char *dirname;
+static struct CommandLineOption gnunetsetupOptions[] = {
+ COMMAND_LINE_OPTION_CFG_FILE, /* -c */
+ { 'd', "daemon", NULL,
+ gettext_noop("generate configuration for gnunetd, the GNUnet daemon"),
+ 0, &gnunet_getopt_configure_set_one, &config_daemon },
+ COMMAND_LINE_OPTION_HELP(gettext_noop("Tool to setup GNUnet.")), /* -h */
+ COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */
+ COMMAND_LINE_OPTION_VERBOSE,
+ COMMAND_LINE_OPTION_END,
+};
- 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}
- };
+static int dyn_config(const char * module,
+ const char * mainfunc,
+ int argc,
+ const char **argv) {
+ void (*mptr)(int, const char **, void*);
+ struct PluginHandle * library;
- c = GNgetopt_long(argc, argv, "c:dhvV", long_options, &option_index);
+ library = os_plugin_load(ectx,
+ "libgnunet",
+ module);
+ if (!library)
+ return SYSERR;
+ mptr = os_plugin_resolve_function(library,
+ mainfunc,
+ YES);
+ if (! mptr)
+ return SYSERR;
+ mptr(argc, argv, library);
+ os_plugin_unload(library);
+ return YES;
+}
- 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"));
+static const char * INFO =
+ "gnunet-setup [OPTIONS] config"
#if HAVE_CURSES
- printf(_(" menuconfig\ttext-based menu\n"));
- printf(_
- (" wizard-curses\tBasic text-based graphical configuration\n"));
+ "|menuconfig|wizard-curses"
#endif
#if HAVE_GTK
- printf(_(" gconfig\tGTK configuration\n"));
- printf(_(" wizard-gtk\tBasic GTK configuration\n\n"));
+ "|gconfig|wizard-gtk"
#endif
- cont = SYSERR;
- break;
- }
- default:
- GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER, _("Use --help to get a
list of options.\n"));
- cont = SYSERR;
- } /* end of parsing commandline */
+ "\n";
+
+static const char * modules[] = {
+ "gconfig", "setup_gtk", "gconf_main" ,
+ "menuconfig", "setup_curses", "mconf_main" ,
+ "config", "setup_text", "conf_main" ,
+ "wizard-curses", "setup_curses", "wizard_curs_main",
+ "wizard-gtk", "setup_gtk", "gtk_wizard_main",
+ NULL,
+};
+
+int main(int argc,
+ const char *argv[]) {
+ const char * operation;
+ int done;
+ char * filename;
+ char * dirname;
+ char * specname;
+ int i;
+
+ ectx = GE_create_context_stderr(NO,
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
+ GE_setDefaultContext(ectx);
+ cfg = GC_create_C_impl();
+ GE_ASSERT(ectx, cfg != NULL);
+ i = gnunet_parse_options(INFO,
+ ectx,
+ cfg,
+ gnunetsetupOptions,
+ (unsigned int) argc,
+ argv);
+ if (i < 0) {
+ GC_free(cfg);
+ GE_free_context(ectx);
+ return -1;
}
- /* 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(DEFAULT_DAEMON_CONFIG_FILE, W_OK) ||
- (errno == ENOENT && 0 == ACCESS(DEFAULT_DAEMON_DIR, W_OK)))
- filename = STRDUP(DEFAULT_DAEMON_CONFIG_FILE);
- else {
- if(0 == ACCESS(VAR_DIRECTORY, W_OK))
- mkdirp(VAR_DAEMON_DIRECTORY);
- if(0 == ACCESS(VAR_DAEMON_CONFIG_FILE, W_OK) ||
- (errno == ENOENT && 0 == ACCESS(VAR_DAEMON_DIRECTORY, W_OK)))
- filename = STRDUP(VAR_DAEMON_CONFIG_FILE);
- else {
- dirname = expandFileName(GNUNET_HOME_DIRECTORY);
- mkdirp(dirname);
- FREE(dirname);
- filename = expandFileName(HOME_DAEMON_CONFIG_FILE);
- }
- }
+ if (i != argc - 1) {
+ if (i < argc - 1) {
+ fprintf(stderr,
+ _("Too many arguments.\n"));
+ return -1;
}
- FREENONNULL(setConfigurationString("FILES", "gnunet.conf", filename));
- conf_parse(GNDATADIR "/config-daemon.in");
+ GE_LOG(ectx,
+ GE_WARNING | GE_REQUEST | GE_USER,
+ _("No interface specified, using default\n"));
+ operation = "config";
+#if HAVE_CURSES
+ operation = "menuconfig";
+#endif
+#if HAVE_GTK
+ operation = "gconfig";
+#endif
+ } else {
+ operation = argv[i];
}
- else {
- FREENONNULL(setConfigurationString("GNUNETD", "_MAGIC_", "NO"));
- if(filename == NULL) {
- dirname = expandFileName(GNUNET_HOME_DIRECTORY);
- mkdirp(dirname);
- FREE(dirname);
- filename = expandFileName(DEFAULT_CLIENT_CONFIG_FILE);
- }
- FREENONNULL(setConfigurationString("FILES", "gnunet.conf", filename));
- conf_parse(GNDATADIR "/config-client.in");
+
+ filename = NULL;
+ if (-1 == GC_get_configuration_value_filename(cfg,
+ "GNUNET",
+ "CONFIGFILE",
+ config_daemon
+ ? DEFAULT_DAEMON_CONFIG_FILE
+ : DEFAULT_CLIENT_CONFIG_FILE,
+ &filename)) {
+ GE_BREAK(ectx, 0); /* should never happen */
+ return -1;
}
+ GE_ASSERT(ectx, filename != NULL);
dirname = STRDUP(filename);
-
- c = strlen(dirname) - 1;
- while(c > -1) {
- char ch = dirname[c];
- if (ch == '/' || ch == '\\') {
- dirname[c + 1] = 0;
+ i = strlen(dirname) - 1;
+ while (i > -1) {
+ char ch = dirname[i];
+ if ( (ch == '/') || (ch == '\\')) {
+ dirname[i + 1] = 0;
break;
}
- c--;
- }
-
- if (c)
- 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);
- }
+ i--;
+ }
+ disk_directory_create(ectx, dirname);
+ if ( ( (0 == ACCESS(filename, W_OK)) ||
+ ( (errno == ENOENT) &&
+ (0 == ACCESS(dirname, W_OK))) ) )
+ GE_DIE_STRERROR_FILE(ectx,
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "access",
+ dirname);
FREE(dirname);
- FREENONNULL(setConfigurationString("GNUNET-SETUP", "FILENAME", filename));
- if(GNoptind < argc)
- FREENONNULL(setConfigurationString("GNUNET-SETUP",
- "OPERATION", argv[GNoptind++]));
- if(GNoptind < argc) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, _("Invalid arguments: "));
- while(GNoptind < argc)
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER, "%s ", argv[GNoptind++]);
- GE_LOG(ectx, GE_FATAL | GE_IMMEDIATE | GE_USER, _("Invalid arguments.
Exiting.\n"));
- FREE(filename);
- return SYSERR;
- }
-
- if(0 != ACCESS(filename, F_OK))
- recreate_main();
- FREE(filename);
-
-
- return cont;
-}
-
-int dyn_config(const char *module,
- const char *mainfunc,
- int argc,
- char **argv) {
- void (*mptr)(int, char **, void*);
- void *library;
-
- library = loadDynamicLibrary("libgnunet", module);
- if (!library)
- return SYSERR;
- mptr = bindDynamicMethod(library, mainfunc, "");
- if (! mptr)
- return SYSERR;
- mptr(argc, argv, library);
- unloadDynamicLibrary(library);
- return YES;
-}
+ dirname = os_get_installation_path(ectx,
+ cfg,
+ GNDATADIR);
+ specname = MALLOC(strlen(dirname) + strlen("/config-daemon.in") + 1);
+ strcpy(specname, dirname);
+ FREE(dirname);
+ if (config_daemon)
+ strcat(specname, "/config-daemon.in");
+ else
+ strcat(specname, "/config-client.in");
+ conf_parse(specname);
+ FREE(specname);
-int main(int argc, char *argv[])
-{
- char *operation;
- int def, done;
+ if(0 != ACCESS(filename, F_OK)) {
+ recreate_main(ectx,
+ cfg,
+ filename,
+ config_daemon);
+ } else {
+ GC_parse_configuration(cfg,
+ filename);
+ }
- if(OK != initUtil(argc, argv, &parser))
- return -1;
-
done = NO;
- operation = getConfigurationString("GNUNET-SETUP", "OPERATION");
- if (operation == NULL) {
- operation = STRDUP("");
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("No interface specified, using default\n"));
- def = YES;
- }
- else {
- def = NO;
- done = YES;
- }
-
- if(strcmp(operation, "gconfig") == 0 || def) {
- if (dyn_config("setup_gtk", "gconf_main",
- argc, argv) != YES) {
- if (!def) {
- FREE(operation);
- errexit(_("`%s' is not available."), "gconfig");
+ i = 0;
+ while ( (done == NO) &&
+ (modules[i] != NULL) ) {
+ if (strcmp(operation, modules[i]) == 0) {
+ if (dyn_config(modules[i+1],
+ modules[i+2],
+ argc,
+ argv) != YES) {
+ GE_LOG(ectx,
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("`%s' is not available."),
+ operation);
+ GC_free(cfg);
+ GE_free_context(ectx);
+ return -1;
+ } else {
+ done = YES;
}
}
- else {
- def = NO;
- done = YES;
- }
+ i += 3;
}
-
- if(strcmp(operation, "menuconfig") == 0 || def) {
- if (dyn_config("setup_curses", "mconf_main",
- argc, argv) != YES) {
- if (!def) {
- FREE(operation);
- errexit(_("`%s' is not available."), "menuconfig");
- }
- }
- else {
- def = NO;
- done = YES;
- }
- }
-
- if(strcmp(operation, "config") == 0 || def)
- conf_main();
- 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 (dyn_config("setup_curses", "wizard_curs_main",
- argc, argv) != YES) {
- FREE(operation);
- errexit(_("`%s' is not available."), "wizard-curses");
- }
- }
- else if(strcmp(operation, "wizard-gtk") == 0) {
- if(!testConfigurationString("GNUNETD", "_MAGIC_", "YES"))
- errexit(_("Can only run wizard to configure gnunetd.\n"
- "Did you forget the `%s' option?\n"), "-d");
+ if (done == NO) {
+ fprintf(stderr,
+ _("Unknown operation `%s'\n"),
+ operation);
+ fprintf(stderr,
+ _("Use --help to get a list of options.\n"));
- if (dyn_config("setup_gtk", "gtk_wizard_main",
- argc, argv) != YES) {
- FREE(operation);
- errexit(_("`%s' is not available."), "wizard-gtk");
- }
- }
- else if (!done) {
- printf(_("Unknown operation `%s'\n"), operation);
- printf(_("Use --help to get a list of options.\n"));
- FREE(operation);
- doneUtil();
+ GC_free(cfg);
+ GE_free_context(ectx);
return 1;
}
-
- FREE(operation);
- doneUtil();
+ GC_free(cfg);
+ GE_free_context(ectx);
return 0;
}
Modified: GNUnet/src/setup/lex.zconf.c
===================================================================
--- GNUnet/src/setup/lex.zconf.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/lex.zconf.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -143,6 +143,8 @@
extern FILE *zconfin, *zconfout;
+extern struct GC_Configuration * cfg;
+
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
@@ -3626,7 +3628,9 @@
struct file *file;
struct buffer *buf;
- realfn = expandDollar("Meta", STRDUP(name));
+ realfn = GC_configuration_expand_dollar(cfg,
+ "Meta",
+ STRDUP(name));
if (strlen(realfn) == 0) {
FREE(realfn);
realfn = STRDUP(name);
Modified: GNUnet/src/setup/recreate.c
===================================================================
--- GNUnet/src/setup/recreate.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/recreate.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -69,21 +69,21 @@
}
}
-static void insert_nic(const char * name,
- int defaultNIC,
- void * cls) {
+static int insert_nic(const char * name,
+ int defaultNIC,
+ void * cls) {
struct symbol * sym = cls;
if ( (NULL == sym_get_string_value(sym)) ||
(defaultNIC) )
sym_set_string_value(sym, name);
+ return OK;
}
/**
* @brief Set reasonable default for GNUNETD_HOME if needed
*/
-static void checkDefaultIFC(struct symbol *sym)
-{
-
+static void checkDefaultIFC(struct GE_Context * ectx,
+ struct symbol *sym) {
if (strncmp(sym->name,
"INTERFACE",
strlen("INTERFACE")) == 0) /* match also for INTERFACES ! */
@@ -97,19 +97,21 @@
if (!val || !strlen(val))
{
/* INTERFACE isn't set yet. Let's choose a sane default */
- enumNetworkIfs(insert_nic, sym);
+ os_list_network_interfaces(ectx,
+ insert_nic,
+ sym);
}
}
}
-int recreate_main() {
+int recreate_main(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename,
+ int config_daemon) {
struct symbol *sym;
int i = 0;
- char * filename;
-
- filename = getConfigurationString("GNUNET-SETUP",
- "FILENAME");
+
/* we are setting advanced/rare settings below */
sym = sym_find("EXPERIMENTAL", "Meta");
if (sym != NULL)
@@ -122,12 +124,10 @@
sym_set_tristate_value(sym, yes);
/* save new config files to DATADIR */
- if (testConfigurationString("GNUNETD",
- "_MAGIC_",
- "YES")) {
+ if (config_daemon) {
for_all_symbols(i, sym) {
checkGNUNETDHome(sym);
- checkDefaultIFC(sym);
+ checkDefaultIFC(ectx, sym);
}
}
/* Write defaults */
@@ -135,10 +135,8 @@
printf(_("Unable to save configuration file `%s': %s.\n"),
filename,
STRERROR(errno));
- FREE(filename);
return 1;
}
- FREE(filename);
return 0;
}
Modified: GNUnet/src/setup/recreate.h
===================================================================
--- GNUnet/src/setup/recreate.h 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/recreate.h 2006-08-19 01:02:21 UTC (rev 3250)
@@ -28,6 +28,9 @@
#ifndef RECREATE_H
#define RECREATE_H
-int recreate_main(void);
+int recreate_main(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename,
+ int config_daemon);
#endif
Modified: GNUnet/src/setup/symbol.c
===================================================================
--- GNUnet/src/setup/symbol.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/symbol.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -645,8 +645,7 @@
if (!sect)
sect = current_sect;
- if (!sect)
- errexit("Error: current section not known (sym_lookup)");
+ GE_ASSERT(NULL, sect);
if (name) {
if (name[0] && !name[1]) {
@@ -728,8 +727,7 @@
if (!sect)
sect = current_sect;
- if (!sect)
- errexit("Error: current section not known (sym_find)");
+ GE_ASSERT(NULL, sect);
if (name[0] && !name[1]) {
switch (name[0]) {
Modified: GNUnet/src/setup/wizard_util.c
===================================================================
--- GNUnet/src/setup/wizard_util.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/wizard_util.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -107,10 +107,15 @@
* @param groupname name of the group to use
* @return 1 on success, 0 on error
*/
-int wiz_autostartService(int doAutoStart, char *username, char *groupname) {
- int ret = autostartService(doAutoStart,
- username,
- groupname);
+int wiz_autostartService(int doAutoStart,
+ char *username,
+ char *groupname) {
+ int ret = os_modify_autostart(NULL,
+ NO,
+ doAutoStart,
+ "gnunetd",
+ username,
+ groupname);
if (ret ) {
#ifdef MINGW
char *err = NULL;
@@ -165,9 +170,13 @@
* @return 1 on success
*/
int wiz_createGroupUser(char *group_name, char *user_name) {
- int ret = createGroupUser(group_name, user_name);
+ int ret = os_modify_user(NULL,
+ NO,
+ YES,
+ user_name,
+ group_name);
- if (ret) {
+ if (ret != OK) {
#ifdef MINGW
char *err;
Modified: GNUnet/src/setup/zconf_tab.c
===================================================================
--- GNUnet/src/setup/zconf_tab.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/setup/zconf_tab.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -1577,7 +1577,7 @@
case 74:
{
- zconf_nextfile(yyvsp[0].string);
+ zconf_nextfile(yyvsp[0].string);
;}
break;
Modified: GNUnet/src/util/config/config.c
===================================================================
--- GNUnet/src/util/config/config.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/util/config/config.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -109,6 +109,20 @@
}
/**
+ * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
+ * where either in the current section or globally FOO is set to
+ * DIRECTORY.
+ *
+ * @param old string to $-expand (will be freed!)
+ * @return $-expanded string
+ */
+char * GC_configuration_expand_dollar(struct GC_Configuration * cfg,
+ const char * section,
+ char * old) {
+ return cfg->configuration_expand_dollar(cfg, section, old);
+}
+
+/**
* Get a configuration value that should be a number.
* @param min minimal legal value
* @param max maximal legal value
Modified: GNUnet/src/util/config_impl/impl.c
===================================================================
--- GNUnet/src/util/config_impl/impl.c 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/src/util/config_impl/impl.c 2006-08-19 01:02:21 UTC (rev 3250)
@@ -600,11 +600,12 @@
* value, or NULL if option is not specified and no default given
* @return 0 on success, -1 on error, 1 for default
*/
-int _get_configuration_value_filename(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char * def,
- char ** value) {
+static int
+_get_configuration_value_filename(struct GC_Configuration * cfg,
+ const char * section,
+ const char * option,
+ const char * def,
+ char ** value) {
GC_ConfigurationData * data;
int ret;
char * tmp;
@@ -617,6 +618,60 @@
return ret;
}
+/**
+ * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
+ * where either in the current section or globally FOO is set to
+ * DIRECTORY.
+ *
+ * @param old string to $-expand (will be freed!)
+ * @return $-expanded string
+ */
+static char *
+_configuration_expand_dollar(struct GC_Configuration * cfg,
+ const char * section,
+ char * orig) {
+ int i;
+ char * prefix;
+ char * result;
+
+ i = 0;
+ while ( (orig[i] != '/') &&
+ (orig[i] != '\\') &&
+ (orig[i] != '\0') )
+ i++;
+ if (orig[i] == '\0')
+ return orig;
+ orig[i] = '\0';
+ _get_configuration_value_string(cfg,
+ section,
+ &orig[1],
+ NULL,
+ &prefix);
+ if (prefix == NULL)
+ _get_configuration_value_string(cfg,
+ "",
+ &orig[1],
+ NULL,
+ &prefix);
+ if (prefix == NULL) {
+ const char * env = getenv(&orig[1]);
+ if (env != NULL)
+ prefix = STRDUP(env);
+ }
+ if (prefix == NULL) {
+ orig[i] = DIR_SEPARATOR;
+ return orig;
+ }
+ result = MALLOC(strlen(prefix) +
+ strlen(&orig[i+1]) + 2);
+ strcpy(result, prefix);
+ strcat(result, DIR_SEPARATOR_STR);
+ strcat(result, &orig[i+1]);
+ FREE(prefix);
+ FREE(orig);
+ return result;
+}
+
static int
_set_configuration_value_number(struct GC_Configuration * cfg,
struct GE_Context * ectx,
@@ -698,6 +753,7 @@
ret->get_configuration_value_string = &_get_configuration_value_string;
ret->get_configuration_value_filename = &_get_configuration_value_filename;
ret->get_configuration_value_choice = &_get_configuration_value_choice;
+ ret->configuration_expand_dollar = &_configuration_expand_dollar;
ret->set_configuration_value_number = &_set_configuration_value_number;
ret->set_configuration_value_string = &_set_configuration_value_string;
ret->set_configuration_value_choice = &_set_configuration_value_choice;
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-19 00:07:16 UTC (rev 3249)
+++ GNUnet/todo 2006-08-19 01:02:21 UTC (rev 3250)
@@ -20,7 +20,7 @@
+ config: call GC change listeners on entire config on registration!!!
* transports:
+ SMTP/HTTP: do not yet compile (commented out from build)
- o libcurl? & libesmtp?
+ o libcurl / libwebserver-gnunet & libesmtp?
* server:
+ needs testing, also likely to be missing features
* applications:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3250 - in GNUnet: . src/include src/server src/setup src/util/config src/util/config_impl,
grothoff <=