* ath.c: Changes to make it work under W32.

* w32-io.c (build_commandline): Quote argv[0].
This commit is contained in:
Werner Koch 2005-09-13 14:17:04 +00:00
parent c6abbb7901
commit 0df0e97634
3 changed files with 60 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2005-09-13 Werner Koch <wk@g10code.com>
* ath.c: Changes to make it work under W32.
2005-09-12 Marcus Brinkmann <marcus@g10code.de> 2005-09-12 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (libgpgme_la_SOURCES): Set to ath.h and ath.c. * 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. * keylist.c (release_op_data): Do not free opd->tmp_uid.
2005-09-07 Werner Koch <wk@g10code.com>
* w32-io.c (build_commandline): Quote argv[0].
2005-08-26 Marcus Brinkmann <marcus@g10code.de> 2005-08-26 Marcus Brinkmann <marcus@g10code.de>
* rungpg.c (command_handler): Use _gpgme_io_write instead of write. * rungpg.c (command_handler): Use _gpgme_io_write instead of write.

View File

@ -30,7 +30,9 @@
# include <sys/time.h> # include <sys/time.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#ifndef HAVE_W32_SYSTEM
#include <sys/wait.h> #include <sys/wait.h>
#endif
#include "ath.h" #include "ath.h"
@ -104,40 +106,64 @@ ssize_t
ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout) struct timeval *timeout)
{ {
#ifdef HAVE_W32_SYSTEM
return -1; /* Not supported. */
#else
return select (nfd, rset, wset, eset, timeout); return select (nfd, rset, wset, eset, timeout);
#endif
} }
ssize_t ssize_t
ath_waitpid (pid_t pid, int *status, int options) ath_waitpid (pid_t pid, int *status, int options)
{ {
#ifdef HAVE_W32_SYSTEM
return -1; /* Not supported. */
#else
return waitpid (pid, status, options); return waitpid (pid, status, options);
#endif
} }
int int
ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr) 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); return accept (s, addr, length_ptr);
#endif
} }
int int
ath_connect (int s, const struct sockaddr *addr, socklen_t length) 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); return connect (s, addr, length);
#endif
} }
int int
ath_sendmsg (int s, const struct msghdr *msg, int flags) ath_sendmsg (int s, const struct msghdr *msg, int flags)
{ {
#ifdef HAVE_W32_SYSTEM
return -1; /* Not supported. */
#else
return sendmsg (s, msg, flags); return sendmsg (s, msg, flags);
#endif
} }
int int
ath_recvmsg (int s, struct msghdr *msg, int flags) ath_recvmsg (int s, struct msghdr *msg, int flags)
{ {
#ifdef HAVE_W32_SYSTEM
return -1; /* Not supported. */
#else
return recvmsg (s, msg, flags); return recvmsg (s, msg, flags);
#endif
} }

View File

@ -762,27 +762,36 @@ _gpgme_io_set_nonblocking ( int fd )
static char * static char *
build_commandline ( char **argv ) build_commandline ( char **argv )
{ {
int i, n = 0; int i, n = 0;
char *buf, *p; char *buf, *p;
/* FIXME: we have to quote some things because under Windows the /* FIXME: we have to quote some things because under Windows the
* program parses the commandline and does some unquoting */ * program parses the commandline and does some unquoting. For now
for (i=0; argv[i]; i++) * we only do very basic quoting to the first argument because this
n += strlen (argv[i]) + 2 + 1; /* 2 extra bytes for possible quoting */ * one often contains a space (e.g. C:\\Program Files\GNU\GnuPG\gpg.exe)
buf = p = malloc (n); * and we would produce an invalid line in that case. */
if ( !buf ) for (i=0; argv[i]; i++)
return NULL; n += strlen (argv[i]) + 2 + 1; /* 2 extra bytes for possible quoting */
*buf = 0; buf = p = malloc (n);
if ( argv[0] ) 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]); p = stpcpy (p, argv[0]);
for (i = 1; argv[i]; i++) { for (i = 1; argv[i]; i++)
if (!*argv[i]) {
if (!*argv[i])
p = stpcpy (p, " \"\""); p = stpcpy (p, " \"\"");
else else
p = stpcpy (stpcpy (p, " "), argv[i]); p = stpcpy (stpcpy (p, " "), argv[i]);
}
} }
return buf; return buf;
} }