gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1294 - in GNUnet/src: applications/advertising application


From: grothoff
Subject: [GNUnet-SVN] r1294 - in GNUnet/src: applications/advertising applications/fs/module applications/identity applications/session applications/transport include server transports util
Date: Wed, 6 Jul 2005 14:08:34 -0700 (PDT)

Author: grothoff
Date: 2005-07-06 14:08:12 -0700 (Wed, 06 Jul 2005)
New Revision: 1294

Removed:
   GNUnet/src/include/gnunet_gnunetd_lib.h
Modified:
   GNUnet/src/applications/advertising/advertising.c
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/fs/module/migration.c
   GNUnet/src/applications/identity/identitytest.c
   GNUnet/src/applications/session/connect.c
   GNUnet/src/applications/transport/transport.c
   GNUnet/src/include/Makefile.am
   GNUnet/src/include/gnunet_gap_service.h
   GNUnet/src/include/gnunet_identity_service.h
   GNUnet/src/include/gnunet_rpc_service.h
   GNUnet/src/include/gnunet_sqstore_service.h
   GNUnet/src/include/gnunet_stats_lib.h
   GNUnet/src/include/gnunet_topology_service.h
   GNUnet/src/include/gnunet_transport.h
   GNUnet/src/include/gnunet_transport_service.h
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/server/gnunet-transport-check.c
   GNUnet/src/server/version.c
   GNUnet/src/transports/http.c
   GNUnet/src/transports/nat.c
   GNUnet/src/transports/smtp.c
   GNUnet/src/transports/tcp.c
   GNUnet/src/transports/tcp6.c
   GNUnet/src/transports/udp.c
   GNUnet/src/transports/udp6.c
   GNUnet/src/util/configuration.c
Log:
more API cleanup

Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c   2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/applications/advertising/advertising.c   2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -434,8 +434,8 @@
   sd.n = identity->forEachHost(now,
                               NULL,
                               NULL); /* just count */
-  if (SYSERR == transport->createHELO(tapi->protocolNumber,
-                                     &sd.m))
+  sd.m = transport->createHELO(tapi->protocolNumber);
+  if (sd.m == NULL)
     return;
 #if DEBUG_HELOEXCHANGE
   LOG(LOG_INFO,

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/applications/fs/module/fs.c      2005-07-06 21:08:12 UTC (rev 
1294)
@@ -34,6 +34,7 @@
 #include "gnunet_dht_service.h"
 #include "gnunet_datastore_service.h"
 #include "gnunet_traffic_service.h"
+#include "anonymity.h"
 #include "ecrs_core.h"
 #include "migration.h"
 #include "ondemand.h"

Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c       2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/applications/fs/module/migration.c       2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -28,8 +28,8 @@
 #include "platform.h"
 #include "migration.h"
 #include "fs.h"
+#include "anonymity.h"
 
-
 /**
  * Datastore service.
  */
@@ -71,8 +71,8 @@
  *   that buffer (must be a positive number).
  */
 static unsigned int
-activeMigrationCallback(PeerIdentity * receiver,
-                       char * position,
+activeMigrationCallback(const PeerIdentity * receiver,
+                       void * position,
                        unsigned int padding) {
   unsigned int ret;
   HashCode512 key;
@@ -133,12 +133,12 @@
   dht = d;
   traffic = t;
   coreAPI->registerSendCallback(512,
-                               (BufferFillCallback)&activeMigrationCallback);
+                               &activeMigrationCallback);
 }
 
 void doneMigration() {
   coreAPI->unregisterSendCallback(512,
-                                 (BufferFillCallback)&activeMigrationCallback);
+                                 &activeMigrationCallback);
   datastore = NULL;
   gap = NULL;
   dht = NULL;

Modified: GNUnet/src/applications/identity/identitytest.c
===================================================================
--- GNUnet/src/applications/identity/identitytest.c     2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/applications/identity/identitytest.c     2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -52,8 +52,8 @@
 
   transport = requestService("transport");
   identity = requestService("identity");
-  if (OK != transport->createHELO(ANY_PROTOCOL_NUMBER,
-                                 &helo)) {
+  helo = transport->createHELO(ANY_PROTOCOL_NUMBER);
+  if (NULL == helo) {
     printf("Cannot run test, failed to create any HELO.\n");
     releaseService(identity);
     releaseService(transport);

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/applications/session/connect.c   2005-07-06 21:08:12 UTC (rev 
1294)
@@ -401,9 +401,8 @@
   }
 
   /* create HELO */
-  helo = NULL;
-  if (SYSERR == transport->createHELO(ANY_PROTOCOL_NUMBER,
-                                     &helo)) {
+  helo = transport->createHELO(ANY_PROTOCOL_NUMBER);
+  if (NULL == helo) {
     LOG(LOG_INFO,
        "Could not create any HELO advertisement.  Not good.");
   }

Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c       2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/applications/transport/transport.c       2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -53,9 +53,8 @@
 static void createSignedHELO(TransportAPI * tapi) {
   MUTEX_LOCK(&tapis_lock);
   FREENONNULL(tapi->helo);
-  tapi->helo = NULL;
-  if (SYSERR == tapi->createHELO(&tapi->helo)) {
-    tapi->helo = NULL;
+  tapi->helo = tapi->createHELO();
+  if (NULL == tapi->helo) {
     LOG(LOG_INFO,
        "Transport '%s' failed to create HELO\n",
        tapi->transName);
@@ -178,7 +177,6 @@
   TransportAPI * tapi;
   unsigned short prot;
   TSession * tsession;
-  HELO_Message * heloCpy;
 
   if (ntohs(helo->protocol) >= tapis_count) {
     LOG(LOG_INFO,
@@ -196,11 +194,7 @@
        ntohs(helo->protocol));
      return NULL;
   } else {
-    heloCpy = MALLOC(HELO_Message_size(helo));
-    memcpy(heloCpy,
-          helo,
-          HELO_Message_size(helo));
-    if (OK == tapi->connect(heloCpy,
+    if (OK == tapi->connect(helo,
                            &tsession)) {
       tsession->ttype = prot;
 #if DEBUG_TRANSPORT
@@ -210,7 +204,6 @@
 #endif
       return tsession;
     } else
-      FREE(heloCpy);
       return NULL;
   }
 }
@@ -448,12 +441,11 @@
  * Create a HELO advertisement for the given
  * transport type for this node.
  */
-static int transportCreateHELO(unsigned short ttype,
-                              HELO_Message ** helo) {
+static HELO_Message * transportCreateHELO(unsigned short ttype) {
   TransportAPI * tapi;
+  HELO_Message * helo;
 
   MUTEX_LOCK(&tapis_lock);
-  *helo = NULL;
   if (ttype == ANY_PROTOCOL_NUMBER) {
     int * perm;
 
@@ -467,7 +459,7 @@
     if (ttype >= tapis_count) {
       FREE(perm);
       MUTEX_UNLOCK(&tapis_lock);
-      return SYSERR;
+      return NULL;
     }
     ttype = perm[ttype];
     FREE(perm);
@@ -477,7 +469,7 @@
        _("No transport of type %d known.\n"),
        ttype);
     MUTEX_UNLOCK(&tapis_lock);
-    return SYSERR;
+    return NULL;
   }
   tapi = tapis[ttype];
   if (tapi == NULL) {
@@ -485,22 +477,22 @@
        _("No transport of type %d known.\n"),
        ttype);
     MUTEX_UNLOCK(&tapis_lock);
-    return SYSERR;
+    return NULL;
   }
   if (tapi->helo == NULL) {
     LOG(LOG_DEBUG,
        "Transport of type %d configured for sending only (no HELO).\n",
        ttype);
     MUTEX_UNLOCK(&tapis_lock);
-    return SYSERR;
+    return NULL;
   }
 
-  *helo = MALLOC(HELO_Message_size(tapi->helo));
-  memcpy(*helo,
+  helo = MALLOC(HELO_Message_size(tapi->helo));
+  memcpy(helo,
         tapi->helo,
         HELO_Message_size(tapi->helo));
   MUTEX_UNLOCK(&tapis_lock);
-  return OK;
+  return helo;
 }
 
 /**
@@ -531,11 +523,13 @@
 
   helos = MALLOC(tcount * sizeof(HELO_Message*));
   tcount = 0;
-  for (i=0;i<tapis_count;i++)
-    if (tapis[i] != NULL)
-      if (OK == transportCreateHELO(i,
-                                   &helos[tcount]))
+  for (i=0;i<tapis_count;i++) {
+    if (tapis[i] != NULL) {
+      helos[tcount] = transportCreateHELO(i);
+      if (NULL != helos[tcount])
        tcount++;
+    }
+  }
   MUTEX_UNLOCK(&tapis_lock);
   if (tcount == 0) {
     LOG(LOG_DEBUG,
@@ -593,8 +587,8 @@
   HELO_Message * helo;
 
   createSignedHELO(tapi);
-  if (OK == transportCreateHELO(tapi->protocolNumber,
-                               &helo)) {
+  helo = transportCreateHELO(tapi->protocolNumber);
+  if (NULL != helo) {
     identity->addHost(helo);
     FREE(helo);
   }
@@ -603,8 +597,6 @@
 
 
 
-
-
 /**
  * Initialize the transport layer.
  */

Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am      2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/include/Makefile.am      2005-07-06 21:08:12 UTC (rev 1294)
@@ -26,7 +26,6 @@
   gnunet_fsui_lib.h \
   gnunet_gap_service.h \
   gnunet_getoption_lib.h \
-  gnunet_gnunetd_lib.h \
   gnunet_identity_service.h \
   gnunet_pingpong_service.h \
   gnunet_protocols.h \

Modified: GNUnet/src/include/gnunet_gap_service.h
===================================================================
--- GNUnet/src/include/gnunet_gap_service.h     2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/include/gnunet_gap_service.h     2005-07-06 21:08:12 UTC (rev 
1294)
@@ -112,7 +112,7 @@
    * What is the average priority of requests that we
    * are currently routing?
    */
-  unsigned int (*getAvgPriority)();
+  unsigned int (*getAvgPriority)(void);
 
 } GAP_ServiceAPI;
 

Deleted: GNUnet/src/include/gnunet_gnunetd_lib.h
===================================================================
--- GNUnet/src/include/gnunet_gnunetd_lib.h     2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/include/gnunet_gnunetd_lib.h     2005-07-06 21:08:12 UTC (rev 
1294)
@@ -1,50 +0,0 @@
-/*
-     This file is part of GNUnet
-
-     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 include/gnunet_gnunetd_lib.h
- * @brief general support for user interface / gnunetd interaction
- * @author Christian Grothoff
- */
-
-#ifndef GNUNET_GNUNETD_LIB_H
-#define GNUNET_GNUNETD_LIB_H
-
-/**
- * Is gnunetd running?
- * @return YES if gnunetd is running, NO if not
- */
-int GNUNETD_checkRunning();
-
-/**
- * Try starting gnunetd.
- *
- * @param cfg configuration file for gnunetd (maybe NULL if
- *        the client has no idea where the file is, then
- *        the default is used)
- * @return YES on success, NO if gnunetd was already running,
- *         SYSERR if trying to start gnunetd failed and gnunetd
- *         was not running (even if YES is returned, there is
- *         no guarantee that the start was successful, try
- *         checkRunning!)
- */
-int GNUNETD_tryStart(char * cfg);
-
-
-#endif

Modified: GNUnet/src/include/gnunet_identity_service.h
===================================================================
--- GNUnet/src/include/gnunet_identity_service.h        2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/include/gnunet_identity_service.h        2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -63,7 +63,7 @@
    *
    * @return reference to the public key. Do not free it!
    */
-  const PublicKey * (*getPublicPrivateKey)();
+  const PublicKey * (*getPublicPrivateKey)(void);
 
   /**
    * Obtain identity from publicPrivateKey.

Modified: GNUnet/src/include/gnunet_rpc_service.h
===================================================================
--- GNUnet/src/include/gnunet_rpc_service.h     2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/include/gnunet_rpc_service.h     2005-07-06 21:08:12 UTC (rev 
1294)
@@ -179,7 +179,7 @@
 /**
  * RPC argument handling helper functions.
  */
-RPC_Param * RPC_paramNew();
+RPC_Param * RPC_paramNew(void);
 
 void RPC_paramFree(RPC_Param * param);
 

Modified: GNUnet/src/include/gnunet_sqstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_sqstore_service.h 2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/include/gnunet_sqstore_service.h 2005-07-06 21:08:12 UTC (rev 
1294)
@@ -46,7 +46,7 @@
    * available.
    * @return number of bytes used on disk
    */
-  unsigned long long (*getSize)();
+  unsigned long long (*getSize)(void);
 
   /**
    * Store an item in the datastore.
@@ -157,10 +157,10 @@
    * Delete the database.  The next operation is
    * guaranteed to be unloading of the module.
    */
-  void (*drop)();
+  void (*drop)(void);
 
 } SQstore_ServiceAPI;
 
 
-/* end of gnunet_datastore_service.h */
+/* end of gnunet_sqstore_service.h */
 #endif

Modified: GNUnet/src/include/gnunet_stats_lib.h
===================================================================
--- GNUnet/src/include/gnunet_stats_lib.h       2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/include/gnunet_stats_lib.h       2005-07-06 21:08:12 UTC (rev 
1294)
@@ -78,7 +78,4 @@
                              ProtocolProcessor processor,
                              void * cls);
 
-
-
-
 #endif

Modified: GNUnet/src/include/gnunet_topology_service.h
===================================================================
--- GNUnet/src/include/gnunet_topology_service.h        2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/include/gnunet_topology_service.h        2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -55,14 +55,14 @@
    * Get an estimate of the network size.
    * @return the estimated number of nodes, SYSERR on error
    */
-  int (*estimateNetworkSize)();
+  int (*estimateNetworkSize)(void);
 
   /**
    * How big is our current desire to connect to other peers?
    * @return 1 for ideal, 0 for maximum desire, > 1 for too many
    *    connections (percent of desired number of connections)
    */
-  double (*getSaturation)();
+  double (*getSaturation)(void);
 
   /**
    * Will the topology allow a connection from the specified peer?

Modified: GNUnet/src/include/gnunet_transport.h
===================================================================
--- GNUnet/src/include/gnunet_transport.h       2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/include/gnunet_transport.h       2005-07-06 21:08:12 UTC (rev 
1294)
@@ -219,7 +219,7 @@
    * @return OK on success, SYSERR on error (e.g. send-only
    *  transports return SYSERR here)
    */
-  int (*createHELO)(HELO_Message ** helo);
+  HELO_Message * (*createHELO)(void);
 
   /**
    * Establish a connection to a remote node.
@@ -228,7 +228,7 @@
    * @param tsession the session handle that is to be set
    * @return OK on success, SYSERR if the operation failed
    */
-  int (*connect)(HELO_Message * helo,
+  int (*connect)(const HELO_Message * helo,
                 TSession ** tsession);
 
   /**

Modified: GNUnet/src/include/gnunet_transport_service.h
===================================================================
--- GNUnet/src/include/gnunet_transport_service.h       2005-07-06 20:35:30 UTC 
(rev 1293)
+++ GNUnet/src/include/gnunet_transport_service.h       2005-07-06 21:08:12 UTC 
(rev 1294)
@@ -49,7 +49,7 @@
   /**
    * Stop the transport services, stop receiving messages.
    */
-  void (*stop)();
+  void (*stop)(void);
 
   /**
    * Is this transport mechanism available (for sending)?
@@ -69,7 +69,7 @@
    * @return number of transports, SYSERR on error
    */
   int (*forEach)(TransportCallback callback,
-                 void * data);
+                void * data);
 
   /**
    * Connect to a remote host using the advertised transport
@@ -169,8 +169,7 @@
    * Create a HELO advertisement for the given
    * transport type for this node.
    */
-  int (*createHELO)(unsigned short ttype,
-                   HELO_Message ** helo);
+  HELO_Message * (*createHELO)(unsigned short ttype);
 
   /**
    * Get a message consisting of (if possible) all addresses that this

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/include/gnunet_util.h    2005-07-06 21:08:12 UTC (rev 1294)
@@ -2288,9 +2288,9 @@
  */
 int cfg_parse_file(char *filename);
 char * cfg_get_str(const char * sec,
-                         const char * ent);
+                  const char * ent);
 int cfg_get_signed_int(const char *sec,
-                             const char *ent);
+                      const char *ent);
 void doneParseConfig(void);
 
 /**

Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c  2005-07-06 20:35:30 UTC (rev 
1293)
+++ GNUnet/src/server/gnunet-transport-check.c  2005-07-06 21:08:12 UTC (rev 
1294)
@@ -102,8 +102,8 @@
     *res = OK;
     return; /* NAT cannot be tested */
   }
-  helo = NULL;
-  if (OK != tapi->createHELO(&helo)) {
+  helo = tapi->createHELO();
+  if (helo == NULL) {
     fprintf(stderr,
            _("'%s': Could not create HELO.\n"),
            tapi->transName);
@@ -120,6 +120,7 @@
     FREE(helo);
     return;
   }
+  FREE(helo);
   repeat = getConfigurationInt("TRANSPORT-CHECK",
                               "REPEAT");
   if (repeat == 0) {
@@ -233,9 +234,8 @@
     FREE(helo);
     return;
   }
-  myHelo = NULL;
-  if (OK != transport->createHELO(ntohs(xhelo->protocol),
-                                 &myHelo)) {
+  myHelo = transport->createHELO(ntohs(xhelo->protocol));
+  if (myHelo == NULL) {
     FREE(helo);
     return;
   }

Modified: GNUnet/src/server/version.c
===================================================================
--- GNUnet/src/server/version.c 2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/server/version.c 2005-07-06 21:08:12 UTC (rev 1294)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file server/version.h
+ * @file server/version.c
  * @brief check if we need to run gnunet-update
  * @author Christian Grothoff
  */

Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c        2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/http.c        2005-07-06 21:08:12 UTC (rev 1294)
@@ -1075,11 +1075,9 @@
  * created without signature and without a timestamp. The
  * GNUnet core will sign the message and add an expiration time.
  *
- * @param helo address where to store the pointer to the HELO
- *        message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
   HostAddress * haddr;
   unsigned short port;
@@ -1088,7 +1086,7 @@
   if (0 == port) {
     LOG(LOG_DEBUG,
        "HTTP port is 0, will only send using HTTP.\n");
-    return SYSERR; /* HTTP transport is configured SEND-only! */
+    return NULL; /* HTTP transport is configured SEND-only! */
   }
   msg = (HELO_Message *) MALLOC(sizeof(HELO_Message) + sizeof(HostAddress));
   haddr = (HostAddress*) &((HELO_Message_GENERIC*)msg)->senderAddress[0];
@@ -1097,7 +1095,7 @@
     FREE(msg);
     LOG(LOG_WARNING,
        _("HTTP: Could not determine my public IP address.\n"));
-    return SYSERR;
+    return NULL;
   }
   LOG(LOG_DEBUG,
       "HTTP uses IP address %u.%u.%u.%u.\n",
@@ -1107,8 +1105,7 @@
   msg->senderAddressSize = htons(sizeof(HostAddress));
   msg->protocol = htons(HTTP_PROTOCOL_NUMBER);
   msg->MTU = htonl(httpAPI.mtu);
-  *helo = msg;
-  return OK;
+  return msg;
 }
 
 /**
@@ -1118,8 +1115,8 @@
  * @param tsessionPtr the session handle that is set
  * @return OK on success, SYSERR if the operation failed
  */
-static int httpConnect(HELO_Message * helo,
-                     TSession ** tsessionPtr) {
+static int httpConnect(const HELO_Message * helo,
+                      TSession ** tsessionPtr) {
   int i;
   HostAddress * haddr;
   HTTPWelcome welcome;
@@ -1224,7 +1221,6 @@
   signalSelect();
 
   *tsessionPtr = tsession;
-  FREE(helo);
   return OK;
 }
 

Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/nat.c 2005-07-06 21:08:12 UTC (rev 1294)
@@ -82,23 +82,21 @@
  * without signature and without a timestamp. The GNUnet core will
  * sign the message and add an expiration time.
  *
- * @param helo where to store the HELO message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
 
   if (! testConfigurationString("NAT",
                                "LIMITED",
                                "YES"))
-    return SYSERR;
+    return NULL;
 
   msg = MALLOC(sizeof(HELO_Message) + sizeof(HostAddress));
   msg->senderAddressSize = htons(sizeof(HostAddress));
   msg->protocol          = htons(NAT_PROTOCOL_NUMBER);
   msg->MTU               = htonl(0);
-  *helo = msg;
-  return OK;
+  return msg;
 }
 
 /**
@@ -107,7 +105,7 @@
  * @param tsessionPtr the session handle that is to be set
  * @return always fails (returns SYSERR)
  */
-static int natConnect(HELO_Message * helo,
+static int natConnect(const HELO_Message * helo,
                      TSession ** tsessionPtr) {
   return SYSERR;
 }

Modified: GNUnet/src/transports/smtp.c
===================================================================
--- GNUnet/src/transports/smtp.c        2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/smtp.c        2005-07-06 21:08:12 UTC (rev 1294)
@@ -546,11 +546,9 @@
  * without signature and without a timestamp. The GNUnet core will
  * sign the message and add an expiration time.
  *
- * @param helo address where to store the pointer to the HELO
- *        message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
   char * email;
   char * filter;
@@ -562,7 +560,7 @@
   if (email == NULL) {
     LOG(LOG_DEBUG,
        "No email-address specified, cannot create SMTP advertisement.\n");
-    return SYSERR;
+    return NULL;
   }
   filter = getConfigurationString("SMTP",
                                  "FILTER");
@@ -570,7 +568,7 @@
     LOG(LOG_ERROR,
        _("No filter for E-mail specified, cannot create SMTP 
advertisement.\n"));
     FREE(email);
-    return SYSERR;
+    return NULL;
   }
   if (strlen(filter) > FILTER_STRING_SIZE) {
     filter[FILTER_STRING_SIZE] = '\0';
@@ -597,11 +595,10 @@
   msg->MTU               = htonl(smtpAPI.mtu);
   msg->header.size
       = htons(HELO_Message_size(msg));
-  *helo = msg;
   FREE(email);
-  if (verifyHelo(*helo) == SYSERR)
+  if (verifyHelo(msg) == SYSERR)
     GNUNET_ASSERT(0);
-  return OK;
+  return msg;
 }
 
 /**
@@ -610,12 +607,15 @@
  * @param tsessionPtr the session handle that is to be set
  * @return OK on success, SYSERR if the operation failed
  */
-static int smtpConnect(HELO_Message * helo,
+static int smtpConnect(const HELO_Message * helo,
                       TSession ** tsessionPtr) {
   TSession * tsession;
 
   tsession = MALLOC(sizeof(TSession));
-  tsession->internal = helo;
+  tsession->internal = MALLOC(HELO_Message_size(helo));
+  memcpy(tsession->internal,
+        helo,
+        HELO_Message_size(helo));
   tsession->ttype = smtpAPI.protocolNumber;
   (*tsessionPtr) = tsession;
   return OK;

Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/tcp.c 2005-07-06 21:08:12 UTC (rev 1294)
@@ -1034,11 +1034,9 @@
  * created without signature and without a timestamp. The
  * GNUnet core will sign the message and add an expiration time.
  *
- * @param helo address where to store the pointer to the HELO
- *        message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
   HostAddress * haddr;
   unsigned short port;
@@ -1047,7 +1045,7 @@
   if (0 == port) {
     LOG(LOG_DEBUG,
        "TCP port is 0, will only send using TCP.\n");
-    return SYSERR; /* TCP transport is configured SEND-only! */
+    return NULL; /* TCP transport is configured SEND-only! */
   }
   msg = (HELO_Message *) MALLOC(sizeof(HELO_Message) + sizeof(HostAddress));
   haddr = (HostAddress*) &((HELO_Message_GENERIC*)msg)->senderAddress[0];
@@ -1056,7 +1054,7 @@
     FREE(msg);
     LOG(LOG_WARNING,
        _("Could not determine my public IP address.\n"));
-    return SYSERR;
+    return NULL;
   }
   LOG(LOG_DEBUG,
       "TCP uses IP address %u.%u.%u.%u.\n",
@@ -1066,8 +1064,7 @@
   msg->senderAddressSize = htons(sizeof(HostAddress));
   msg->protocol = htons(TCP_PROTOCOL_NUMBER);
   msg->MTU = htonl(tcpAPI.mtu);
-  *helo = msg;
-  return OK;
+  return msg;
 }
 
 /**
@@ -1077,7 +1074,7 @@
  * @param tsessionPtr the session handle that is set
  * @return OK on success, SYSERR if the operation failed
  */
-static int tcpConnect(HELO_Message * helo,
+static int tcpConnect(const HELO_Message * helo,
                      TSession ** tsessionPtr) {
   int i;
   HostAddress * haddr;
@@ -1175,7 +1172,6 @@
   signalSelect();
 
   *tsessionPtr = tsession;
-  FREE(helo);
   return OK;
 }
 

Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c        2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/tcp6.c        2005-07-06 21:08:12 UTC (rev 1294)
@@ -935,11 +935,9 @@
  * created without signature and without a timestamp. The
  * GNUnet core will sign the message and add an expiration time.
  *
- * @param helo address where to store the pointer to the HELO
- *        message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
   Host6Address * haddr;
   unsigned short port;
@@ -948,7 +946,7 @@
   if (0 == port) {
     LOG(LOG_DEBUG,
        "TCP6 port is 0, will only send using TCP6\n");
-    return SYSERR; /* TCP6 transport is configured SEND-only! */
+    return NULL; /* TCP6 transport is configured SEND-only! */
   }
   msg = (HELO_Message *) MALLOC(sizeof(HELO_Message) + sizeof(Host6Address));
   haddr = (Host6Address*) &((HELO_Message_GENERIC*)msg)->senderAddress[0];
@@ -957,15 +955,14 @@
     FREE(msg);
     LOG(LOG_WARNING,
        _("Could not determine my public IPv6 address.\n"));
-    return SYSERR;
+    return NULL;
   }
   haddr->port = htons(port);
   haddr->reserved = htons(0);
   msg->senderAddressSize = htons(sizeof(Host6Address));
   msg->protocol = htons(TCP6_PROTOCOL_NUMBER);
   msg->MTU = htonl(tcp6API.mtu);
-  *helo = msg;
-  return OK;
+  return msg;
 }
 
 /**
@@ -975,7 +972,7 @@
  * @param tsessionPtr the session handle that is set
  * @return OK on success, SYSERR if the operation failed
  */
-static int tcp6Connect(HELO_Message * helo,
+static int tcp6Connect(const HELO_Message * helo,
                       TSession ** tsessionPtr) {
   int i;
   Host6Address * haddr;
@@ -1094,7 +1091,6 @@
   signalSelect();
 
   *tsessionPtr = tsession;
-  FREE(helo);
   return OK;
 }
 

Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/udp.c 2005-07-06 21:08:12 UTC (rev 1294)
@@ -336,16 +336,15 @@
  * without signature and without a timestamp. The GNUnet core will
  * sign the message and add an expiration time.
  *
- * @param helo where to store the HELO message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
   HostAddress * haddr;
 
   if ( ( (udp_shutdown == YES) && (getGNUnetUDPPort() == 0) ) ||
        ( (udp_shutdown == NO) && (port == 0) ) )
-    return SYSERR; /* UDP transport configured send-only */
+    return NULL; /* UDP transport configured send-only */
 
   msg = MALLOC(sizeof(HELO_Message) + sizeof(HostAddress));
   haddr = (HostAddress*) &((HELO_Message_GENERIC*)msg)->senderAddress[0];
@@ -354,7 +353,7 @@
     FREE(msg);
     LOG(LOG_WARNING,
        _("UDP: Could not determine my public IP address.\n"));
-    return SYSERR;
+    return NULL;
   }
   LOG(LOG_DEBUG,
       "UDP uses IP address %u.%u.%u.%u.\n",
@@ -367,8 +366,7 @@
   msg->senderAddressSize = htons(sizeof(HostAddress));
   msg->protocol          = htons(UDP_PROTOCOL_NUMBER);
   msg->MTU               = htonl(udpAPI.mtu);
-  *helo = msg;
-  return OK;
+  return msg;
 }
 
 /**
@@ -377,13 +375,16 @@
  * @param tsessionPtr the session handle that is to be set
  * @return OK on success, SYSERR if the operation failed
  */
-static int udpConnect(HELO_Message * helo,
+static int udpConnect(const HELO_Message * helo,
                      TSession ** tsessionPtr) {
   TSession * tsession;
   HostAddress * haddr;
 
   tsession = MALLOC(sizeof(TSession));
-  tsession->internal = helo;
+  tsession->internal = MALLOC(HELO_Message_size(helo));
+  memcpy(tsession->internal,
+        helo,
+        HELO_Message_size(helo));
   tsession->ttype = udpAPI.protocolNumber;
   haddr = (HostAddress*) &((HELO_Message_GENERIC*)helo)->senderAddress[0];
 #if DEBUG_UDP

Modified: GNUnet/src/transports/udp6.c
===================================================================
--- GNUnet/src/transports/udp6.c        2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/transports/udp6.c        2005-07-06 21:08:12 UTC (rev 1294)
@@ -1,5 +1,5 @@
 /*
-     This file is part of GNUnet
+o     This file is part of GNUnet
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -332,17 +332,16 @@
  * without signature and without a timestamp. The GNUnet core will
  * sign the message and add an expiration time.
  *
- * @param helo where to store the HELO message
- * @return OK on success, SYSERR on error
+ * @return HELO on success, NULL on error
  */
-static int createHELO(HELO_Message ** helo) {
+static HELO_Message * createHELO() {
   HELO_Message * msg;
   Host6Address * haddr;
   unsigned short port;
 
   port = getGNUnetUDP6Port();
   if (port == 0)
-    return SYSERR; /* UDP6 transport configured send-only */
+    return NULL; /* UDP6 transport configured send-only */
 
   msg = MALLOC(sizeof(HELO_Message) + sizeof(Host6Address));
   haddr = (Host6Address*) &((HELO_Message_GENERIC*)msg)->senderAddress[0];
@@ -351,15 +350,14 @@
     FREE(msg);
     LOG(LOG_WARNING,
        _("UDP6: Could not determine my public IPv6 address.\n"));
-    return SYSERR;
+    return NULL;
   }
   haddr->senderPort      = htons(port);
   haddr->reserved        = htons(0);
   msg->senderAddressSize = htons(sizeof(Host6Address));
   msg->protocol          = htons(UDP6_PROTOCOL_NUMBER);
   msg->MTU               = htonl(udp6API.mtu);
-  *helo = msg;
-  return OK;
+  return msg;
 }
 
 /**
@@ -368,7 +366,7 @@
  * @param tsessionPtr the session handle that is to be set
  * @return OK on success, SYSERR if the operation failed
  */
-static int udp6Connect(HELO_Message * helo,
+static int udp6Connect(const HELO_Message * helo,
                       TSession ** tsessionPtr) {
   TSession * tsession;
   Host6Address * haddr;
@@ -377,7 +375,10 @@
 #endif
 
   tsession = MALLOC(sizeof(TSession));
-  tsession->internal = helo;
+  tsession->internal = MALLOC(HELO_Message_size(helo));
+  memcpy(tsession->internal,
+        helo,
+        HELO_Message_size(helo));
   tsession->ttype = udp6API.protocolNumber;
   haddr = (Host6Address*) &((HELO_Message_GENERIC*)helo)->senderAddress[0];
 #if DEBUG_UDP6

Modified: GNUnet/src/util/configuration.c
===================================================================
--- GNUnet/src/util/configuration.c     2005-07-06 20:35:30 UTC (rev 1293)
+++ GNUnet/src/util/configuration.c     2005-07-06 21:08:12 UTC (rev 1294)
@@ -228,14 +228,14 @@
 /* ------------------------------------------------------------------------ */
 
 char * cfg_get_str(const char * sec,
-                         const char * ent) {
+                  const char * ent) {
   struct CFG_ENTRIES * e = NULL;
   int i;
 
-       if (c)
-         for (i = 0; i < c->sec_count; i++)
-           if (0 == strcasecmp(c->sec_names[i],sec))
-             e = c->sec_entries[i];
+  if (c)
+    for (i = 0; i < c->sec_count; i++)
+      if (0 == strcasecmp(c->sec_names[i],sec))
+       e = c->sec_entries[i];
   if (NULL == e)
     return NULL;
   for (i = 0; i < e->ent_count; i++)





reply via email to

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