| 1 | /* Copyright (C) 1992-1998 Free Software Foundation, Inc.
|
|---|
| 2 | This file is part of the GNU C Library.
|
|---|
| 3 |
|
|---|
| 4 | The GNU C Library is free software; you can redistribute it and/or
|
|---|
| 5 | modify it under the terms of the GNU Lesser General Public License as
|
|---|
| 6 | published by the Free Software Foundation; either version 3 of the
|
|---|
| 7 | License, or (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | The GNU C Library is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 12 | Library General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 15 | License along with the GNU C Library; see the file COPYING.LIB. If
|
|---|
| 16 | not, 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
|
|---|
| 30 | typedef 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 |
|
|---|
| 45 | static 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 |
|
|---|
| 59 | static int tcgetattr(int fd, struct termio *_t)
|
|---|
| 60 | {
|
|---|
| 61 | return ioctl(fd, TCGETA, _t);
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | static 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 |
|
|---|
| 75 | static 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 |
|
|---|
| 84 | static int tcgetattr(int fd, struct sgttyb *_t)
|
|---|
| 85 | {
|
|---|
| 86 | return ioctl(fd, TIOCGETP, (char *)_t);
|
|---|
| 87 | }
|
|---|
|
|---|