[svn] GnuPG - r4751 - in trunk: . common keyserver scd
svn author wk
cvs at cvs.gnupg.org
Mon Apr 21 21:13:38 CEST 2008
Author: wk
Date: 2008-04-21 21:13:36 +0200 (Mon, 21 Apr 2008)
New Revision: 4751
Modified:
trunk/NEWS
trunk/common/ChangeLog
trunk/common/http.c
trunk/common/i18n.c
trunk/keyserver/ChangeLog
trunk/keyserver/curl-shim.c
trunk/keyserver/gpgkeys_finger.c
trunk/keyserver/ksutil.c
trunk/keyserver/ksutil.h
trunk/scd/ChangeLog
Log:
W32 related keyserver fixes.
Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/common/ChangeLog 2008-04-21 19:13:36 UTC (rev 4751)
@@ -1,3 +1,9 @@
+2008-04-21 Werner Koch <wk at g10code.com>
+
+ * http.c (http_wait_response) [W32]: Use DuplicateHandle because
+ it is a socket.
+ (cookie_read) [W32]: Use recv in place of read.
+
2008-04-08 Werner Koch <wk at g10code.com>
* i18n.c (i18n_switchto_utf8, i18n_switchback)
Modified: trunk/keyserver/ChangeLog
===================================================================
--- trunk/keyserver/ChangeLog 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/keyserver/ChangeLog 2008-04-21 19:13:36 UTC (rev 4751)
@@ -1,3 +1,11 @@
+2008-04-21 Werner Koch <wk at 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 at jabberwocky.com>
* gpgkeys_curl.c (main), gpgkeys_hkp.c (main): Make sure all
Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/scd/ChangeLog 2008-04-21 19:13:36 UTC (rev 4751)
@@ -1,4 +1,4 @@
-2008-04-21 Werner Koch <wk at g10code.com>
+2008-04-21 Moritz Schulte <mo at g10code.com> (wk)
* app-openpgp.c (verify_a_chv): Make use of the default CHV flag.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/NEWS 2008-04-21 19:13:36 UTC (rev 4751)
@@ -7,7 +7,9 @@
* New mechanisms "local" and "nodefault" for --auto-key-locate [gpg].
Fixed a few problems with this option.
+ * [W32] Initialize the socket subsystem for all keyserver helpers.
+
Noteworthy changes in version 2.0.9 (2008-03-26)
------------------------------------------------
Modified: trunk/common/http.c
===================================================================
--- trunk/common/http.c 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/common/http.c 2008-04-21 19:13:36 UTC (rev 4751)
@@ -396,7 +396,16 @@
else
#endif /*HTTP_USE_ESTREAM*/
{
+#ifdef HAVE_W32_SYSTEM
+ HANDLE handle = (HANDLE)hd->sock;
+ if (!DuplicateHandle (GetCurrentProcess(), handle,
+ GetCurrentProcess(), &handle, 0,
+ TRUE, DUPLICATE_SAME_ACCESS ))
+ return gpg_error_from_syserror ();
+ hd->sock = (int)handle;
+#else
hd->sock = dup (hd->sock);
+#endif
if (hd->sock == -1)
return gpg_error_from_syserror ();
}
@@ -1490,7 +1499,7 @@
}
#endif
-/* Actually connect to a server. Returns the file descripto or -1 on
+/* Actually connect to a server. Returns the file descriptor or -1 on
error. ERRNO is set on error. */
static int
connect_server (const char *server, unsigned short port,
@@ -1765,7 +1774,12 @@
{
do
{
+#ifdef HAVE_W32_SYSTEM
+ /* Under Windows we need to use recv for a socket. */
+ nread = recv (c->fd, buffer, size, 0);
+#else
nread = read (c->fd, buffer, size);
+#endif
}
while (nread == -1 && errno == EINTR);
}
Modified: trunk/common/i18n.c
===================================================================
--- trunk/common/i18n.c 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/common/i18n.c 2008-04-21 19:13:36 UTC (rev 4751)
@@ -52,7 +52,7 @@
{
#ifdef USE_SIMPLE_GETTEXT
gettext_select_utf8 (1);
-#elif define(ENABLE_NLS)
+#elif defined(ENABLE_NLS)
char *orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL);
# ifdef HAVE_LANGINFO_CODESET
if (!orig_codeset)
Modified: trunk/keyserver/curl-shim.c
===================================================================
--- trunk/keyserver/curl-shim.c 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/keyserver/curl-shim.c 2008-04-21 19:13:36 UTC (rev 4751)
@@ -89,6 +89,10 @@
{
CURL *handle;
+#ifdef HAVE_W32_SYSTEM
+ w32_init_sockets ();
+#endif
+
handle=calloc(1,sizeof(CURL));
if(handle)
handle->errors=stderr;
Modified: trunk/keyserver/gpgkeys_finger.c
===================================================================
--- trunk/keyserver/gpgkeys_finger.c 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/keyserver/gpgkeys_finger.c 2008-04-21 19:13:36 UTC (rev 4751)
@@ -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,41 +58,7 @@
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. */
static int
@@ -100,12 +66,12 @@
{
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 @@
{
int nwritten;
-#ifdef _WIN32
+#ifdef HAVE_W32_SYSTEM
nwritten = send (sock, data, nleft, 0);
if ( nwritten == SOCKET_ERROR )
{
Modified: trunk/keyserver/ksutil.c
===================================================================
--- trunk/keyserver/ksutil.c 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/keyserver/ksutil.c 2008-04-21 19:13:36 UTC (rev 4751)
@@ -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 @@
#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)
{
Modified: trunk/keyserver/ksutil.h
===================================================================
--- trunk/keyserver/ksutil.h 2008-04-21 07:53:20 UTC (rev 4750)
+++ trunk/keyserver/ksutil.h 2008-04-21 19:13:36 UTC (rev 4751)
@@ -79,6 +79,11 @@
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,
More information about the Gnupg-commits
mailing list