[svn] gpgme - r1098 - trunk/gpgme

svn author wk cvs at cvs.gnupg.org
Tue Sep 13 16:17:05 CEST 2005


Author: wk
Date: 2005-09-13 16:17:04 +0200 (Tue, 13 Sep 2005)
New Revision: 1098

Modified:
   trunk/gpgme/ChangeLog
   trunk/gpgme/ath.c
   trunk/gpgme/w32-io.c
Log:
* ath.c: Changes to make it work under W32.
* w32-io.c (build_commandline): Quote argv[0].





Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog	2005-09-12 19:15:14 UTC (rev 1097)
+++ trunk/gpgme/ChangeLog	2005-09-13 14:17:04 UTC (rev 1098)
@@ -1,3 +1,7 @@
+2005-09-13  Werner Koch  <wk at g10code.com>
+
+	* ath.c: Changes to make it work under W32.
+
 2005-09-12  Marcus Brinkmann  <marcus at g10code.de>
 
 	* Makefile.am (libgpgme_la_SOURCES): Set to ath.h and ath.c.
@@ -16,6 +20,10 @@
 
 	* keylist.c (release_op_data): Do not free opd->tmp_uid.
 
+2005-09-07  Werner Koch  <wk at g10code.com>
+
+	* w32-io.c (build_commandline): Quote argv[0].
+
 2005-08-26  Marcus Brinkmann  <marcus at g10code.de>
 
 	* rungpg.c (command_handler): Use _gpgme_io_write instead of write.

Modified: trunk/gpgme/ath.c
===================================================================
--- trunk/gpgme/ath.c	2005-09-12 19:15:14 UTC (rev 1097)
+++ trunk/gpgme/ath.c	2005-09-13 14:17:04 UTC (rev 1098)
@@ -30,7 +30,9 @@
 # include <sys/time.h>
 #endif
 #include <sys/types.h>
+#ifndef HAVE_W32_SYSTEM
 #include <sys/wait.h>
+#endif
 
 #include "ath.h"
 
@@ -104,40 +106,64 @@
 ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
 	    struct timeval *timeout)
 {
+#ifdef HAVE_W32_SYSTEM
+  return -1; /* Not supported. */
+#else
   return select (nfd, rset, wset, eset, timeout);
+#endif
 }
 
  
 ssize_t
 ath_waitpid (pid_t pid, int *status, int options)
 {
+#ifdef HAVE_W32_SYSTEM
+  return -1; /* Not supported. */
+#else
   return waitpid (pid, status, options);
+#endif
 }
 
 
 int
 ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
 {
+#ifdef HAVE_W32_SYSTEM
+  return -1; /* Not supported. */
+#else
   return accept (s, addr, length_ptr);
+#endif
 }
 
 
 int
 ath_connect (int s, const struct sockaddr *addr, socklen_t length)
 {
+#ifdef HAVE_W32_SYSTEM
+  return -1; /* Not supported. */
+#else
   return connect (s, addr, length);
+#endif
 }
 
 
 int
 ath_sendmsg (int s, const struct msghdr *msg, int flags)
 {
+#ifdef HAVE_W32_SYSTEM
+  return -1; /* Not supported. */
+#else
   return sendmsg (s, msg, flags);
+#endif
 }
 
 
 int
 ath_recvmsg (int s, struct msghdr *msg, int flags)
 {
+#ifdef HAVE_W32_SYSTEM
+  return -1; /* Not supported. */
+#else
   return recvmsg (s, msg, flags);
+#endif
 }

Modified: trunk/gpgme/w32-io.c
===================================================================
--- trunk/gpgme/w32-io.c	2005-09-12 19:15:14 UTC (rev 1097)
+++ trunk/gpgme/w32-io.c	2005-09-13 14:17:04 UTC (rev 1098)
@@ -762,27 +762,36 @@
 static char *
 build_commandline ( char **argv )
 {
-    int i, n = 0;
-    char *buf, *p;
-
-    /* FIXME: we have to quote some things because under Windows the 
-     * program parses the commandline and does some unquoting */
-    for (i=0; argv[i]; i++)
-        n += strlen (argv[i]) + 2 + 1; /* 2 extra bytes for possible quoting */
-    buf = p = malloc (n);
-    if ( !buf )
-        return NULL;
-    *buf = 0;
-    if ( argv[0] )
+  int i, n = 0;
+  char *buf, *p;
+  
+  /* FIXME: we have to quote some things because under Windows the
+   * program parses the commandline and does some unquoting.  For now
+   * we only do very basic quoting to the first argument because this
+   * one often contains a space (e.g. C:\\Program Files\GNU\GnuPG\gpg.exe) 
+   * and we would produce an invalid line in that case.  */
+  for (i=0; argv[i]; i++)
+    n += strlen (argv[i]) + 2 + 1; /* 2 extra bytes for possible quoting */
+  buf = p = malloc (n);
+  if ( !buf )
+    return NULL;
+  *buf = 0;
+  if ( argv[0] )
+    {
+      if (strpbrk (argv[0], " \t"))
+        p = stpcpy (stpcpy (stpcpy (p, "\""), argv[0]), "\"");
+      else
         p = stpcpy (p, argv[0]);
-    for (i = 1; argv[i]; i++) {
-        if (!*argv[i])
+      for (i = 1; argv[i]; i++)
+        {
+          if (!*argv[i])
             p = stpcpy (p, " \"\"");
-        else
+          else
             p = stpcpy (stpcpy (p, " "), argv[i]);
+        }
     }
-
-    return buf;
+  
+  return buf;
 }
 
 




More information about the Gnupg-commits mailing list