gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3212 - in GNUnet: . m4 src/applications/stats src/applicat


From: grothoff
Subject: [GNUnet-SVN] r3212 - in GNUnet: . m4 src/applications/stats src/applications/template src/include
Date: Sun, 6 Aug 2006 20:51:56 -0700 (PDT)

Author: grothoff
Date: 2006-08-06 20:51:48 -0700 (Sun, 06 Aug 2006)
New Revision: 3212

Modified:
   GNUnet/m4/Makefile.in
   GNUnet/src/applications/stats/gnunet-stats.c
   GNUnet/src/applications/template/Makefile.am
   GNUnet/src/applications/template/gnunet-template.c
   GNUnet/src/applications/template/template.c
   GNUnet/src/include/gnunet_util_os.h
   GNUnet/todo
Log:
fixing template


Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in       2006-08-07 02:59:36 UTC (rev 3211)
+++ GNUnet/m4/Makefile.in       2006-08-07 03:51:48 UTC (rev 3212)
@@ -93,7 +93,6 @@
 GMSGFMT = @GMSGFMT@
 GNUNETGTK_CFLAGS = @GNUNETGTK_CFLAGS@
 GNUNETGTK_LIBS = @GNUNETGTK_LIBS@
-GREP = @GREP@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 GUILE = @GUILE@
@@ -170,9 +169,15 @@
 XFREEBSD_FALSE = @XFREEBSD_FALSE@
 XFREEBSD_TRUE = @XFREEBSD_TRUE@
 XGETTEXT = @XGETTEXT@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_AS = @ac_ct_AS@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
 ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -187,9 +192,6 @@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 guile_available = @guile_available@
 host = @host@
@@ -197,21 +199,17 @@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
-htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
-localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
-psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 subdirs = @subdirs@

Modified: GNUnet/src/applications/stats/gnunet-stats.c
===================================================================
--- GNUnet/src/applications/stats/gnunet-stats.c        2006-08-07 02:59:36 UTC 
(rev 3211)
+++ GNUnet/src/applications/stats/gnunet-stats.c        2006-08-07 03:51:48 UTC 
(rev 3212)
@@ -117,6 +117,7 @@
   GE_setDefaultContext(ectx);
   cfg = GC_create_C_impl();
   GE_ASSERT(ectx, cfg != NULL);
+  os_init();
   if (-1 == gnunet_parse_options("gnunet-stats",
                                 ectx,
                                 cfg,

Modified: GNUnet/src/applications/template/Makefile.am
===================================================================
--- GNUnet/src/applications/template/Makefile.am        2006-08-07 02:59:36 UTC 
(rev 3211)
+++ GNUnet/src/applications/template/Makefile.am        2006-08-07 03:51:48 UTC 
(rev 3212)
@@ -3,7 +3,10 @@
 plugindir = $(libdir)/GNUnet
 
 LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la 
+ $(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
 
 bin_PROGRAMS = \
   gnunet-template
@@ -19,5 +22,6 @@
   template.c 
 libgnunetmodule_template_la_LDFLAGS = \
   -export-dynamic -avoid-version -module \
-  $(LDADD)
+  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la 
 
+

Modified: GNUnet/src/applications/template/gnunet-template.c
===================================================================
--- GNUnet/src/applications/template/gnunet-template.c  2006-08-07 02:59:36 UTC 
(rev 3211)
+++ GNUnet/src/applications/template/gnunet-template.c  2006-08-07 03:51:48 UTC 
(rev 3212)
@@ -25,78 +25,35 @@
  */
 
 #include "gnunet_util.h"
+#include "gnunet_util_network_client.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_error_loggers.h"
 #include "platform.h"
 
 #define TEMPLATE_VERSION "0.0.0"
 
-static Semaphore * doneSem;
+static struct SEMAPHORE * doneSem;
 
+
 /**
- * Parse the options, set the timeout.
- * @param argc the number of options
- * @param argv the option list (including keywords)
- * @return OK on error, SYSERR if we should exit
+ * All gnunetd command line options
  */
-static int parseOptions(int argc,
-                       char ** argv) {
-  int option_index;
-  int c;
+static struct CommandLineOption gnunettemplateOptions[] = {
+  COMMAND_LINE_OPTION_CFG_FILE, /* -c */
+  COMMAND_LINE_OPTION_HELP(gettext_noop("Template description.")), /* -h */
+  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
+  COMMAND_LINE_OPTION_LOGGING, /* -L */
+  COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */
+  COMMAND_LINE_OPTION_END,
+};
 
-  FREENONNULL(setConfigurationString("GNUNETD",
-                                    "LOGFILE",
-                                    NULL));
-  while (1) {
-    static struct GNoption long_options[] = {
-      LONG_DEFAULT_OPTIONS,
-      { 0,0,0,0 }
-    };
-    option_index=0;
-    c = GNgetopt_long(argc,
-                     argv,
-                     "vhdc:L:H:t",
-                     long_options,
-                     &option_index);
-    if (c == -1)
-      break;  /* No more flags to process */
-    if (YES == parseDefaultOptions(c, GNoptarg))
-      continue;
-    switch(c) {
-    case 'h': {
-      static Help help[] = {
-       HELP_CONFIG,
-       HELP_HELP,
-       HELP_LOGLEVEL,
-       { 't', "longoptionname", "ARGUMENT",
-         gettext_noop("helptext for -t") },
-       HELP_VERSION,
-       HELP_END,
-      };
-      formatHelp("gnunet-template [OPTIONS]",
-                _("Template for gnunet-clients."),
-                help);
-
-      return SYSERR;
-    }
-    case 'v':
-      printf("GNUnet v%s, gnunet-template v%s\n",
-            VERSION,
-            TEMPLATE_VERSION);
-      return SYSERR;
-    default:
-      GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
-         _("Use --help to get a list of options.\n"));
-      return -1;
-    } /* end of parsing commandline */
-  } /* while (1) */
-  return OK;
-}
-
-static void * receiveThread(GNUNET_TCP_SOCKET * sock) {
+static void * receiveThread(void * cls) {
+  struct ClientServerConnection * sock = cls;
   void * buffer;
 
   buffer = MALLOC(MAX_BUFFER_SIZE);
-  while (OK == readFromSocket(sock,
-                             (CS_MESSAGE_HEADER**)&buffer)) {
+  while (OK == connection_read(sock,
+                              (MESSAGE_HEADER**)&buffer)) {
     /* process */
   }
   FREE(buffer);
@@ -109,35 +66,60 @@
  * @param argv command line arguments
  * @return return value from gnunet-template: 0: ok, -1: error
  */
-int main(int argc, char ** argv) {
-  GNUNET_TCP_SOCKET * sock;
-  PTHREAD_T messageReceiveThread;
+int main(int argc, 
+        const char ** argv) {
+  struct ClientServerConnection * sock;
+  struct PTHREAD * messageReceiveThread;
   void * unused;
+  struct GE_Context * ectx;
+  struct GC_Configuration * cfg;
 
-  if (SYSERR == initUtil(argc, argv, &parseOptions))
-    return 0; /* parse error, --help, etc. */
-  sock = getClientSocket();
+  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);
+  os_init(ectx);
+  if (-1 == gnunet_parse_options("gnunet-template",
+                                ectx,
+                                cfg,
+                                gnunettemplateOptions,
+                                (unsigned int) argc,
+                                argv)) {
+    GC_free(cfg);
+    GE_free_context(ectx);
+    return -1;  
+  }
 
-  if (0 != PTHREAD_CREATE(&messageReceiveThread,
-                         (PThreadMain) &receiveThread,
-                         sock,
-                         128 * 1024))
-    DIE_STRERROR("pthread_create");
+  sock = client_connection_create(ectx,
+                                 cfg);
+  if (sock == NULL) {
+    fprintf(stderr,
+           _("Error establishing connection with gnunetd.\n"));
+    GC_free(cfg);
+    GE_free_context(ectx);
+    return 1;
+  }
+  messageReceiveThread = PTHREAD_CREATE(&receiveThread,
+                                       sock,
+                                       128 * 1024);
+  if (messageReceiveThread == NULL) {
+    GE_DIE_STRERROR(ectx,
+                   GE_IMMEDIATE | GE_FATAL | GE_USER | GE_ADMIN, 
+                   "pthread_create");
+  }
 
-  /*
-  if (SYSERR == writeToSocket(sock,
-                              &msg.header))
-    return -1;
-  */
   /* wait for shutdown... */
 
-  closeSocketTemporarily(sock);
-  SEMAPHORE_DOWN(doneSem);
+  connection_close_temporarily(sock);
+  SEMAPHORE_DOWN(doneSem, YES);
   SEMAPHORE_DESTROY(doneSem);
-  PTHREAD_JOIN(&messageReceiveThread, &unused);
-  releaseClientSocket(sock);
-
-  doneUtil();
+  PTHREAD_JOIN(messageReceiveThread, &unused);
+  connection_destroy(sock);
+  GC_free(cfg);
+  GE_free_context(ectx);
   return 0;
 }
 

Modified: GNUnet/src/applications/template/template.c
===================================================================
--- GNUnet/src/applications/template/template.c 2006-08-07 02:59:36 UTC (rev 
3211)
+++ GNUnet/src/applications/template/template.c 2006-08-07 03:51:48 UTC (rev 
3212)
@@ -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
@@ -30,38 +30,39 @@
 #include "gnunet_protocols.h"
 
 static CoreAPIForApplication * coreAPI = NULL;
-static ClientHandle client;
-static Mutex lock;
+static struct ClientHandle * client;
+static struct MUTEX * lock;
 
 static int handlep2pMSG(const PeerIdentity * sender,
-                       const P2P_MESSAGE_HEADER * message) {
+                       const MESSAGE_HEADER * message) {
   return OK;
 }
 
-static int csHandle(ClientHandle client,
-                   const CS_MESSAGE_HEADER * message) {
+static int csHandle(struct ClientHandle * client,
+                   const MESSAGE_HEADER * message) {
   return OK;
 }
 
-static void clientExitHandler(ClientHandle c) {
-  MUTEX_LOCK(&lock);
+static void clientExitHandler(struct ClientHandle * c) {
+  MUTEX_LOCK(lock);
   if (c == client)
     client = NULL;
-  MUTEX_UNLOCK(&lock);
+  MUTEX_UNLOCK(lock);
 }
 
 int initialize_module_template(CoreAPIForApplication * capi) {
   int ok = OK;
 
-  MUTEX_CREATE(&lock);
+  lock = MUTEX_CREATE(NO);
   client = NULL;
   coreAPI = capi;
 
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      _("`%s' registering client handler %d and %d\n"),
-      "template",
-      CS_PROTO_MAX_USED,
-      P2P_PROTO_MAX_USED);
+  GE_LOG(capi->ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        _("`%s' registering client handler %d and %d\n"),
+        "template",
+        CS_PROTO_MAX_USED,
+        P2P_PROTO_MAX_USED);
   if (SYSERR == capi->registerHandler(P2P_PROTO_MAX_USED,
                                      &handlep2pMSG))
     ok = SYSERR;
@@ -79,7 +80,7 @@
   coreAPI->unregisterClientExitHandler(&clientExitHandler);
   coreAPI->unregisterClientHandler(CS_PROTO_MAX_USED,
                                   &csHandle);
-  MUTEX_DESTROY(&lock);
+  MUTEX_DESTROY(lock);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/include/gnunet_util_os.h
===================================================================
--- GNUnet/src/include/gnunet_util_os.h 2006-08-07 02:59:36 UTC (rev 3211)
+++ GNUnet/src/include/gnunet_util_os.h 2006-08-07 03:51:48 UTC (rev 3212)
@@ -317,7 +317,7 @@
 /**
  * @brief Perform OS specific cleanup
  */
-void os_done();
+void os_done(void);
 
 #if 0 /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-07 02:59:36 UTC (rev 3211)
+++ GNUnet/todo 2006-08-07 03:51:48 UTC (rev 3212)
@@ -23,15 +23,14 @@
        o libwww & libesmtp?
   * server:
     + needs testing, also likely to be missing features
-      - gnunet-update needs to initialize ectx + cfg in UpdateAPI struct
   * applications:
     + fragmentation, identity,  pingpong, session, transport,
       stats, topology_default, state, getoption, advertising,
-      traffic compile
+      traffic, ecrs_core, template compile
     + bootstrap_http: maybe switch to libwww?
-    + for fs: datastore (787), fs (18500), gap (2800), sqstore_sqlite (1375)
+    + for fs: fs (18500), gap (2800)
     + rest: sqstore_mysql, dht, chat, kvstore_sqlite, 
-            sqstore_mysql, rpc, tbench, template, testbed, 
+            sqstore_mysql, rpc, tbench, testbed, 
             topology_f2f, vpn, tracekit
   * setup:
     + nothing compiles





reply via email to

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