[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3259 - in GNUnet/src/setup: . text
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3259 - in GNUnet/src/setup: . text |
Date: |
Sat, 19 Aug 2006 15:42:48 -0700 (PDT) |
Author: grothoff
Date: 2006-08-19 15:42:46 -0700 (Sat, 19 Aug 2006)
New Revision: 3259
Modified:
GNUnet/src/setup/Makefile.am
GNUnet/src/setup/gnunet-setup.c
GNUnet/src/setup/text/conf.c
GNUnet/src/setup/text/conf.h
Log:
adjust
Modified: GNUnet/src/setup/Makefile.am
===================================================================
--- GNUnet/src/setup/Makefile.am 2006-08-19 22:33:59 UTC (rev 3258)
+++ GNUnet/src/setup/Makefile.am 2006-08-19 22:42:46 UTC (rev 3259)
@@ -26,6 +26,7 @@
gnunet-setup.c
gnunet_setup_LDADD = \
+ $(top_builddir)/src/setup/lib/libgnunetsetup.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
$(top_builddir)/src/util/config_impl/libgnunetutil_config.la
Modified: GNUnet/src/setup/gnunet-setup.c
===================================================================
--- GNUnet/src/setup/gnunet-setup.c 2006-08-19 22:33:59 UTC (rev 3258)
+++ GNUnet/src/setup/gnunet-setup.c 2006-08-19 22:42:46 UTC (rev 3259)
@@ -28,22 +28,26 @@
#include "platform.h"
#include "gnunet_util.h"
#include "gnunet_directories.h"
+#include "gnunet_setup_lib.h"
#include "gnunet_util_config_impl.h"
#include "gnunet_util_error_loggers.h"
-#include "recreate.h"
-#include "zconf_tab.h"
+typedef int (*ConfigurationPluginMain)(int argc,
+ const char ** argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ int is_daemon);
static int config_daemon;
static struct GE_Context * ectx;
-/**
- * FIXME: bad hack to make "cfg" available to zconf!
- * -- need to re-organize zconf bits!
- */
-struct GC_Configuration * cfg;
+static struct GC_Configuration * cfg;
+static struct GNS_Context * gns;
+
/**
* All gnunet-setup command line options
*/
@@ -61,8 +65,9 @@
static int dyn_config(const char * module,
const char * mainfunc,
int argc,
- const char **argv) {
- void (*mptr)(int, const char **, void*);
+ const char **argv,
+ const char * filename) {
+ ConfigurationPluginMain mptr;
struct PluginHandle * library;
library = os_plugin_load(ectx,
@@ -75,7 +80,13 @@
YES);
if (! mptr)
return SYSERR;
- mptr(argc, argv, library);
+ mptr(argc,
+ argv,
+ library,
+ ectx,
+ cfg,
+ filename,
+ config_daemon);
os_plugin_unload(library);
return YES;
}
@@ -90,6 +101,11 @@
#endif
"\n";
+/**
+ * List of supported plugins. One entry consists
+ * of three strings: option name, plugin library
+ * name and main method name.
+ */
static const char * modules[] = {
"gconfig", "setup_gtk", "gconf_main" ,
"menuconfig", "setup_curses", "mconf_main" ,
@@ -99,6 +115,7 @@
NULL,
};
+
int main(int argc,
const char *argv[]) {
const char * operation;
@@ -178,6 +195,9 @@
dirname);
FREE(dirname);
+ if(0 == ACCESS(filename, F_OK))
+ GC_parse_configuration(cfg,
+ filename);
dirname = os_get_installation_path(ectx,
cfg,
GNDATADIR);
@@ -188,17 +208,15 @@
strcat(specname, "/config-daemon.in");
else
strcat(specname, "/config-client.in");
- conf_parse(specname);
+ gns = GNS_load_specification(ectx,
+ cfg,
+ specname);
FREE(specname);
-
- if(0 != ACCESS(filename, F_OK)) {
- recreate_main(ectx,
- cfg,
- filename,
- config_daemon);
- } else {
- GC_parse_configuration(cfg,
- filename);
+ if (gns == NULL) {
+ GC_free(cfg);
+ GE_free_context(ectx);
+ FREE(filename);
+ return -1;
}
done = NO;
@@ -209,13 +227,15 @@
if (dyn_config(modules[i+1],
modules[i+2],
argc,
- argv) != YES) {
+ argv,
+ filename) != YES) {
GE_LOG(ectx,
GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
_("`%s' is not available."),
operation);
GC_free(cfg);
GE_free_context(ectx);
+ FREE(filename);
return -1;
} else {
done = YES;
@@ -223,17 +243,19 @@
}
i += 3;
}
+ FREE(filename);
if (done == NO) {
fprintf(stderr,
_("Unknown operation `%s'\n"),
operation);
fprintf(stderr,
_("Use --help to get a list of options.\n"));
-
+ GNS_free_specification(gns);
GC_free(cfg);
GE_free_context(ectx);
return 1;
}
+ GNS_free_specification(gns);
GC_free(cfg);
GE_free_context(ectx);
return 0;
Modified: GNUnet/src/setup/text/conf.c
===================================================================
--- GNUnet/src/setup/text/conf.c 2006-08-19 22:33:59 UTC (rev 3258)
+++ GNUnet/src/setup/text/conf.c 2006-08-19 22:42:46 UTC (rev 3259)
@@ -32,9 +32,10 @@
#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "confdata.h"
+#include "gnunet_setup_lib.h"
static void conf(struct menu *menu);
+
static void check_conf(struct menu *menu);
enum {
@@ -47,12 +48,17 @@
set_no,
set_random
} input_mode = ask_all;
+
char *defconfig_file;
static int indent = 1;
+
static int valid_stdin = 1;
+
static int conf_cnt;
+
static char line[128];
+
static struct menu *rootEntry;
static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
@@ -505,12 +511,13 @@
int conf_main(int argc,
char **argv,
- void * lib) {
- char * filename;
-
- filename = getConfigurationString("GNUNET-SETUP",
- "FILENAME");
- conf_read(filename);
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename,
+ int is_daemon) {
+ conf_read(ectx,
+ cfg);
input_mode = ask_all; /* for now */
rootEntry = &rootmenu;
conf(&rootmenu);
@@ -523,13 +530,10 @@
printf(_("Unable to save configuration file `%s': %s.\n"),
filename,
STRERROR(errno));
- FREE(filename);
return 1;
- }
- else {
+ } else {
printf(_("Configuration file `%s' created.\n"),
filename);
- FREE(filename);
return 0;
}
}
Modified: GNUnet/src/setup/text/conf.h
===================================================================
--- GNUnet/src/setup/text/conf.h 2006-08-19 22:33:59 UTC (rev 3258)
+++ GNUnet/src/setup/text/conf.h 2006-08-19 22:42:46 UTC (rev 3259)
@@ -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
@@ -28,8 +28,14 @@
#ifndef CONF_H
#define CONF_H
+#include "gnunet_util.h"
+
int conf_main(int argc,
- char **argv,
- void * lib);
+ const char ** argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename,
+ int is_daemon);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3259 - in GNUnet/src/setup: . text,
grothoff <=