From 2f304957f5122a5d9da643dc9951ee67ece06eaf Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 19 Jan 2012 18:43:10 +0100 Subject: Fix Solaris problems with ttyname_r. * m4/gnupg-ttyname.m4: New. Based on ttyname_r from gnulib. * src/ttyname_r.c (_gpgme_ttyname_r): Rename from ttyname_r. Implement hacks required for Solaris and possible other non-fully Posix systems. * src/util.h: Include unistd.h. Redefine ttyname_r depending on REPLACE_TTYNAME_R and put it into the gpgme name space. -- Unfortunately we cant not use the ttyname_r replacement from gnulib because we want to keep GPGME LGPLv2+. --- src/util.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/util.h') diff --git a/src/util.h b/src/util.h index 6c2cec69..27620aa7 100644 --- a/src/util.h +++ b/src/util.h @@ -1,19 +1,19 @@ -/* util.h +/* util.h Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH This file is part of GPGME. - + GPGME is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + GPGME 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 Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -34,6 +34,10 @@ #ifdef HAVE_SYS_TYPES_H # include #endif +/* We must see the symbol ttyname_r before a redefinition. */ +#ifdef HAVE_UNISTD_H +# include +#endif #include "gpgme.h" @@ -78,11 +82,14 @@ int vasprintf (char **result, const char *format, va_list args); int asprintf (char **result, const char *format, ...); #endif -#ifndef HAVE_TTYNAME_R -int ttyname_r (int fd, char *buf, size_t buflen); -#endif +#if REPLACE_TTYNAME_R +int _gpgme_ttyname_r (int fd, char *buf, size_t buflen); +#undef ttyname_r +#define ttyname_r(a,b,c) _gpgme_ttyname_r ((a), (b), (c)) #endif +#endif /*HAVE_CONFIG_H*/ + /*-- conversion.c --*/ /* Convert two hexadecimal digits from STR to the value they @@ -142,7 +149,7 @@ char *_gpgme_w32ce_get_debug_envvar (void); #ifndef GPG_ERR_UNFINISHED #define GPG_ERR_UNFINISHED 199 #endif -#ifndef GPG_ERR_NOT_OPERATIONAL +#ifndef GPG_ERR_NOT_OPERATIONAL #define GPG_ERR_NOT_OPERATIONAL 176 #endif #ifndef GPG_ERR_MISSING_ISSUER_CERT -- cgit v1.2.3