[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3151 - in GNUnet/src: include transports util util/cron ut
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3151 - in GNUnet/src: include transports util util/cron util/network util/network_client util/string |
Date: |
Fri, 28 Jul 2006 18:13:53 -0700 (PDT) |
Author: grothoff
Date: 2006-07-28 18:13:50 -0700 (Fri, 28 Jul 2006)
New Revision: 3151
Modified:
GNUnet/src/include/gnunet_util_network_client.h
GNUnet/src/transports/nat.c
GNUnet/src/util/cron/Makefile.am
GNUnet/src/util/dump
GNUnet/src/util/initialize.c
GNUnet/src/util/network/io.c
GNUnet/src/util/network_client/Makefile.am
GNUnet/src/util/network_client/daemon.c
GNUnet/src/util/network_client/tcpio.c
GNUnet/src/util/string/string.c
Log:
cleanup
Modified: GNUnet/src/include/gnunet_util_network_client.h
===================================================================
--- GNUnet/src/include/gnunet_util_network_client.h 2006-07-29 00:51:47 UTC
(rev 3150)
+++ GNUnet/src/include/gnunet_util_network_client.h 2006-07-29 01:13:50 UTC
(rev 3151)
@@ -47,22 +47,10 @@
* Get a connection with gnunetd.
*/
struct ClientServerConnection *
-daemon_connection_create(struct GE_Context * ectx,
+client_connection_create(struct GE_Context * ectx,
struct GC_Configuration * cfg);
/**
- * Initialize a GNUnet server socket.
- *
- * @param sock the open socket
- * @param result the SOCKET (filled in)
- * @return OK (always successful)
- */
-struct ClientServerConnection *
-client_connection_create(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct SocketHandle * sock);
-
-/**
* Close a GNUnet TCP socket for now (use to temporarily close
* a TCP connection that will probably not be used for a long
* time; the socket will still be auto-reopened by the
Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2006-07-29 00:51:47 UTC (rev 3150)
+++ GNUnet/src/transports/nat.c 2006-07-29 01:13:50 UTC (rev 3151)
@@ -74,8 +74,9 @@
(value == "YES") ) {
/* if WE are a NAT and this is not our hello,
it is invalid since NAT-to-NAT is not possible! */
- if (equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
- &helo->senderIdentity.hashPubKey))
+ if (0 == memcmp(&coreAPI->myIdentity->hashPubKey,
+ &helo->senderIdentity.hashPubKey,
+ sizeof(HashCode512)))
return OK;
else
return SYSERR;
Modified: GNUnet/src/util/cron/Makefile.am
===================================================================
--- GNUnet/src/util/cron/Makefile.am 2006-07-29 00:51:47 UTC (rev 3150)
+++ GNUnet/src/util/cron/Makefile.am 2006-07-29 01:13:50 UTC (rev 3151)
@@ -7,6 +7,8 @@
libgnunetutil_cron_la_SOURCES = \
cron.c
+libgnunetutil_cron_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
check_PROGRAMS = \
crontest
Modified: GNUnet/src/util/dump
===================================================================
--- GNUnet/src/util/dump 2006-07-29 00:51:47 UTC (rev 3150)
+++ GNUnet/src/util/dump 2006-07-29 01:13:50 UTC (rev 3151)
@@ -1,3 +1,10 @@
+#if ENABLE_NLS
+ setlocale (LC_ALL, "");
+ BINDTEXTDOMAIN("GNUnet", LOCALEDIR);
+ textdomain("GNUnet");
+#endif
+
+
case 'H': {
port_string = strstr(optarg, ":");
if (NULL != port_string) {
Modified: GNUnet/src/util/initialize.c
===================================================================
--- GNUnet/src/util/initialize.c 2006-07-29 00:51:47 UTC (rev 3150)
+++ GNUnet/src/util/initialize.c 2006-07-29 01:13:50 UTC (rev 3151)
@@ -27,26 +27,19 @@
#include "platform.h"
#include "gnunet_util.h"
+#ifdef MINGW
/**
* Initialize the util library.
*/
int __attribute__ ((constructor)) gnunet_util_init() {
-#ifdef MINGW
if (InitWinEnv() != ERROR_SUCCESS)
return SYSERR;
-#endif
-#if ENABLE_NLS
- setlocale (LC_ALL, "");
- BINDTEXTDOMAIN("GNUnet", LOCALEDIR);
- textdomain("GNUnet");
-#endif
return OK;
}
void __attribute__ ((destructor)) gnunet_util_fini() {
-#ifdef MINGW
ShutdownWinEnv();
-#endif
}
+#endif
/* end of initialize.c */
Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c 2006-07-29 00:51:47 UTC (rev 3150)
+++ GNUnet/src/util/network/io.c 2006-07-29 01:13:50 UTC (rev 3151)
@@ -30,6 +30,55 @@
#include "platform.h"
#include "network.h"
+/**
+ * Global lock for gethostbyname.
+ */
+static struct MUTEX * lock;
+
+void __attribute__ ((constructor)) gnunet_network_io_init() {
+ lock = MUTEX_CREATE(NO);
+}
+
+void __attribute__ ((destructor)) gnunet_network_io_fini() {
+ MUTEX_DESTROY(lock);
+ lock = NULL;
+}
+
+/**
+ * Get the IP address of the given host.
+ * @return OK on success, SYSERR on error
+ */
+int get_host_by_name(struct GE_Context * ectx,
+ const char * hostname,
+ IPaddr * ip) {
+ struct hostent * he;
+
+ /* slight hack: re-use config lock */
+ MUTEX_LOCK(lock);
+ he = GETHOSTBYNAME(hostname);
+ if (he == NULL) {
+ GE_LOG(ectx,
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("Could not find IP of host `%s': %s\n"),
+ hostname,
+ hstrerror(h_errno));
+ MUTEX_UNLOCK(lock);
+ return SYSERR;
+ }
+ if (he->h_addrtype != AF_INET) {
+ GE_BREAK(ectx, 0);
+ MUTEX_UNLOCK(lock);
+ return SYSERR;
+ }
+ memcpy(ip,
+ &((struct in_addr*)he->h_addr_list[0])->s_addr,
+ sizeof(struct in_addr));
+ MUTEX_UNLOCK(lock);
+ return OK;
+}
+
+
+
struct SocketHandle *
socket_create(struct GE_Context * ectx,
struct LoadMonitor * mon,
Modified: GNUnet/src/util/network_client/Makefile.am
===================================================================
--- GNUnet/src/util/network_client/Makefile.am 2006-07-29 00:51:47 UTC (rev
3150)
+++ GNUnet/src/util/network_client/Makefile.am 2006-07-29 01:13:50 UTC (rev
3151)
@@ -8,6 +8,8 @@
libgnunetutil_network_client_la_SOURCES = \
daemon.c \
tcpio.c
+libgnunetutil_network_client_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
check_PROGRAMS = \
tcpiotest
Modified: GNUnet/src/util/network_client/daemon.c
===================================================================
--- GNUnet/src/util/network_client/daemon.c 2006-07-29 00:51:47 UTC (rev
3150)
+++ GNUnet/src/util/network_client/daemon.c 2006-07-29 01:13:50 UTC (rev
3151)
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util_network.h"
+#include "gnunet_util_network_client.h"
#include "gnunet_protocols.h"
#include "gnunet_util_threads.h"
@@ -35,7 +36,7 @@
MESSAGE_HEADER csHdr;
int ret;
- sock = daemon_connection_create(ectx, cfg);
+ sock = client_connection_create(ectx, cfg);
if (sock == NULL)
return SYSERR;
csHdr.size
Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c 2006-07-29 00:51:47 UTC (rev
3150)
+++ GNUnet/src/util/network_client/tcpio.c 2006-07-29 01:13:50 UTC (rev
3151)
@@ -119,12 +119,11 @@
struct ClientServerConnection *
client_connection_create(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct SocketHandle * sock) {
+ struct GC_Configuration * cfg) {
ClientServerConnection * result;
result = MALLOC(sizeof(ClientServerConnection));
- result->sock = sock;
+ result->sock = NULL;
result->readlock = MUTEX_CREATE(NO);
result->writelock = MUTEX_CREATE(NO);
result->ectx = ectx;
Modified: GNUnet/src/util/string/string.c
===================================================================
--- GNUnet/src/util/string/string.c 2006-07-29 00:51:47 UTC (rev 3150)
+++ GNUnet/src/util/string/string.c 2006-07-29 01:13:50 UTC (rev 3151)
@@ -29,6 +29,24 @@
#include "platform.h"
#include <iconv.h>
+
+int SNPRINTF(char * buf,
+ size_t size,
+ const char * format,
+ ...) {
+ int ret;
+ va_list args;
+
+ va_start(args, format);
+ ret = VSNPRINTF(buf,
+ size,
+ format,
+ args);
+ va_end(args);
+ GE_ASSERT(NULL, ret <= size);
+ return ret;
+}
+
#if !HAVE_STRLCPY
/**
* @brief Copy a %NUL terminated string into a sized buffer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3151 - in GNUnet/src: include transports util util/cron util/network util/network_client util/string,
grothoff <=