Latest & greatest version of telnet
authorPaul Borman <borman@ucbvax.Berkeley.EDU>
Wed, 15 Nov 1989 02:20:26 +0000 (18:20 -0800)
committerPaul Borman <borman@ucbvax.Berkeley.EDU>
Wed, 15 Nov 1989 02:20:26 +0000 (18:20 -0800)
SCCS-vsn: usr.bin/telnet/terminal.c 1.17
SCCS-vsn: usr.bin/telnet/externs.h 1.20
SCCS-vsn: usr.bin/telnet/telnet.c 5.44
SCCS-vsn: usr.bin/telnet/sys_bsd.c 1.22
SCCS-vsn: usr.bin/telnet/utilities.c 1.16
SCCS-vsn: usr.bin/telnet/main.c 1.12
SCCS-vsn: usr.bin/telnet/commands.c 1.23

usr/src/usr.bin/telnet/commands.c
usr/src/usr.bin/telnet/externs.h
usr/src/usr.bin/telnet/main.c
usr/src/usr.bin/telnet/sys_bsd.c
usr/src/usr.bin/telnet/telnet.c
usr/src/usr.bin/telnet/terminal.c
usr/src/usr.bin/telnet/utilities.c

index 1e3e9be..3c646df 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)commands.c 1.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)commands.c 1.23 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -47,9 +47,9 @@ static char sccsid[] = "@(#)commands.c        1.22 (Berkeley) %G%";
 #ifdef SRCRT
 # ifndef CRAY
 # include <netinet/in_systm.h>
 #ifdef SRCRT
 # ifndef CRAY
 # include <netinet/in_systm.h>
-#  ifndef sun
+#  if defined(vax) || defined(tahoe)
 #  include <machine/endian.h>
 #  include <machine/endian.h>
-#  endif /* sun */
+#  endif /* vax */
 # endif /* CRAY */
 #include <netinet/ip.h>
 #endif /* SRCRT */
 # endif /* CRAY */
 #include <netinet/ip.h>
 #endif /* SRCRT */
@@ -758,7 +758,7 @@ struct setlist {
     char *name;                                /* name */
     char *help;                                /* help information */
     void (*handler)();
     char *name;                                /* name */
     char *help;                                /* help information */
     void (*handler)();
-    char *charp;                       /* where it is located at */
+    unsigned char *charp;                      /* where it is located at */
 };
 
 static struct setlist Setlist[] = {
 };
 
 static struct setlist Setlist[] = {
@@ -767,9 +767,7 @@ static struct setlist Setlist[] = {
     { "tracefile", "file to write trace intormation to", SetNetTrace, NetTraceFile},
     { " ", "" },
     { " ", "The following need 'localchars' to be toggled true", 0, 0 },
     { "tracefile", "file to write trace intormation to", SetNetTrace, NetTraceFile},
     { " ", "" },
     { " ", "The following need 'localchars' to be toggled true", 0, 0 },
-#ifndef        CRAY
     { "flushoutput", "character to cause an Abort Oubput", 0, termFlushCharp },
     { "flushoutput", "character to cause an Abort Oubput", 0, termFlushCharp },
-#endif
     { "interrupt", "character to cause an Interrupt Process", 0, termIntCharp },
     { "quit",  "character to cause an Abort process", 0, termQuitCharp },
     { "eof",   "character to cause an EOF ", 0, termEofCharp },
     { "interrupt", "character to cause an Interrupt Process", 0, termIntCharp },
     { "quit",  "character to cause an Abort process", 0, termQuitCharp },
     { "eof",   "character to cause an EOF ", 0, termEofCharp },
@@ -777,14 +775,12 @@ static struct setlist Setlist[] = {
     { " ", "The following are for local editing in linemode", 0, 0 },
     { "erase", "character to use to erase a character", 0, termEraseCharp },
     { "kill",  "character to use to erase a line", 0, termKillCharp },
     { " ", "The following are for local editing in linemode", 0, 0 },
     { "erase", "character to use to erase a character", 0, termEraseCharp },
     { "kill",  "character to use to erase a line", 0, termKillCharp },
-#ifndef        CRAY
     { "lnext", "character to use for literal next", 0, termLiteralNextCharp },
     { "susp",  "character to cuase a Suspend Process", 0, termSuspCharp },
     { "reprint", "character to use for line reprint", 0, termRprntCharp },
     { "worderase", "character to use to erase a word", 0, termWerasCharp },
     { "start", "character to use for XON", 0, termStartCharp },
     { "stop",  "character to sue for XOFF", 0, termStopCharp },
     { "lnext", "character to use for literal next", 0, termLiteralNextCharp },
     { "susp",  "character to cuase a Suspend Process", 0, termSuspCharp },
     { "reprint", "character to use for line reprint", 0, termRprntCharp },
     { "worderase", "character to use to erase a word", 0, termWerasCharp },
     { "start", "character to use for XON", 0, termStartCharp },
     { "stop",  "character to sue for XOFF", 0, termStopCharp },
-#endif
     { 0 }
 };
 
     { 0 }
 };
 
@@ -792,11 +788,18 @@ static struct setlist Setlist[] = {
 /* Work around compiler bug */
 _setlist_init()
 {
 /* Work around compiler bug */
 _setlist_init()
 {
+       Setlist[5].charp = &termFlushChar;
        Setlist[6].charp = &termIntChar;
        Setlist[7].charp = &termQuitChar;
        Setlist[8].charp = &termEofChar;
        Setlist[11].charp = &termEraseChar;
        Setlist[12].charp = &termKillChar;
        Setlist[6].charp = &termIntChar;
        Setlist[7].charp = &termQuitChar;
        Setlist[8].charp = &termEofChar;
        Setlist[11].charp = &termEraseChar;
        Setlist[12].charp = &termKillChar;
+       Setlist[13].charp = &termLiteralNextChar;
+       Setlist[14].charp = &termSuspChar;
+       Setlist[15].charp = &termRprntChar;
+       Setlist[16].charp = &termWerasChar;
+       Setlist[17].charp = &termStartChar;
+       Setlist[18].charp = &termStopChar;
 }
 #endif /* CRAY */
 
 }
 #endif /* CRAY */
 
@@ -1030,12 +1033,12 @@ extern int modehelp();
 
 static struct modelist ModeList[] = {
     { "character", "Disable LINEMODE option",  docharmode, 1 },
 
 static struct modelist ModeList[] = {
     { "character", "Disable LINEMODE option",  docharmode, 1 },
-#ifdef KLUDEGLINEMODE
-    { "",      "(or disable obsolete line-by-line mode)", 0 };
+#ifdef KLUDGELINEMODE
+    { "",      "(or disable obsolete line-by-line mode)", 0 },
 #endif
     { "line",  "Enable LINEMODE option",       dolinemode, 1 },
 #endif
     { "line",  "Enable LINEMODE option",       dolinemode, 1 },
-#ifdef KLUDEGLINEMODE
-    { "",      "(or enable obsolete line-by-line mode)", 0 };
+#ifdef KLUDGELINEMODE
+    { "",      "(or enable obsolete line-by-line mode)", 0 },
 #endif
     { "", "", 0 },
     { "",      "These require the LINEMODE option to be enabled", 0 },
 #endif
     { "", "", 0 },
     { "",      "These require the LINEMODE option to be enabled", 0 },
@@ -1241,9 +1244,6 @@ suspend()
 }
 
 #if    !defined(TN3270)
 }
 
 #if    !defined(TN3270)
-#ifdef CRAY
-#define        vfork   fork
-#endif
 shell(argc, argv)
 int argc;
 char *argv[];
 shell(argc, argv)
 int argc;
 char *argv[];
@@ -1513,7 +1513,7 @@ char      *argv[];
                                        (mode&MODE_TRAPSIG) ? "Local" : "No");
                slcstate();
 #ifdef KLUDGELINEMODE
                                        (mode&MODE_TRAPSIG) ? "Local" : "No");
                slcstate();
 #ifdef KLUDGELINEMODE
-           } else if (kludgelinemode && my_want_state_is_wont(TELOPT_SGA)) {
+           } else if (kludgelinemode && my_want_state_is_dont(TELOPT_SGA)) {
                printf("Operating in obsolete linemode\n");
 #endif
            } else {
                printf("Operating in obsolete linemode\n");
 #endif
            } else {
@@ -1581,10 +1581,6 @@ tn(argc, argv)
 #endif
 
 
 #endif
 
 
-#if defined(MSDOS)
-    char *cp;
-#endif /* defined(MSDOS) */
-
     if (connected) {
        printf("?Already connected to %s\n", hostname);
        return 0;
     if (connected) {
        printf("?Already connected to %s\n", hostname);
        return 0;
@@ -1601,13 +1597,6 @@ tn(argc, argv)
        printf("usage: %s host-name [port]\n", argv[0]);
        return 0;
     }
        printf("usage: %s host-name [port]\n", argv[0]);
        return 0;
     }
-#if    defined(MSDOS)
-    for (cp = argv[1]; *cp; cp++) {
-       if (isupper(*cp)) {
-           *cp = tolower(*cp);
-       }
-    }
-#endif /* defined(MSDOS) */
 #if    defined(SRCRT) && defined(IPPROTO_IP)
     if (argv[1][0] == '@' || argv[1][0] == '!') {
        if ((hostname = strrchr(argv[1], ':')) == NULL)
 #if    defined(SRCRT) && defined(IPPROTO_IP)
     if (argv[1][0] == '@' || argv[1][0] == '!') {
        if ((hostname = strrchr(argv[1], ':')) == NULL)
index 8d7b0f4..497e466 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)externs.h   1.19 (Berkeley) %G%
+ *     @(#)externs.h   1.20 (Berkeley) %G%
  */
 
  */
 
-#ifdef CRAY
-#define        USE_TERMIO
+#ifndef        BSD
+# define BSD 43
+#endif
+
+#if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO)
+# define USE_TERMIO
 #endif
 
 #include <stdio.h>
 #include <setjmp.h>
 #include <sys/ioctl.h>
 #ifdef USE_TERMIO
 #endif
 
 #include <stdio.h>
 #include <setjmp.h>
 #include <sys/ioctl.h>
 #ifdef USE_TERMIO
-#ifndef        VINTR
-#include <sys/termio.h>
-#endif
+# ifndef       VINTR
+#  ifdef SYSV_TERMIO
+#   include <sys/termio.h>
+#  else
+#   include <sys/termios.h>
+#   define termio termios
+#  endif
+# endif
 #endif
 
 #define        SUBBUFSIZE      256
 #endif
 
 #define        SUBBUFSIZE      256
@@ -69,16 +78,18 @@ extern int
 #endif /* defined(unix) */
     debug;                     /* Debug level */
 
 #endif /* defined(unix) */
     debug;                     /* Debug level */
 
+extern unsigned char
+    echoc,             /* Toggle local echoing */
+    escape,            /* Escape to command mode */
+    *prompt;           /* Prompt for command. */
+
 extern char
 extern char
-    echoc,                     /* Toggle local echoing */
-    escape,                    /* Escape to command mode */
     doopt[],
     dont[],
     will[],
     wont[],
     options[],         /* All the little options */
     doopt[],
     dont[],
     will[],
     wont[],
     options[],         /* All the little options */
-    *hostname,         /* Who are we connected to? */
-    *prompt;           /* Prompt for command. */
+    *hostname;         /* Who are we connected to? */
 
 /*
  * We keep track of each side of the option negotiation.
 
 /*
  * We keep track of each side of the option negotiation.
@@ -145,7 +156,7 @@ extern char
 
 extern FILE
     *NetTrace;         /* Where debugging output goes */
 
 extern FILE
     *NetTrace;         /* Where debugging output goes */
-extern char
+extern unsigned char
     NetTraceFile[];    /* Name of file where debugging output goes */
 extern void
     SetNetTrace();     /* Function to change where debugging goes */
     NetTraceFile[];    /* Name of file where debugging output goes */
 extern void
     SetNetTrace();     /* Function to change where debugging goes */
@@ -184,72 +195,90 @@ extern int
     dosynch();
 #endif /* defined(NOT43) */
 
     dosynch();
 #endif /* defined(NOT43) */
 
-#if    !defined(MSDOS)
-# ifndef       USE_TERMIO
+#ifndef        USE_TERMIO
 
 extern struct  tchars ntc;
 extern struct  ltchars nltc;
 extern struct  sgttyb nttyb;
 
 
 extern struct  tchars ntc;
 extern struct  ltchars nltc;
 extern struct  sgttyb nttyb;
 
-#  define termEofChar          ntc.t_eofc
-#  define termEraseChar                nttyb.sg_erase
-#  define termFlushChar                nltc.t_flushc
-#  define termIntChar          ntc.t_intrc
-#  define termKillChar         nttyb.sg_kill
-#  define termLiteralNextChar  nltc.t_lnextc
-#  define termQuitChar         ntc.t_quitc
-#  define termSuspChar         nltc.t_suspc
-#  define termRprntChar                nltc.t_rprntc
-#  define termWerasChar                nltc.t_werasc
-#  define termStartChar                ntc.t_startc
-#  define termStopChar         ntc.t_stopc
-
-#  define termEofCharp         &ntc.t_eofc
-#  define termEraseCharp       &nttyb.sg_erase
-#  define termFlushCharp       &nltc.t_flushc
-#  define termIntCharp         &ntc.t_intrc
-#  define termKillCharp                &nttyb.sg_kill
-#  define termLiteralNextCharp &nltc.t_lnextc
-#  define termQuitCharp                &ntc.t_quitc
-#  define termSuspCharp                &nltc.t_suspc
-#  define termRprntCharp       &nltc.t_rprntc
-#  define termWerasCharp       &nltc.t_werasc
-#  define termStartCharp       &ntc.t_startc
-#  define termStopCharp                &ntc.t_stopc
+# define termEofChar           ntc.t_eofc
+# define termEraseChar         nttyb.sg_erase
+# define termFlushChar         nltc.t_flushc
+# define termIntChar           ntc.t_intrc
+# define termKillChar          nttyb.sg_kill
+# define termLiteralNextChar   nltc.t_lnextc
+# define termQuitChar          ntc.t_quitc
+# define termSuspChar          nltc.t_suspc
+# define termRprntChar         nltc.t_rprntc
+# define termWerasChar         nltc.t_werasc
+# define termStartChar         ntc.t_startc
+# define termStopChar          ntc.t_stopc
+
+# define termEofCharp          (unsigned char *)&ntc.t_eofc
+# define termEraseCharp                (unsigned char *)&nttyb.sg_erase
+# define termFlushCharp                (unsigned char *)&nltc.t_flushc
+# define termIntCharp          (unsigned char *)&ntc.t_intrc
+# define termKillCharp         (unsigned char *)&nttyb.sg_kill
+# define termLiteralNextCharp  (unsigned char *)&nltc.t_lnextc
+# define termQuitCharp         (unsigned char *)&ntc.t_quitc
+# define termSuspCharp         (unsigned char *)&nltc.t_suspc
+# define termRprntCharp                (unsigned char *)&nltc.t_rprntc
+# define termWerasCharp                (unsigned char *)&nltc.t_werasc
+# define termStartCharp                (unsigned char *)&ntc.t_startc
+# define termStopCharp         (unsigned char *)&ntc.t_stopc
 
 # else
 
 extern struct  termio new_tc;
 
 
 # else
 
 extern struct  termio new_tc;
 
-#  define termEofChar          new_tc.c_cc[VEOF]
-#  define termEraseChar                new_tc.c_cc[VERASE]
-#  define termIntChar          new_tc.c_cc[VINTR]
-#  define termKillChar         new_tc.c_cc[VKILL]
-#  define termQuitChar         new_tc.c_cc[VQUIT]
+# define termEofChar           new_tc.c_cc[VEOF]
+# define termEraseChar         new_tc.c_cc[VERASE]
+# define termIntChar           new_tc.c_cc[VINTR]
+# define termKillChar          new_tc.c_cc[VKILL]
+# define termQuitChar          new_tc.c_cc[VQUIT]
 
 
-extern char
-    termSuspChar,
-    termFlushChar,
-    termWerasChar,
-    termRprntChar,
-    termLiteralNextChar,
-    termStartChar,
-    termStopChar;
-
-# ifndef CRAY
-#  define termEofCharp         &new_tc.c_cc[VEOF]
-#  define termEraseCharp       &new_tc.c_cc[VERASE]
-#  define termIntCharp         &new_tc.c_cc[VINTR]
-#  define termKillCharp                &new_tc.c_cc[VKILL]
-#  define termQuitCharp                &new_tc.c_cc[VQUIT]
+# ifndef       VSUSP
+extern char termSuspChar;
 # else
 # else
-       /* Work around a compiler bug */
-#  define termEofCharp         0
-#  define termEraseCharp       0
-#  define termIntCharp         0
-#  define termKillCharp                0
-#  define termQuitCharp                0
+#  define termSuspChar         new_tc.c_cc[VSUSP]
+# endif
+# ifndef       VFLUSHO
+extern char termFlushChar;
+# else
+#  define termFlushChar                new_tc.c_cc[VFLUSHO]
+# endif
+# ifndef VWERASE
+extern char termWerasChar;
+# else
+#  define termWerasChar                new_tc.c_cc[VWERASE]
 # endif
 # endif
+# ifndef       VREPRINT
+extern char termRprntChar;
+# else
+#  define termRprntChar                new_tc.c_cc[VREPRINT]
+# endif
+# ifndef       VLNEXT
+extern char termLiteralNextChar;
+# else
+#  define termLiteralNextChar  new_tc.c_cc[VLNEXT]
+# endif
+# ifndef       VSTART
+extern char termStartChar;
+# else
+#  define termStartChar                new_tc.c_cc[VSTART]
+# endif
+# ifndef       VSTOP
+extern char termStopChar;
+# else
+#  define termStopChar         new_tc.c_cc[VSTOP]
+# endif
+
+# ifndef CRAY
+#  define termEofCharp         &termEofChar
+#  define termEraseCharp       &termEraseChar
+#  define termIntCharp         &termIntChar
+#  define termKillCharp                &termKillChar
+#  define termQuitCharp                &termQuitChar
 #  define termSuspCharp                &termSuspChar
 #  define termFlushCharp       &termFlushChar
 #  define termWerasCharp       &termWerasChar
 #  define termSuspCharp                &termSuspChar
 #  define termFlushCharp       &termFlushChar
 #  define termWerasCharp       &termWerasChar
@@ -257,24 +286,21 @@ extern char
 #  define termLiteralNextCharp &termLiteralNextChar
 #  define termStartCharp       &termStartChar
 #  define termStopCharp                &termStopChar
 #  define termLiteralNextCharp &termLiteralNextChar
 #  define termStartCharp       &termStartChar
 #  define termStopCharp                &termStopChar
+# else
+       /* Work around a compiler bug */
+#  define termEofCharp         0
+#  define termEraseCharp       0
+#  define termIntCharp         0
+#  define termKillCharp                0
+#  define termQuitCharp                0
+#  define termSuspCharp                0
+#  define termFlushCharp       0
+#  define termWerasCharp       0
+#  define termRprntCharp       0
+#  define termLiteralNextCharp 0
+#  define termStartCharp       0
+#  define termStopCharp                0
 # endif
 # endif
-
-#else  /* MSDOS */
-
-extern char
-    termEofChar,
-    termEraseChar,
-    termIntChar,
-    termKillChar,
-    termQuitChar,
-    termSuspChar,
-    termFlushChar,
-    termWerasChar,
-    termRprntChar,
-    termLiteralNextChar,
-    termStartChar,
-    termStopChar;
-
 #endif
 
 
 #endif
 
 
index f2464fe..c20f4c3 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     1.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     1.12 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -68,7 +68,7 @@ main(argc, argv)
 
     TerminalSaveState();
 
 
     TerminalSaveState();
 
-    prompt = argv[0];
+    prompt = (unsigned char *)argv[0];
     while ((argc > 1) && (argv[1][0] == '-')) {
        if (!strcmp(argv[1], "-d")) {
            debug = 1;
     while ((argc > 1) && (argv[1][0] == '-')) {
        if (!strcmp(argv[1], "-d")) {
            debug = 1;
index d16647a..9137d05 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sys_bsd.c  1.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)sys_bsd.c  1.22 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -24,7 +24,6 @@ static char sccsid[] = "@(#)sys_bsd.c 1.21 (Berkeley) %G%";
  * (at least between 4.x and dos) which is used in telnet.c.
  */
 
  * (at least between 4.x and dos) which is used in telnet.c.
  */
 
-#if    defined(unix)
 
 #include <fcntl.h>
 #include <sys/types.h>
 
 #include <fcntl.h>
 #include <sys/types.h>
@@ -53,14 +52,10 @@ struct      ltchars oltc = { 0 }, nltc = { 0 };
 struct sgttyb ottyb = { 0 }, nttyb = { 0 };
 int    olmode = 0;
 
 struct sgttyb ottyb = { 0 }, nttyb = { 0 };
 int    olmode = 0;
 
-#define        ISPEED  ottyb.sg_ispeed
-#define        OSPEED  ottyb.sg_ospeed
 #else  /* USE_TERMIO */
 struct termio old_tc = { 0 };
 extern struct termio new_tc;
 
 #else  /* USE_TERMIO */
 struct termio old_tc = { 0 };
 extern struct termio new_tc;
 
-#define        ISPEED  (old_tc.c_cflag&CBAUD)
-#define        OSPEED  ISPEED
 #endif /* USE_TERMIO */
 
 static fd_set ibits, obits, xbits;
 #endif /* USE_TERMIO */
 
 static fd_set ibits, obits, xbits;
@@ -173,7 +168,7 @@ int c;
 void
 TerminalFlushOutput()
 {
 void
 TerminalFlushOutput()
 {
-#ifndef        USE_TERMIO
+#ifdef TIOCFLUSH
     (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
 #else
     (void) ioctl(fileno(stdout), TCFLSH, (char *) 0);
     (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
 #else
     (void) ioctl(fileno(stdout), TCFLSH, (char *) 0);
@@ -207,25 +202,26 @@ TerminalSaveState()
 #endif /* USE_TERMIO */
 }
 
 #endif /* USE_TERMIO */
 }
 
+unsigned
 char *
 tcval(func)
 register int func;
 {
     switch(func) {
 char *
 tcval(func)
 register int func;
 {
     switch(func) {
-    case SLC_IP:       return(&termIntChar);
-    case SLC_ABORT:    return(&termQuitChar);
-    case SLC_EOF:      return(&termEofChar);
-    case SLC_EC:       return(&termEraseChar);
-    case SLC_EL:       return(&termKillChar);
-    case SLC_XON:      return(&termStartChar);
-    case SLC_XOFF:     return(&termStopChar);
-#ifndef        CRAY
-    case SLC_AO:       return(&termFlushChar);
-    case SLC_SUSP:     return(&termSuspChar);
-    case SLC_EW:       return(&termWerasChar);
-    case SLC_RP:       return(&termRprntChar);
-    case SLC_LNEXT:    return(&termLiteralNextChar);
-#endif /* CRAY */
+    case SLC_IP:       return((unsigned char *)&termIntChar);
+    case SLC_ABORT:    return((unsigned char *)&termQuitChar);
+    case SLC_EOF:      return((unsigned char *)&termEofChar);
+    case SLC_EC:       return((unsigned char *)&termEraseChar);
+    case SLC_EL:       return((unsigned char *)&termKillChar);
+    case SLC_XON:      return((unsigned char *)&termStartChar);
+    case SLC_XOFF:     return((unsigned char *)&termStopChar);
+#ifndef        SYSV_TERMIO
+    case SLC_AO:       return((unsigned char *)&termFlushChar);
+    case SLC_SUSP:     return((unsigned char *)&termSuspChar);
+    case SLC_EW:       return((unsigned char *)&termWerasChar);
+    case SLC_RP:       return((unsigned char *)&termRprntChar);
+    case SLC_LNEXT:    return((unsigned char *)&termLiteralNextChar);
+#endif /* SYSV_TERMIO */
 
     case SLC_SYNCH:
     case SLC_BRK:
 
     case SLC_SYNCH:
     case SLC_BRK:
@@ -234,7 +230,7 @@ register int func;
     case SLC_FORW1:
     case SLC_FORW2:
     default:
     case SLC_FORW1:
     case SLC_FORW2:
     default:
-       return((char *)0);
+       return((unsigned char *)0);
     }
 }
 
     }
 }
 
@@ -248,12 +244,24 @@ TerminalDefaultChars()
     nttyb.sg_erase = ottyb.sg_erase;
 #else  /* USE_TERMIO */
     memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
     nttyb.sg_erase = ottyb.sg_erase;
 #else  /* USE_TERMIO */
     memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
+# ifndef       VFLUSHO
     termFlushChar = 'O'&0x37;
     termFlushChar = 'O'&0x37;
+# endif
+# ifndef       VWERASE
     termWerasChar = 'W'&0x37;
     termWerasChar = 'W'&0x37;
+# endif
+# ifndef       VREPRINT
     termRprntChar = 'R'&0x37;
     termRprntChar = 'R'&0x37;
+# endif
+# ifndef       VLNEXT
     termLiteralNextChar = 'V'&0x37;
     termLiteralNextChar = 'V'&0x37;
+# endif
+# ifndef       VSTART
     termStartChar = 'Q'&0x37;
     termStartChar = 'Q'&0x37;
+# endif
+# ifndef       VSTOP
     termStopChar = 'S'&0x37;
     termStopChar = 'S'&0x37;
+# endif
 #endif /* USE_TERMIO */
 }
 
 #endif /* USE_TERMIO */
 }
 
@@ -349,7 +357,9 @@ register int f;
 #else
        tmp_tc.c_lflag |= ECHO;
        tmp_tc.c_oflag |= ONLCR;
 #else
        tmp_tc.c_lflag |= ECHO;
        tmp_tc.c_oflag |= ONLCR;
+# ifdef notdef
        tmp_tc.c_iflag |= ICRNL;
        tmp_tc.c_iflag |= ICRNL;
+# endif
 #endif
     } else {
 #ifndef        USE_TERMIO
 #endif
     } else {
 #ifndef        USE_TERMIO
@@ -357,7 +367,9 @@ register int f;
 #else
        tmp_tc.c_lflag &= ~ECHO;
        tmp_tc.c_oflag &= ~ONLCR;
 #else
        tmp_tc.c_lflag &= ~ECHO;
        tmp_tc.c_oflag &= ~ONLCR;
+# ifdef notdef
        tmp_tc.c_iflag &= ~ICRNL;
        tmp_tc.c_iflag &= ~ICRNL;
+# endif
 #endif
     }
 
 #endif
     }
 
@@ -416,46 +428,70 @@ register int f;
        onoff = 0;
     } else {
 #ifndef        USE_TERMIO
        onoff = 0;
     } else {
 #ifndef        USE_TERMIO
-       if (his_want_state_is_will(TELOPT_BINARY))
+       if (f & MODE_OUTBIN)
                lmode |= LLITOUT;
        else
                lmode &= ~LLITOUT;
                lmode |= LLITOUT;
        else
                lmode &= ~LLITOUT;
-       if (my_want_state_is_will(TELOPT_BINARY))
+
+       if (f & MODE_INBIN)
                lmode |= LPASS8;
        else
                lmode &= ~LPASS8;
 #else
                lmode |= LPASS8;
        else
                lmode &= ~LPASS8;
 #else
-       if (my_want_state_is_will(TELOPT_BINARY))
-               tmp.tc.c_lflag &= ~ISTRIP;
+       if (f & MODE_OUTBIN)
+               tmp_tc.c_lflag &= ~ISTRIP;
        else
        else
-               tmp.tc.c_lflag |= ISTRIP;
+               tmp_tc.c_lflag |= ISTRIP;
+       if (f & MODE_INBIN) {
+               tmp_tc.c_cflag &= ~(CSIZE|PARENB);
+               tmp_tc.c_cflag |= CS8;
+               tmp_tc.c_cflag &= ~OPOST;
+       } else {
+               tmp_tc.c_cflag &= ~CSIZE;
+               tmp_tc.c_cflag |= CS7|PARENB;
+               tmp_tc.c_cflag |= OPOST;
+       }
 #endif
        onoff = 1;
     }
 
 #endif
        onoff = 1;
     }
 
-#ifndef        USE_TERMIO
     if (f != -1) {
     if (f != -1) {
+#ifdef SIGTSTP
        if (f&MODE_EDIT) {
            void doescape();
 
        if (f&MODE_EDIT) {
            void doescape();
 
+# ifndef USE_TERMIO
            ltc.t_suspc = escape;
            ltc.t_suspc = escape;
+# else
+           tmp_tc.c_cc[VSUSP] = escape;
+# endif
            (void) signal(SIGTSTP, (int (*)())doescape);
        } else if (old&MODE_EDIT) {
            (void) signal(SIGTSTP, SIG_DFL);
            sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
        }
            (void) signal(SIGTSTP, (int (*)())doescape);
        } else if (old&MODE_EDIT) {
            (void) signal(SIGTSTP, SIG_DFL);
            sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
        }
-       ioctl(tin, TIOCLSET, (char *)&lmode);
-       ioctl(tin, TIOCSLTC, (char *)&ltc);
-       ioctl(tin, TIOCSETC, (char *)&tc);
-       ioctl(tin, TIOCSETP, (char *)&sb);
+#endif /* SIGTSTP */
     } else {
     } else {
+#ifdef SIGTSTP
        (void) signal(SIGTSTP, SIG_DFL);
        sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
        (void) signal(SIGTSTP, SIG_DFL);
        sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
-       ioctl(tin, TIOCLSET, (char *)&lmode);
-       ioctl(tin, TIOCSLTC, (char *)&oltc);
-       ioctl(tin, TIOCSETC, (char *)&otc);
-       ioctl(tin, TIOCSETP, (char *)&ottyb);
+#endif /* SIGTSTP */
+#ifndef USE_TERMIO
+       ltc = oltc;
+       tc = otc;
+       sb = ottyb;
+#endif
     }
     }
+#ifndef USE_TERMIO
+    ioctl(tin, TIOCLSET, (char *)&lmode);
+    ioctl(tin, TIOCSLTC, (char *)&ltc);
+    ioctl(tin, TIOCSETC, (char *)&tc);
+    ioctl(tin, TIOCSETP, (char *)&sb);
+#else
+    if (ioctl(tin, TCSETAW, &tmp_tc) < 0)
+       ioctl(tin, TCSETA, &tmp_tc);
+#endif
+
 #if    (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR))
     ioctl(tin, FIONBIO, (char *)&onoff);
     ioctl(tout, FIONBIO, (char *)&onoff);
 #if    (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR))
     ioctl(tin, FIONBIO, (char *)&onoff);
     ioctl(tout, FIONBIO, (char *)&onoff);
@@ -465,37 +501,62 @@ register int f;
        ioctl(tin, FIOASYNC, (char *)&onoff);
     }
 #endif /* defined(TN3270) */
        ioctl(tin, FIOASYNC, (char *)&onoff);
     }
 #endif /* defined(TN3270) */
-#else  /* USE_TERMIO */
-    if (ioctl(tin, TCSETAW, &tmp_tc) < 0)
-       ioctl(tin, TCSETA, &tmp_tc);
-#endif /* USE_TERMIO */
 }
 
 }
 
+#ifndef        B19200
+# define B19200 B9600
+#endif
+
+#ifndef        B38400
+# define B38400 B19200
+#endif
+
+/*
+ * This code assumes that the values B0, B50, B75...
+ * are in ascending order.  They do not have to be
+ * contiguous.
+ */
+struct termspeeds {
+       long speed;
+       long value;
+} termspeeds[] = {
+       { 0,     B0 },     { 50,    B50 },   { 75,    B75 },
+       { 110,   B110 },   { 134,   B134 },  { 150,   B150 },
+       { 200,   B200 },   { 300,   B300 },  { 600,   B600 },
+       { 1200,  B1200 },  { 1800,  B1800 }, { 2400,  B2400 },
+       { 4800,  B4800 },  { 9600,  B9600 }, { 19200, B19200 },
+       { 38400, B38400 }, { -1,    B38400 }
+};
+
+#ifndef        USE_TERMIO
+# define       ISPEED  ottyb.sg_ispeed
+# define       OSPEED  ottyb.sg_ospeed
+#else
+# ifdef        SYSV_TERMIO
+#  define      ISPEED  (old_tc.c_cflag&CBAUD)
+#  define      OSPEED  ISPEED
+# else
+#  define      ISPEED  old_tc.c_ispeed
+#  define OSPEED       old_tc.c_ospeed
+# endif
+#endif
+
 void
 TerminalSpeeds(ispeed, ospeed)
 long *ispeed;
 long *ospeed;
 {
 void
 TerminalSpeeds(ispeed, ospeed)
 long *ispeed;
 long *ospeed;
 {
-    /*
-     * The order here is important.  The index of each speed needs to
-     * correspond with the sgtty structure value for that speed.
-     *
-     * Additionally, the search algorithm assumes the table is in
-     * ascending sequence.
-     */
-    static int ttyspeeds[] = {
-           0, 50, 75, 110, 134, 150, 200, 300,
-           600, 1200, 1800, 2400, 4800, 9600, 19200, 38400 };
-#define NUMSPEEDS sizeof ttyspeeds/sizeof ttyspeeds[0]
-
-    if ((OSPEED < 0) || (OSPEED > NUMSPEEDS) ||
-       (ISPEED < 0) || (ISPEED > NUMSPEEDS)) {
-       ExitString("Invalid terminal speed.");
-       /*NOTREACHED*/
-    } else {
-       *ispeed = ttyspeeds[ISPEED];
-       *ospeed = ttyspeeds[OSPEED];
-    }
+    register struct termspeeds *tp;
+
+    tp = termspeeds;
+    while ((tp->speed != -1) && (tp->value < ISPEED))
+       tp++;
+    *ispeed = tp->speed;
+
+    tp = termspeeds;
+    while ((tp->speed != -1) && (tp->value < OSPEED))
+       tp++;
+    *ospeed = tp->speed;
 }
 
 int
 }
 
 int
@@ -605,7 +666,7 @@ doescape()
 void
 sys_telnet_init()
 {
 void
 sys_telnet_init()
 {
-#ifndef        CRAY
+#ifndef        VOID_SIGNAL
     (void) signal(SIGINT, (int (*)())intr);
     (void) signal(SIGQUIT, (int (*)())intr2);
     (void) signal(SIGPIPE, (int (*)())deadpeer);
     (void) signal(SIGINT, (int (*)())intr);
     (void) signal(SIGQUIT, (int (*)())intr2);
     (void) signal(SIGPIPE, (int (*)())deadpeer);
@@ -846,4 +907,3 @@ int poll;           /* If 0, then block until something to do */
 
     return returnValue;
 }
 
     return returnValue;
 }
-#endif /* defined(unix) */
index e915383..97ec938 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)telnet.c   5.43 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnet.c   5.44 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -27,7 +27,6 @@ static char sccsid[] = "@(#)telnet.c  5.43 (Berkeley) %G%";
  * among other things, telnet.h #defines 'DO', which is a variable
  * declared in curses.h.
  */
  * among other things, telnet.h #defines 'DO', which is a variable
  * declared in curses.h.
  */
-#include <curses.h>
 #endif /* defined(unix) */
 
 #include <arpa/telnet.h>
 #endif /* defined(unix) */
 
 #include <arpa/telnet.h>
@@ -91,7 +90,7 @@ int
 
 #define        CONTROL(x)      ((x)&0x1f)              /* CTRL(x) is not portable */
 
 
 #define        CONTROL(x)      ((x)&0x1f)              /* CTRL(x) is not portable */
 
-char
+unsigned char
        *prompt = 0,
        escape,
        echoc;
        *prompt = 0,
        escape,
        echoc;
@@ -513,6 +512,7 @@ dontoption(option)
            /* we always accept a DONT */
            set_my_want_state_wont(option);
            send_wont(option, 0);
            /* we always accept a DONT */
            set_my_want_state_wont(option);
            send_wont(option, 0);
+           setconnmode(0);                     /* Set new tty mode */
        }
        set_my_state_wont(option);
 }
        }
        set_my_state_wont(option);
 }
@@ -646,13 +646,13 @@ register char *name, **as, **ae;
 }
 
 #ifdef TERMCAP
 }
 
 #ifdef TERMCAP
-char ttytype[1024];
+char termbuf[1024];
 setupterm(tname, fd, errp)
 char *tname;
 int fd, *errp;
 {
 setupterm(tname, fd, errp)
 char *tname;
 int fd, *errp;
 {
-       if (tgetent(ttytype, tname) == 1) {
-               ttytype[1023] = '\0';
+       if (tgetent(termbuf, tname) == 1) {
+               termbuf[1023] = '\0';
                if (errp)
                        *errp = 1;
                return(0);
                if (errp)
                        *errp = 1;
                return(0);
@@ -661,6 +661,9 @@ int fd, *errp;
                *errp = 0;
        return(-1);
 }
                *errp = 0;
        return(-1);
 }
+#else
+#define        termbuf ttytype
+extern char ttytype[];
 #endif
 
 char *
 #endif
 
 char *
@@ -668,7 +671,6 @@ gettermname()
 {
        char *tname;
        static int first = 1;
 {
        char *tname;
        static int first = 1;
-       extern char ttytype[];
        static char **tnamep;
        static char **next;
        char *getenv();
        static char **tnamep;
        static char **next;
        char *getenv();
@@ -678,7 +680,7 @@ gettermname()
                first = 0;
                if ((tname = getenv("TERM")) &&
                                (setupterm(tname, 1, &err) == 0)) {
                first = 0;
                if ((tname = getenv("TERM")) &&
                                (setupterm(tname, 1, &err) == 0)) {
-                       tnamep = mklist(ttytype, tname);
+                       tnamep = mklist(termbuf, tname);
                } else {
                        if (tname && (strlen(tname) <= 40)) {
                                unknown[0] = tname;
                } else {
                        if (tname && (strlen(tname) <= 40)) {
                                unknown[0] = tname;
@@ -934,19 +936,19 @@ slc_init()
        /* No EOR */
        initfunc(SLC_ABORT, SLC_FLUSHIN|SLC_FLUSHOUT);
        initfunc(SLC_EOF, 0);
        /* No EOR */
        initfunc(SLC_ABORT, SLC_FLUSHIN|SLC_FLUSHOUT);
        initfunc(SLC_EOF, 0);
-#ifndef        CRAY
+#ifndef        SYSV_TERMIO
        initfunc(SLC_SUSP, SLC_FLUSHIN);
 #endif
        initfunc(SLC_EC, 0);
        initfunc(SLC_EL, 0);
        initfunc(SLC_SUSP, SLC_FLUSHIN);
 #endif
        initfunc(SLC_EC, 0);
        initfunc(SLC_EL, 0);
-#ifndef        CRAY
+#ifndef        SYSV_TERMIO
        initfunc(SLC_EW, 0);
        initfunc(SLC_RP, 0);
        initfunc(SLC_LNEXT, 0);
 #endif
        initfunc(SLC_XON, 0);
        initfunc(SLC_XOFF, 0);
        initfunc(SLC_EW, 0);
        initfunc(SLC_RP, 0);
        initfunc(SLC_LNEXT, 0);
 #endif
        initfunc(SLC_XON, 0);
        initfunc(SLC_XOFF, 0);
-#ifdef CRAY
+#ifdef SYSV_TERMIO
        spc_data[SLC_XON].mylevel = SLC_CANTCHANGE;
        spc_data[SLC_XOFF].mylevel = SLC_CANTCHANGE;
 #endif
        spc_data[SLC_XON].mylevel = SLC_CANTCHANGE;
        spc_data[SLC_XOFF].mylevel = SLC_CANTCHANGE;
 #endif
@@ -1206,7 +1208,8 @@ telrcv()
            telrcv_state = TS_DATA;
            if (c == '\0') {
                break;  /* Ignore \0 after CR */
            telrcv_state = TS_DATA;
            if (c == '\0') {
                break;  /* Ignore \0 after CR */
-           } else if ((c == '\n') && my_want_state_is_dont(TELOPT_ECHO) && !crmod) {
+           }
+           else if ((c == '\n') && my_want_state_is_dont(TELOPT_ECHO) && !crmod) {
                TTYADD(c);
                break;
            }
                TTYADD(c);
                break;
            }
index 1f6c997..4c4ef35 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)terminal.c 1.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)terminal.c 1.17 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <arpa/telnet.h>
 #endif /* not lint */
 
 #include <arpa/telnet.h>
@@ -33,14 +33,27 @@ char        ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ];
 int termdata;                  /* Debugging flag */
 
 #ifdef USE_TERMIO
 int termdata;                  /* Debugging flag */
 
 #ifdef USE_TERMIO
-char
-    termFlushChar,
-    termLiteralNextChar,
-    termSuspChar,
-    termWerasChar,
-    termRprntChar,
-    termStartChar,
-    termStopChar;
+# ifndef VFLUSHO
+char termFlushChar;
+# endif
+# ifndef VLNEXT
+char termLiteralNextChar;
+# endif
+# ifndef VSUSP
+char termSuspChar;
+# endif
+# ifndef VWERASE
+char termWerasChar;
+# endif
+# ifndef VREPRINT
+char termRprntChar;
+# endif
+# ifndef VSTART
+char termStartChar;
+# endif
+# ifndef VSTOP
+char termStopChar;
+# endif
 #endif
 
 /*
 #endif
 
 /*
@@ -137,6 +150,12 @@ getconnmode()
     if (localflow)
        mode |= MODE_FLOW;
 
     if (localflow)
        mode |= MODE_FLOW;
 
+    if (my_want_state_is_will(TELOPT_BINARY))
+       mode |= MODE_INBIN;
+
+    if (his_want_state_is_will(TELOPT_BINARY))
+       mode |= MODE_OUTBIN;
+
 #ifdef KLUDGELINEMODE
     if (kludgelinemode) {
        if (my_want_state_is_dont(TELOPT_SGA)) {
 #ifdef KLUDGELINEMODE
     if (kludgelinemode) {
        if (my_want_state_is_dont(TELOPT_SGA)) {
index af73ea4..d8e0d31 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utilities.c        1.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)utilities.c        1.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        TELOPTS
 #endif /* not lint */
 
 #define        TELOPTS
@@ -90,7 +90,7 @@ int
  * The following are routines used to print out debugging information.
  */
 
  * The following are routines used to print out debugging information.
  */
 
-char NetTraceFile[256] = "(standard output)";
+unsigned char NetTraceFile[256] = "(standard output)";
 
 void
 SetNetTrace(file)
 
 void
 SetNetTrace(file)
@@ -645,15 +645,3 @@ int returnCode;
     fwrite(string, 1, strlen(string), stderr);
     exit(returnCode);
 }
     fwrite(string, 1, strlen(string), stderr);
     exit(returnCode);
 }
-
-#if defined(MSDOS)
-void
-ExitPerror(string, returnCode)
-char *string;
-int returnCode;
-{
-    SetForExit();
-    perror(string);
-    exit(returnCode);
-}
-#endif /* defined(MSDOS) */