source: branches/samba-3.3.x/source/lib/replace/getpass.c@ 259

Last change on this file since 259 was 259, checked in by Herwig Bauernfeind, 16 years ago

Preliminary fix for password prompt (by diver) in 3.3 branch

File size: 5.0 KB
Line 
1/* Copyright (C) 1992-1998 Free Software Foundation, Inc.
2This file is part of the GNU C Library.
3
4The GNU C Library is free software; you can redistribute it and/or
5modify it under the terms of the GNU Lesser General Public License as
6published by the Free Software Foundation; either version 3 of the
7License, or (at your option) any later version.
8
9The GNU C Library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12Library General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public
15License along with the GNU C Library; see the file COPYING.LIB. If
16not, see <http://www.gnu.org/licenses/>. */
17
18/* Modified to use with samba by Jeremy Allison, 8th July 1995. */
19
20#include "replace.h"
21#include "system/filesys.h"
22#include "system/wait.h"
23#include "system/terminal.h"
24#include "system/passwd.h"
25
26/*
27 * Define additional missing types
28 */
29#ifndef HAVE_SIG_ATOMIC_T_TYPE
30typedef int sig_atomic_t;
31#endif
32
33#ifndef SIGCLD
34#define SIGCLD SIGCHLD
35#endif
36
37#ifndef SIGNAL_CAST
38#define SIGNAL_CAST (RETSIGTYPE (*)(int))
39#endif
40
41#ifdef SYSV_TERMIO
42
43/* SYSTEM V TERMIO HANDLING */
44
45static struct termio t;
46
47#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
48#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
49#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
50
51#ifndef TCSAFLUSH
52#define TCSAFLUSH 1
53#endif
54
55#ifndef TCSANOW
56#define TCSANOW 0
57#endif
58
59static int tcgetattr(int fd, struct termio *_t)
60{
61 return ioctl(fd, TCGETA, _t);
62}
63
64static int tcsetattr(int fd, int flags, struct termio *_t)
65{
66 if(flags & TCSAFLUSH)
67 ioctl(fd, TCFLSH, TCIOFLUSH);
68 return ioctl(fd, TCSETS, _t);
69}
70
71#elif !defined(TCSAFLUSH)
72
73/* BSD TERMIO HANDLING */
74
75static struct sgttyb t;
76
77#define ECHO_IS_ON(t) ((t).sg_flags & ECHO)
78#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO)
79#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO)
80
81#define TCSAFLUSH 1
82#define TCSANOW 0
83
84static int tcgetattr(int fd, struct sgttyb *_t)
85{
86 return ioctl(fd, TIOCGETP, (char *)_t);
87}