Major nuking of dead code.
This might break in some situations, but is probably worth it. You can now get at least a glimpse of the code behind all #ifdefs. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@224 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -35,21 +35,13 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
#if defined(unix)
|
||||
#include <sys/param.h>
|
||||
#if defined(CRAY) || defined(sysV88)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/file.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif /* defined(unix) */
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef CRAY
|
||||
#include <fcntl.h>
|
||||
#endif /* CRAY */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
@@ -57,6 +49,7 @@ RCSID("$Id$");
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <arpa/telnet.h>
|
||||
|
||||
@@ -711,18 +704,6 @@ static struct togglelist Togglelist[] = {
|
||||
&localchars,
|
||||
"recognize certain control characters" },
|
||||
{ " ", "", 0 }, /* empty line */
|
||||
#if defined(unix) && defined(TN3270)
|
||||
{ "apitrace",
|
||||
"(debugging) toggle tracing of API transactions",
|
||||
0,
|
||||
&apitrace,
|
||||
"trace API transactions" },
|
||||
{ "cursesdata",
|
||||
"(debugging) toggle printing of hexadecimal curses data",
|
||||
0,
|
||||
&cursesdata,
|
||||
"print hexadecimal representation of curses data" },
|
||||
#endif /* defined(unix) && defined(TN3270) */
|
||||
{ "debug",
|
||||
"debugging",
|
||||
togdebug,
|
||||
@@ -743,13 +724,11 @@ static struct togglelist Togglelist[] = {
|
||||
0,
|
||||
&showoptions,
|
||||
"show option processing" },
|
||||
#if defined(unix)
|
||||
{ "termdata",
|
||||
"(debugging) toggle printing of hexadecimal terminal data",
|
||||
0,
|
||||
&termdata,
|
||||
"print hexadecimal representation of terminal traffic" },
|
||||
#endif /* defined(unix) */
|
||||
{ "?",
|
||||
0,
|
||||
togglehelp },
|
||||
@@ -844,9 +823,7 @@ toggle(argc, argv)
|
||||
* The following perform the "set" command.
|
||||
*/
|
||||
|
||||
#ifdef USE_TERMIO
|
||||
struct termio new_tc = { 0 };
|
||||
#endif
|
||||
struct termios new_tc = { 0 };
|
||||
|
||||
struct setlist {
|
||||
char *name; /* name */
|
||||
@@ -1328,9 +1305,8 @@ setescape(argc, argv)
|
||||
}
|
||||
if (arg[0] != '\0')
|
||||
escape = arg[0];
|
||||
if (!In3270) {
|
||||
printf("Escape character is '%s'.\n", control(escape));
|
||||
}
|
||||
printf("Escape character is '%s'.\n", control(escape));
|
||||
|
||||
(void) fflush(stdout);
|
||||
return 1;
|
||||
}
|
||||
@@ -1376,19 +1352,16 @@ suspend()
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(TN3270)
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
shell(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int
|
||||
shell(int argc, char **argv)
|
||||
{
|
||||
long oldrows, oldcols, newrows, newcols, err;
|
||||
|
||||
setcommandmode();
|
||||
|
||||
err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
|
||||
switch(vfork()) {
|
||||
switch(fork()) {
|
||||
case -1:
|
||||
perror("Fork failed\n");
|
||||
break;
|
||||
@@ -1425,9 +1398,6 @@ shell(argc, argv)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#else /* !defined(TN3270) */
|
||||
extern int shell();
|
||||
#endif /* !defined(TN3270) */
|
||||
|
||||
static int bye(int argc, char **argv)
|
||||
{
|
||||
@@ -1444,9 +1414,6 @@ static int bye(int argc, char **argv)
|
||||
#endif
|
||||
/* reset options */
|
||||
tninit();
|
||||
#if defined(TN3270)
|
||||
SetIn3270(); /* Get out of 3270 mode */
|
||||
#endif /* defined(TN3270) */
|
||||
}
|
||||
if ((argc != 2) || (strcmp(argv[1], "fromquit") != 0)) {
|
||||
longjmp(toplevel, 1);
|
||||
@@ -1563,9 +1530,6 @@ extern void
|
||||
env_export P((unsigned char *)),
|
||||
env_unexport P((unsigned char *)),
|
||||
env_send P((unsigned char *)),
|
||||
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
|
||||
env_varval P((unsigned char *)),
|
||||
#endif
|
||||
env_list P((void));
|
||||
static void
|
||||
env_help P((void));
|
||||
@@ -1582,10 +1546,6 @@ struct envlist EnvList[] = {
|
||||
{ "send", "Send an environment variable", env_send, 1 },
|
||||
{ "list", "List the current environment variables",
|
||||
env_list, 0 },
|
||||
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
|
||||
{ "varval", "Reverse VAR and VALUE (auto, right, wrong, status)",
|
||||
env_varval, 1 },
|
||||
#endif
|
||||
{ "help", 0, env_help, 0 },
|
||||
{ "?", "Print help information", env_help, 0 },
|
||||
{ 0 },
|
||||
@@ -1857,43 +1817,6 @@ env_getvalue(var)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
|
||||
void
|
||||
env_varval(what)
|
||||
unsigned char *what;
|
||||
{
|
||||
extern int old_env_var, old_env_value, env_auto;
|
||||
int len = strlen((char *)what);
|
||||
|
||||
if (len == 0)
|
||||
goto unknown;
|
||||
|
||||
if (strncasecmp((char *)what, "status", len) == 0) {
|
||||
if (env_auto)
|
||||
printf("%s%s", "VAR and VALUE are/will be ",
|
||||
"determined automatically\n");
|
||||
if (old_env_var == OLD_ENV_VAR)
|
||||
printf("VAR and VALUE set to correct definitions\n");
|
||||
else
|
||||
printf("VAR and VALUE definitions are reversed\n");
|
||||
} else if (strncasecmp((char *)what, "auto", len) == 0) {
|
||||
env_auto = 1;
|
||||
old_env_var = OLD_ENV_VALUE;
|
||||
old_env_value = OLD_ENV_VAR;
|
||||
} else if (strncasecmp((char *)what, "right", len) == 0) {
|
||||
env_auto = 0;
|
||||
old_env_var = OLD_ENV_VAR;
|
||||
old_env_value = OLD_ENV_VALUE;
|
||||
} else if (strncasecmp((char *)what, "wrong", len) == 0) {
|
||||
env_auto = 0;
|
||||
old_env_var = OLD_ENV_VALUE;
|
||||
old_env_value = OLD_ENV_VAR;
|
||||
} else {
|
||||
unknown:
|
||||
printf("Unknown \"varval\" command. (\"auto\", \"right\", \"wrong\", \"status\")\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUTHENTICATION)
|
||||
/*
|
||||
@@ -2089,38 +2012,6 @@ int encrypt_cmd(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(unix) && defined(TN3270)
|
||||
static void
|
||||
filestuff(fd)
|
||||
int fd;
|
||||
{
|
||||
int res;
|
||||
|
||||
#ifdef F_GETOWN
|
||||
setconnmode(0);
|
||||
res = fcntl(fd, F_GETOWN, 0);
|
||||
setcommandmode();
|
||||
|
||||
if (res == -1) {
|
||||
perror("fcntl");
|
||||
return;
|
||||
}
|
||||
printf("\tOwner is %d.\n", res);
|
||||
#endif
|
||||
|
||||
setconnmode(0);
|
||||
res = fcntl(fd, F_GETFL, 0);
|
||||
setcommandmode();
|
||||
|
||||
if (res == -1) {
|
||||
perror("fcntl");
|
||||
return;
|
||||
}
|
||||
#ifdef notdef
|
||||
printf("\tFlags are 0x%x: %s\n", res, decodeflags(res));
|
||||
#endif
|
||||
}
|
||||
#endif /* defined(unix) && defined(TN3270) */
|
||||
|
||||
/*
|
||||
* Print status about the connection.
|
||||
@@ -2158,37 +2049,8 @@ static int status(int argc, char **argv)
|
||||
} else {
|
||||
printf("No connection.\n");
|
||||
}
|
||||
# if !defined(TN3270)
|
||||
printf("Escape character is '%s'.\n", control(escape));
|
||||
(void) fflush(stdout);
|
||||
# else /* !defined(TN3270) */
|
||||
if ((!In3270) && ((argc < 2) || strcmp(argv[1], "notmuch"))) {
|
||||
printf("Escape character is '%s'.\n", control(escape));
|
||||
}
|
||||
# if defined(unix)
|
||||
if ((argc >= 2) && !strcmp(argv[1], "everything")) {
|
||||
printf("SIGIO received %d time%s.\n",
|
||||
sigiocount, (sigiocount == 1)? "":"s");
|
||||
if (In3270) {
|
||||
printf("Process ID %d, process group %d.\n",
|
||||
getpid(), getpgrp(getpid()));
|
||||
printf("Terminal input:\n");
|
||||
filestuff(tin);
|
||||
printf("Terminal output:\n");
|
||||
filestuff(tout);
|
||||
printf("Network socket:\n");
|
||||
filestuff(net);
|
||||
}
|
||||
}
|
||||
if (In3270 && transcom) {
|
||||
printf("Transparent mode command is '%s'.\n", transcom);
|
||||
}
|
||||
# endif /* defined(unix) */
|
||||
(void) fflush(stdout);
|
||||
if (In3270) {
|
||||
return 0;
|
||||
}
|
||||
# endif /* defined(TN3270) */
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2533,18 +2395,13 @@ static char
|
||||
togglestring[] ="toggle operating parameters ('toggle ?' for more)",
|
||||
slchelp[] = "change state of special charaters ('slc ?' for more)",
|
||||
displayhelp[] = "display operating parameters",
|
||||
#if defined(TN3270) && defined(unix)
|
||||
transcomhelp[] = "specify Unix command for transparent mode pipe",
|
||||
#endif /* defined(TN3270) && defined(unix) */
|
||||
#if defined(AUTHENTICATION)
|
||||
authhelp[] = "turn on (off) authentication ('auth ?' for more)",
|
||||
#endif
|
||||
#if defined(ENCRYPTION)
|
||||
encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
|
||||
#endif
|
||||
#if defined(unix)
|
||||
zhelp[] = "suspend telnet",
|
||||
#endif /* defined(unix) */
|
||||
shellhelp[] = "invoke a subshell",
|
||||
envhelp[] = "change environment variables ('environ ?' for more)",
|
||||
modestring[] = "try to enter line or character mode ('mode ?' for more)";
|
||||
@@ -2564,23 +2421,14 @@ static Command cmdtab[] = {
|
||||
{ "status", statushelp, status, 0 },
|
||||
{ "toggle", togglestring, toggle, 0 },
|
||||
{ "slc", slchelp, slccmd, 0 },
|
||||
#if defined(TN3270) && defined(unix)
|
||||
{ "transcom", transcomhelp, settranscom, 0 },
|
||||
#endif /* defined(TN3270) && defined(unix) */
|
||||
#if defined(AUTHENTICATION)
|
||||
{ "auth", authhelp, auth_cmd, 0 },
|
||||
#endif
|
||||
#if defined(ENCRYPTION)
|
||||
{ "encrypt", encrypthelp, encrypt_cmd, 0 },
|
||||
#endif
|
||||
#if defined(unix)
|
||||
{ "z", zhelp, suspend, 0 },
|
||||
#endif /* defined(unix) */
|
||||
#if defined(TN3270)
|
||||
{ "!", shellhelp, shell, 1 },
|
||||
#else
|
||||
{ "!", shellhelp, shell, 0 },
|
||||
#endif
|
||||
{ "environ", envhelp, env_cmd, 0 },
|
||||
{ "?", helphelp, help, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
@@ -2634,11 +2482,9 @@ command(top, tbuf, cnt)
|
||||
setcommandmode();
|
||||
if (!top) {
|
||||
putchar('\n');
|
||||
#if defined(unix)
|
||||
} else {
|
||||
(void) signal(SIGINT, SIG_DFL);
|
||||
(void) signal(SIGQUIT, SIG_DFL);
|
||||
#endif /* defined(unix) */
|
||||
}
|
||||
for (;;) {
|
||||
if (rlogin == _POSIX_VDISABLE)
|
||||
@@ -2694,13 +2540,7 @@ command(top, tbuf, cnt)
|
||||
longjmp(toplevel, 1);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
#if defined(TN3270)
|
||||
if (shell_active == 0) {
|
||||
setconnmode(0);
|
||||
}
|
||||
#else /* defined(TN3270) */
|
||||
setconnmode(0);
|
||||
#endif /* defined(TN3270) */
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -35,12 +35,6 @@
|
||||
|
||||
#define settimer(x) clocks.x = clocks.system++
|
||||
|
||||
#if !defined(TN3270)
|
||||
|
||||
#define SetIn3270()
|
||||
|
||||
#endif /* !defined(TN3270) */
|
||||
|
||||
#define NETADD(c) { *netoring.supply = c; ring_supplied(&netoring, 1); }
|
||||
#define NET2ADD(c1,c2) { NETADD(c1); NETADD(c2); }
|
||||
#define NETBYTES() (ring_full_count(&netoring))
|
||||
|
@@ -38,54 +38,21 @@
|
||||
#if defined(CRAY) && !defined(NO_BSD_SETJMP)
|
||||
#include <bsdsetjmp.h>
|
||||
#endif
|
||||
#ifndef FILIO_H
|
||||
/* not with SunOS 4 */
|
||||
#if defined(HAVE_SYS_IOCTL_H) && (defined(sun) && !defined(__svr4__))
|
||||
#include <sys/ioctl.h>
|
||||
#else
|
||||
#endif
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
#ifdef CRAY
|
||||
# include <errno.h>
|
||||
#endif /* CRAY */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef BSD
|
||||
# define BSD 43
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ucb stdio.h defines BSD as something wierd
|
||||
*/
|
||||
#if defined(sun) && defined(__svr4__)
|
||||
#undef BSD
|
||||
#define BSD 43
|
||||
#endif
|
||||
|
||||
#ifndef USE_TERMIO
|
||||
# if BSD > 43 || defined(SYSV_TERMIO)
|
||||
# define USE_TERMIO
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_TERMIO
|
||||
# ifdef SYSV_TERMIO
|
||||
# include <sys/termio.h>
|
||||
# else
|
||||
# include <termios.h>
|
||||
# define termio termios
|
||||
# endif
|
||||
#endif
|
||||
#if defined(NO_CC_T) || !defined(USE_TERMIO)
|
||||
# if !defined(USE_TERMIO)
|
||||
typedef char cc_t;
|
||||
# else
|
||||
typedef unsigned char cc_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <termios.h>
|
||||
|
||||
#ifndef _POSIX_VDISABLE
|
||||
# ifdef sun
|
||||
@@ -100,10 +67,6 @@ typedef unsigned char cc_t;
|
||||
|
||||
#define SUBBUFSIZE 256
|
||||
|
||||
#ifndef CRAY
|
||||
extern int errno; /* outside this world */
|
||||
#endif /* !CRAY */
|
||||
|
||||
#if !defined(P)
|
||||
# ifdef __STDC__
|
||||
# define P(x) x
|
||||
@@ -119,7 +82,6 @@ extern int
|
||||
flushout, /* flush output */
|
||||
connected, /* Are we connected to the other side? */
|
||||
globalmode, /* Mode tty should be in */
|
||||
In3270, /* Are we in 3270 mode? */
|
||||
telnetport, /* Are we connected to the telnet port? */
|
||||
localflow, /* Flow control handled locally */
|
||||
restartany, /* If flow control, restart output on any character */
|
||||
@@ -138,13 +100,7 @@ extern int
|
||||
crmod,
|
||||
netdata, /* Print out network data flow */
|
||||
prettydump, /* Print "netdata" output in user readable format */
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
#if defined(TN3270)
|
||||
cursesdata, /* Print out curses data flow */
|
||||
apitrace, /* Trace API transactions */
|
||||
#endif /* defined(TN3270) */
|
||||
termdata, /* Print out terminal data flow */
|
||||
#endif /* defined(unix) */
|
||||
debug; /* Debug level */
|
||||
|
||||
extern cc_t escape; /* Escape to command mode */
|
||||
@@ -245,7 +201,6 @@ extern jmp_buf
|
||||
extern void
|
||||
command P((int, char *, int)),
|
||||
Dump P((int, unsigned char *, int)),
|
||||
init_3270 P((void)),
|
||||
printoption P((char *, int, int)),
|
||||
printsub P((int, unsigned char *, int)),
|
||||
sendnaws P((void)),
|
||||
@@ -287,7 +242,7 @@ extern void
|
||||
slc P((unsigned char *, int)),
|
||||
slc_check P((void)),
|
||||
slc_start_reply P((void)),
|
||||
slc_add_reply P((int, int, int)),
|
||||
slc_add_reply P((unsigned char, unsigned char, cc_t)),
|
||||
slc_end_reply P((void));
|
||||
extern int
|
||||
slc_update P((void));
|
||||
@@ -312,47 +267,8 @@ extern cc_t
|
||||
|
||||
extern int quit P((void));
|
||||
|
||||
#ifndef USE_TERMIO
|
||||
|
||||
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 termForw1Char ntc.t_brkc
|
||||
extern cc_t termForw2Char;
|
||||
extern cc_t termAytChar;
|
||||
|
||||
# define termEofCharp (cc_t *)&ntc.t_eofc
|
||||
# define termEraseCharp (cc_t *)&nttyb.sg_erase
|
||||
# define termFlushCharp (cc_t *)&nltc.t_flushc
|
||||
# define termIntCharp (cc_t *)&ntc.t_intrc
|
||||
# define termKillCharp (cc_t *)&nttyb.sg_kill
|
||||
# define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
|
||||
# define termQuitCharp (cc_t *)&ntc.t_quitc
|
||||
# define termSuspCharp (cc_t *)&nltc.t_suspc
|
||||
# define termRprntCharp (cc_t *)&nltc.t_rprntc
|
||||
# define termWerasCharp (cc_t *)&nltc.t_werasc
|
||||
# define termStartCharp (cc_t *)&ntc.t_startc
|
||||
# define termStopCharp (cc_t *)&ntc.t_stopc
|
||||
# define termForw1Charp (cc_t *)&ntc.t_brkc
|
||||
# define termForw2Charp (cc_t *)&termForw2Char
|
||||
# define termAytCharp (cc_t *)&termAytChar
|
||||
|
||||
# else
|
||||
|
||||
extern struct termio new_tc;
|
||||
extern struct termios new_tc;
|
||||
|
||||
# define termEofChar new_tc.c_cc[VEOF]
|
||||
# define termEraseChar new_tc.c_cc[VERASE]
|
||||
@@ -414,7 +330,6 @@ extern cc_t termAytChar;
|
||||
# define termAytChar new_tc.c_cc[VSTATUS]
|
||||
#endif
|
||||
|
||||
# if !defined(CRAY) || defined(__STDC__)
|
||||
# define termEofCharp &termEofChar
|
||||
# define termEraseCharp &termEraseChar
|
||||
# define termIntCharp &termIntChar
|
||||
@@ -430,25 +345,6 @@ extern cc_t termAytChar;
|
||||
# define termForw1Charp &termForw1Char
|
||||
# define termForw2Charp &termForw2Char
|
||||
# define termAytCharp &termAytChar
|
||||
# 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
|
||||
# define termForw1Charp 0
|
||||
# define termForw2Charp 0
|
||||
# define termAytCharp 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Ring buffer structures which are shared */
|
||||
@@ -459,26 +355,3 @@ extern Ring
|
||||
ttyoring,
|
||||
ttyiring;
|
||||
|
||||
/* Tn3270 section */
|
||||
#if defined(TN3270)
|
||||
|
||||
extern int
|
||||
HaveInput, /* Whether an asynchronous I/O indication came in */
|
||||
noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
|
||||
noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
|
||||
sigiocount, /* Count of SIGIO receptions */
|
||||
shell_active; /* Subshell is active */
|
||||
|
||||
extern char
|
||||
*Ibackp, /* Oldest byte of 3270 data */
|
||||
Ibuf[], /* 3270 buffer */
|
||||
*Ifrontp, /* Where next 3270 byte goes */
|
||||
tline[],
|
||||
*transcom; /* Transparent command */
|
||||
|
||||
extern int
|
||||
settranscom P((int, char**));
|
||||
|
||||
extern void
|
||||
inputAvailable P((int));
|
||||
#endif /* defined(TN3270) */
|
||||
|
@@ -42,6 +42,7 @@ static char copyright[] =
|
||||
RCSID("$Id$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ring.h"
|
||||
#include "externs.h"
|
||||
@@ -69,10 +70,6 @@ tninit()
|
||||
init_telnet();
|
||||
|
||||
init_sys();
|
||||
|
||||
#if defined(TN3270)
|
||||
init_3270();
|
||||
#endif
|
||||
}
|
||||
|
||||
void usage(void)
|
||||
@@ -85,15 +82,7 @@ void usage(void)
|
||||
"[-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
|
||||
"\n\t[-n tracefile]",
|
||||
#endif
|
||||
#if defined(TN3270) && defined(unix)
|
||||
# ifdef AUTHENTICATION
|
||||
"[-noasynch] [-noasynctty]\n\t[-noasyncnet] [-r] [-t transcom] ",
|
||||
# else
|
||||
"[-noasynch] [-noasynctty] [-noasyncnet] [-r]\n\t[-t transcom]",
|
||||
# endif
|
||||
#else
|
||||
"[-r] ",
|
||||
#endif
|
||||
#ifdef ENCRYPTION
|
||||
"[-x] [host-name [port]]"
|
||||
#else
|
||||
@@ -244,34 +233,11 @@ int main(int argc, char **argv)
|
||||
user = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
#if defined(TN3270) && defined(unix)
|
||||
/* distinguish between "-n oasynch" and "-noasynch" */
|
||||
if (argv[optind - 1][0] == '-' && argv[optind - 1][1]
|
||||
== 'n' && argv[optind - 1][2] == 'o') {
|
||||
if (!strcmp(optarg, "oasynch")) {
|
||||
noasynchtty = 1;
|
||||
noasynchnet = 1;
|
||||
} else if (!strcmp(optarg, "oasynchtty"))
|
||||
noasynchtty = 1;
|
||||
else if (!strcmp(optarg, "oasynchnet"))
|
||||
noasynchnet = 1;
|
||||
} else
|
||||
#endif /* defined(TN3270) && defined(unix) */
|
||||
SetNetTrace(optarg);
|
||||
break;
|
||||
case 'r':
|
||||
rlogin = '~';
|
||||
break;
|
||||
case 't':
|
||||
#if defined(TN3270) && defined(unix)
|
||||
transcom = tline;
|
||||
(void)strcpy(transcom, optarg);
|
||||
#else
|
||||
fprintf(stderr,
|
||||
"%s: Warning: -t ignored, no TN3270 support.\n",
|
||||
prompt);
|
||||
#endif
|
||||
break;
|
||||
case 'x':
|
||||
#ifdef ENCRYPTION
|
||||
encrypt_auto(1);
|
||||
@@ -329,11 +295,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
(void)setjmp(toplevel);
|
||||
for (;;) {
|
||||
#ifdef TN3270
|
||||
if (shell_active)
|
||||
shell_continue();
|
||||
else
|
||||
#endif
|
||||
command(1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ RCSID("$Id$");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef FILIO_H
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include <sys/socket.h>
|
||||
|
@@ -60,14 +60,9 @@ RCSID("$Id$");
|
||||
#include "externs.h"
|
||||
#include "types.h"
|
||||
|
||||
#if defined(CRAY) || (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();
|
||||
extern RETSIGTYPE ayt_status();
|
||||
#endif
|
||||
|
||||
int
|
||||
@@ -75,18 +70,8 @@ int
|
||||
tin, /* Input file descriptor */
|
||||
net;
|
||||
|
||||
#ifndef USE_TERMIO
|
||||
struct tchars otc = { 0 }, ntc = { 0 };
|
||||
struct ltchars oltc = { 0 }, nltc = { 0 };
|
||||
struct sgttyb ottyb = { 0 }, nttyb = { 0 };
|
||||
int olmode = 0;
|
||||
# define cfgetispeed(ptr) (ptr)->sg_ispeed
|
||||
# define cfgetospeed(ptr) (ptr)->sg_ospeed
|
||||
# define old_tc ottyb
|
||||
|
||||
#else /* USE_TERMIO */
|
||||
struct termio old_tc = { 0 };
|
||||
extern struct termio new_tc;
|
||||
struct termios old_tc = { 0 };
|
||||
extern struct termios new_tc;
|
||||
|
||||
# ifndef TCSANOW
|
||||
# ifdef TCSETS
|
||||
@@ -115,12 +100,11 @@ extern struct termio new_tc;
|
||||
# ifdef sysV88
|
||||
# define TIOCFLUSH TC_PX_DRAIN
|
||||
# endif
|
||||
#endif /* USE_TERMIO */
|
||||
|
||||
static fd_set ibits, obits, xbits;
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
init_sys()
|
||||
{
|
||||
tout = fileno(stdout);
|
||||
@@ -133,18 +117,14 @@ init_sys()
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -153,7 +133,7 @@ TerminalRead(buf, n)
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
int
|
||||
TerminalAutoFlush()
|
||||
{
|
||||
#if defined(LNOFLSH)
|
||||
@@ -183,9 +163,8 @@ extern int kludgelinemode;
|
||||
|
||||
extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk();
|
||||
|
||||
int
|
||||
TerminalSpecialChars(c)
|
||||
int c;
|
||||
int
|
||||
TerminalSpecialChars(int c)
|
||||
{
|
||||
if (c == termIntChar) {
|
||||
intp();
|
||||
@@ -227,7 +206,7 @@ TerminalSpecialChars(c)
|
||||
* Flush output to the terminal
|
||||
*/
|
||||
|
||||
void
|
||||
void
|
||||
TerminalFlushOutput()
|
||||
{
|
||||
#ifdef TIOCFLUSH
|
||||
@@ -237,20 +216,9 @@ TerminalFlushOutput()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
TerminalSaveState()
|
||||
{
|
||||
#ifndef USE_TERMIO
|
||||
ioctl(0, TIOCGETP, (char *)&ottyb);
|
||||
ioctl(0, TIOCGETC, (char *)&otc);
|
||||
ioctl(0, TIOCGLTC, (char *)&oltc);
|
||||
ioctl(0, TIOCLGET, (char *)&olmode);
|
||||
|
||||
ntc = otc;
|
||||
nltc = oltc;
|
||||
nttyb = ottyb;
|
||||
|
||||
#else /* USE_TERMIO */
|
||||
tcgetattr(0, &old_tc);
|
||||
|
||||
new_tc = old_tc;
|
||||
@@ -276,12 +244,10 @@ TerminalSaveState()
|
||||
#ifndef VSTATUS
|
||||
termAytChar = CONTROL('T');
|
||||
#endif
|
||||
#endif /* USE_TERMIO */
|
||||
}
|
||||
|
||||
cc_t *
|
||||
tcval(func)
|
||||
register int func;
|
||||
cc_t*
|
||||
tcval(int func)
|
||||
{
|
||||
switch(func) {
|
||||
case SLC_IP: return(&termIntChar);
|
||||
@@ -292,7 +258,6 @@ tcval(func)
|
||||
case SLC_XON: return(&termStartChar);
|
||||
case SLC_XOFF: return(&termStopChar);
|
||||
case SLC_FORW1: return(&termForw1Char);
|
||||
#ifdef USE_TERMIO
|
||||
case SLC_FORW2: return(&termForw2Char);
|
||||
# ifdef VDISCARD
|
||||
case SLC_AO: return(&termFlushChar);
|
||||
@@ -312,7 +277,6 @@ tcval(func)
|
||||
# ifdef VSTATUS
|
||||
case SLC_AYT: return(&termAytChar);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
case SLC_SYNCH:
|
||||
case SLC_BRK:
|
||||
@@ -322,15 +286,9 @@ tcval(func)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
TerminalDefaultChars()
|
||||
{
|
||||
#ifndef USE_TERMIO
|
||||
ntc = otc;
|
||||
nltc = oltc;
|
||||
nttyb.sg_kill = ottyb.sg_kill;
|
||||
nttyb.sg_erase = ottyb.sg_erase;
|
||||
#else /* USE_TERMIO */
|
||||
memmove(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
|
||||
# ifndef VDISCARD
|
||||
termFlushChar = CONTROL('O');
|
||||
@@ -353,7 +311,6 @@ TerminalDefaultChars()
|
||||
# ifndef VSTATUS
|
||||
termAytChar = CONTROL('T');
|
||||
# endif
|
||||
#endif /* USE_TERMIO */
|
||||
}
|
||||
|
||||
#ifdef notdef
|
||||
@@ -386,19 +343,11 @@ TerminalRestoreState()
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
TerminalNewMode(f)
|
||||
register int f;
|
||||
void
|
||||
TerminalNewMode(int f)
|
||||
{
|
||||
static int prevmode = 0;
|
||||
#ifndef USE_TERMIO
|
||||
struct tchars tc;
|
||||
struct ltchars ltc;
|
||||
struct sgttyb sb;
|
||||
int lmode;
|
||||
#else /* USE_TERMIO */
|
||||
struct termio tmp_tc;
|
||||
#endif /* USE_TERMIO */
|
||||
struct termios tmp_tc;
|
||||
int onoff;
|
||||
int old;
|
||||
cc_t esc;
|
||||
@@ -413,68 +362,38 @@ TerminalNewMode(f)
|
||||
* left to write out, it returns -1 if it couldn't do
|
||||
* anything at all, otherwise it returns 1 + the number
|
||||
* of characters left to write.
|
||||
#ifndef USE_TERMIO
|
||||
* We would really like ask the kernel to wait for the output
|
||||
* to drain, like we can do with the TCSADRAIN, but we don't have
|
||||
* that option. The only ioctl that waits for the output to
|
||||
* drain, TIOCSETP, also flushes the input queue, which is NOT
|
||||
* what we want (TIOCSETP is like TCSADFLUSH).
|
||||
#endif
|
||||
*/
|
||||
old = ttyflush(SYNCHing|flushout);
|
||||
if (old < 0 || old > 1) {
|
||||
#ifdef USE_TERMIO
|
||||
tcgetattr(tin, &tmp_tc);
|
||||
#endif /* USE_TERMIO */
|
||||
do {
|
||||
/*
|
||||
* Wait for data to drain, then flush again.
|
||||
*/
|
||||
#ifdef USE_TERMIO
|
||||
tcsetattr(tin, TCSADRAIN, &tmp_tc);
|
||||
#endif /* USE_TERMIO */
|
||||
old = ttyflush(SYNCHing|flushout);
|
||||
} while (old < 0 || old > 1);
|
||||
}
|
||||
|
||||
old = prevmode;
|
||||
prevmode = f&~MODE_FORCE;
|
||||
#ifndef USE_TERMIO
|
||||
sb = nttyb;
|
||||
tc = ntc;
|
||||
ltc = nltc;
|
||||
lmode = olmode;
|
||||
#else
|
||||
tmp_tc = new_tc;
|
||||
#endif
|
||||
|
||||
if (f&MODE_ECHO) {
|
||||
#ifndef USE_TERMIO
|
||||
sb.sg_flags |= ECHO;
|
||||
#else
|
||||
tmp_tc.c_lflag |= ECHO;
|
||||
tmp_tc.c_oflag |= ONLCR;
|
||||
if (crlf)
|
||||
tmp_tc.c_iflag |= ICRNL;
|
||||
#endif
|
||||
} else {
|
||||
#ifndef USE_TERMIO
|
||||
sb.sg_flags &= ~ECHO;
|
||||
#else
|
||||
tmp_tc.c_lflag &= ~ECHO;
|
||||
tmp_tc.c_oflag &= ~ONLCR;
|
||||
# ifdef notdef
|
||||
if (crlf)
|
||||
tmp_tc.c_iflag &= ~ICRNL;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((f&MODE_FLOW) == 0) {
|
||||
#ifndef USE_TERMIO
|
||||
tc.t_startc = _POSIX_VDISABLE;
|
||||
tc.t_stopc = _POSIX_VDISABLE;
|
||||
#else
|
||||
tmp_tc.c_iflag &= ~(IXOFF|IXON); /* Leave the IXANY bit alone */
|
||||
} else {
|
||||
if (restartany < 0) {
|
||||
@@ -485,63 +404,32 @@ TerminalNewMode(f)
|
||||
tmp_tc.c_iflag |= IXOFF|IXON;
|
||||
tmp_tc.c_iflag &= ~IXANY;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((f&MODE_TRAPSIG) == 0) {
|
||||
#ifndef USE_TERMIO
|
||||
tc.t_intrc = _POSIX_VDISABLE;
|
||||
tc.t_quitc = _POSIX_VDISABLE;
|
||||
tc.t_eofc = _POSIX_VDISABLE;
|
||||
ltc.t_suspc = _POSIX_VDISABLE;
|
||||
ltc.t_dsuspc = _POSIX_VDISABLE;
|
||||
#else
|
||||
tmp_tc.c_lflag &= ~ISIG;
|
||||
#endif
|
||||
localchars = 0;
|
||||
} else {
|
||||
#ifdef USE_TERMIO
|
||||
tmp_tc.c_lflag |= ISIG;
|
||||
#endif
|
||||
localchars = 1;
|
||||
}
|
||||
|
||||
if (f&MODE_EDIT) {
|
||||
#ifndef USE_TERMIO
|
||||
sb.sg_flags &= ~CBREAK;
|
||||
sb.sg_flags |= CRMOD;
|
||||
#else
|
||||
tmp_tc.c_lflag |= ICANON;
|
||||
#endif
|
||||
} else {
|
||||
#ifndef USE_TERMIO
|
||||
sb.sg_flags |= CBREAK;
|
||||
if (f&MODE_ECHO)
|
||||
sb.sg_flags |= CRMOD;
|
||||
else
|
||||
sb.sg_flags &= ~CRMOD;
|
||||
#else
|
||||
tmp_tc.c_lflag &= ~ICANON;
|
||||
tmp_tc.c_iflag &= ~ICRNL;
|
||||
tmp_tc.c_cc[VMIN] = 1;
|
||||
tmp_tc.c_cc[VTIME] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((f&(MODE_EDIT|MODE_TRAPSIG)) == 0) {
|
||||
#ifndef USE_TERMIO
|
||||
ltc.t_lnextc = _POSIX_VDISABLE;
|
||||
#else
|
||||
# ifdef VLNEXT
|
||||
tmp_tc.c_cc[VLNEXT] = (cc_t)(_POSIX_VDISABLE);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (f&MODE_SOFT_TAB) {
|
||||
#ifndef USE_TERMIO
|
||||
sb.sg_flags |= XTABS;
|
||||
#else
|
||||
# ifdef OXTABS
|
||||
tmp_tc.c_oflag |= OXTABS;
|
||||
# endif
|
||||
@@ -549,52 +437,28 @@ TerminalNewMode(f)
|
||||
tmp_tc.c_oflag &= ~TABDLY;
|
||||
tmp_tc.c_oflag |= TAB3;
|
||||
# endif
|
||||
#endif
|
||||
} else {
|
||||
#ifndef USE_TERMIO
|
||||
sb.sg_flags &= ~XTABS;
|
||||
#else
|
||||
# ifdef OXTABS
|
||||
tmp_tc.c_oflag &= ~OXTABS;
|
||||
# endif
|
||||
# ifdef TABDLY
|
||||
tmp_tc.c_oflag &= ~TABDLY;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (f&MODE_LIT_ECHO) {
|
||||
#ifndef USE_TERMIO
|
||||
lmode &= ~LCTLECH;
|
||||
#else
|
||||
# ifdef ECHOCTL
|
||||
tmp_tc.c_lflag &= ~ECHOCTL;
|
||||
# endif
|
||||
#endif
|
||||
} else {
|
||||
#ifndef USE_TERMIO
|
||||
lmode |= LCTLECH;
|
||||
#else
|
||||
# ifdef ECHOCTL
|
||||
tmp_tc.c_lflag |= ECHOCTL;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (f == -1) {
|
||||
onoff = 0;
|
||||
} else {
|
||||
#ifndef USE_TERMIO
|
||||
if (f & MODE_OUTBIN)
|
||||
lmode |= LLITOUT;
|
||||
else
|
||||
lmode &= ~LLITOUT;
|
||||
|
||||
if (f & MODE_INBIN)
|
||||
lmode |= LPASS8;
|
||||
else
|
||||
lmode &= ~LPASS8;
|
||||
#else
|
||||
if (f & MODE_INBIN)
|
||||
tmp_tc.c_iflag &= ~ISTRIP;
|
||||
else
|
||||
@@ -608,16 +472,15 @@ TerminalNewMode(f)
|
||||
tmp_tc.c_cflag |= old_tc.c_cflag & (CSIZE|PARENB);
|
||||
tmp_tc.c_oflag |= OPOST;
|
||||
}
|
||||
#endif
|
||||
onoff = 1;
|
||||
}
|
||||
|
||||
if (f != -1) {
|
||||
#ifdef SIGTSTP
|
||||
SIG_FUNC_RET susp();
|
||||
RETSIGTYPE susp();
|
||||
#endif /* SIGTSTP */
|
||||
#ifdef SIGINFO
|
||||
SIG_FUNC_RET ayt();
|
||||
RETSIGTYPE ayt();
|
||||
#endif
|
||||
|
||||
#ifdef SIGTSTP
|
||||
@@ -626,7 +489,7 @@ TerminalNewMode(f)
|
||||
#ifdef SIGINFO
|
||||
(void) signal(SIGINFO, ayt);
|
||||
#endif
|
||||
#if defined(USE_TERMIO) && defined(NOKERNINFO)
|
||||
#ifdef NOKERNINFO
|
||||
tmp_tc.c_lflag |= NOKERNINFO;
|
||||
#endif
|
||||
/*
|
||||
@@ -635,14 +498,9 @@ TerminalNewMode(f)
|
||||
* to process it because it will be processed when the
|
||||
* user attempts to read it, not when we send it.
|
||||
*/
|
||||
#ifndef USE_TERMIO
|
||||
ltc.t_dsuspc = _POSIX_VDISABLE;
|
||||
#else
|
||||
# ifdef VDSUSP
|
||||
tmp_tc.c_cc[VDSUSP] = (cc_t)(_POSIX_VDISABLE);
|
||||
# endif
|
||||
#endif
|
||||
#ifdef USE_TERMIO
|
||||
/*
|
||||
* If the VEOL character is already set, then use VEOL2,
|
||||
* otherwise use VEOL.
|
||||
@@ -660,54 +518,26 @@ TerminalNewMode(f)
|
||||
tmp_tc.c_cc[VEOL2] = esc;
|
||||
# endif
|
||||
}
|
||||
#else
|
||||
if (tc.t_brkc == (cc_t)(_POSIX_VDISABLE))
|
||||
tc.t_brkc = esc;
|
||||
#endif
|
||||
} else {
|
||||
sigset_t sm;
|
||||
#ifdef SIGINFO
|
||||
SIG_FUNC_RET ayt_status();
|
||||
RETSIGTYPE ayt_status();
|
||||
|
||||
(void) signal(SIGINFO, ayt_status);
|
||||
#endif
|
||||
#ifdef SIGTSTP
|
||||
(void) signal(SIGTSTP, SIG_DFL);
|
||||
# ifndef SOLARIS
|
||||
(void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
|
||||
# else
|
||||
(void) sigrelse(SIGTSTP);
|
||||
# endif
|
||||
sigemptyset(sm);
|
||||
sigaddset(sm, SIGTSTP);
|
||||
sigprocmask(SIG_UNBLOCK, &sm, NULL);
|
||||
#endif /* SIGTSTP */
|
||||
#ifndef USE_TERMIO
|
||||
ltc = oltc;
|
||||
tc = otc;
|
||||
sb = ottyb;
|
||||
lmode = olmode;
|
||||
#else
|
||||
tmp_tc = old_tc;
|
||||
#endif
|
||||
}
|
||||
#ifndef USE_TERMIO
|
||||
ioctl(tin, TIOCLSET, (char *)&lmode);
|
||||
ioctl(tin, TIOCSLTC, (char *)<c);
|
||||
ioctl(tin, TIOCSETC, (char *)&tc);
|
||||
ioctl(tin, TIOCSETN, (char *)&sb);
|
||||
#else
|
||||
if (tcsetattr(tin, TCSADRAIN, &tmp_tc) < 0)
|
||||
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) */
|
||||
|
||||
}
|
||||
|
||||
@@ -839,32 +669,13 @@ NetNonblockingIO(fd, 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
|
||||
RETSIGTYPE
|
||||
deadpeer(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -873,7 +684,7 @@ deadpeer(sig)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
RETSIGTYPE
|
||||
intr(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -886,7 +697,7 @@ intr(sig)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
RETSIGTYPE
|
||||
intr2(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -903,7 +714,7 @@ intr2(sig)
|
||||
|
||||
#ifdef SIGTSTP
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
RETSIGTYPE
|
||||
susp(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -916,7 +727,7 @@ susp(sig)
|
||||
|
||||
#ifdef SIGWINCH
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
RETSIGTYPE
|
||||
sendwin(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -928,7 +739,7 @@ sendwin(sig)
|
||||
|
||||
#ifdef SIGINFO
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
RETSIGTYPE
|
||||
ayt(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -960,12 +771,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) {
|
||||
@@ -1004,24 +809,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);
|
||||
}
|
||||
@@ -1036,23 +829,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\r\n");
|
||||
sleep(5);
|
||||
|
@@ -38,13 +38,11 @@ RCSID("$Id$");
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(unix)
|
||||
#include <signal.h>
|
||||
/* By the way, we need to include curses.h before telnet.h since,
|
||||
* among other things, telnet.h #defines 'DO', which is a variable
|
||||
* declared in curses.h.
|
||||
*/
|
||||
#endif /* defined(unix) */
|
||||
|
||||
#include <arpa/telnet.h>
|
||||
|
||||
@@ -83,17 +81,11 @@ int
|
||||
skiprc = 0,
|
||||
connected,
|
||||
showoptions,
|
||||
In3270, /* Are we in 3270 mode? */
|
||||
ISend, /* trying to send network data in */
|
||||
debug = 0,
|
||||
crmod,
|
||||
netdata, /* Print out network data flow */
|
||||
crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
|
||||
#if defined(TN3270)
|
||||
noasynchtty = 0,/* User specified "-noasynch" on command line */
|
||||
noasynchnet = 0,/* User specified "-noasynch" on command line */
|
||||
askedSGA = 0, /* We have talked about suppress go ahead */
|
||||
#endif /* defined(TN3270) */
|
||||
telnetport,
|
||||
SYNCHing, /* we are in TELNET SYNCH mode */
|
||||
flushout, /* flush output */
|
||||
@@ -177,7 +169,7 @@ init_telnet()
|
||||
SB_CLEAR();
|
||||
ClearArray(options);
|
||||
|
||||
connected = In3270 = ISend = localflow = donebinarytoggle = 0;
|
||||
connected = ISend = localflow = donebinarytoggle = 0;
|
||||
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
|
||||
auth_encrypt_connect(connected);
|
||||
#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
|
||||
@@ -338,30 +330,6 @@ willoption(option)
|
||||
switch (option) {
|
||||
|
||||
case TELOPT_ECHO:
|
||||
# if defined(TN3270)
|
||||
/*
|
||||
* The following is a pain in the rear-end.
|
||||
* Various IBM servers (some versions of Wiscnet,
|
||||
* possibly Fibronics/Spartacus, and who knows who
|
||||
* else) will NOT allow us to send "DO SGA" too early
|
||||
* in the setup proceedings. On the other hand,
|
||||
* 4.2 servers (telnetd) won't set SGA correctly.
|
||||
* So, we are stuck. Empirically (but, based on
|
||||
* a VERY small sample), the IBM servers don't send
|
||||
* out anything about ECHO, so we postpone our sending
|
||||
* "DO SGA" until we see "WILL ECHO" (which 4.2 servers
|
||||
* DO send).
|
||||
*/
|
||||
{
|
||||
if (askedSGA == 0) {
|
||||
askedSGA = 1;
|
||||
if (my_want_state_is_dont(TELOPT_SGA))
|
||||
send_do(TELOPT_SGA, 1);
|
||||
}
|
||||
}
|
||||
/* Fall through */
|
||||
case TELOPT_EOR:
|
||||
#endif /* defined(TN3270) */
|
||||
case TELOPT_BINARY:
|
||||
case TELOPT_SGA:
|
||||
settimer(modenegotiated);
|
||||
@@ -484,9 +452,6 @@ dooption(option)
|
||||
set_my_state_wont(TELOPT_TM);
|
||||
return;
|
||||
|
||||
# if defined(TN3270)
|
||||
case TELOPT_EOR: /* end of record */
|
||||
# endif /* defined(TN3270) */
|
||||
case TELOPT_BINARY: /* binary mode */
|
||||
case TELOPT_NAWS: /* window size */
|
||||
case TELOPT_TSPEED: /* terminal speed */
|
||||
@@ -685,7 +650,7 @@ mklist(buf, name)
|
||||
* Skip entries with spaces or non-ascii values.
|
||||
* Convert lower case letters to upper case.
|
||||
*/
|
||||
#define ISASCII(c) (0 <= (c) && (c) < 0200)
|
||||
#define ISASCII(c) (!((c)&0x80))
|
||||
if ((c == ' ') || !ISASCII(c))
|
||||
n = 1;
|
||||
else if (islower(c))
|
||||
@@ -742,14 +707,11 @@ is_unique(name, as, ae)
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef TERMCAP
|
||||
#ifndef HAVE_SETUPTERM
|
||||
char termbuf[1024];
|
||||
|
||||
#ifndef HAVE_SETUPTERM
|
||||
int
|
||||
setupterm(tname, fd, errp)
|
||||
char *tname;
|
||||
int fd, *errp;
|
||||
setupterm(char *tname, int fd, int *errp)
|
||||
{
|
||||
if (tgetent(termbuf, tname) == 1) {
|
||||
termbuf[1023] = '\0';
|
||||
@@ -761,7 +723,6 @@ setupterm(tname, fd, errp)
|
||||
*errp = 0;
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define termbuf ttytype
|
||||
extern char ttytype[];
|
||||
@@ -769,7 +730,7 @@ extern char ttytype[];
|
||||
|
||||
int resettermname = 1;
|
||||
|
||||
char *
|
||||
char *
|
||||
gettermname()
|
||||
{
|
||||
char *tname;
|
||||
@@ -829,11 +790,6 @@ suboption()
|
||||
unsigned char temp[50];
|
||||
int len;
|
||||
|
||||
#if defined(TN3270)
|
||||
if (tn3270_ttype()) {
|
||||
return;
|
||||
}
|
||||
#endif /* defined(TN3270) */
|
||||
name = gettermname();
|
||||
len = strlen(name) + 4 + 2;
|
||||
if (len < NETROOM()) {
|
||||
@@ -1231,27 +1187,17 @@ slc_init()
|
||||
/* No EOR */
|
||||
initfunc(SLC_ABORT, SLC_FLUSHIN|SLC_FLUSHOUT);
|
||||
initfunc(SLC_EOF, 0);
|
||||
#ifndef SYSV_TERMIO
|
||||
initfunc(SLC_SUSP, SLC_FLUSHIN);
|
||||
#endif
|
||||
initfunc(SLC_EC, 0);
|
||||
initfunc(SLC_EL, 0);
|
||||
#ifndef SYSV_TERMIO
|
||||
initfunc(SLC_EW, 0);
|
||||
initfunc(SLC_RP, 0);
|
||||
initfunc(SLC_LNEXT, 0);
|
||||
#endif
|
||||
initfunc(SLC_XON, 0);
|
||||
initfunc(SLC_XOFF, 0);
|
||||
#ifdef SYSV_TERMIO
|
||||
spc_data[SLC_XON].mylevel = SLC_CANTCHANGE;
|
||||
spc_data[SLC_XOFF].mylevel = SLC_CANTCHANGE;
|
||||
#endif
|
||||
initfunc(SLC_FORW1, 0);
|
||||
#ifdef USE_TERMIO
|
||||
initfunc(SLC_FORW2, 0);
|
||||
/* No FORW2 */
|
||||
#endif
|
||||
|
||||
initfunc(SLC_IP, SLC_FLUSHIN|SLC_FLUSHOUT);
|
||||
#undef initfunc
|
||||
@@ -1263,7 +1209,7 @@ slc_init()
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
slcstate()
|
||||
{
|
||||
printf("Special characters are %s values\n",
|
||||
@@ -1272,7 +1218,7 @@ slcstate()
|
||||
"remote");
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
slc_mode_export()
|
||||
{
|
||||
slc_mode = SLC_EXPORT;
|
||||
@@ -1280,9 +1226,8 @@ slc_mode_export()
|
||||
slc_export();
|
||||
}
|
||||
|
||||
void
|
||||
slc_mode_import(def)
|
||||
int def;
|
||||
void
|
||||
slc_mode_import(int def)
|
||||
{
|
||||
slc_mode = def ? SLC_IMPORT : SLC_RVALUE;
|
||||
if (my_state_is_will(TELOPT_LINEMODE))
|
||||
@@ -1296,9 +1241,8 @@ unsigned char slc_import_def[] = {
|
||||
IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE
|
||||
};
|
||||
|
||||
void
|
||||
slc_import(def)
|
||||
int def;
|
||||
void
|
||||
slc_import(int def)
|
||||
{
|
||||
if (NETROOM() > sizeof(slc_import_val)) {
|
||||
if (def) {
|
||||
@@ -1312,7 +1256,7 @@ slc_import(def)
|
||||
/*@*/ else printf("slc_import: not enough room\n");
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
slc_export()
|
||||
{
|
||||
register struct spc *spcp;
|
||||
@@ -1336,10 +1280,8 @@ slc_export()
|
||||
setconnmode(1); /* Make sure the character values are set */
|
||||
}
|
||||
|
||||
void
|
||||
slc(cp, len)
|
||||
register unsigned char *cp;
|
||||
int len;
|
||||
void
|
||||
slc(unsigned char *cp, int len)
|
||||
{
|
||||
register struct spc *spcp;
|
||||
register int func,level;
|
||||
@@ -1406,7 +1348,7 @@ slc(cp, len)
|
||||
setconnmode(1); /* set the new character values */
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
slc_check()
|
||||
{
|
||||
register struct spc *spcp;
|
||||
@@ -1430,7 +1372,7 @@ slc_check()
|
||||
unsigned char slc_reply[128];
|
||||
unsigned char *slc_replyp;
|
||||
|
||||
void
|
||||
void
|
||||
slc_start_reply()
|
||||
{
|
||||
slc_replyp = slc_reply;
|
||||
@@ -1440,11 +1382,8 @@ slc_start_reply()
|
||||
*slc_replyp++ = LM_SLC;
|
||||
}
|
||||
|
||||
void
|
||||
slc_add_reply(func, flags, value)
|
||||
unsigned char func;
|
||||
unsigned char flags;
|
||||
cc_t value;
|
||||
void
|
||||
slc_add_reply(unsigned char func, unsigned char flags, cc_t value)
|
||||
{
|
||||
if ((*slc_replyp++ = func) == IAC)
|
||||
*slc_replyp++ = IAC;
|
||||
@@ -1454,7 +1393,7 @@ slc_add_reply(func, flags, value)
|
||||
*slc_replyp++ = IAC;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
slc_end_reply()
|
||||
{
|
||||
register int len;
|
||||
@@ -1471,7 +1410,7 @@ slc_end_reply()
|
||||
/*@*/else printf("slc_end_reply: not enough room\n");
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
slc_update()
|
||||
{
|
||||
register struct spc *spcp;
|
||||
@@ -1490,23 +1429,8 @@ slc_update()
|
||||
}
|
||||
|
||||
#ifdef OLD_ENVIRON
|
||||
# ifdef ENV_HACK
|
||||
/*
|
||||
* Earlier version of telnet/telnetd from the BSD code had
|
||||
* the definitions of VALUE and VAR reversed. To ensure
|
||||
* maximum interoperability, we assume that the server is
|
||||
* an older BSD server, until proven otherwise. The newer
|
||||
* BSD servers should be able to handle either definition,
|
||||
* so it is better to use the wrong values if we don't
|
||||
* know what type of server it is.
|
||||
*/
|
||||
int env_auto = 1;
|
||||
int old_env_var = OLD_ENV_VAR;
|
||||
int old_env_value = OLD_ENV_VALUE;
|
||||
# else
|
||||
# define old_env_var OLD_ENV_VAR
|
||||
# define old_env_value OLD_ENV_VALUE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void
|
||||
@@ -1526,15 +1450,6 @@ env_opt(buf, len)
|
||||
switch (buf[i]&0xff) {
|
||||
#ifdef OLD_ENVIRON
|
||||
case OLD_ENV_VAR:
|
||||
# ifdef ENV_HACK
|
||||
if (telopt_environ == TELOPT_OLD_ENVIRON
|
||||
&& env_auto) {
|
||||
/* Server has the same definitions */
|
||||
old_env_var = OLD_ENV_VAR;
|
||||
old_env_value = OLD_ENV_VALUE;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
# endif
|
||||
case OLD_ENV_VALUE:
|
||||
/*
|
||||
* Although OLD_ENV_VALUE is not legal, we will
|
||||
@@ -1772,23 +1687,6 @@ telrcv()
|
||||
telrcv_state = TS_IAC;
|
||||
break;
|
||||
}
|
||||
# if defined(TN3270)
|
||||
if (In3270) {
|
||||
*Ifrontp++ = c;
|
||||
while (scc > 0) {
|
||||
c = *sbp++ & 0377, scc--; count++;
|
||||
#if defined(ENCRYPTION)
|
||||
if (decrypt_input)
|
||||
c = (*decrypt_input)(c);
|
||||
#endif
|
||||
if (c == IAC) {
|
||||
telrcv_state = TS_IAC;
|
||||
break;
|
||||
}
|
||||
*Ifrontp++ = c;
|
||||
}
|
||||
} else
|
||||
# endif /* defined(TN3270) */
|
||||
/*
|
||||
* The 'crmod' hack (see following) is needed
|
||||
* since we can't * set CRMOD on output only.
|
||||
@@ -1872,31 +1770,9 @@ process_iac:
|
||||
telrcv_state = TS_SB;
|
||||
continue;
|
||||
|
||||
# if defined(TN3270)
|
||||
case EOR:
|
||||
if (In3270) {
|
||||
if (Ibackp == Ifrontp) {
|
||||
Ibackp = Ifrontp = Ibuf;
|
||||
ISend = 0; /* should have been! */
|
||||
} else {
|
||||
Ibackp += DataFromNetwork(Ibackp, Ifrontp-Ibackp, 1);
|
||||
ISend = 1;
|
||||
}
|
||||
}
|
||||
printoption("RCVD", IAC, EOR);
|
||||
break;
|
||||
# endif /* defined(TN3270) */
|
||||
|
||||
case IAC:
|
||||
# if !defined(TN3270)
|
||||
TTYADD(IAC);
|
||||
# else /* !defined(TN3270) */
|
||||
if (In3270) {
|
||||
*Ifrontp++ = IAC;
|
||||
} else {
|
||||
TTYADD(IAC);
|
||||
}
|
||||
# endif /* !defined(TN3270) */
|
||||
break;
|
||||
|
||||
case NOP:
|
||||
@@ -1911,21 +1787,18 @@ process_iac:
|
||||
case TS_WILL:
|
||||
printoption("RCVD", WILL, c);
|
||||
willoption(c);
|
||||
SetIn3270();
|
||||
telrcv_state = TS_DATA;
|
||||
continue;
|
||||
|
||||
case TS_WONT:
|
||||
printoption("RCVD", WONT, c);
|
||||
wontoption(c);
|
||||
SetIn3270();
|
||||
telrcv_state = TS_DATA;
|
||||
continue;
|
||||
|
||||
case TS_DO:
|
||||
printoption("RCVD", DO, c);
|
||||
dooption(c);
|
||||
SetIn3270();
|
||||
if (c == TELOPT_NAWS) {
|
||||
sendnaws();
|
||||
} else if (c == TELOPT_LFLOW) {
|
||||
@@ -1941,7 +1814,6 @@ process_iac:
|
||||
dontoption(c);
|
||||
flushline = 1;
|
||||
setconnmode(0); /* set new tty mode (maybe) */
|
||||
SetIn3270();
|
||||
telrcv_state = TS_DATA;
|
||||
continue;
|
||||
|
||||
@@ -1975,7 +1847,6 @@ process_iac:
|
||||
|
||||
printoption("In SUBOPTION processing, RCVD", IAC, c);
|
||||
suboption(); /* handle sub-option */
|
||||
SetIn3270();
|
||||
telrcv_state = TS_IAC;
|
||||
goto process_iac;
|
||||
}
|
||||
@@ -1987,7 +1858,6 @@ process_iac:
|
||||
subpointer -= 2;
|
||||
SB_TERM();
|
||||
suboption(); /* handle sub-option */
|
||||
SetIn3270();
|
||||
telrcv_state = TS_DATA;
|
||||
}
|
||||
}
|
||||
@@ -2186,27 +2056,13 @@ Scheduler(block)
|
||||
my_want_state_is_will(TELOPT_BINARY));
|
||||
ttyout = ring_full_count(&ttyoring);
|
||||
|
||||
#if defined(TN3270)
|
||||
ttyin = ring_empty_count(&ttyiring) && (shell_active == 0);
|
||||
#else /* defined(TN3270) */
|
||||
ttyin = ring_empty_count(&ttyiring);
|
||||
#endif /* defined(TN3270) */
|
||||
|
||||
#if defined(TN3270)
|
||||
netin = ring_empty_count(&netiring);
|
||||
# else /* !defined(TN3270) */
|
||||
netin = !ISend && ring_empty_count(&netiring);
|
||||
# endif /* !defined(TN3270) */
|
||||
|
||||
netex = !SYNCHing;
|
||||
|
||||
/* If we have seen a signal recently, reset things */
|
||||
# if defined(TN3270) && defined(unix)
|
||||
if (HaveInput) {
|
||||
HaveInput = 0;
|
||||
(void) signal(SIGIO, inputAvailable);
|
||||
}
|
||||
#endif /* defined(TN3270) && defined(unix) */
|
||||
|
||||
/* Call to system code to process rings */
|
||||
|
||||
@@ -2215,30 +2071,11 @@ Scheduler(block)
|
||||
/* Now, look at the input rings, looking for work to do. */
|
||||
|
||||
if (ring_full_count(&ttyiring)) {
|
||||
# if defined(TN3270)
|
||||
if (In3270) {
|
||||
int c;
|
||||
|
||||
c = DataFromTerminal(ttyiring.consume,
|
||||
ring_full_consecutive(&ttyiring));
|
||||
if (c) {
|
||||
returnValue = 1;
|
||||
ring_consumed(&ttyiring, c);
|
||||
}
|
||||
} else {
|
||||
# endif /* defined(TN3270) */
|
||||
returnValue |= telsnd();
|
||||
# if defined(TN3270)
|
||||
}
|
||||
# endif /* defined(TN3270) */
|
||||
}
|
||||
|
||||
if (ring_full_count(&netiring)) {
|
||||
# if !defined(TN3270)
|
||||
returnValue |= telrcv();
|
||||
# else /* !defined(TN3270) */
|
||||
returnValue = Push3270();
|
||||
# endif /* !defined(TN3270) */
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -2264,7 +2101,6 @@ telnet(user)
|
||||
auth_encrypt_user(user);
|
||||
}
|
||||
#endif
|
||||
# if !defined(TN3270)
|
||||
if (telnetport) {
|
||||
#if defined(AUTHENTICATION)
|
||||
if (autologin)
|
||||
@@ -2287,9 +2123,7 @@ telnet(user)
|
||||
if (eight)
|
||||
tel_enter_binary(eight);
|
||||
}
|
||||
# endif /* !defined(TN3270) */
|
||||
|
||||
# if !defined(TN3270)
|
||||
for (;;) {
|
||||
int schedValue;
|
||||
|
||||
@@ -2305,45 +2139,6 @@ telnet(user)
|
||||
return;
|
||||
}
|
||||
}
|
||||
# else /* !defined(TN3270) */
|
||||
for (;;) {
|
||||
int schedValue;
|
||||
|
||||
while (!In3270 && !shell_active) {
|
||||
if (Scheduler(1) == -1) {
|
||||
setcommandmode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while ((schedValue = Scheduler(0)) != 0) {
|
||||
if (schedValue == -1) {
|
||||
setcommandmode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* If there is data waiting to go out to terminal, don't
|
||||
* schedule any more data for the terminal.
|
||||
*/
|
||||
if (ring_full_count(&ttyoring)) {
|
||||
schedValue = 1;
|
||||
} else {
|
||||
if (shell_active) {
|
||||
if (shell_continue() == 0) {
|
||||
ConnectScreen();
|
||||
}
|
||||
} else if (In3270) {
|
||||
schedValue = DoTerminalOutput();
|
||||
}
|
||||
}
|
||||
if (schedValue && (shell_active == 0)) {
|
||||
if (Scheduler(1) == -1) {
|
||||
setcommandmode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif /* !defined(TN3270) */
|
||||
}
|
||||
|
||||
#if 0 /* XXX - this not being in is a bug */
|
||||
|
@@ -48,7 +48,6 @@ unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ];
|
||||
|
||||
int termdata; /* Debugging flag */
|
||||
|
||||
#ifdef USE_TERMIO
|
||||
# ifndef VDISCARD
|
||||
cc_t termFlushChar;
|
||||
# endif
|
||||
@@ -79,10 +78,6 @@ cc_t termForw2Char;
|
||||
# ifndef VSTATUS
|
||||
cc_t termAytChar;
|
||||
# endif
|
||||
#else
|
||||
cc_t termForw2Char;
|
||||
cc_t termAytChar;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* initialize the terminal data structures.
|
||||
@@ -171,9 +166,6 @@ getconnmode()
|
||||
extern int kludgelinemode;
|
||||
#endif
|
||||
|
||||
if (In3270)
|
||||
return(MODE_FLOW);
|
||||
|
||||
if (my_want_state_is_dont(TELOPT_ECHO))
|
||||
mode |= MODE_ECHO;
|
||||
|
||||
|
@@ -1,411 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <arpa/telnet.h>
|
||||
|
||||
#include "general.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "ring.h"
|
||||
#include "externs.h"
|
||||
#include "fdset.h"
|
||||
|
||||
#if defined(TN3270)
|
||||
|
||||
#include "../ctlr/screen.h"
|
||||
#include "../general/globals.h"
|
||||
|
||||
#include "../sys_curses/telextrn.h"
|
||||
#include "../ctlr/externs.h"
|
||||
|
||||
#if defined(unix)
|
||||
int
|
||||
HaveInput, /* There is input available to scan */
|
||||
cursesdata, /* Do we dump curses data? */
|
||||
sigiocount; /* Number of times we got a SIGIO */
|
||||
|
||||
char tline[200];
|
||||
char *transcom = 0; /* transparent mode command (default: none) */
|
||||
#endif /* defined(unix) */
|
||||
|
||||
char Ibuf[8*BUFSIZ], *Ifrontp, *Ibackp;
|
||||
|
||||
static char sb_terminal[] = { IAC, SB,
|
||||
TELOPT_TTYPE, TELQUAL_IS,
|
||||
'I', 'B', 'M', '-', '3', '2', '7', '8', '-', '2',
|
||||
IAC, SE };
|
||||
#define SBTERMMODEL 13
|
||||
|
||||
static int
|
||||
Sent3270TerminalType; /* Have we said we are a 3270? */
|
||||
|
||||
#endif /* defined(TN3270) */
|
||||
|
||||
|
||||
void
|
||||
init_3270()
|
||||
{
|
||||
#if defined(TN3270)
|
||||
#if defined(unix)
|
||||
HaveInput = 0;
|
||||
sigiocount = 0;
|
||||
#endif /* defined(unix) */
|
||||
Sent3270TerminalType = 0;
|
||||
Ifrontp = Ibackp = Ibuf;
|
||||
init_ctlr(); /* Initialize some things */
|
||||
init_keyboard();
|
||||
init_screen();
|
||||
init_system();
|
||||
#endif /* defined(TN3270) */
|
||||
}
|
||||
|
||||
|
||||
#if defined(TN3270)
|
||||
|
||||
/*
|
||||
* DataToNetwork - queue up some data to go to network. If "done" is set,
|
||||
* then when last byte is queued, we add on an IAC EOR sequence (so,
|
||||
* don't call us with "done" until you want that done...)
|
||||
*
|
||||
* We actually do send all the data to the network buffer, since our
|
||||
* only client needs for us to do that.
|
||||
*/
|
||||
|
||||
int
|
||||
DataToNetwork(buffer, count, done)
|
||||
register char *buffer; /* where the data is */
|
||||
register int count; /* how much to send */
|
||||
int done; /* is this the last of a logical block */
|
||||
{
|
||||
register int loop, c;
|
||||
int origCount;
|
||||
|
||||
origCount = count;
|
||||
|
||||
while (count) {
|
||||
/* If not enough room for EORs, IACs, etc., wait */
|
||||
if (NETROOM() < 6) {
|
||||
fd_set o;
|
||||
|
||||
FD_ZERO(&o);
|
||||
netflush();
|
||||
while (NETROOM() < 6) {
|
||||
FD_SET(net, &o);
|
||||
(void) select(net+1, (fd_set *) 0, &o, (fd_set *) 0,
|
||||
(struct timeval *) 0);
|
||||
netflush();
|
||||
}
|
||||
}
|
||||
c = ring_empty_count(&netoring);
|
||||
if (c > count) {
|
||||
c = count;
|
||||
}
|
||||
loop = c;
|
||||
while (loop) {
|
||||
if (((unsigned char)*buffer) == IAC) {
|
||||
break;
|
||||
}
|
||||
buffer++;
|
||||
loop--;
|
||||
}
|
||||
if ((c = c-loop)) {
|
||||
ring_supply_data(&netoring, buffer-c, c);
|
||||
count -= c;
|
||||
}
|
||||
if (loop) {
|
||||
NET2ADD(IAC, IAC);
|
||||
count--;
|
||||
buffer++;
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
NET2ADD(IAC, EOR);
|
||||
netflush(); /* try to move along as quickly as ... */
|
||||
}
|
||||
return(origCount - count);
|
||||
}
|
||||
|
||||
|
||||
#if defined(unix)
|
||||
void
|
||||
inputAvailable(signo)
|
||||
int signo;
|
||||
{
|
||||
HaveInput = 1;
|
||||
sigiocount++;
|
||||
}
|
||||
#endif /* defined(unix) */
|
||||
|
||||
void
|
||||
outputPurge()
|
||||
{
|
||||
(void) ttyflush(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The following routines are places where the various tn3270
|
||||
* routines make calls into telnet.c.
|
||||
*/
|
||||
|
||||
/*
|
||||
* DataToTerminal - queue up some data to go to terminal.
|
||||
*
|
||||
* Note: there are people who call us and depend on our processing
|
||||
* *all* the data at one time (thus the select).
|
||||
*/
|
||||
|
||||
int
|
||||
DataToTerminal(buffer, count)
|
||||
register char *buffer; /* where the data is */
|
||||
register int count; /* how much to send */
|
||||
{
|
||||
register int c;
|
||||
int origCount;
|
||||
|
||||
origCount = count;
|
||||
|
||||
while (count) {
|
||||
if (TTYROOM() == 0) {
|
||||
#if defined(unix)
|
||||
fd_set o;
|
||||
|
||||
FD_ZERO(&o);
|
||||
#endif /* defined(unix) */
|
||||
(void) ttyflush(0);
|
||||
while (TTYROOM() == 0) {
|
||||
#if defined(unix)
|
||||
FD_SET(tout, &o);
|
||||
(void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
|
||||
(struct timeval *) 0);
|
||||
#endif /* defined(unix) */
|
||||
(void) ttyflush(0);
|
||||
}
|
||||
}
|
||||
c = TTYROOM();
|
||||
if (c > count) {
|
||||
c = count;
|
||||
}
|
||||
ring_supply_data(&ttyoring, buffer, c);
|
||||
count -= c;
|
||||
buffer += c;
|
||||
}
|
||||
return(origCount);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Push3270 - Try to send data along the 3270 output (to screen) direction.
|
||||
*/
|
||||
|
||||
int
|
||||
Push3270()
|
||||
{
|
||||
int save = ring_full_count(&netiring);
|
||||
|
||||
if (save) {
|
||||
if (Ifrontp+save > Ibuf+sizeof Ibuf) {
|
||||
if (Ibackp != Ibuf) {
|
||||
memmove(Ibuf, Ibackp, Ifrontp-Ibackp);
|
||||
Ifrontp -= (Ibackp-Ibuf);
|
||||
Ibackp = Ibuf;
|
||||
}
|
||||
}
|
||||
if (Ifrontp+save < Ibuf+sizeof Ibuf) {
|
||||
(void)telrcv();
|
||||
}
|
||||
}
|
||||
return save != ring_full_count(&netiring);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Finish3270 - get the last dregs of 3270 data out to the terminal
|
||||
* before quitting.
|
||||
*/
|
||||
|
||||
void
|
||||
Finish3270()
|
||||
{
|
||||
while (Push3270() || !DoTerminalOutput()) {
|
||||
#if defined(unix)
|
||||
HaveInput = 0;
|
||||
#endif /* defined(unix) */
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* StringToTerminal - output a null terminated string to the terminal */
|
||||
|
||||
void
|
||||
StringToTerminal(s)
|
||||
char *s;
|
||||
{
|
||||
int count;
|
||||
|
||||
count = strlen(s);
|
||||
if (count) {
|
||||
(void) DataToTerminal(s, count); /* we know it always goes... */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if ((!defined(NOT43)) || defined(PUTCHAR))
|
||||
/* _putchar - output a single character to the terminal. This name is so that
|
||||
* curses(3x) can call us to send out data.
|
||||
*/
|
||||
|
||||
void
|
||||
_putchar(c)
|
||||
char c;
|
||||
{
|
||||
#if defined(sun) /* SunOS 4.0 bug */
|
||||
c &= 0x7f;
|
||||
#endif /* defined(sun) */
|
||||
if (cursesdata) {
|
||||
Dump('>', &c, 1);
|
||||
}
|
||||
if (!TTYROOM()) {
|
||||
(void) DataToTerminal(&c, 1);
|
||||
} else {
|
||||
TTYADD(c);
|
||||
}
|
||||
}
|
||||
#endif /* ((!defined(NOT43)) || defined(PUTCHAR)) */
|
||||
|
||||
void
|
||||
SetIn3270()
|
||||
{
|
||||
if (Sent3270TerminalType && my_want_state_is_will(TELOPT_BINARY)
|
||||
&& my_want_state_is_do(TELOPT_BINARY) && !donebinarytoggle) {
|
||||
if (!In3270) {
|
||||
In3270 = 1;
|
||||
Init3270(); /* Initialize 3270 functions */
|
||||
/* initialize terminal key mapping */
|
||||
InitTerminal(); /* Start terminal going */
|
||||
setconnmode(0);
|
||||
}
|
||||
} else {
|
||||
if (In3270) {
|
||||
StopScreen(1);
|
||||
In3270 = 0;
|
||||
Stop3270(); /* Tell 3270 we aren't here anymore */
|
||||
setconnmode(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* tn3270_ttype()
|
||||
*
|
||||
* Send a response to a terminal type negotiation.
|
||||
*
|
||||
* Return '0' if no more responses to send; '1' if a response sent.
|
||||
*/
|
||||
|
||||
int
|
||||
tn3270_ttype()
|
||||
{
|
||||
/*
|
||||
* Try to send a 3270 type terminal name. Decide which one based
|
||||
* on the format of our screen, and (in the future) color
|
||||
* capaiblities.
|
||||
*/
|
||||
InitTerminal(); /* Sets MaxNumberColumns, MaxNumberLines */
|
||||
if ((MaxNumberLines >= 24) && (MaxNumberColumns >= 80)) {
|
||||
Sent3270TerminalType = 1;
|
||||
if ((MaxNumberLines >= 27) && (MaxNumberColumns >= 132)) {
|
||||
MaxNumberLines = 27;
|
||||
MaxNumberColumns = 132;
|
||||
sb_terminal[SBTERMMODEL] = '5';
|
||||
} else if (MaxNumberLines >= 43) {
|
||||
MaxNumberLines = 43;
|
||||
MaxNumberColumns = 80;
|
||||
sb_terminal[SBTERMMODEL] = '4';
|
||||
} else if (MaxNumberLines >= 32) {
|
||||
MaxNumberLines = 32;
|
||||
MaxNumberColumns = 80;
|
||||
sb_terminal[SBTERMMODEL] = '3';
|
||||
} else {
|
||||
MaxNumberLines = 24;
|
||||
MaxNumberColumns = 80;
|
||||
sb_terminal[SBTERMMODEL] = '2';
|
||||
}
|
||||
NumberLines = 24; /* before we start out... */
|
||||
NumberColumns = 80;
|
||||
ScreenSize = NumberLines*NumberColumns;
|
||||
if ((MaxNumberLines*MaxNumberColumns) > MAXSCREENSIZE) {
|
||||
ExitString("Programming error: MAXSCREENSIZE too small.\n",
|
||||
1);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
printsub('>', sb_terminal+2, sizeof sb_terminal-2);
|
||||
ring_supply_data(&netoring, sb_terminal, sizeof sb_terminal);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(unix)
|
||||
int
|
||||
settranscom(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc == 1 && transcom) {
|
||||
transcom = 0;
|
||||
}
|
||||
if (argc == 1) {
|
||||
return 1;
|
||||
}
|
||||
transcom = tline;
|
||||
(void) strcpy(transcom, argv[1]);
|
||||
for (i = 2; i < argc; ++i) {
|
||||
(void) strcat(transcom, " ");
|
||||
(void) strcat(transcom, argv[i]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /* defined(unix) */
|
||||
|
||||
#endif /* defined(TN3270) */
|
@@ -774,20 +774,12 @@ printsub(direction, pointer, length)
|
||||
env_common:
|
||||
{
|
||||
register int noquote = 2;
|
||||
#if defined(ENV_HACK) && defined(OLD_ENVIRON)
|
||||
extern int old_env_var, old_env_value;
|
||||
#endif
|
||||
for (i = 2; i < length; i++ ) {
|
||||
switch (pointer[i]) {
|
||||
case NEW_ENV_VALUE:
|
||||
#ifdef OLD_ENVIRON
|
||||
/* case NEW_ENV_OVAR: */
|
||||
if (pointer[0] == TELOPT_OLD_ENVIRON) {
|
||||
# ifdef ENV_HACK
|
||||
if (old_env_var == OLD_ENV_VALUE)
|
||||
fprintf(NetTrace, "\" (VALUE) " + noquote);
|
||||
else
|
||||
# endif
|
||||
fprintf(NetTrace, "\" VAR " + noquote);
|
||||
} else
|
||||
#endif /* OLD_ENVIRON */
|
||||
@@ -799,11 +791,6 @@ printsub(direction, pointer, length)
|
||||
#ifdef OLD_ENVIRON
|
||||
/* case OLD_ENV_VALUE: */
|
||||
if (pointer[0] == TELOPT_OLD_ENVIRON) {
|
||||
# ifdef ENV_HACK
|
||||
if (old_env_value == OLD_ENV_VAR)
|
||||
fprintf(NetTrace, "\" (VAR) " + noquote);
|
||||
else
|
||||
# endif
|
||||
fprintf(NetTrace, "\" VALUE " + noquote);
|
||||
} else
|
||||
#endif /* OLD_ENVIRON */
|
||||
@@ -872,26 +859,20 @@ printsub(direction, pointer, length)
|
||||
void
|
||||
EmptyTerminal()
|
||||
{
|
||||
#if defined(unix)
|
||||
fd_set o;
|
||||
|
||||
FD_ZERO(&o);
|
||||
#endif /* defined(unix) */
|
||||
|
||||
if (TTYBYTES() == 0) {
|
||||
#if defined(unix)
|
||||
FD_SET(tout, &o);
|
||||
(void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
|
||||
(struct timeval *) 0); /* wait for TTLOWAT */
|
||||
#endif /* defined(unix) */
|
||||
} else {
|
||||
while (TTYBYTES()) {
|
||||
(void) ttyflush(0);
|
||||
#if defined(unix)
|
||||
FD_SET(tout, &o);
|
||||
(void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
|
||||
(struct timeval *) 0); /* wait for TTLOWAT */
|
||||
#endif /* defined(unix) */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -900,24 +881,13 @@ EmptyTerminal()
|
||||
SetForExit()
|
||||
{
|
||||
setconnmode(0);
|
||||
#if defined(TN3270)
|
||||
if (In3270) {
|
||||
Finish3270();
|
||||
}
|
||||
#else /* defined(TN3270) */
|
||||
do {
|
||||
(void)telrcv(); /* Process any incoming data */
|
||||
EmptyTerminal();
|
||||
} while (ring_full_count(&netiring)); /* While there is any */
|
||||
#endif /* defined(TN3270) */
|
||||
setcommandmode();
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
#if defined(TN3270)
|
||||
if (In3270) {
|
||||
StopScreen(1);
|
||||
}
|
||||
#endif /* defined(TN3270) */
|
||||
setconnmode(0);
|
||||
EmptyTerminal(); /* Flush the path to the tty */
|
||||
setcommandmode();
|
||||
|
Reference in New Issue
Block a user