gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3531 - in GNUnet: . src/applications/chat src/applications


From: grothoff
Subject: [GNUnet-SVN] r3531 - in GNUnet: . src/applications/chat src/applications/dht/tools src/applications/fs/fsui src/applications/fs/tools src/applications/stats src/applications/tbench src/applications/template src/applications/tracekit src/applications/vpn src/include src/server src/util src/util/boot
Date: Sat, 21 Oct 2006 15:38:20 -0700 (PDT)

Author: grothoff
Date: 2006-10-21 15:38:05 -0700 (Sat, 21 Oct 2006)
New Revision: 3531

Added:
   GNUnet/src/util/boot/
   GNUnet/src/util/boot/Makefile.am
   GNUnet/src/util/boot/startup.c
Modified:
   GNUnet/configure.ac
   GNUnet/src/applications/chat/Makefile.am
   GNUnet/src/applications/dht/tools/Makefile.am
   GNUnet/src/applications/dht/tools/dht-join.c
   GNUnet/src/applications/dht/tools/dht-query.c
   GNUnet/src/applications/fs/fsui/Makefile.am
   GNUnet/src/applications/fs/fsui/fsui-loader.c
   GNUnet/src/applications/fs/tools/Makefile.am
   GNUnet/src/applications/fs/tools/gnunet-directory.c
   GNUnet/src/applications/fs/tools/gnunet-download.c
   GNUnet/src/applications/fs/tools/gnunet-insert.c
   GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
   GNUnet/src/applications/fs/tools/gnunet-search.c
   GNUnet/src/applications/fs/tools/gnunet-unindex.c
   GNUnet/src/applications/stats/Makefile.am
   GNUnet/src/applications/stats/gnunet-stats.c
   GNUnet/src/applications/tbench/Makefile.am
   GNUnet/src/applications/tbench/gnunet-tbench.c
   GNUnet/src/applications/template/Makefile.am
   GNUnet/src/applications/template/gnunet-template.c
   GNUnet/src/applications/tracekit/Makefile.am
   GNUnet/src/applications/tracekit/gnunet-tracekit.c
   GNUnet/src/applications/vpn/Makefile.am
   GNUnet/src/applications/vpn/gnunet-vpn.c
   GNUnet/src/include/Makefile.am
   GNUnet/src/server/Makefile.am
   GNUnet/src/server/gnunet-peer-info.c
   GNUnet/src/server/gnunet-transport-check.c
   GNUnet/src/server/gnunet-update.c
   GNUnet/src/server/gnunetd.c
   GNUnet/src/util/Makefile.am
   GNUnet/todo
Log:
refactoring boot sequence

Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/configure.ac 2006-10-21 22:38:05 UTC (rev 3531)
@@ -519,6 +519,7 @@
 src/server/Makefile
 src/transports/Makefile
 src/util/Makefile
+src/util/boot/Makefile
 src/util/config/Makefile
 src/util/config_impl/Makefile
 src/util/containers/Makefile

Modified: GNUnet/src/applications/chat/Makefile.am
===================================================================
--- GNUnet/src/applications/chat/Makefile.am    2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/applications/chat/Makefile.am    2006-10-21 22:38:05 UTC (rev 
3531)
@@ -3,7 +3,8 @@
 plugindir = $(libdir)/GNUnet
 
 LDADD =  \
-  $(top_builddir)/src/util/libgnunetutil.la 
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 bin_PROGRAMS = \
   gnunet-chat

Modified: GNUnet/src/applications/dht/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/dht/tools/Makefile.am       2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/dht/tools/Makefile.am       2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -19,8 +19,7 @@
 gnunet_dht_join_LDADD = \
   $(top_builddir)/src/applications/dht/module/libgnunetdht_datastore_memory.la 
\
   $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
@@ -29,8 +28,7 @@
   dht-query.c
 gnunet_dht_query_LDADD =  \
   $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
   $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/libgnunetutil.la

Modified: GNUnet/src/applications/dht/tools/dht-join.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-join.c        2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/dht/tools/dht-join.c        2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -30,8 +30,7 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_dht_lib.h"
 #include "gnunet_dht_datastore_memory.h"
 
@@ -150,24 +149,17 @@
   struct GC_Configuration * cfg;
   Blockstore myStore;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-insert [OPTIONS] FILENAME",
-                          ectx,
-                          cfg,
-                          gnunetjoinOptions,
-                          (unsigned int) argc,
-                          argv);
-  if (i == SYSERR) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return 1;
+
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-dht-join",
+                 &cfgFilename,
+                 gnunetjoinOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
+    GNUNET_fini(ectx, cfg);
+    return -1;
   }
   if (table_id == NULL) {
     printf(_("No table name specified, using `%s'.\n"),

Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c       2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/dht/tools/dht-query.c       2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -29,8 +29,7 @@
 #include "gnunet_util.h"
 #include "gnunet_util_crypto.h"
 #include "gnunet_dht_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_network_client.h"
 #include "gnunet_dht_datastore_memory.h"
 
@@ -49,7 +48,7 @@
 /**
  * All gnunet-dht-query command line options
  */
-static struct CommandLineOption gnunetjoinOptions[] = {
+static struct CommandLineOption gnunetqueryOptions[] = {
   COMMAND_LINE_OPTION_CFG_FILE(&cfgFilename), /* -c */
   COMMAND_LINE_OPTION_HELP(gettext_noop("Query (get KEY, put KEY VALUE, remove 
KEY VALUE) a DHT table.")), /* -h */
   COMMAND_LINE_OPTION_HOSTNAME, /* -H */
@@ -179,24 +178,17 @@
   struct ClientServerConnection * handle;
   HashCode512 table;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-insert [OPTIONS] FILENAME",
-                          ectx,
-                          cfg,
-                          gnunetjoinOptions,
-                          (unsigned int) argc,
-                          argv);
-  if (i == SYSERR) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return 1;
+
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-dht-query",
+                 &cfgFilename,
+                 gnunetqueryOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
+    GNUNET_fini(ectx, cfg);
+    return -1;
   }
   if (table_id == NULL) {
     printf(_("No table name specified, using `%s'.\n"),
@@ -268,8 +260,7 @@
     break;
   }
   connection_destroy(handle);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/applications/fs/fsui/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/fsui/Makefile.am 2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/applications/fs/fsui/Makefile.am 2006-10-21 22:38:05 UTC (rev 
3531)
@@ -32,7 +32,6 @@
  $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la  \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 check_PROGRAMS = \

Modified: GNUnet/src/applications/fs/fsui/fsui-loader.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui-loader.c       2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/fsui/fsui-loader.c       2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,7 +27,6 @@
 #include "platform.h"
 #include "gnunet_fsui_lib.h"
 #include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
 
 static void * eventCallback(void * cls,
                            const FSUI_Event * event) {
@@ -57,22 +56,15 @@
         char * argv[]) {
   struct FSUI_Context * ctx;
   struct GC_Configuration * cfg;
-  struct GE_Context * ectx;
 
-  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);
-  os_init(ectx);
+  os_init(NULL);
   cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
   if (argc != 2) {
     fprintf(stderr,
            "Call with name of FSUI resource file!\n");
     return -1;
   }
-  ctx = FSUI_start(ectx,
+  ctx = FSUI_start(NULL,
                   cfg,
                   argv[1],
                   16,
@@ -84,5 +76,6 @@
   else
     fprintf(stderr,
            "FSUI_start failed!\n");
+  GC_free(cfg);
   return (ctx == NULL);
 }

Modified: GNUnet/src/applications/fs/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/tools/Makefile.am        2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/Makefile.am        2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -4,8 +4,7 @@
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 bin_PROGRAMS = \
@@ -29,8 +28,7 @@
 gnunet_directory_LDADD = \
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 
@@ -40,8 +38,7 @@
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
   $(top_builddir)/src/applications/fs/collection/libgnunetcollection.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 gnunet_search_SOURCES = \

Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -29,8 +29,7 @@
 #include "platform.h"
 #include "gnunet_ecrs_lib.h"
 #include "gnunet_uritrack_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 
 static char * cfgFilename;
 
@@ -159,23 +158,15 @@
   int i;
   struct GC_Configuration * cfg;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-directory [OPTIONS] [FILENAMES]",
-                          ectx,
-                          cfg,
-                          gnunetdirectoryOptions,
-                          (unsigned int) argc,
-                          argv);
-  if (i == SYSERR) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-directory [OPTIONS] [FILENAMES]",
+                 &cfgFilename,
+                 gnunetdirectoryOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   if (do_list)
@@ -195,8 +186,7 @@
   while (i < argc)
     printDirectory(argv[i]);
 
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c  2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c  2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,8 +27,7 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_fsui_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 
 static struct GE_Context * ectx;
 
@@ -143,24 +142,14 @@
   struct ECRS_URI * uri;
   int i;
 
-  /* startup */
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-download [OPTIONS] [KEYWORDS]",
-                          ectx,
-                          cfg,
-                          gnunetdownloadOptions,
-                          (unsigned int) argc,
-                          argv);
-  if ( (i == SYSERR) ||
-       (0 != GC_parse_configuration(cfg,
-                                   cfgFilename)) ) {   
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-download [OPTIONS] [KEYWORDS]",
+                 &cfgFilename,
+                 gnunetdownloadOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
     errorCode = -1;
     goto quit;
   }
@@ -248,8 +237,7 @@
   FREE(filename);
   ECRS_freeUri(uri);
  quit:
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return errorCode;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -30,8 +30,7 @@
 #include "platform.h"
 #include "gnunet_fsui_lib.h"
 #include "gnunet_namespace_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_crypto.h"
 
 /* hmm. Man says time.h, but that doesn't yield the
@@ -299,29 +298,17 @@
   char * tmp;
   unsigned long long verbose;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-insert [OPTIONS] FILENAME",
-                          ectx,
-                          cfg,
-                          gnunetinsertOptions,
-                          (unsigned int) argc,
-                          argv);
-  if (i == SYSERR) {
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-insert [OPTIONS] FILENAME",
+                 &cfgFilename,
+                 gnunetinsertOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
     errorCode = -1;
     goto quit;
   }
-  if (OK != GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    errorCode = -1;
-    goto quit;
-  }
   if (i != argc - 1) {
     printf(_("You must specify one and only one filename for insertion.\n"));
     errorCode = -1;
@@ -473,8 +460,7 @@
   FSUI_stop(ctx);
 
 quit:
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return errorCode;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,8 +27,7 @@
 #include "platform.h"
 #include "gnunet_collection_lib.h"
 #include "gnunet_namespace_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_crypto.h"
 
 static struct GE_Context * ectx;
@@ -191,26 +190,16 @@
   int i;
   HashCode512 hc;
 
-  /* startup */
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  meta = ECRS_createMetaData();
-  i = gnunet_parse_options("gnunet-pseudonym [OPTIONS]",
-                          ectx,
-                          cfg,
-                          gnunetpseudonymOptions,
-                          (unsigned int) argc,
-                          argv);
-  if (i == SYSERR) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-pseudonym [OPTIONS]",
+                 &cfgFilename,
+                 gnunetpseudonymOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
     ECRS_freeMetaData(meta);
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   success = 0; /* no errors */
@@ -314,8 +303,6 @@
     FREE(pname);
     pname = NULL;
   }
-  ECRS_freeMetaData(meta);
-
   if (0 == be_quiet) {
   /* print information about pseudonyms */
     cnt = NS_listNamespaces(ectx,
@@ -327,8 +314,7 @@
       printf(_("Could not access namespace information.\n"));
   }
   ECRS_freeMetaData(meta);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return success;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-search.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-search.c    2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/gnunet-search.c    2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,9 +27,9 @@
 #include "platform.h"
 #include "gnunet_fsui_lib.h"
 #include "gnunet_util_cron.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 
+
 static struct GE_Context * ectx;
 
 static struct GC_Configuration * cfg;
@@ -163,30 +163,18 @@
   struct FSUI_Context * ctx;
   struct FSUI_SearchList * s;
 
-  /* startup */
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-search [OPTIONS] [KEYWORDS]",
-                          ectx,
-                          cfg,
-                          gnunetsearchOptions,
-                          (unsigned int) argc,
-                          argv);
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-search [OPTIONS] [KEYWORDS]",
+                 &cfgFilename,
+                 gnunetsearchOptions,
+                 &ectx,
+                 &cfg);
   if (i == SYSERR) {
-    errorCode = -1;
-    goto quit;
+    GNUNET_fini(ectx,
+               cfg);
+    return -1;
   }
-  if (OK != GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    errorCode = -1;
-    goto quit;
-  }
   /* convert args to URI */
  uri = ECRS_parseArgvKeywordURI(ectx,
                                 argc - i,
@@ -207,6 +195,7 @@
                   NULL);
   if (ctx == NULL) {
     ECRS_freeUri(uri);
+    GNUNET_fini(ectx, cfg);
     return SYSERR;
   }
   errorCode = 1;
@@ -263,8 +252,7 @@
        fiCount,
        0);
  quit:
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return errorCode;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-unindex.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-unindex.c   2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/fs/tools/gnunet-unindex.c   2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -30,8 +30,7 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_fsui_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 
 static struct GE_Context * ectx;
 
@@ -118,24 +117,15 @@
   unsigned long long verbose;
   struct FSUI_UnindexList * ul;
 
-  /* startup */
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  i = gnunet_parse_options("gnunet-unindex [OPTIONS] FILENAME",
-                          ectx,
-                          cfg,
-                          gnunetunindexOptions,
-                          (unsigned int) argc,
-                          argv);
-  if (i == SYSERR) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-unindex [OPTIONS] FILENAME",
+                 &cfgFilename,
+                 gnunetunindexOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   if (i == argc) {
@@ -143,16 +133,9 @@
           GE_WARNING | GE_BULK | GE_USER,
           _("Not enough arguments. "
             "You must specify a filename.\n"));
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
-  if (OK != GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
   GC_get_configuration_value_number(cfg,
                                    "GNUNET",
                                    "VERBOSE",
@@ -187,8 +170,7 @@
   }
   FREE(filename);
   FSUI_stop(ctx);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return errorCode;
 }
 

Modified: GNUnet/src/applications/stats/Makefile.am
===================================================================
--- GNUnet/src/applications/stats/Makefile.am   2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/applications/stats/Makefile.am   2006-10-21 22:38:05 UTC (rev 
3531)
@@ -20,8 +20,7 @@
 gnunet_stats_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 libgnunetstats_api_la_SOURCES = \
   clientapi.c 

Modified: GNUnet/src/applications/stats/gnunet-stats.c
===================================================================
--- GNUnet/src/applications/stats/gnunet-stats.c        2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/stats/gnunet-stats.c        2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,8 +27,7 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_stats_lib.h"
 #include "statistics.h"
 
@@ -112,22 +111,15 @@
   struct GC_Configuration * cfg;
   struct GE_Context * ectx;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunet-stats",
-                                ectx,
-                                cfg,
-                                gnunetstatsOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  res = GNUNET_init(argc,
+                   argv,
+                   "gnunet-stats",
+                   &cfgFilename,
+                   gnunetstatsOptions,
+                   &ectx,
+                   &cfg);
+  if (res == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   sock = client_connection_create(ectx,
@@ -155,8 +147,7 @@
     fprintf(stderr,
            _("Error reading information from gnunetd.\n"));
   connection_destroy(sock);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
 
   return (res == OK) ? 0 : 1;
 }

Modified: GNUnet/src/applications/tbench/Makefile.am
===================================================================
--- GNUnet/src/applications/tbench/Makefile.am  2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/applications/tbench/Makefile.am  2006-10-21 22:38:05 UTC (rev 
3531)
@@ -6,8 +6,7 @@
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 bin_PROGRAMS = \
   gnunet-tbench

Modified: GNUnet/src/applications/tbench/gnunet-tbench.c
===================================================================
--- GNUnet/src/applications/tbench/gnunet-tbench.c      2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/tbench/gnunet-tbench.c      2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,8 +27,7 @@
 #include "platform.h"
 #include "gnunet_protocols.h"
 #include "gnunet_util_network_client.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_crypto.h"
 #include "tbench.h"
 
@@ -107,26 +106,19 @@
   CS_tbench_request_MESSAGE msg;
   CS_tbench_reply_MESSAGE * buffer;
   float messagesPercentLoss;
-
   struct GE_Context * ectx;
   struct GC_Configuration * cfg;
-
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunet-tbench",
-                                ectx,
-                                cfg,
-                                gnunettbenchOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  int res;
+  
+  res = GNUNET_init(argc,
+                   argv,
+                   "gnunet-tbench",
+                   &cfgFilename,
+                   gnunettbenchOptions,
+                   &ectx,
+                   &cfg);
+  if (res == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   sock = client_connection_create(ectx,
@@ -134,8 +126,7 @@
   if (sock == NULL) {
     fprintf(stderr,
            _("Error establishing connection with gnunetd.\n"));
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
 
@@ -152,8 +143,7 @@
     fprintf(stderr,
            _("You must specify a receiver!\n"));
     connection_destroy(sock);
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
   if (OK != enc2hash(messageReceiver,
@@ -163,8 +153,7 @@
            messageReceiver);
     FREE(messageReceiver);
     connection_destroy(sock);
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
   FREE(messageReceiver);
@@ -172,8 +161,7 @@
   if (SYSERR == connection_write(sock,
                                 &msg.header)) {
     connection_destroy(sock);
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
 
@@ -224,8 +212,7 @@
     printf(_("\nDid not receive the message from gnunetd. Is gnunetd 
running?\n"));
 
   connection_destroy(sock);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/applications/template/Makefile.am
===================================================================
--- GNUnet/src/applications/template/Makefile.am        2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/template/Makefile.am        2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -4,9 +4,8 @@
 
 LDADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
+ $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 bin_PROGRAMS = \
   gnunet-template

Modified: GNUnet/src/applications/template/gnunet-template.c
===================================================================
--- GNUnet/src/applications/template/gnunet-template.c  2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/template/gnunet-template.c  2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004 Christian Grothoff (and other contributing authors)
+     (C) 2001, 2002, 2004, 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
@@ -26,8 +26,7 @@
 
 #include "gnunet_util.h"
 #include "gnunet_util_network_client.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "platform.h"
 
 #define TEMPLATE_VERSION "0.0.0"
@@ -71,26 +70,20 @@
         const char ** argv) {
   struct ClientServerConnection * sock;
   struct PTHREAD * messageReceiveThread;
-  void * unused;
+  void * unused;  
   struct GE_Context * ectx;
   struct GC_Configuration * cfg;
+  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunet-template",
-                                ectx,
-                                cfg,
-                                gnunettemplateOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-template",
+                 &cfgFilename,
+                 gnunettemplateOptions,
+                 &ectx,
+                 &cfg);
+  if (-1 == i) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
 
@@ -99,8 +92,7 @@
   if (sock == NULL) {
     fprintf(stderr,
            _("Error establishing connection with gnunetd.\n"));
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
   messageReceiveThread = PTHREAD_CREATE(&receiveThread,
@@ -119,8 +111,7 @@
   SEMAPHORE_DESTROY(doneSem);
   PTHREAD_JOIN(messageReceiveThread, &unused);
   connection_destroy(sock);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/applications/tracekit/Makefile.am
===================================================================
--- GNUnet/src/applications/tracekit/Makefile.am        2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/tracekit/Makefile.am        2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -5,10 +5,9 @@
 LDADD =  \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
+  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+  $(top_builddir)/src/util/cron/libgnunetutil_cron.la 
 
 bin_PROGRAMS = \
   gnunet-tracekit

Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/gnunet-tracekit.c  2006-10-21 19:58:30 UTC 
(rev 3530)
+++ GNUnet/src/applications/tracekit/gnunet-tracekit.c  2006-10-21 22:38:05 UTC 
(rev 3531)
@@ -27,9 +27,8 @@
 #include "platform.h"
 #include "gnunet_protocols.h"
 #include "gnunet_util_network_client.h"
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_crypto.h"
-#include "gnunet_util_error_loggers.h"
 #include "tracekit.h"
 
 static struct SEMAPHORE * doneSem;
@@ -294,31 +293,24 @@
   int sleepTime;
   struct GE_Context * ectx;
   struct CronManager * cron;
-
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunet-tracekit",
-                                ectx,
-                                cfg,
-                                gnunettracekitOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  int res;
+ 
+  res = GNUNET_init(argc,
+                   argv,
+                   "gnunet-tracekit",
+                   &cfgFilename,
+                   gnunettracekitOptions,
+                   &ectx,
+                   &cfg);
+  if (res == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   sock = client_connection_create(ectx, cfg);
   if (sock == NULL) {
     fprintf(stderr,
            _("Error establishing connection with gnunetd.\n"));
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
 
@@ -370,8 +362,7 @@
   connection_destroy(sock);
   cron_stop(cron);
   cron_destroy(cron);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/applications/vpn/Makefile.am
===================================================================
--- GNUnet/src/applications/vpn/Makefile.am     2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/applications/vpn/Makefile.am     2006-10-21 22:38:05 UTC (rev 
3531)
@@ -14,9 +14,8 @@
 gnunet_vpn_SOURCES = \
   gnunet-vpn.c         
 gnunet_vpn_LDADD = \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 libgnunetmodule_vpn_la_SOURCES = \

Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c    2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c    2006-10-21 22:38:05 UTC (rev 
3531)
@@ -26,8 +26,7 @@
 
 #include "gnunet_util.h"
 #include "gnunet_util_network_client.h"
-#include "gnunet_util_error_loggers.h"
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_protocols.h"
 #include "platform.h"
 
@@ -126,23 +125,17 @@
   int rancommand = 0;
   struct GC_Configuration * cfg;
   struct GE_Context * ectx;
+  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunet-vpn",
-                                ectx,
-                                cfg,
-                                gnunetvpnOptions,
-                                argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  i = GNUNET_init(argc,
+                 argv,
+                 "gnunet-vpn",
+                 &cfgFilename,
+                 gnunetvpnOptions,
+                 &ectx,
+                 &cfg);
+  if (i == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
   sock = client_connection_create(ectx,
@@ -150,8 +143,7 @@
   if (sock == NULL) {
     fprintf(stderr,
            _("Error establishing connection with gnunetd.\n"));
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
 
@@ -259,6 +251,7 @@
   MUTEX_DESTROY(lock);
   PTHREAD_JOIN(messageReceiveThread, &unused);
   connection_destroy(sock);
+  GNUNET_fini(ectx, cfg);
 
   return 0;
 }

Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am      2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/include/Makefile.am      2006-10-21 22:38:05 UTC (rev 3531)
@@ -45,6 +45,7 @@
   gnunet_transport_service.h \
   gnunet_uritrack_lib.h \
   gnunet_util.h \
+  gnunet_util_boot.h \
   gnunet_util_common.h \
   gnunet_util_config.h \
   gnunet_util_config_impl.h \

Modified: GNUnet/src/server/Makefile.am
===================================================================
--- GNUnet/src/server/Makefile.am       2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/server/Makefile.am       2006-10-21 22:38:05 UTC (rev 3531)
@@ -27,28 +27,24 @@
  gnunetd.c 
 gnunetd_LDADD = \
  $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 
 gnunet_update_SOURCES = \
  gnunet-update.c 
 gnunet_update_LDADD = \
  $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 gnunet_peer_info_SOURCES = \
  gnunet-peer-info.c 
 gnunet_peer_info_LDADD  = \
  $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 
 gnunet_transport_check_SOURCES = \
  gnunet-transport-check.c 
 gnunet_transport_check_LDADD  = \
  $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
 

Modified: GNUnet/src/server/gnunet-peer-info.c
===================================================================
--- GNUnet/src/server/gnunet-peer-info.c        2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/server/gnunet-peer-info.c        2006-10-21 22:38:05 UTC (rev 
3531)
@@ -31,8 +31,7 @@
 #include "gnunet_transport_service.h"
 #include "gnunet_identity_service.h"
 #include "gnunet_core.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_cron.h"
 #include "core.h"
 
@@ -107,31 +106,19 @@
         const char *argv[]) {
   struct GC_Configuration * cfg;
   struct CronManager * cron;
+  int ret;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunet-peer-info",
-                                ectx,
-                                cfg,
-                                gnunetpeerinfoOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  ret = GNUNET_init(argc,
+                   argv,
+                   "gnunet-peer-info",
+                   &cfgFilename,
+                   gnunetpeerinfoOptions,
+                   &ectx,
+                   &cfg);
+  if (ret == -1) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
-  if (-1 == GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
   GE_ASSERT(ectx,
            0 == GC_set_configuration_value_string(cfg,
                                                   ectx,
@@ -149,8 +136,7 @@
   releaseService(transport);
   doneCore();
   cron_destroy(cron);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c  2006-10-21 19:58:30 UTC (rev 
3530)
+++ GNUnet/src/server/gnunet-transport-check.c  2006-10-21 22:38:05 UTC (rev 
3531)
@@ -29,8 +29,7 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
 #include "gnunet_transport_service.h"
@@ -385,35 +384,18 @@
   int stats[3];
   int pos;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunetd",
-                                ectx,
-                                cfg,
-                                gnunettransportcheckOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  res = GNUNET_init(argc,
+                   argv,
+                   "gnunet-transport-check",
+                   &cfgFilename,
+                   gnunettransportcheckOptions,
+                   &ectx,
+                   &cfg);
+  if ( (res == -1) ||
+       (OK != changeUser(ectx, cfg)) ) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
-  if (-1 == GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
-  if (OK != changeUser(ectx, cfg)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
 
   if (-1 == GC_get_configuration_value_number(cfg,
                                              "TRANSPORT-CHECK",
@@ -422,6 +404,7 @@
                                              60000,
                                              12,
                                              &expectedSize)) {
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
   if (-1 == GC_get_configuration_value_number(cfg,
@@ -431,6 +414,7 @@
                                              60000,
                                              60 * cronSECONDS,
                                              &timeout)) {
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
 
@@ -445,8 +429,10 @@
                                              "GNUNETD",
                                              "TRANSPORTS",
                                              "udp tcp http",
-                                             &trans))
+                                             &trans)) {
+    GNUNET_fini(ectx, cfg);
     return 1;
+  }
   GE_ASSERT(ectx, trans != NULL);
   ping = GC_get_configuration_value_yesno(cfg,
                                          "TRANSPORT-CHECK",
@@ -537,13 +523,11 @@
   doneCore();
   FREE(expectedValue);
   cron_destroy(cron);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
 
-  if (res == OK)
-    return 0;
-  else
+  if (res != OK)
     return -1;
+  return 0;
 }
 
 

Modified: GNUnet/src/server/gnunet-update.c
===================================================================
--- GNUnet/src/server/gnunet-update.c   2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/server/gnunet-update.c   2006-10-21 22:38:05 UTC (rev 3531)
@@ -26,8 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_cron.h"
 #include "gnunet_directories.h"
 #include "gnunet_core.h"
@@ -235,37 +234,20 @@
 int main(int argc,
         const char * argv[]) {
   char * get;
+  int ret;
 
-  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);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-
-  if (-1 == gnunet_parse_options("gnunet-update",
-                                ectx,
-                                cfg,
-                                gnunetupdateOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  ret = GNUNET_init(argc,
+                   argv,
+                   "gnunet-update",
+                   &cfgFilename,
+                   gnunetupdateOptions,
+                   &ectx,
+                   &cfg);
+  if ( (ret == -1) ||
+       (OK != changeUser(ectx, cfg)) ) {
+    GNUNET_fini(ectx, cfg);
     return -1;
   }
-  if (-1 == GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
-  if (OK != changeUser(ectx, cfg)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
   if (0 == GC_get_configuration_value_string(cfg,
                                             "GNUNET-UPDATE",
                                             "GET",
@@ -276,9 +258,7 @@
   } else {
     work();
   }
-  GC_free(cfg);
-  GE_free_context(ectx);
-
+  GNUNET_fini(ectx, cfg);
   return 0;
 }
 

Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/server/gnunetd.c 2006-10-21 22:38:05 UTC (rev 3531)
@@ -28,8 +28,7 @@
  */
 
 #include "gnunet_util.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_boot.h"
 #include "gnunet_util_cron.h"
 #include "gnunet_core.h"
 #include "gnunet_directories.h"
@@ -199,34 +198,16 @@
            "Sorry, your C compiler did not properly align the C structs. 
Aborting.\n");
     return -1;
   }
-  ectx = GE_create_context_stderr(YES,
-                                 GE_DEBUG |
-                                 GE_WARNING | GE_ERROR | GE_FATAL |
-                                 GE_USER | GE_ADMIN | GE_DEVELOPER |
-                                 GE_IMMEDIATE | GE_BULK);
-  GE_setDefaultContext(ectx);
-  os_init(ectx);
-  cfg = GC_create_C_impl();
-  GE_ASSERT(ectx, cfg != NULL);
-  if (-1 == gnunet_parse_options("gnunetd",
-                                ectx,
-                                cfg,
-                                gnunetdOptions,
-                                (unsigned int) argc,
-                                argv)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
-  if (-1 == GC_parse_configuration(cfg,
-                                  cfgFilename)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
-    return -1;
-  }
-  if (OK != changeUser(ectx, cfg)) {
-    GC_free(cfg);
-    GE_free_context(ectx);
+  ret = GNUNET_init(argc,
+                   argv,
+                   "gnunetd",
+                   &cfgFilename,
+                   gnunetdOptions,
+                   &ectx,
+                   &cfg);
+  if ( (ret == -1) ||
+       (OK != changeUser(ectx, cfg)) ) {
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
   if (OK != checkUpToDate(ectx,
@@ -235,13 +216,11 @@
           GE_USER | GE_FATAL | GE_IMMEDIATE,
           _("Configuration or GNUnet version changed.  You need to run 
`%s'!\n"),
           "gnunet-update");
-    GC_free(cfg);
-    GE_free_context(ectx);
+    GNUNET_fini(ectx, cfg);
     return 1;
   }
   ret = gnunet_main(ectx);
-  GC_free(cfg);
-  GE_free_context(ectx);
+  GNUNET_fini(ectx, cfg);
   if (ret != OK)
     return 1;
   return 0;

Modified: GNUnet/src/util/Makefile.am
===================================================================
--- GNUnet/src/util/Makefile.am 2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/util/Makefile.am 2006-10-21 22:38:05 UTC (rev 3531)
@@ -3,7 +3,8 @@
   getopt disk threads \
   os network . \
   config_impl cron crypto \
-  containers loggers network_client
+  containers loggers network_client \
+  boot
 
 INCLUDES = -I$(top_srcdir)/src/include
 

Added: GNUnet/src/util/boot/Makefile.am
===================================================================
--- GNUnet/src/util/boot/Makefile.am    2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/util/boot/Makefile.am    2006-10-21 22:38:05 UTC (rev 3531)
@@ -0,0 +1,15 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+SUBDIRS = .
+
+lib_LTLIBRARIES = \
+  libgnunetutil_boot.la
+
+libgnunetutil_boot_la_SOURCES = \
+  startup.c
+
+libgnunetutil_boot_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/loggers/libgnunetutil_logging.la 
+

Added: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c      2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/src/util/boot/startup.c      2006-10-21 22:38:05 UTC (rev 3531)
@@ -0,0 +1,80 @@
+/*
+     This file is part of GNUnet.
+     (C) 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
+     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 util/boot/startup.c
+ * @brief standard code for GNUnet startup and shutdown
+ * @author Christian Grothoff
+ */
+
+#include "gnunet_util_boot.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_error_loggers.h"
+#include "platform.h"
+
+/**
+ * Run a standard GNUnet startup sequence
+ * (initialize loggers and configuration,
+ * parse options).
+ *
+ * @return -1 on error, position of next
+ *  command-line argument to be processed in argv
+ *  otherwise
+ */
+int GNUNET_init(int argc,
+               const char ** argv,
+               const char * binaryName,
+               char ** cfgFileName,
+               const struct CommandLineOption * options,
+               struct GE_Context ** ectx,
+               struct GC_Configuration ** cfg) {
+  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);
+  os_init(*ectx);
+  *cfg = GC_create_C_impl();
+  GE_ASSERT(*ectx, *cfg != NULL);
+  i = gnunet_parse_options(binaryName,
+                          *ectx,
+                          *cfg,
+                          options,
+                          (unsigned int) argc,
+                          argv);
+  if (i == -1)
+    return -1;
+  if (OK != GC_parse_configuration(*cfg,
+                                  *cfgFileName)) 
+    return -1;
+  return i;
+}
+
+/**
+ * Free resources allocated during GNUnet_init.
+ */
+void GNUNET_fini(struct GE_Context * ectx,
+                struct GC_Configuration * cfg) {
+  GC_free(cfg);
+  GE_free_context(ectx);
+}
+               


Property changes on: GNUnet/src/util/boot/startup.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-10-21 19:58:30 UTC (rev 3530)
+++ GNUnet/todo 2006-10-21 22:38:05 UTC (rev 3531)
@@ -19,8 +19,10 @@
     + make sure all tools load configuration file
   * error handling: [RC]
     + tcpio
+    + fs/module
     + fs/fslib
-    + fs/module
+    + fs/ecrs
+    + fs/fsui
   * gnunet-setup: [RC]
     + Scheme (scm) specification of entire configuration
       @ check for dead options!





reply via email to

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