1 /* ttyname_r.c - A ttyname_r() replacement.
2 Copyright (C) 2003, 2004 g10 Code GmbH
4 This file is part of GPGME.
6 GPGME is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of
9 the License, or (at your option) any later version.
11 GPGME is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 # warning ttyname is not thread-safe, and ttyname_r is missing
37 ttyname_r (int fd, char *buf, size_t buflen)
42 /* We use this default one for now. AFAICS we only need it to be
43 passed to gpg and in turn to pinentry. Providing a replacement
44 is needed because elsewhere we bail out on error. If we
45 eventually implement a pinentry for Windows it is uinlikely that
46 we need a real tty at all. */
54 strncpy (buf, tty, buflen);
55 buf[buflen - 1] = '\0';
56 return (strlen (tty) >= buflen) ? ERANGE : 0;