* The following routines try to encapsulate what is system dependent
* (at least between 4.x and dos) which is used in telnet.c.
HaveInput
; /* There is input available to scan */
char *transcom
= 0; /* transparent mode command (default: none) */
#endif /* defined(TN3270) */
static struct tchars otc
= { 0 }, ntc
= { 0 };
static struct ltchars oltc
= { 0 }, nltc
= { 0 };
static struct sgttyb ottyb
= { 0 }, nttyb
= { 0 };
TerminalWrite(fd
, buf
, n
)
return write(fd
, buf
, n
);
TerminalAutoFlush() /* unix */
ioctl(0, TIOCLGET
, (char *)&flush
);
return !(flush
&LNOFLSH
); /* if LNOFLSH, no autoflush */
* Look at an input character to see if it is a special character
* 0 Don't add this character.
* 1 Do add this character
TerminalSpecialChars(c
) /* unix */
void doflush(), intp(), sendbrk();
} else if (c
== ntc
.t_quitc
) {
} else if (c
== nltc
.t_flushc
) {
xmitAO(); /* Transmit Abort Output */
} else if (!MODE_LOCAL_CHARS(globalmode
)) {
if (c
== nttyb
.sg_kill
) {
} else if (c
== nttyb
.sg_erase
) {
xmitEC(); /* Transmit Erase Character */
* Flush output to the terminal
TerminalFlushOutput() /* unix */
(void) ioctl(fileno(stdout
), TIOCFLUSH
, (char *) 0);
TerminalSaveState() /* unix */
ioctl(0, TIOCGETP
, (char *)&ottyb
);
ioctl(0, TIOCGETC
, (char *)&otc
);
ioctl(0, TIOCGLTC
, (char *)&oltc
);
termEofChar
= ntc
.t_eofc
;
termEraseChar
= nttyb
.sg_erase
;
termFlushChar
= nltc
.t_flushc
;
termIntChar
= ntc
.t_intrc
;
termKillChar
= nttyb
.sg_kill
;
termQuitChar
= ntc
.t_quitc
;
TerminalRestoreState() /* unix */
* TerminalNewMode - set up terminal to a specific mode.
TerminalNewMode(fd_in
, fd_out
, f
) /* unix */
int fd_in
, fd_out
; /* File descriptor */
static struct tchars notc
= { -1, -1, -1, -1, -1, -1 };
static struct ltchars noltc
= { -1, -1, -1, -1, -1, -1 };
case 1: /* remote character processing, remote echo */
case 2: /* remote character processing, local echo */
case 6: /* 3270 mode - like 1, but with xon/xoff local */
/* (might be nice to have "6" in telnet also...) */
if ((f
== 1) || (f
== 6)) {
sb
.sg_flags
&= ~(ECHO
|CRMOD
);
sb
.sg_flags
|= ECHO
|CRMOD
;
sb
.sg_erase
= sb
.sg_kill
= -1;
/* get XON, XOFF characters */
tc3
.t_startc
= otc
.t_startc
;
tc3
.t_stopc
= otc
.t_stopc
;
* If user hasn't specified one way or the other,
* then default to not trapping signals.
notc2
.t_intrc
= ntc
.t_intrc
;
notc2
.t_quitc
= ntc
.t_quitc
;
case 3: /* local character processing, remote echo */
case 4: /* local character processing, local echo */
case 5: /* local character processing, no echo */
* If user hasn't specified one way or the other,
* then default to trapping signals.
notc2
.t_brkc
= nltc
.t_flushc
;
notc2
.t_intrc
= notc2
.t_quitc
= -1;
ioctl(fd_in
, TIOCSLTC
, (char *)ltc
);
ioctl(fd_in
, TIOCSETC
, (char *)tc
);
ioctl(fd_in
, TIOCSETP
, (char *)&sb
);
#if (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR))
ioctl(fd_in
, FIONBIO
, (char *)&onoff
);
ioctl(fd_out
, FIONBIO
, (char *)&onoff
);
#endif /* (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR)) */
ioctl(fd_in
, FIOASYNC
, (char *)&onoff
);
#endif /* defined(TN3270) */
signal(SIGTSTP
, doescape
);
} else if (MODE_LINE(old
)) {
signal(SIGTSTP
, SIG_DFL
);
sigsetmask(sigblock(0) & ~(1<<(SIGTSTP
-1)));
NetNonblockingIO(fd
, onoff
) /* unix */
ioctl(fd
, FIONBIO
, (char *)&onoff
);
NetSigIO(fd
, onoff
) /* unix */
ioctl(fd
, FIOASYNC
, (char *)&onoff
); /* hear about input */
NetSetPgrp(fd
) /* unix */
#endif /* defined(NOT43) */
ioctl(fd
, SIOCSPGRP
, (char *)&myPid
); /* set my pid */
#endif /* defined(unix) */