summaryrefslogtreecommitdiffstats
path: root/keyserver
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2008-04-21 21:13:36 +0200
committerWerner Koch <wk@gnupg.org>2008-04-21 21:13:36 +0200
commit08a612f26e7657daf7adb39cc62b91ab76e488fb (patch)
treec2f33a0073571cd5d47dc42a777f855cc75384a1 /keyserver
parentUse default PIN flag (diff)
downloadgnupg2-08a612f26e7657daf7adb39cc62b91ab76e488fb.tar.xz
gnupg2-08a612f26e7657daf7adb39cc62b91ab76e488fb.zip
W32 related keyserver fixes.
Diffstat (limited to 'keyserver')
-rw-r--r--keyserver/ChangeLog8
-rw-r--r--keyserver/curl-shim.c4
-rw-r--r--keyserver/gpgkeys_finger.c44
-rw-r--r--keyserver/ksutil.c20
-rw-r--r--keyserver/ksutil.h5
5 files changed, 42 insertions, 39 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog
index 28a5ed5c1..be11f7de5 100644
--- a/keyserver/ChangeLog
+++ b/keyserver/ChangeLog
@@ -1,3 +1,11 @@
+2008-04-21 Werner Koch <wk@g10code.com>
+
+ * ksutil.c (w32_init_sockets) [HAVE_W32_SYSTEM]: New.
+ * curl-shim.c (curl_easy_init) [HAVE_W32_SYSTEM]: Call it.
+ * gpgkeys_finger.c: s/_WIN32/HAVE_W32_SYSTEM/.
+ (init_sockets): Remove.
+ (connect_server) [HAVE_W32_SYSTEM]: Call new function.
+
2008-04-14 David Shaw <dshaw@jabberwocky.com>
* gpgkeys_curl.c (main), gpgkeys_hkp.c (main): Make sure all
diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c
index 74b3f17e0..dfa3d1e3c 100644
--- a/keyserver/curl-shim.c
+++ b/keyserver/curl-shim.c
@@ -89,6 +89,10 @@ curl_easy_init(void)
{
CURL *handle;
+#ifdef HAVE_W32_SYSTEM
+ w32_init_sockets ();
+#endif
+
handle=calloc(1,sizeof(CURL));
if(handle)
handle->errors=stderr;
diff --git a/keyserver/gpgkeys_finger.c b/keyserver/gpgkeys_finger.c
index 9933991b1..cdca85ef4 100644
--- a/keyserver/gpgkeys_finger.c
+++ b/keyserver/gpgkeys_finger.c
@@ -27,7 +27,7 @@
#include <getopt.h>
#endif
-#ifdef _WIN32
+#ifdef HAVE_W32_SYSTEM
#include <windows.h>
#else
#include <unistd.h>
@@ -46,7 +46,7 @@
#include "ksutil.h"
#include "iobuf.h"
-#ifdef _WIN32
+#ifdef HAVE_W32_SYSTEM
#define sock_close(a) closesocket(a)
#else
#define sock_close(a) close(a)
@@ -58,40 +58,6 @@ extern int optind;
static FILE *input,*output,*console;
static struct ks_options *opt;
-#ifdef _WIN32
-static void
-deinit_sockets (void)
-{
- WSACleanup();
-}
-
-static void
-init_sockets (void)
-{
- static int initialized;
- static WSADATA wsdata;
-
- if (initialized)
- return;
-
- if (WSAStartup (0x0101, &wsdata) )
- {
- fprintf (console, "error initializing socket library: ec=%d\n",
- (int)WSAGetLastError () );
- return;
- }
- if (wsdata.wVersion < 0x0001)
- {
- fprintf (console, "socket library version is %x.%x - but 1.1 needed\n",
- LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion));
- WSACleanup();
- return;
- }
- atexit (deinit_sockets);
- initialized = 1;
-}
-#endif /*_WIN32*/
-
/* Connect to SERVER at PORT and return a file descriptor or -1 on
error. */
@@ -100,12 +66,12 @@ connect_server (const char *server, unsigned short port)
{
int sock = -1;
-#ifdef _WIN32
+#ifdef HAVE_W32_SYSTEM
struct hostent *hp;
struct sockaddr_in addr;
unsigned long l;
- init_sockets ();
+ w32_init_sockets ();
memset (&addr, 0, sizeof addr);
addr.sin_family = AF_INET;
@@ -201,7 +167,7 @@ write_server (int sock, const char *data, size_t length)
{
int nwritten;
-#ifdef _WIN32
+#ifdef HAVE_W32_SYSTEM
nwritten = send (sock, data, nleft, 0);
if ( nwritten == SOCKET_ERROR )
{
diff --git a/keyserver/ksutil.c b/keyserver/ksutil.c
index 04e21b6a8..b25f8eb7b 100644
--- a/keyserver/ksutil.c
+++ b/keyserver/ksutil.c
@@ -35,6 +35,10 @@
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_W32_SYSTEM
+#include <windows.h>
+#endif
+
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#else
@@ -83,6 +87,22 @@ register_timeout(void)
#endif /* !HAVE_DOSISH_SYSTEM */
+#ifdef HAVE_W32_SYSTEM
+void
+w32_init_sockets (void)
+{
+ static int initialized;
+ static WSADATA wsdata;
+
+ if (!initialized)
+ {
+ WSAStartup (0x0202, &wsdata);
+ initialized = 1;
+ }
+}
+#endif /*HAVE_W32_SYSTEM*/
+
+
struct ks_options *
init_ks_options(void)
{
diff --git a/keyserver/ksutil.h b/keyserver/ksutil.h
index 3068592e8..9f51359df 100644
--- a/keyserver/ksutil.h
+++ b/keyserver/ksutil.h
@@ -79,6 +79,11 @@ struct keylist
unsigned int set_timeout(unsigned int seconds);
int register_timeout(void);
+#ifdef HAVE_W32_SYSTEM
+void w32_init_sockets (void);
+#endif
+
+
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
enum ks_search_type {KS_SEARCH_SUBSTR,KS_SEARCH_EXACT,