After running "make unifdef", commit the result. This code is now
a complete subset of the crypto (master) code.
This commit is contained in:
parent
e895047b95
commit
6f1129fac7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87154
File diff suppressed because it is too large
Load Diff
@ -31,16 +31,11 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)defines.h 8.1 (Berkeley) 6/6/93
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#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))
|
||||
|
@ -53,21 +53,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#ifndef FILIO_H
|
||||
#include <sys/ioctl.h>
|
||||
#else
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
# include <errno.h>
|
||||
#include <errno.h>
|
||||
#ifdef USE_TERMIO
|
||||
# ifndef VINTR
|
||||
# ifdef SYSV_TERMIO
|
||||
# include <sys/termio.h>
|
||||
# else
|
||||
# include <sys/termios.h>
|
||||
# define termio termios
|
||||
# endif
|
||||
# include <sys/termios.h>
|
||||
# endif
|
||||
# define termio termios
|
||||
#endif
|
||||
#if defined(NO_CC_T) || !defined(USE_TERMIO)
|
||||
# if !defined(USE_TERMIO)
|
||||
@ -77,11 +69,7 @@ typedef unsigned char cc_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined(IPSEC)
|
||||
#include <netinet6/ipsec.h>
|
||||
@ -120,7 +108,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 */
|
||||
@ -139,13 +126,7 @@ extern int
|
||||
crmod,
|
||||
netdata, /* Print out network data flow */
|
||||
prettydump, /* Print "netdata" output in user readable format */
|
||||
#if 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 */
|
||||
doaddrlookup, /* do a reverse lookup? */
|
||||
clienteof; /* Client received EOF */
|
||||
@ -229,6 +210,16 @@ extern char
|
||||
#define set_his_want_state_dont set_my_want_state_wont
|
||||
#define set_his_want_state_wont set_my_want_state_dont
|
||||
|
||||
#if defined(USE_TERMIO)
|
||||
#define SIG_FUNC_RET void
|
||||
#else
|
||||
#define SIG_FUNC_RET int
|
||||
#endif
|
||||
|
||||
#ifdef SIGINFO
|
||||
extern SIG_FUNC_RET
|
||||
ayt_status P((void));
|
||||
#endif
|
||||
|
||||
extern FILE
|
||||
*NetTrace; /* Where debugging output goes */
|
||||
@ -242,23 +233,40 @@ extern jmp_buf
|
||||
toplevel; /* For error conditions. */
|
||||
|
||||
extern void
|
||||
command P((int, char *, int)),
|
||||
Dump P((int, unsigned char *, int)),
|
||||
ExitString P((char *, int)),
|
||||
init_3270 P((void)),
|
||||
printoption P((char *, int, int)),
|
||||
printsub P((int, unsigned char *, int)),
|
||||
command P((int, const char *, int)),
|
||||
Dump P((char, unsigned char *, int)),
|
||||
env_init P((void)),
|
||||
Exit P((int)),
|
||||
ExitString P((const char *, int)),
|
||||
init_network P((void)),
|
||||
init_sys P((void)),
|
||||
init_telnet P((void)),
|
||||
init_terminal P((void)),
|
||||
intp P((void)),
|
||||
optionstatus P((void)),
|
||||
printoption P((const char *, int, int)),
|
||||
printsub P((char, unsigned char *, int)),
|
||||
quit P((void)),
|
||||
sendabort P((void)),
|
||||
sendbrk P((void)),
|
||||
sendeof P((void)),
|
||||
sendsusp P((void)),
|
||||
sendnaws P((void)),
|
||||
sendayt P((void)),
|
||||
setconnmode P((int)),
|
||||
setcommandmode P((void)),
|
||||
set_escape_char P((char *s)),
|
||||
setneturg P((void)),
|
||||
sys_telnet_init P((void)),
|
||||
telnet P((char *)),
|
||||
tel_enter_binary P((int)),
|
||||
tel_leave_binary P((int)),
|
||||
TerminalFlushOutput P((void)),
|
||||
TerminalNewMode P((int)),
|
||||
TerminalRestoreState P((void)),
|
||||
TerminalSaveState P((void)),
|
||||
TerminalDefaultChars P((void)),
|
||||
TerminalSpeeds P((long *, long *)),
|
||||
tninit P((void)),
|
||||
upcase P((char *)),
|
||||
willoption P((int)),
|
||||
@ -287,16 +295,25 @@ 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
|
||||
getconnmode P((void)),
|
||||
opt_welldefined P((const char *)),
|
||||
NetClose P((int)),
|
||||
netflush P((void)),
|
||||
process_rings P((int, int, int, int, int, int)),
|
||||
rlogin_susp P((void)),
|
||||
SetSockOpt P((int, int, int, int)),
|
||||
slc_update P((void)),
|
||||
stilloob P((void)),
|
||||
telrcv P((void)),
|
||||
TerminalRead P((char *, int)),
|
||||
TerminalWrite P((char *, int)),
|
||||
TerminalAutoFlush P((void)),
|
||||
TerminalWindowSize P((long *, long *)),
|
||||
TerminalSpecialChars P((int)),
|
||||
tn P((int, char **)),
|
||||
ttyflush P((int));
|
||||
|
||||
extern void
|
||||
@ -308,11 +325,11 @@ extern void
|
||||
|
||||
extern unsigned char
|
||||
*env_default P((int, int)),
|
||||
*env_getvalue P((unsigned char *));
|
||||
*env_getvalue P((const unsigned char *));
|
||||
|
||||
extern int
|
||||
get_status P((void)),
|
||||
dosynch P((void));
|
||||
get_status P((char *)),
|
||||
dosynch P((char *));
|
||||
|
||||
extern cc_t
|
||||
*tcval P((int));
|
||||
@ -464,26 +481,7 @@ 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) */
|
||||
xmitAO P((void)),
|
||||
xmitEC P((void)),
|
||||
xmitEL P((void));
|
||||
|
@ -29,19 +29,15 @@
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1988, 1990, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef lint
|
||||
static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@ -53,6 +49,7 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
|
||||
#include "externs.h"
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
/* These values need to be the same as defined in libtelnet/kerberos5.c */
|
||||
/* Either define them in both places, or put in some common header file. */
|
||||
#define OPTS_FORWARD_CREDS 0x00000002
|
||||
@ -62,12 +59,6 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
|
||||
#define FORWARD
|
||||
#endif
|
||||
|
||||
void init_terminal(void);
|
||||
void init_network(void);
|
||||
void init_telnet(void);
|
||||
void init_sys(void);
|
||||
void init_3270(void);
|
||||
|
||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
|
||||
char *ipsec_policy_in = NULL;
|
||||
char *ipsec_policy_out = NULL;
|
||||
@ -78,8 +69,8 @@ int family = AF_UNSPEC;
|
||||
/*
|
||||
* Initialize variables.
|
||||
*/
|
||||
void
|
||||
tninit()
|
||||
void
|
||||
tninit(void)
|
||||
{
|
||||
init_terminal();
|
||||
|
||||
@ -88,25 +79,16 @@ tninit()
|
||||
init_telnet();
|
||||
|
||||
init_sys();
|
||||
|
||||
#if defined(TN3270)
|
||||
init_3270();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s %s%s%s%s\n",
|
||||
prompt,
|
||||
"[-4] [-6] [-8] [-E] [-L] [-N] [-S tos] [-c] [-d]",
|
||||
"\n\t[-e char] [-l user] [-n tracefile] ",
|
||||
#if defined(TN3270) && defined(unix)
|
||||
"[-noasynch] [-noasynctty] [-noasyncnet] [-r]\n\t"
|
||||
"[-s src_addr] [-t transcom] ",
|
||||
#else
|
||||
"[-r] [-s src_addr] [-u] ",
|
||||
#endif
|
||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
|
||||
"[-P policy] "
|
||||
#endif
|
||||
@ -119,10 +101,8 @@ usage()
|
||||
* main. Parse arguments, invoke the protocol or command parser.
|
||||
*/
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
char *user;
|
||||
@ -145,6 +125,7 @@ main(argc, argv)
|
||||
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
|
||||
autologin = -1;
|
||||
|
||||
|
||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
|
||||
#define IPSECOPT "P:"
|
||||
#else
|
||||
@ -228,19 +209,6 @@ main(argc, 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':
|
||||
@ -249,16 +217,6 @@ main(argc, argv)
|
||||
case 's':
|
||||
src_addr = optarg;
|
||||
break;
|
||||
case 't':
|
||||
#if defined(TN3270) && defined(unix)
|
||||
(void)strlcpy(tline, optarg, sizeof(tline));
|
||||
transcom = tline;
|
||||
#else
|
||||
fprintf(stderr,
|
||||
"%s: Warning: -t ignored, no TN3270 support.\n",
|
||||
prompt);
|
||||
#endif
|
||||
break;
|
||||
case 'u':
|
||||
family = AF_UNIX;
|
||||
break;
|
||||
@ -267,6 +225,11 @@ main(argc, argv)
|
||||
"%s: Warning: -x ignored, no ENCRYPT support.\n",
|
||||
prompt);
|
||||
break;
|
||||
case 'y':
|
||||
fprintf(stderr,
|
||||
"%s: Warning: -y ignored, no ENCRYPT support.\n",
|
||||
prompt);
|
||||
break;
|
||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
|
||||
case 'P':
|
||||
if (!strncmp("in", optarg, 2))
|
||||
@ -296,11 +259,11 @@ main(argc, argv)
|
||||
usage();
|
||||
*argp++ = prompt;
|
||||
if (user) {
|
||||
*argp++ = "-l";
|
||||
*argp++ = strdup("-l");
|
||||
*argp++ = user;
|
||||
}
|
||||
if (src_addr) {
|
||||
*argp++ = "-s";
|
||||
*argp++ = strdup("-s");
|
||||
*argp++ = src_addr;
|
||||
}
|
||||
*argp++ = argv[0]; /* host */
|
||||
@ -317,11 +280,6 @@ main(argc, argv)
|
||||
}
|
||||
(void)setjmp(toplevel);
|
||||
for (;;) {
|
||||
#ifdef TN3270
|
||||
if (shell_active)
|
||||
shell_continue();
|
||||
else
|
||||
#endif
|
||||
command(1, 0, 0);
|
||||
}
|
||||
return 0;
|
||||
|
@ -31,14 +31,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@ -62,8 +61,8 @@ unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ];
|
||||
* Initialize internal network data structures.
|
||||
*/
|
||||
|
||||
void
|
||||
init_network()
|
||||
void
|
||||
init_network(void)
|
||||
{
|
||||
if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) {
|
||||
exit(1);
|
||||
@ -80,10 +79,10 @@ init_network()
|
||||
* Telnet "synch" processing).
|
||||
*/
|
||||
|
||||
int
|
||||
stilloob()
|
||||
int
|
||||
stilloob(void)
|
||||
{
|
||||
static struct timeval timeout = { 0 };
|
||||
static struct timeval timeout = { 0, 0 };
|
||||
fd_set excepts;
|
||||
int value;
|
||||
|
||||
@ -112,8 +111,8 @@ stilloob()
|
||||
* Sets "neturg" to the current location.
|
||||
*/
|
||||
|
||||
void
|
||||
setneturg()
|
||||
void
|
||||
setneturg(void)
|
||||
{
|
||||
ring_mark(&netoring);
|
||||
}
|
||||
@ -128,11 +127,10 @@ setneturg()
|
||||
* useful work.
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
netflush()
|
||||
int
|
||||
netflush(void)
|
||||
{
|
||||
register int n, n1;
|
||||
int n, n1;
|
||||
|
||||
if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
|
||||
if (!ring_at_mark(&netoring)) {
|
||||
|
@ -31,14 +31,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* This defines a structure for a ring buffer.
|
||||
@ -99,17 +98,10 @@ static u_long ring_clock = 0;
|
||||
#define ring_full(d) (((d)->supply == (d)->consume) && \
|
||||
((d)->supplytime > (d)->consumetime))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Buffer state transition routines */
|
||||
|
||||
int
|
||||
ring_init(ring, buffer, count)
|
||||
Ring *ring;
|
||||
unsigned char *buffer;
|
||||
int count;
|
||||
int
|
||||
ring_init(Ring *ring, unsigned char *buffer, int count)
|
||||
{
|
||||
memset((char *)ring, 0, sizeof *ring);
|
||||
|
||||
@ -129,9 +121,8 @@ ring_init(ring, buffer, count)
|
||||
* Mark the most recently supplied byte.
|
||||
*/
|
||||
|
||||
void
|
||||
ring_mark(ring)
|
||||
Ring *ring;
|
||||
void
|
||||
ring_mark(Ring *ring)
|
||||
{
|
||||
ring->mark = ring_decrement(ring, ring->supply, 1);
|
||||
}
|
||||
@ -140,9 +131,8 @@ ring_mark(ring)
|
||||
* Is the ring pointing to the mark?
|
||||
*/
|
||||
|
||||
int
|
||||
ring_at_mark(ring)
|
||||
Ring *ring;
|
||||
int
|
||||
ring_at_mark(Ring *ring)
|
||||
{
|
||||
if (ring->mark == ring->consume) {
|
||||
return 1;
|
||||
@ -155,9 +145,8 @@ ring_at_mark(ring)
|
||||
* Clear any mark set on the ring.
|
||||
*/
|
||||
|
||||
void
|
||||
ring_clear_mark(ring)
|
||||
Ring *ring;
|
||||
void
|
||||
ring_clear_mark(Ring *ring)
|
||||
{
|
||||
ring->mark = 0;
|
||||
}
|
||||
@ -165,10 +154,8 @@ ring_clear_mark(ring)
|
||||
/*
|
||||
* Add characters from current segment to ring buffer.
|
||||
*/
|
||||
void
|
||||
ring_supplied(ring, count)
|
||||
Ring *ring;
|
||||
int count;
|
||||
void
|
||||
ring_supplied(Ring *ring, int count)
|
||||
{
|
||||
ring->supply = ring_increment(ring, ring->supply, count);
|
||||
ring->supplytime = ++ring_clock;
|
||||
@ -177,10 +164,8 @@ ring_supplied(ring, count)
|
||||
/*
|
||||
* We have just consumed "c" bytes.
|
||||
*/
|
||||
void
|
||||
ring_consumed(ring, count)
|
||||
Ring *ring;
|
||||
int count;
|
||||
void
|
||||
ring_consumed(Ring *ring, int count)
|
||||
{
|
||||
if (count == 0) /* don't update anything */
|
||||
return;
|
||||
@ -205,9 +190,8 @@ ring_consumed(ring, count)
|
||||
|
||||
|
||||
/* Number of bytes that may be supplied */
|
||||
int
|
||||
ring_empty_count(ring)
|
||||
Ring *ring;
|
||||
int
|
||||
ring_empty_count(Ring *ring)
|
||||
{
|
||||
if (ring_empty(ring)) { /* if empty */
|
||||
return ring->size;
|
||||
@ -217,9 +201,8 @@ ring_empty_count(ring)
|
||||
}
|
||||
|
||||
/* number of CONSECUTIVE bytes that may be supplied */
|
||||
int
|
||||
ring_empty_consecutive(ring)
|
||||
Ring *ring;
|
||||
int
|
||||
ring_empty_consecutive(Ring *ring)
|
||||
{
|
||||
if ((ring->consume < ring->supply) || ring_empty(ring)) {
|
||||
/*
|
||||
@ -239,9 +222,8 @@ ring_empty_consecutive(ring)
|
||||
* (but don't give more than enough to get to cross over set mark)
|
||||
*/
|
||||
|
||||
int
|
||||
ring_full_count(ring)
|
||||
Ring *ring;
|
||||
int
|
||||
ring_full_count(Ring *ring)
|
||||
{
|
||||
if ((ring->mark == 0) || (ring->mark == ring->consume)) {
|
||||
if (ring_full(ring)) {
|
||||
@ -258,9 +240,8 @@ ring_full_count(ring)
|
||||
* Return the number of CONSECUTIVE bytes available for consuming.
|
||||
* However, don't return more than enough to cross over set mark.
|
||||
*/
|
||||
int
|
||||
ring_full_consecutive(ring)
|
||||
Ring *ring;
|
||||
int
|
||||
ring_full_consecutive(Ring *ring)
|
||||
{
|
||||
if ((ring->mark == 0) || (ring->mark == ring->consume)) {
|
||||
if ((ring->supply < ring->consume) || ring_full(ring)) {
|
||||
@ -280,11 +261,8 @@ ring_full_consecutive(ring)
|
||||
/*
|
||||
* Move data into the "supply" portion of of the ring buffer.
|
||||
*/
|
||||
void
|
||||
ring_supply_data(ring, buffer, count)
|
||||
Ring *ring;
|
||||
unsigned char *buffer;
|
||||
int count;
|
||||
void
|
||||
ring_supply_data(Ring *ring, unsigned char *buffer, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -297,26 +275,3 @@ ring_supply_data(ring, buffer, count)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef notdef
|
||||
|
||||
/*
|
||||
* Move data from the "consume" portion of the ring buffer
|
||||
*/
|
||||
void
|
||||
ring_consume_data(ring, buffer, count)
|
||||
Ring *ring;
|
||||
unsigned char *buffer;
|
||||
int count;
|
||||
{
|
||||
int i;
|
||||
|
||||
while (count) {
|
||||
i = MIN(count, ring_full_consecutive(ring));
|
||||
memcpy(buffer, ring->consume, i);
|
||||
ring_consumed(ring, i);
|
||||
count -= i;
|
||||
buffer += i;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -86,6 +86,7 @@ extern void
|
||||
|
||||
/* Buffer state query routines */
|
||||
extern int
|
||||
ring_at_mark P((Ring *)),
|
||||
ring_empty_count P((Ring *ring)),
|
||||
ring_empty_consecutive P((Ring *ring)),
|
||||
ring_full_count P((Ring *ring)),
|
||||
@ -93,5 +94,5 @@ extern int
|
||||
|
||||
|
||||
extern void
|
||||
ring_clear_mark P((Ring *)),
|
||||
ring_mark P((Ring *));
|
||||
ring_clear_mark P((Ring *)),
|
||||
ring_mark P((Ring *));
|
||||
|
@ -31,48 +31,34 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* The following routines try to encapsulate what is system dependent
|
||||
* (at least between 4.x and dos) which is used in telnet.c.
|
||||
*/
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/telnet.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/telnet.h>
|
||||
|
||||
#include "ring.h"
|
||||
|
||||
#include "fdset.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "externs.h"
|
||||
#include "types.h"
|
||||
|
||||
#if defined(USE_TERMIO) && !defined(SYSV_TERMIO)
|
||||
#define SIG_FUNC_RET void
|
||||
#else
|
||||
#define SIG_FUNC_RET int
|
||||
#endif
|
||||
|
||||
#ifdef SIGINFO
|
||||
extern SIG_FUNC_RET ayt_status();
|
||||
#endif
|
||||
|
||||
int
|
||||
tout, /* Output file descriptor */
|
||||
tin, /* Input file descriptor */
|
||||
@ -88,8 +74,7 @@ int olmode = 0;
|
||||
# define old_tc ottyb
|
||||
|
||||
#else /* USE_TERMIO */
|
||||
struct termio old_tc = { 0 };
|
||||
extern struct termio new_tc;
|
||||
struct termio old_tc = { 0, 0, 0, 0, {}, 0, 0 };
|
||||
|
||||
# ifndef TCSANOW
|
||||
# ifdef TCSETS
|
||||
@ -122,9 +107,21 @@ extern struct termio new_tc;
|
||||
|
||||
static fd_set ibits, obits, xbits;
|
||||
|
||||
#ifdef SIGINT
|
||||
static SIG_FUNC_RET intr(int);
|
||||
#endif /* SIGINT */
|
||||
#ifdef SIGQUIT
|
||||
static SIG_FUNC_RET intr2(int);
|
||||
#endif /* SIGQUIT */
|
||||
#ifdef SIGTSTP
|
||||
static SIG_FUNC_RET susp(int);
|
||||
#endif /* SIGTSTP */
|
||||
#ifdef SIGINFO
|
||||
static SIG_FUNC_RET ayt(int);
|
||||
#endif
|
||||
|
||||
void
|
||||
init_sys()
|
||||
void
|
||||
init_sys(void)
|
||||
{
|
||||
tout = fileno(stdout);
|
||||
tin = fileno(stdin);
|
||||
@ -135,19 +132,14 @@ init_sys()
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TerminalWrite(buf, n)
|
||||
char *buf;
|
||||
int n;
|
||||
int
|
||||
TerminalWrite(char *buf, int n)
|
||||
{
|
||||
return write(tout, buf, n);
|
||||
}
|
||||
|
||||
int
|
||||
TerminalRead(buf, n)
|
||||
char *buf;
|
||||
int n;
|
||||
int
|
||||
TerminalRead(char *buf, int n)
|
||||
{
|
||||
return read(tin, buf, n);
|
||||
}
|
||||
@ -156,8 +148,8 @@ TerminalRead(buf, n)
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
TerminalAutoFlush()
|
||||
int
|
||||
TerminalAutoFlush(void)
|
||||
{
|
||||
#if defined(LNOFLSH)
|
||||
int flush;
|
||||
@ -184,11 +176,8 @@ extern int kludgelinemode;
|
||||
* 1 Do add this character
|
||||
*/
|
||||
|
||||
extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk();
|
||||
|
||||
int
|
||||
TerminalSpecialChars(c)
|
||||
int c;
|
||||
int
|
||||
TerminalSpecialChars(int c)
|
||||
{
|
||||
if (c == termIntChar) {
|
||||
intp();
|
||||
@ -230,8 +219,8 @@ TerminalSpecialChars(c)
|
||||
* Flush output to the terminal
|
||||
*/
|
||||
|
||||
void
|
||||
TerminalFlushOutput()
|
||||
void
|
||||
TerminalFlushOutput(void)
|
||||
{
|
||||
#ifdef TIOCFLUSH
|
||||
(void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
|
||||
@ -240,8 +229,8 @@ TerminalFlushOutput()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
TerminalSaveState()
|
||||
void
|
||||
TerminalSaveState(void)
|
||||
{
|
||||
#ifndef USE_TERMIO
|
||||
ioctl(0, TIOCGETP, (char *)&ottyb);
|
||||
@ -282,9 +271,8 @@ TerminalSaveState()
|
||||
#endif /* USE_TERMIO */
|
||||
}
|
||||
|
||||
cc_t *
|
||||
tcval(func)
|
||||
register int func;
|
||||
cc_t *
|
||||
tcval(int func)
|
||||
{
|
||||
switch(func) {
|
||||
case SLC_IP: return(&termIntChar);
|
||||
@ -325,8 +313,8 @@ tcval(func)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TerminalDefaultChars()
|
||||
void
|
||||
TerminalDefaultChars(void)
|
||||
{
|
||||
#ifndef USE_TERMIO
|
||||
ntc = otc;
|
||||
@ -359,13 +347,6 @@ TerminalDefaultChars()
|
||||
#endif /* USE_TERMIO */
|
||||
}
|
||||
|
||||
#ifdef notdef
|
||||
void
|
||||
TerminalRestoreState()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TerminalNewMode - set up terminal to a specific mode.
|
||||
* MODE_ECHO: do local terminal echo
|
||||
@ -388,10 +369,8 @@ TerminalRestoreState()
|
||||
* local/no signal mapping
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
TerminalNewMode(f)
|
||||
register int f;
|
||||
void
|
||||
TerminalNewMode(int f)
|
||||
{
|
||||
static int prevmode = 0;
|
||||
#ifndef USE_TERMIO
|
||||
@ -466,10 +445,6 @@ TerminalNewMode(f)
|
||||
#else
|
||||
tmp_tc.c_lflag &= ~ECHO;
|
||||
tmp_tc.c_oflag &= ~ONLCR;
|
||||
# ifdef notdef
|
||||
if (crlf)
|
||||
tmp_tc.c_iflag &= ~ICRNL;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -616,19 +591,6 @@ TerminalNewMode(f)
|
||||
}
|
||||
|
||||
if (f != -1) {
|
||||
#ifdef SIGINT
|
||||
SIG_FUNC_RET intr();
|
||||
#endif /* SIGINT */
|
||||
#ifdef SIGQUIT
|
||||
SIG_FUNC_RET intr2();
|
||||
#endif /* SIGQUIT */
|
||||
#ifdef SIGTSTP
|
||||
SIG_FUNC_RET susp();
|
||||
#endif /* SIGTSTP */
|
||||
#ifdef SIGINFO
|
||||
SIG_FUNC_RET ayt();
|
||||
#endif
|
||||
|
||||
#ifdef SIGINT
|
||||
(void) signal(SIGINT, intr);
|
||||
#endif
|
||||
@ -681,9 +643,7 @@ TerminalNewMode(f)
|
||||
#endif
|
||||
} else {
|
||||
#ifdef SIGINFO
|
||||
SIG_FUNC_RET ayt_status();
|
||||
|
||||
(void) signal(SIGINFO, ayt_status);
|
||||
(void) signal(SIGINFO, (void (*)(int))ayt_status);
|
||||
#endif
|
||||
#ifdef SIGINT
|
||||
(void) signal(SIGINT, SIG_DFL);
|
||||
@ -718,17 +678,8 @@ TerminalNewMode(f)
|
||||
tcsetattr(tin, TCSANOW, &tmp_tc);
|
||||
#endif
|
||||
|
||||
#if (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR))
|
||||
# if !defined(sysV88)
|
||||
ioctl(tin, FIONBIO, (char *)&onoff);
|
||||
ioctl(tout, FIONBIO, (char *)&onoff);
|
||||
# endif
|
||||
#endif /* (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR)) */
|
||||
#if defined(TN3270)
|
||||
if (noasynchtty == 0) {
|
||||
ioctl(tin, FIOASYNC, (char *)&onoff);
|
||||
}
|
||||
#endif /* defined(TN3270) */
|
||||
|
||||
}
|
||||
|
||||
@ -797,15 +748,13 @@ struct termspeeds {
|
||||
};
|
||||
#endif /* DECODE_BAUD */
|
||||
|
||||
void
|
||||
TerminalSpeeds(ispeed, ospeed)
|
||||
long *ispeed;
|
||||
long *ospeed;
|
||||
void
|
||||
TerminalSpeeds(long *ispeed, long *ospeed)
|
||||
{
|
||||
#ifdef DECODE_BAUD
|
||||
register struct termspeeds *tp;
|
||||
struct termspeeds *tp;
|
||||
#endif /* DECODE_BAUD */
|
||||
register long in, out;
|
||||
long in, out;
|
||||
|
||||
out = cfgetospeed(&old_tc);
|
||||
in = cfgetispeed(&old_tc);
|
||||
@ -828,9 +777,8 @@ TerminalSpeeds(ispeed, ospeed)
|
||||
#endif /* DECODE_BAUD */
|
||||
}
|
||||
|
||||
int
|
||||
TerminalWindowSize(rows, cols)
|
||||
long *rows, *cols;
|
||||
int
|
||||
TerminalWindowSize(long *rows, long *cols)
|
||||
{
|
||||
#ifdef TIOCGWINSZ
|
||||
struct winsize ws;
|
||||
@ -844,59 +792,34 @@ TerminalWindowSize(rows, cols)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
NetClose(fd)
|
||||
int fd;
|
||||
int
|
||||
NetClose(int fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetNonblockingIO(fd, onoff)
|
||||
int fd;
|
||||
int onoff;
|
||||
static void
|
||||
NetNonblockingIO(int fd, int onoff)
|
||||
{
|
||||
ioctl(fd, FIONBIO, (char *)&onoff);
|
||||
}
|
||||
|
||||
#if defined(TN3270)
|
||||
void
|
||||
NetSigIO(fd, onoff)
|
||||
int fd;
|
||||
int onoff;
|
||||
{
|
||||
ioctl(fd, FIOASYNC, (char *)&onoff); /* hear about input */
|
||||
}
|
||||
|
||||
void
|
||||
NetSetPgrp(fd)
|
||||
int fd;
|
||||
{
|
||||
int myPid;
|
||||
|
||||
myPid = getpid();
|
||||
fcntl(fd, F_SETOWN, myPid);
|
||||
}
|
||||
#endif /*defined(TN3270)*/
|
||||
|
||||
/*
|
||||
* Various signal handling routines.
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
deadpeer(sig)
|
||||
int sig;
|
||||
/* ARGSUSED */
|
||||
static SIG_FUNC_RET
|
||||
deadpeer(int sig __unused)
|
||||
{
|
||||
setcommandmode();
|
||||
longjmp(peerdied, -1);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
intr(sig)
|
||||
int sig;
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
intr(int sig __unused)
|
||||
{
|
||||
if (localchars) {
|
||||
intp();
|
||||
@ -906,10 +829,9 @@ intr(sig)
|
||||
longjmp(toplevel, -1);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
intr2(sig)
|
||||
int sig;
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
intr2(int sig __unused)
|
||||
{
|
||||
if (localchars) {
|
||||
#ifdef KLUDGELINEMODE
|
||||
@ -923,10 +845,9 @@ intr2(sig)
|
||||
}
|
||||
|
||||
#ifdef SIGTSTP
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
susp(sig)
|
||||
int sig;
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
susp(int sig __unused)
|
||||
{
|
||||
if ((rlogin != _POSIX_VDISABLE) && rlogin_susp())
|
||||
return;
|
||||
@ -936,10 +857,9 @@ susp(sig)
|
||||
#endif
|
||||
|
||||
#ifdef SIGWINCH
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
sendwin(sig)
|
||||
int sig;
|
||||
/* ARGSUSED */
|
||||
static SIG_FUNC_RET
|
||||
sendwin(int sig __unused)
|
||||
{
|
||||
if (connected) {
|
||||
sendnaws();
|
||||
@ -948,10 +868,9 @@ sendwin(sig)
|
||||
#endif
|
||||
|
||||
#ifdef SIGINFO
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
ayt(sig)
|
||||
int sig;
|
||||
/* ARGSUSED */
|
||||
SIG_FUNC_RET
|
||||
ayt(int sig __unused)
|
||||
{
|
||||
if (connected)
|
||||
sendayt();
|
||||
@ -961,8 +880,8 @@ ayt(sig)
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
sys_telnet_init()
|
||||
void
|
||||
sys_telnet_init(void)
|
||||
{
|
||||
(void) signal(SIGINT, intr);
|
||||
(void) signal(SIGQUIT, intr2);
|
||||
@ -981,13 +900,6 @@ sys_telnet_init()
|
||||
|
||||
NetNonblockingIO(net, 1);
|
||||
|
||||
#if defined(TN3270)
|
||||
if (noasynchnet == 0) { /* DBX can't handle! */
|
||||
NetSigIO(net, 1);
|
||||
NetSetPgrp(net);
|
||||
}
|
||||
#endif /* defined(TN3270) */
|
||||
|
||||
#if defined(SO_OOBINLINE)
|
||||
if (SetSockOpt(net, SOL_SOCKET, SO_OOBINLINE, 1) == -1) {
|
||||
perror("SetSockOpt");
|
||||
@ -1006,18 +918,12 @@ sys_telnet_init()
|
||||
* The return value is 1 if something happened, 0 if not.
|
||||
*/
|
||||
|
||||
int
|
||||
process_rings(netin, netout, netex, ttyin, ttyout, poll)
|
||||
int poll; /* If 0, then block until something to do */
|
||||
int
|
||||
process_rings(int netin, int netout, int netex, int ttyin, int ttyout, int poll)
|
||||
{
|
||||
register int c;
|
||||
/* One wants to be a bit careful about setting returnValue
|
||||
* to one, since a one implies we did some useful work,
|
||||
* and therefore probably won't be called to block next
|
||||
* time (TN3270 mode only).
|
||||
*/
|
||||
int c;
|
||||
int returnValue = 0;
|
||||
static struct timeval TimeValue = { 0 };
|
||||
static struct timeval TimeValue = { 0, 0 };
|
||||
|
||||
if (netout) {
|
||||
FD_SET(net, &obits);
|
||||
@ -1025,24 +931,12 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
|
||||
if (ttyout) {
|
||||
FD_SET(tout, &obits);
|
||||
}
|
||||
#if defined(TN3270)
|
||||
if (ttyin) {
|
||||
FD_SET(tin, &ibits);
|
||||
}
|
||||
#else /* defined(TN3270) */
|
||||
if (ttyin) {
|
||||
FD_SET(tin, &ibits);
|
||||
}
|
||||
#endif /* defined(TN3270) */
|
||||
#if defined(TN3270)
|
||||
if (netin) {
|
||||
FD_SET(net, &ibits);
|
||||
}
|
||||
# else /* !defined(TN3270) */
|
||||
if (netin) {
|
||||
FD_SET(net, &ibits);
|
||||
}
|
||||
# endif /* !defined(TN3270) */
|
||||
if (netex) {
|
||||
FD_SET(net, &xbits);
|
||||
}
|
||||
@ -1057,23 +951,6 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
|
||||
if (errno == EINTR) {
|
||||
return 0;
|
||||
}
|
||||
# if defined(TN3270)
|
||||
/*
|
||||
* we can get EBADF if we were in transparent
|
||||
* mode, and the transcom process died.
|
||||
*/
|
||||
if (errno == EBADF) {
|
||||
/*
|
||||
* zero the bits (even though kernel does it)
|
||||
* to make sure we are selecting on the right
|
||||
* ones.
|
||||
*/
|
||||
FD_ZERO(&ibits);
|
||||
FD_ZERO(&obits);
|
||||
FD_ZERO(&xbits);
|
||||
return 0;
|
||||
}
|
||||
# endif /* defined(TN3270) */
|
||||
/* I don't like this, does it ever happen? */
|
||||
printf("sleep(5) from telnet, after select: %s\r\n", strerror(errno));
|
||||
sleep(5);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,14 +31,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <arpa/telnet.h>
|
||||
#include <sys/types.h>
|
||||
@ -48,6 +47,7 @@ static const char rcsid[] =
|
||||
#include "externs.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
Ring ttyoring, ttyiring;
|
||||
unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ];
|
||||
|
||||
@ -93,8 +93,8 @@ cc_t termAytChar;
|
||||
* initialize the terminal data structures.
|
||||
*/
|
||||
|
||||
void
|
||||
init_terminal()
|
||||
void
|
||||
init_terminal(void)
|
||||
{
|
||||
if (ring_init(&ttyoring, ttyobuf, sizeof ttyobuf) != 1) {
|
||||
exit(1);
|
||||
@ -105,7 +105,6 @@ init_terminal()
|
||||
autoflush = TerminalAutoFlush();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send as much data as possible to the terminal.
|
||||
*
|
||||
@ -116,12 +115,10 @@ init_terminal()
|
||||
* n: All data - n was written out.
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
ttyflush(drop)
|
||||
int drop;
|
||||
int
|
||||
ttyflush(int drop)
|
||||
{
|
||||
register int n, n0, n1;
|
||||
int n, n0, n1;
|
||||
|
||||
n0 = ring_full_count(&ttyoring);
|
||||
if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) {
|
||||
@ -167,8 +164,8 @@ ttyflush(drop)
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
getconnmode()
|
||||
int
|
||||
getconnmode(void)
|
||||
{
|
||||
extern int linemode;
|
||||
int mode = 0;
|
||||
@ -176,9 +173,6 @@ getconnmode()
|
||||
extern int kludgelinemode;
|
||||
#endif
|
||||
|
||||
if (In3270)
|
||||
return(MODE_FLOW);
|
||||
|
||||
if (my_want_state_is_dont(TELOPT_ECHO))
|
||||
mode |= MODE_ECHO;
|
||||
|
||||
@ -207,11 +201,10 @@ getconnmode()
|
||||
return(mode);
|
||||
}
|
||||
|
||||
void
|
||||
setconnmode(force)
|
||||
int force;
|
||||
void
|
||||
setconnmode(int force)
|
||||
{
|
||||
register int newmode;
|
||||
int newmode;
|
||||
|
||||
newmode = getconnmode()|(force?MODE_FORCE:0);
|
||||
|
||||
@ -220,9 +213,8 @@ setconnmode(force)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setcommandmode()
|
||||
void
|
||||
setcommandmode(void)
|
||||
{
|
||||
TerminalNewMode(-1);
|
||||
}
|
||||
|
@ -1,416 +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
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#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) */
|
@ -31,14 +31,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#define TELOPTS
|
||||
#define TELCMDS
|
||||
@ -60,6 +59,7 @@ static const char rcsid[] =
|
||||
|
||||
#include "externs.h"
|
||||
|
||||
|
||||
FILE *NetTrace = 0; /* Not in bss, since needs to stay */
|
||||
int prettydump;
|
||||
|
||||
@ -69,11 +69,10 @@ int prettydump;
|
||||
* Upcase (in place) the argument.
|
||||
*/
|
||||
|
||||
void
|
||||
upcase(argument)
|
||||
register char *argument;
|
||||
void
|
||||
upcase(char *argument)
|
||||
{
|
||||
register int c;
|
||||
int c;
|
||||
|
||||
while ((c = *argument) != 0) {
|
||||
if (islower(c)) {
|
||||
@ -89,21 +88,11 @@ upcase(argument)
|
||||
* Compensate for differences in 4.2 and 4.3 systems.
|
||||
*/
|
||||
|
||||
int
|
||||
SetSockOpt(fd, level, option, yesno)
|
||||
int fd, level, option, yesno;
|
||||
int
|
||||
SetSockOpt(int fd, int level, int option, int yesno)
|
||||
{
|
||||
#ifndef NOT43
|
||||
return setsockopt(fd, level, option,
|
||||
(char *)&yesno, sizeof yesno);
|
||||
#else /* NOT43 */
|
||||
if (yesno == 0) { /* Can't do that in 4.2! */
|
||||
fprintf(stderr, "Error: attempt to turn off an option 0x%x.\n",
|
||||
option);
|
||||
return -1;
|
||||
}
|
||||
return setsockopt(fd, level, option, 0, 0);
|
||||
#endif /* NOT43 */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -112,9 +101,8 @@ SetSockOpt(fd, level, option, yesno)
|
||||
|
||||
unsigned char NetTraceFile[256] = "(standard output)";
|
||||
|
||||
void
|
||||
SetNetTrace(file)
|
||||
register char *file;
|
||||
void
|
||||
SetNetTrace(char *file)
|
||||
{
|
||||
if (NetTrace && NetTrace != stdout)
|
||||
fclose(NetTrace);
|
||||
@ -130,11 +118,8 @@ SetNetTrace(file)
|
||||
strcpy((char *)NetTraceFile, "(standard output)");
|
||||
}
|
||||
|
||||
void
|
||||
Dump(direction, buffer, length)
|
||||
char direction;
|
||||
unsigned char *buffer;
|
||||
int length;
|
||||
void
|
||||
Dump(char direction, unsigned char *buffer, int length)
|
||||
{
|
||||
# define BYTES_PER_LINE 32
|
||||
# define min(x,y) ((x<y)? x:y)
|
||||
@ -181,10 +166,8 @@ Dump(direction, buffer, length)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
printoption(direction, cmd, option)
|
||||
char *direction;
|
||||
int cmd, option;
|
||||
void
|
||||
printoption(const char *direction, int cmd, int option)
|
||||
{
|
||||
if (!showoptions)
|
||||
return;
|
||||
@ -194,7 +177,7 @@ printoption(direction, cmd, option)
|
||||
else
|
||||
fprintf(NetTrace, "%s IAC %d", direction, option);
|
||||
} else {
|
||||
register char *fmt;
|
||||
const char *fmt;
|
||||
fmt = (cmd == WILL) ? "WILL" : (cmd == WONT) ? "WONT" :
|
||||
(cmd == DO) ? "DO" : (cmd == DONT) ? "DONT" : 0;
|
||||
if (fmt) {
|
||||
@ -217,10 +200,10 @@ printoption(direction, cmd, option)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
optionstatus()
|
||||
void
|
||||
optionstatus(void)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
extern char will_wont_resp[], do_dont_resp[];
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
@ -294,14 +277,10 @@ optionstatus()
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
printsub(direction, pointer, length)
|
||||
char direction; /* '<' or '>' */
|
||||
unsigned char *pointer; /* where suboption data sits */
|
||||
int length; /* length of suboption data */
|
||||
void
|
||||
printsub(char direction, unsigned char *pointer, int length)
|
||||
{
|
||||
register int i;
|
||||
char buf[512];
|
||||
int i;
|
||||
extern int want_status_response;
|
||||
|
||||
if (showoptions || direction == 0 ||
|
||||
@ -310,7 +289,7 @@ printsub(direction, pointer, length)
|
||||
fprintf(NetTrace, "%s IAC SB ",
|
||||
(direction == '<')? "RCVD":"SENT");
|
||||
if (length >= 3) {
|
||||
register int j;
|
||||
int j;
|
||||
|
||||
i = pointer[length-2];
|
||||
j = pointer[length-1];
|
||||
@ -525,8 +504,8 @@ printsub(direction, pointer, length)
|
||||
break;
|
||||
|
||||
case TELOPT_STATUS: {
|
||||
register char *cp;
|
||||
register int j, k;
|
||||
const char *cp;
|
||||
int j, k;
|
||||
|
||||
fprintf(NetTrace, "STATUS");
|
||||
|
||||
@ -639,7 +618,7 @@ printsub(direction, pointer, length)
|
||||
fprintf(NetTrace, "INFO ");
|
||||
env_common:
|
||||
{
|
||||
register int noquote = 2;
|
||||
int noquote = 2;
|
||||
#if defined(ENV_HACK) && defined(OLD_ENVIRON)
|
||||
extern int old_env_var, old_env_value;
|
||||
#endif
|
||||
@ -734,72 +713,52 @@ printsub(direction, pointer, length)
|
||||
* way to the kernel (thus the select).
|
||||
*/
|
||||
|
||||
void
|
||||
EmptyTerminal()
|
||||
static void
|
||||
EmptyTerminal(void)
|
||||
{
|
||||
#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) */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SetForExit()
|
||||
static void
|
||||
SetForExit(void)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void
|
||||
Exit(returnCode)
|
||||
int returnCode;
|
||||
void
|
||||
Exit(int returnCode)
|
||||
{
|
||||
SetForExit();
|
||||
exit(returnCode);
|
||||
}
|
||||
|
||||
void
|
||||
ExitString(string, returnCode)
|
||||
char *string;
|
||||
int returnCode;
|
||||
void
|
||||
ExitString(const char *string, int returnCode)
|
||||
{
|
||||
SetForExit();
|
||||
fwrite(string, 1, strlen(string), stderr);
|
||||
|
Loading…
Reference in New Issue
Block a user