diff options
author | markm <markm@FreeBSD.org> | 2001-11-30 22:09:10 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2001-11-30 22:09:10 +0000 |
commit | 57acab063b3ef9760ddafee33cca79b6f179421a (patch) | |
tree | 872c39a50cab6fcadd1ac8e8806bfb0b5f2c9bd9 /usr.bin/telnet/sys_bsd.c | |
parent | b72e252a0180e401fa4d5bd71ab4374f6f6e2735 (diff) | |
download | FreeBSD-src-57acab063b3ef9760ddafee33cca79b6f179421a.zip FreeBSD-src-57acab063b3ef9760ddafee33cca79b6f179421a.tar.gz |
After running "make unifdef", commit the result. This code is now
a complete subset of the crypto (master) code.
Diffstat (limited to 'usr.bin/telnet/sys_bsd.c')
-rw-r--r-- | usr.bin/telnet/sys_bsd.c | 275 |
1 files changed, 76 insertions, 199 deletions
diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index 7935821..bcb302c 100644 --- a/usr.bin/telnet/sys_bsd.c +++ b/usr.bin/telnet/sys_bsd.c @@ -31,48 +31,34 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> + +__FBSDID("$FreeBSD$"); + #ifndef lint -#if 0 static const char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95"; -#else -static const char rcsid[] = - "$FreeBSD$"; #endif -#endif /* not lint */ /* * The following routines try to encapsulate what is system dependent * (at least between 4.x and dos) which is used in telnet.c. */ - -#include <fcntl.h> #include <sys/types.h> -#include <sys/time.h> #include <sys/socket.h> -#include <signal.h> +#include <sys/time.h> #include <errno.h> -#include <arpa/telnet.h> +#include <fcntl.h> +#include <signal.h> #include <unistd.h> +#include <arpa/telnet.h> #include "ring.h" - #include "fdset.h" - #include "defines.h" #include "externs.h" #include "types.h" -#if defined(USE_TERMIO) && !defined(SYSV_TERMIO) -#define SIG_FUNC_RET void -#else -#define SIG_FUNC_RET int -#endif - -#ifdef SIGINFO -extern SIG_FUNC_RET ayt_status(); -#endif - int tout, /* Output file descriptor */ tin, /* Input file descriptor */ @@ -88,8 +74,7 @@ int olmode = 0; # define old_tc ottyb #else /* USE_TERMIO */ -struct termio old_tc = { 0 }; -extern struct termio new_tc; +struct termio old_tc = { 0, 0, 0, 0, {}, 0, 0 }; # ifndef TCSANOW # ifdef TCSETS @@ -122,9 +107,21 @@ extern struct termio new_tc; static fd_set ibits, obits, xbits; +#ifdef SIGINT +static SIG_FUNC_RET intr(int); +#endif /* SIGINT */ +#ifdef SIGQUIT +static SIG_FUNC_RET intr2(int); +#endif /* SIGQUIT */ +#ifdef SIGTSTP +static SIG_FUNC_RET susp(int); +#endif /* SIGTSTP */ +#ifdef SIGINFO +static SIG_FUNC_RET ayt(int); +#endif - void -init_sys() +void +init_sys(void) { tout = fileno(stdout); tin = fileno(stdin); @@ -135,19 +132,14 @@ init_sys() errno = 0; } - - int -TerminalWrite(buf, n) - char *buf; - int n; +int +TerminalWrite(char *buf, int n) { return write(tout, buf, n); } - int -TerminalRead(buf, n) - char *buf; - int n; +int +TerminalRead(char *buf, int n) { return read(tin, buf, n); } @@ -156,8 +148,8 @@ TerminalRead(buf, n) * */ - int -TerminalAutoFlush() +int +TerminalAutoFlush(void) { #if defined(LNOFLSH) int flush; @@ -184,11 +176,8 @@ extern int kludgelinemode; * 1 Do add this character */ -extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk(); - - int -TerminalSpecialChars(c) - int c; +int +TerminalSpecialChars(int c) { if (c == termIntChar) { intp(); @@ -230,8 +219,8 @@ TerminalSpecialChars(c) * Flush output to the terminal */ - void -TerminalFlushOutput() +void +TerminalFlushOutput(void) { #ifdef TIOCFLUSH (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0); @@ -240,8 +229,8 @@ TerminalFlushOutput() #endif } - void -TerminalSaveState() +void +TerminalSaveState(void) { #ifndef USE_TERMIO ioctl(0, TIOCGETP, (char *)&ottyb); @@ -282,9 +271,8 @@ TerminalSaveState() #endif /* USE_TERMIO */ } - cc_t * -tcval(func) - register int func; +cc_t * +tcval(int func) { switch(func) { case SLC_IP: return(&termIntChar); @@ -325,8 +313,8 @@ tcval(func) } } - void -TerminalDefaultChars() +void +TerminalDefaultChars(void) { #ifndef USE_TERMIO ntc = otc; @@ -359,13 +347,6 @@ TerminalDefaultChars() #endif /* USE_TERMIO */ } -#ifdef notdef -void -TerminalRestoreState() -{ -} -#endif - /* * TerminalNewMode - set up terminal to a specific mode. * MODE_ECHO: do local terminal echo @@ -388,10 +369,8 @@ TerminalRestoreState() * local/no signal mapping */ - - void -TerminalNewMode(f) - register int f; +void +TerminalNewMode(int f) { static int prevmode = 0; #ifndef USE_TERMIO @@ -466,10 +445,6 @@ TerminalNewMode(f) #else tmp_tc.c_lflag &= ~ECHO; tmp_tc.c_oflag &= ~ONLCR; -# ifdef notdef - if (crlf) - tmp_tc.c_iflag &= ~ICRNL; -# endif #endif } @@ -616,19 +591,6 @@ TerminalNewMode(f) } if (f != -1) { -#ifdef SIGINT - SIG_FUNC_RET intr(); -#endif /* SIGINT */ -#ifdef SIGQUIT - SIG_FUNC_RET intr2(); -#endif /* SIGQUIT */ -#ifdef SIGTSTP - SIG_FUNC_RET susp(); -#endif /* SIGTSTP */ -#ifdef SIGINFO - SIG_FUNC_RET ayt(); -#endif - #ifdef SIGINT (void) signal(SIGINT, intr); #endif @@ -681,9 +643,7 @@ TerminalNewMode(f) #endif } else { #ifdef SIGINFO - SIG_FUNC_RET ayt_status(); - - (void) signal(SIGINFO, ayt_status); + (void) signal(SIGINFO, (void (*)(int))ayt_status); #endif #ifdef SIGINT (void) signal(SIGINT, SIG_DFL); @@ -718,17 +678,8 @@ TerminalNewMode(f) tcsetattr(tin, TCSANOW, &tmp_tc); #endif -#if (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR)) -# if !defined(sysV88) ioctl(tin, FIONBIO, (char *)&onoff); ioctl(tout, FIONBIO, (char *)&onoff); -# endif -#endif /* (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR)) */ -#if defined(TN3270) - if (noasynchtty == 0) { - ioctl(tin, FIOASYNC, (char *)&onoff); - } -#endif /* defined(TN3270) */ } @@ -797,15 +748,13 @@ struct termspeeds { }; #endif /* DECODE_BAUD */ - void -TerminalSpeeds(ispeed, ospeed) - long *ispeed; - long *ospeed; +void +TerminalSpeeds(long *ispeed, long *ospeed) { #ifdef DECODE_BAUD - register struct termspeeds *tp; + struct termspeeds *tp; #endif /* DECODE_BAUD */ - register long in, out; + long in, out; out = cfgetospeed(&old_tc); in = cfgetispeed(&old_tc); @@ -828,9 +777,8 @@ TerminalSpeeds(ispeed, ospeed) #endif /* DECODE_BAUD */ } - int -TerminalWindowSize(rows, cols) - long *rows, *cols; +int +TerminalWindowSize(long *rows, long *cols) { #ifdef TIOCGWINSZ struct winsize ws; @@ -844,59 +792,34 @@ TerminalWindowSize(rows, cols) return 0; } - int -NetClose(fd) - int fd; +int +NetClose(int fd) { return close(fd); } - - void -NetNonblockingIO(fd, onoff) - int fd; - int onoff; +static void +NetNonblockingIO(int fd, int onoff) { ioctl(fd, FIONBIO, (char *)&onoff); } -#if defined(TN3270) - void -NetSigIO(fd, onoff) - int fd; - int onoff; -{ - ioctl(fd, FIOASYNC, (char *)&onoff); /* hear about input */ -} - - void -NetSetPgrp(fd) - int fd; -{ - int myPid; - - myPid = getpid(); - fcntl(fd, F_SETOWN, myPid); -} -#endif /*defined(TN3270)*/ /* * Various signal handling routines. */ - /* ARGSUSED */ - SIG_FUNC_RET -deadpeer(sig) - int sig; +/* ARGSUSED */ +static SIG_FUNC_RET +deadpeer(int sig __unused) { setcommandmode(); longjmp(peerdied, -1); } - /* ARGSUSED */ - SIG_FUNC_RET -intr(sig) - int sig; +/* ARGSUSED */ +SIG_FUNC_RET +intr(int sig __unused) { if (localchars) { intp(); @@ -906,10 +829,9 @@ intr(sig) longjmp(toplevel, -1); } - /* ARGSUSED */ - SIG_FUNC_RET -intr2(sig) - int sig; +/* ARGSUSED */ +SIG_FUNC_RET +intr2(int sig __unused) { if (localchars) { #ifdef KLUDGELINEMODE @@ -923,10 +845,9 @@ intr2(sig) } #ifdef SIGTSTP - /* ARGSUSED */ - SIG_FUNC_RET -susp(sig) - int sig; +/* ARGSUSED */ +SIG_FUNC_RET +susp(int sig __unused) { if ((rlogin != _POSIX_VDISABLE) && rlogin_susp()) return; @@ -936,10 +857,9 @@ susp(sig) #endif #ifdef SIGWINCH - /* ARGSUSED */ - SIG_FUNC_RET -sendwin(sig) - int sig; +/* ARGSUSED */ +static SIG_FUNC_RET +sendwin(int sig __unused) { if (connected) { sendnaws(); @@ -948,10 +868,9 @@ sendwin(sig) #endif #ifdef SIGINFO - /* ARGSUSED */ - SIG_FUNC_RET -ayt(sig) - int sig; +/* ARGSUSED */ +SIG_FUNC_RET +ayt(int sig __unused) { if (connected) sendayt(); @@ -961,8 +880,8 @@ ayt(sig) #endif - void -sys_telnet_init() +void +sys_telnet_init(void) { (void) signal(SIGINT, intr); (void) signal(SIGQUIT, intr2); @@ -981,13 +900,6 @@ sys_telnet_init() NetNonblockingIO(net, 1); -#if defined(TN3270) - if (noasynchnet == 0) { /* DBX can't handle! */ - NetSigIO(net, 1); - NetSetPgrp(net); - } -#endif /* defined(TN3270) */ - #if defined(SO_OOBINLINE) if (SetSockOpt(net, SOL_SOCKET, SO_OOBINLINE, 1) == -1) { perror("SetSockOpt"); @@ -1006,18 +918,12 @@ sys_telnet_init() * The return value is 1 if something happened, 0 if not. */ - int -process_rings(netin, netout, netex, ttyin, ttyout, poll) - int poll; /* If 0, then block until something to do */ +int +process_rings(int netin, int netout, int netex, int ttyin, int ttyout, int poll) { - register int c; - /* One wants to be a bit careful about setting returnValue - * to one, since a one implies we did some useful work, - * and therefore probably won't be called to block next - * time (TN3270 mode only). - */ + int c; int returnValue = 0; - static struct timeval TimeValue = { 0 }; + static struct timeval TimeValue = { 0, 0 }; if (netout) { FD_SET(net, &obits); @@ -1025,24 +931,12 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll) if (ttyout) { FD_SET(tout, &obits); } -#if defined(TN3270) if (ttyin) { FD_SET(tin, &ibits); } -#else /* defined(TN3270) */ - if (ttyin) { - FD_SET(tin, &ibits); - } -#endif /* defined(TN3270) */ -#if defined(TN3270) - if (netin) { - FD_SET(net, &ibits); - } -# else /* !defined(TN3270) */ if (netin) { FD_SET(net, &ibits); } -# endif /* !defined(TN3270) */ if (netex) { FD_SET(net, &xbits); } @@ -1057,23 +951,6 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll) if (errno == EINTR) { return 0; } -# if defined(TN3270) - /* - * we can get EBADF if we were in transparent - * mode, and the transcom process died. - */ - if (errno == EBADF) { - /* - * zero the bits (even though kernel does it) - * to make sure we are selecting on the right - * ones. - */ - FD_ZERO(&ibits); - FD_ZERO(&obits); - FD_ZERO(&xbits); - return 0; - } -# endif /* defined(TN3270) */ /* I don't like this, does it ever happen? */ printf("sleep(5) from telnet, after select: %s\r\n", strerror(errno)); sleep(5); |