From b50a587d8df43b01b5c3b99950aab8fc050b3fe1 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 7 Dec 2004 11:21:40 +0000 Subject: [PATCH] * asshelp.c (send_pinentry_environment) [W32]: Do not use ttyname. * w32-pth.c, w32-pth.h: New. * Makefile.am (gpgsm_LDADD): Put libassuan before jnlib because under W32 we need the w32 pth code from jnlib. * misc.c (setup_pinentry_env) [W32]: Disabled. --- common/ChangeLog | 4 ++++ common/asshelp.c | 5 +++++ configure.ac | 4 ++-- jnlib/ChangeLog | 4 ++++ jnlib/Makefile.am | 4 +++- jnlib/w32-pth.c | 42 ++++++++++++++++++++++++++++++++++++++++++ jnlib/w32-pth.h | 6 +++--- sm/ChangeLog | 7 +++++++ sm/Makefile.am | 5 +++-- sm/misc.c | 3 ++- 10 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 jnlib/w32-pth.c diff --git a/common/ChangeLog b/common/ChangeLog index 8c311f4dc..afdded6d9 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,7 @@ +2004-12-07 Werner Koch + + * asshelp.c (send_pinentry_environment) [W32]: Do not use ttyname. + 2004-12-06 Werner Koch * exechelp.h, exechelp.c: New. Based on code from ../sm/import.c. diff --git a/common/asshelp.c b/common/asshelp.c index 23feca507..751412e6c 100644 --- a/common/asshelp.c +++ b/common/asshelp.c @@ -66,8 +66,13 @@ send_pinentry_environment (assuan_context_t ctx, if (!opt_ttyname) { dft_ttyname = getenv ("GPG_TTY"); +#ifdef HAVE_DOSISH_SYSTEM + if (!dft_ttyname || !*dft_ttyname ) + dft_ttyname = "/dev/tty"; /* Use a fake. */ +#else if ((!dft_ttyname || !*dft_ttyname) && ttyname (0)) dft_ttyname = ttyname (0); +#endif } if (opt_ttyname || dft_ttyname) { diff --git a/configure.ac b/configure.ac index 2b5d21a23..481e52c52 100644 --- a/configure.ac +++ b/configure.ac @@ -345,7 +345,7 @@ try_gettext=yes have_dosish_system=no have_w32_system=no case "${host}" in - *-*-mingw32*) + *-mingw32*) # special stuff for Windoze NT ac_cv_have_dev_random=no AC_DEFINE(USE_ONLY_8DOT3,1, @@ -677,7 +677,7 @@ fi AC_SUBST(GPGKEYS_MAILTO) case "${host}" in - *-*-mingw32*) + *-mingw32*) PRINTABLE_OS_NAME="MingW32" ;; *-*-cygwin*) diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog index 5ca33d5fb..cc3ec9f4f 100644 --- a/jnlib/ChangeLog +++ b/jnlib/ChangeLog @@ -1,3 +1,7 @@ +2004-12-07 Werner Koch + + * w32-pth.c, w32-pth.h: New. + 2004-11-26 Werner Koch * logging.c [_WIN32]: Don't include socket headers. diff --git a/jnlib/Makefile.am b/jnlib/Makefile.am index bad3c5a71..69eac4bf7 100644 --- a/jnlib/Makefile.am +++ b/jnlib/Makefile.am @@ -37,7 +37,9 @@ libjnlib_a_SOURCES = \ argparse.c argparse.h \ logging.c logging.h \ dotlock.c dotlock.h \ - types.h mischelp.h + types.h mischelp.h \ + w32-pth.c w32-pth.h \ + w32-afunix.c w32-afunix.h # xmalloc.c xmalloc.h diff --git a/jnlib/w32-pth.c b/jnlib/w32-pth.c new file mode 100644 index 000000000..c23cebf4a --- /dev/null +++ b/jnlib/w32-pth.c @@ -0,0 +1,42 @@ +/* w32-pth.c - GNU Pth emulation for W32 (MS Windows). + * Copyright (C) 2004 g10 Code GmbH + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#ifdef HAVE_W32_SYSTEM +#include +#include +#include + +#include "w32-pth.h" + +ssize_t +pth_read (int fd, void *buffer, size_t size) +{ + return read (fd, buffer, size); +} + +ssize_t +pth_write (int fd, const void *buffer, size_t size) +{ + return write (fd, buffer, size); +} + + +#endif /*HAVE_W32_SYSTEM*/ diff --git a/jnlib/w32-pth.h b/jnlib/w32-pth.h index b9c03323f..6b57d9bd2 100644 --- a/jnlib/w32-pth.h +++ b/jnlib/w32-pth.h @@ -18,9 +18,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -/* Note that this header is usually through a symlinked pth.h file. - This is needed so that we don't have a pth.h file here which would - conflict if a system really has pth available. */ +/* Note that this header is usually used through a symlinked pth.h + file. This is needed so that we don't have a pth.h file here which + would conflict if a system really has pth available. */ #ifndef W32_PTH_H #define W32_PTH_H diff --git a/sm/ChangeLog b/sm/ChangeLog index 02f0014e8..c1e445e4e 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,10 @@ +2004-12-07 Werner Koch + + * Makefile.am (gpgsm_LDADD): Put libassuan before jnlib because + under W32 we need the w32 pth code from jnlib. + + * misc.c (setup_pinentry_env) [W32]: Disabled. + 2004-12-06 Werner Koch * gpgsm.c (run_protect_tool) [_WIN32]: Disabled. diff --git a/sm/Makefile.am b/sm/Makefile.am index 0cb96c57f..ff4524fc7 100644 --- a/sm/Makefile.am +++ b/sm/Makefile.am @@ -51,8 +51,9 @@ gpgsm_SOURCES = \ certreqgen.c -gpgsm_LDADD = ../jnlib/libjnlib.a ../kbx/libkeybox.a ../common/libcommon.a \ - $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(KSBA_LIBS) -lgpg-error \ +gpgsm_LDADD = $(LIBASSUAN_LIBS) ../jnlib/libjnlib.a ../kbx/libkeybox.a \ + ../common/libcommon.a \ + $(LIBGCRYPT_LIBS) $(KSBA_LIBS) -lgpg-error \ $(LIBINTL) diff --git a/sm/misc.c b/sm/misc.c index bfe8191fd..36c4dda70 100644 --- a/sm/misc.c +++ b/sm/misc.c @@ -38,6 +38,7 @@ void setup_pinentry_env (void) { +#ifndef HAVE_W32_SYSTEM char *lc; if (opt.display) @@ -75,6 +76,6 @@ setup_pinentry_env (void) else if ( (lc = setlocale (LC_MESSAGES, "")) ) setenv ("LC_MESSAGES", lc, 1); #endif - +#endif /*!HAVE_W32_SYSTEM*/ }