* 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>
* 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@g10code.com>
* w32-io.c (build_commandline): Quote argv[0].
2005-08-26 Marcus Brinkmann <marcus@g10code.de>
* rungpg.c (command_handler): Use _gpgme_io_write instead of write.

View File

@ -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 @@ ssize_t
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
}

View File

@ -762,27 +762,36 @@ _gpgme_io_set_nonblocking ( int fd )
static char *
build_commandline ( char **argv )
{
int i, n = 0;
char *buf, *p;
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] )
/* 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;
}