version 1.9, 1996/12/22 03:26:08 |
version 1.10, 1998/03/12 04:57:29 |
|
|
* SUCH DAMAGE. |
* SUCH DAMAGE. |
*/ |
*/ |
|
|
#ifndef lint |
#include "telnet_locl.h" |
#if 0 |
|
static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; |
|
static char rcsid[] = "$NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $"; |
|
#else |
|
static char rcsid[] = "$OpenBSD$"; |
|
#endif |
|
#endif /* not lint */ |
|
|
|
#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 <signal.h> |
|
#include <netdb.h> |
|
#include <ctype.h> |
|
#include <pwd.h> |
|
#include <varargs.h> |
|
#include <errno.h> |
|
|
|
#include <arpa/telnet.h> |
|
#include <sys/cdefs.h> |
|
#define P __P |
|
|
|
#include "general.h" |
|
|
|
#include "ring.h" |
|
|
|
#include "externs.h" |
|
#include "defines.h" |
|
#include "types.h" |
|
|
|
#if !defined(CRAY) && !defined(sysV88) |
|
#include <netinet/in_systm.h> |
|
# if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix) |
|
# include <machine/endian.h> |
|
# endif /* vax */ |
|
#endif /* !defined(CRAY) && !defined(sysV88) */ |
|
#include <netinet/ip.h> |
|
|
|
|
|
#ifndef MAXHOSTNAMELEN |
|
#define MAXHOSTNAMELEN 64 |
|
#endif MAXHOSTNAMELEN |
|
|
|
#if defined(IPPROTO_IP) && defined(IP_TOS) |
#if defined(IPPROTO_IP) && defined(IP_TOS) |
int tos = -1; |
int tos = -1; |
#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */ |
#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */ |
|
|
char *hostname; |
char *hostname; |
static char _hostname[MAXHOSTNAMELEN]; |
static char _hostname[MAXHOSTNAMELEN]; |
|
|
extern char *getenv(); |
typedef int (*intrtn_t)(int, char**); |
|
static int call __P((intrtn_t, ...)); |
|
|
extern int isprefix(); |
|
extern char **genget(); |
|
extern int Ambiguous(); |
|
|
|
static call(); |
|
|
|
typedef struct { |
typedef struct { |
char *name; /* command name */ |
char *name; /* command name */ |
char *help; /* help string (NULL for no help) */ |
char *help; /* help string (NULL for no help) */ |
|
|
margc++; |
margc++; |
cp++; |
cp++; |
} |
} |
while (c = *cp) { |
while ((c = *cp)) { |
register int inquote = 0; |
register int inquote = 0; |
while (isspace(c)) |
while (isspace(c)) |
c = *++cp; |
c = *++cp; |
|
|
{ |
{ |
int count; /* how many bytes we are going to need to send */ |
int count; /* how many bytes we are going to need to send */ |
int i; |
int i; |
int question = 0; /* was at least one argument a question */ |
|
struct sendlist *s; /* pointer to current command */ |
struct sendlist *s; /* pointer to current command */ |
int success = 0; |
int success = 0; |
int needconnect = 0; |
int needconnect = 0; |
|
|
if (argc < 2) { |
if (argc < 2) { |
printf("need at least one argument for 'send' command\n"); |
printf("need at least one argument for 'send' command\r\n"); |
printf("'send ?' for help\n"); |
printf("'send ?' for help\r\n"); |
return 0; |
return 0; |
} |
} |
/* |
/* |
|
|
for (i = 1; i < argc; i++) { |
for (i = 1; i < argc; i++) { |
s = GETSEND(argv[i]); |
s = GETSEND(argv[i]); |
if (s == 0) { |
if (s == 0) { |
printf("Unknown send argument '%s'\n'send ?' for help.\n", |
printf("Unknown send argument '%s'\r\n'send ?' for help.\r\n", |
argv[i]); |
argv[i]); |
return 0; |
return 0; |
} else if (Ambiguous(s)) { |
} else if (Ambiguous(s)) { |
printf("Ambiguous send argument '%s'\n'send ?' for help.\n", |
printf("Ambiguous send argument '%s'\r\n'send ?' for help.\r\n", |
argv[i]); |
argv[i]); |
return 0; |
return 0; |
} |
} |
if (i + s->narg >= argc) { |
if (i + s->narg >= argc) { |
fprintf(stderr, |
fprintf(stderr, |
"Need %d argument%s to 'send %s' command. 'send %s ?' for help.\n", |
"Need %d argument%s to 'send %s' command. 'send %s ?' for help.\r\n", |
s->narg, s->narg == 1 ? "" : "s", s->name, s->name); |
s->narg, s->narg == 1 ? "" : "s", s->name, s->name); |
return 0; |
return 0; |
} |
} |
|
|
needconnect += s->needconnect; |
needconnect += s->needconnect; |
} |
} |
if (!connected && needconnect) { |
if (!connected && needconnect) { |
printf("?Need to be connected first.\n"); |
printf("?Need to be connected first.\r\n"); |
printf("'send ?' for help\n"); |
printf("'send ?' for help\r\n"); |
return 0; |
return 0; |
} |
} |
/* Now, do we have enough room? */ |
/* Now, do we have enough room? */ |
if (NETROOM() < count) { |
if (NETROOM() < count) { |
printf("There is not enough room in the buffer TO the network\n"); |
printf("There is not enough room in the buffer TO the network\r\n"); |
printf("to process your request. Nothing will be done.\n"); |
printf("to process your request. Nothing will be done.\r\n"); |
printf("('send synch' will throw away most data in the network\n"); |
printf("('send synch' will throw away most data in the network\r\n"); |
printf("buffer, if this might help.)\n"); |
printf("buffer, if this might help.)\r\n"); |
return 0; |
return 0; |
} |
} |
/* OK, they are all OK, now go through again and actually send */ |
/* OK, they are all OK, now go through again and actually send */ |
count = 0; |
count = 0; |
for (i = 1; i < argc; i++) { |
for (i = 1; i < argc; i++) { |
if ((s = GETSEND(argv[i])) == 0) { |
if ((s = GETSEND(argv[i])) == 0) { |
fprintf(stderr, "Telnet 'send' error - argument disappeared!\n"); |
fprintf(stderr, "Telnet 'send' error - argument disappeared!\r\n"); |
(void) quit(); |
(void) quit(); |
/*NOTREACHED*/ |
/*NOTREACHED*/ |
} |
} |
|
|
return (count == success); |
return (count == success); |
} |
} |
|
|
|
static int |
|
send_tncmd(void (*func)(), char *cmd, char *name); |
|
|
static int |
static int |
send_esc() |
send_esc() |
{ |
{ |
|
|
extern char *telopts[]; |
extern char *telopts[]; |
register int val = 0; |
register int val = 0; |
|
|
if (isprefix(name, "?")) { |
if (isprefix(name, "help") || isprefix(name, "?")) { |
register int col, len; |
register int col, len; |
|
|
printf("Usage: send %s <value|option>\n", cmd); |
printf("Usage: send %s <value|option>\r\n", cmd); |
printf("\"value\" must be from 0 to 255\n"); |
printf("\"value\" must be from 0 to 255\r\n"); |
printf("Valid options are:\n\t"); |
printf("Valid options are:\r\n\t"); |
|
|
col = 8; |
col = 8; |
for (cpp = telopts; *cpp; cpp++) { |
for (cpp = telopts; *cpp; cpp++) { |
len = strlen(*cpp) + 3; |
len = strlen(*cpp) + 3; |
if (col + len > 65) { |
if (col + len > 65) { |
printf("\n\t"); |
printf("\r\n\t"); |
col = 8; |
col = 8; |
} |
} |
printf(" \"%s\"", *cpp); |
printf(" \"%s\"", *cpp); |
col += len; |
col += len; |
} |
} |
printf("\n"); |
printf("\r\n"); |
return 0; |
return 0; |
} |
} |
cpp = (char **)genget(name, telopts, sizeof(char *)); |
cpp = (char **)genget(name, telopts, sizeof(char *)); |
if (Ambiguous(cpp)) { |
if (Ambiguous(cpp)) { |
fprintf(stderr,"'%s': ambiguous argument ('send %s ?' for help).\n", |
fprintf(stderr,"'%s': ambiguous argument ('send %s ?' for help).\r\n", |
name, cmd); |
name, cmd); |
return 0; |
return 0; |
} |
} |
|
|
cp++; |
cp++; |
} |
} |
if (*cp != 0) { |
if (*cp != 0) { |
fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\r\n", |
name, cmd); |
name, cmd); |
return 0; |
return 0; |
} else if (val < 0 || val > 255) { |
} else if (val < 0 || val > 255) { |
fprintf(stderr, "'%s': bad value ('send %s ?' for help).\n", |
fprintf(stderr, "'%s': bad value ('send %s ?' for help).\r\n", |
name, cmd); |
name, cmd); |
return 0; |
return 0; |
} |
} |
} |
} |
if (!connected) { |
if (!connected) { |
printf("?Need to be connected first.\n"); |
printf("?Need to be connected first.\r\n"); |
return 0; |
return 0; |
} |
} |
(*func)(val, 1); |
(*func)(val, 1); |
|
|
struct sendlist *s; /* pointer to current command */ |
struct sendlist *s; /* pointer to current command */ |
for (s = Sendlist; s->name; s++) { |
for (s = Sendlist; s->name; s++) { |
if (s->help) |
if (s->help) |
printf("%-15s %s\n", s->name, s->help); |
printf("%-15s %s\r\n", s->name, s->help); |
} |
} |
return(0); |
return(0); |
} |
} |
|
|
} |
} |
#else /* NOT43 */ |
#else /* NOT43 */ |
if (debug) { |
if (debug) { |
if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0) |
if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) |
perror("setsockopt (SO_DEBUG)"); |
perror("setsockopt (SO_DEBUG)"); |
} else |
} else |
printf("Cannot turn off socket debugging\n"); |
printf("Cannot turn off socket debugging\r\n"); |
#endif /* NOT43 */ |
#endif /* NOT43 */ |
return 1; |
return 1; |
} |
} |
|
|
togcrlf() |
togcrlf() |
{ |
{ |
if (crlf) { |
if (crlf) { |
printf("Will send carriage returns as telnet <CR><LF>.\n"); |
printf("Will send carriage returns as telnet <CR><LF>.\r\n"); |
} else { |
} else { |
printf("Will send carriage returns as telnet <CR><NUL>.\n"); |
printf("Will send carriage returns as telnet <CR><NUL>.\r\n"); |
} |
} |
return 1; |
return 1; |
} |
} |
|
|
if (val == 1) { |
if (val == 1) { |
if (my_want_state_is_will(TELOPT_BINARY) && |
if (my_want_state_is_will(TELOPT_BINARY) && |
my_want_state_is_do(TELOPT_BINARY)) { |
my_want_state_is_do(TELOPT_BINARY)) { |
printf("Already operating in binary mode with remote host.\n"); |
printf("Already operating in binary mode with remote host.\r\n"); |
} else { |
} else { |
printf("Negotiating binary mode with remote host.\n"); |
printf("Negotiating binary mode with remote host.\r\n"); |
tel_enter_binary(3); |
tel_enter_binary(3); |
} |
} |
} else { |
} else { |
if (my_want_state_is_wont(TELOPT_BINARY) && |
if (my_want_state_is_wont(TELOPT_BINARY) && |
my_want_state_is_dont(TELOPT_BINARY)) { |
my_want_state_is_dont(TELOPT_BINARY)) { |
printf("Already in network ascii mode with remote host.\n"); |
printf("Already in network ascii mode with remote host.\r\n"); |
} else { |
} else { |
printf("Negotiating network ascii mode with remote host.\n"); |
printf("Negotiating network ascii mode with remote host.\r\n"); |
tel_leave_binary(3); |
tel_leave_binary(3); |
} |
} |
} |
} |
|
|
|
|
if (val == 1) { |
if (val == 1) { |
if (my_want_state_is_do(TELOPT_BINARY)) { |
if (my_want_state_is_do(TELOPT_BINARY)) { |
printf("Already receiving in binary mode.\n"); |
printf("Already receiving in binary mode.\r\n"); |
} else { |
} else { |
printf("Negotiating binary mode on input.\n"); |
printf("Negotiating binary mode on input.\r\n"); |
tel_enter_binary(1); |
tel_enter_binary(1); |
} |
} |
} else { |
} else { |
if (my_want_state_is_dont(TELOPT_BINARY)) { |
if (my_want_state_is_dont(TELOPT_BINARY)) { |
printf("Already receiving in network ascii mode.\n"); |
printf("Already receiving in network ascii mode.\r\n"); |
} else { |
} else { |
printf("Negotiating network ascii mode on input.\n"); |
printf("Negotiating network ascii mode on input.\r\n"); |
tel_leave_binary(1); |
tel_leave_binary(1); |
} |
} |
} |
} |
|
|
|
|
if (val == 1) { |
if (val == 1) { |
if (my_want_state_is_will(TELOPT_BINARY)) { |
if (my_want_state_is_will(TELOPT_BINARY)) { |
printf("Already transmitting in binary mode.\n"); |
printf("Already transmitting in binary mode.\r\n"); |
} else { |
} else { |
printf("Negotiating binary mode on output.\n"); |
printf("Negotiating binary mode on output.\r\n"); |
tel_enter_binary(2); |
tel_enter_binary(2); |
} |
} |
} else { |
} else { |
if (my_want_state_is_wont(TELOPT_BINARY)) { |
if (my_want_state_is_wont(TELOPT_BINARY)) { |
printf("Already transmitting in network ascii mode.\n"); |
printf("Already transmitting in network ascii mode.\r\n"); |
} else { |
} else { |
printf("Negotiating network ascii mode on output.\n"); |
printf("Negotiating network ascii mode on output.\r\n"); |
tel_leave_binary(2); |
tel_leave_binary(2); |
} |
} |
} |
} |
|
|
#if defined(AUTHENTICATION) |
#if defined(AUTHENTICATION) |
extern int auth_togdebug P((int)); |
extern int auth_togdebug P((int)); |
#endif |
#endif |
|
#if defined(ENCRYPTION) |
|
extern int EncryptAutoEnc P((int)); |
|
extern int EncryptAutoDec P((int)); |
|
extern int EncryptDebug P((int)); |
|
extern int EncryptVerbose P((int)); |
|
#endif |
|
|
|
|
struct togglelist { |
struct togglelist { |
char *name; /* name of toggle */ |
char *name; /* name of toggle */ |
char *help; /* help message */ |
char *help; /* help message */ |
|
|
"flushing of output when sending interrupt characters", |
"flushing of output when sending interrupt characters", |
0, |
0, |
&autoflush, |
&autoflush, |
"flush output when sending interrupt characters", 0 }, |
"flush output when sending interrupt characters" }, |
{ "autosynch", |
{ "autosynch", |
"automatic sending of interrupt characters in urgent mode", |
"automatic sending of interrupt characters in urgent mode", |
0, |
0, |
&autosynch, |
&autosynch, |
"send interrupt characters in urgent mode", 0 }, |
"send interrupt characters in urgent mode" }, |
#if defined(AUTHENTICATION) |
#if defined(AUTHENTICATION) |
{ "autologin", |
{ "autologin", |
"automatic sending of login and/or authentication info", |
"automatic sending of login and/or authentication info", |
0, |
0, |
&autologin, |
&autologin, |
"send login name and/or authentication information", 0 }, |
"send login name and/or authentication information" }, |
{ "authdebug", |
{ "authdebug", |
"Toggle authentication debugging", |
"Toggle authentication debugging", |
auth_togdebug, |
auth_togdebug, |
0, |
0, |
"print authentication debugging information", 0 }, |
"print authentication debugging information" }, |
#endif |
#endif |
|
#if defined(ENCRYPTION) |
|
{ "autoencrypt", |
|
"automatic encryption of data stream", |
|
EncryptAutoEnc, |
|
0, |
|
"automatically encrypt output" }, |
|
{ "autodecrypt", |
|
"automatic decryption of data stream", |
|
EncryptAutoDec, |
|
0, |
|
"automatically decrypt input" }, |
|
{ "verbose_encrypt", |
|
"Toggle verbose encryption output", |
|
EncryptVerbose, |
|
0, |
|
"print verbose encryption output" }, |
|
{ "encdebug", |
|
"Toggle encryption debugging", |
|
EncryptDebug, |
|
0, |
|
"print encryption debugging information" }, |
|
#endif |
{ "skiprc", |
{ "skiprc", |
"don't read ~/.telnetrc file", |
"don't read ~/.telnetrc file", |
0, |
0, |
&skiprc, |
&skiprc, |
"skip reading of ~/.telnetrc file", 0 }, |
"skip reading of ~/.telnetrc file" }, |
{ "binary", |
{ "binary", |
"sending and receiving of binary data", |
"sending and receiving of binary data", |
togbinary, |
togbinary, |
0, |
0, |
0, 1 }, |
0 }, |
{ "inbinary", |
{ "inbinary", |
"receiving of binary data", |
"receiving of binary data", |
togrbinary, |
togrbinary, |
0, |
0, |
0, 1 }, |
0 }, |
{ "outbinary", |
{ "outbinary", |
"sending of binary data", |
"sending of binary data", |
togxbinary, |
togxbinary, |
0, |
0, |
0, 1 }, |
0 }, |
{ "crlf", |
{ "crlf", |
"sending carriage returns as telnet <CR><LF>", |
"sending carriage returns as telnet <CR><LF>", |
togcrlf, |
togcrlf, |
&crlf, |
&crlf, |
0, 0 }, |
0 }, |
{ "crmod", |
{ "crmod", |
"mapping of received carriage returns", |
"mapping of received carriage returns", |
0, |
0, |
&crmod, |
&crmod, |
"map carriage return on output", 0 }, |
"map carriage return on output" }, |
{ "localchars", |
{ "localchars", |
"local recognition of certain control characters", |
"local recognition of certain control characters", |
lclchars, |
lclchars, |
&localchars, |
&localchars, |
"recognize certain control characters", 0 }, |
"recognize certain control characters" }, |
{ " ", "", 0, 0 }, /* empty line */ |
{ " ", "", 0, 0 }, /* empty line */ |
#if defined(unix) && defined(TN3270) |
#if defined(unix) && defined(TN3270) |
{ "apitrace", |
{ "apitrace", |
|
|
"debugging", |
"debugging", |
togdebug, |
togdebug, |
&debug, |
&debug, |
"turn on socket level debugging", 0 }, |
"turn on socket level debugging" }, |
{ "netdata", |
{ "netdata", |
"printing of hexadecimal network data (debugging)", |
"printing of hexadecimal network data (debugging)", |
0, |
0, |
&netdata, |
&netdata, |
"print hexadecimal representation of network traffic", 0 }, |
"print hexadecimal representation of network traffic" }, |
{ "prettydump", |
{ "prettydump", |
"output of \"netdata\" to user readable format (debugging)", |
"output of \"netdata\" to user readable format (debugging)", |
0, |
0, |
&prettydump, |
&prettydump, |
"print user readable output for \"netdata\"", 0 }, |
"print user readable output for \"netdata\"" }, |
{ "options", |
{ "options", |
"viewing of options processing (debugging)", |
"viewing of options processing (debugging)", |
0, |
0, |
&showoptions, |
&showoptions, |
"show option processing", 0 }, |
"show option processing" }, |
#if defined(unix) |
#if defined(unix) |
{ "termdata", |
{ "termdata", |
"(debugging) toggle printing of hexadecimal terminal data", |
"(debugging) toggle printing of hexadecimal terminal data", |
0, |
0, |
&termdata, |
&termdata, |
"print hexadecimal representation of terminal traffic", 0 }, |
"print hexadecimal representation of terminal traffic" }, |
#endif /* defined(unix) */ |
#endif /* defined(unix) */ |
{ "?", |
{ "?", |
0, |
0, |
togglehelp, 0 }, |
togglehelp }, |
{ "help", |
{ "help", |
0, |
0, |
togglehelp, 0 }, |
togglehelp }, |
{ 0 } |
{ 0 } |
}; |
}; |
|
|
|
|
for (c = Togglelist; c->name; c++) { |
for (c = Togglelist; c->name; c++) { |
if (c->help) { |
if (c->help) { |
if (*c->help) |
if (*c->help) |
printf("%-15s toggle %s\n", c->name, c->help); |
printf("%-15s toggle %s\r\n", c->name, c->help); |
else |
else |
printf("\n"); |
printf("\r\n"); |
} |
} |
} |
} |
printf("\n"); |
printf("\r\n"); |
printf("%-15s %s\n", "?", "display help information"); |
printf("%-15s %s\r\n", "?", "display help information"); |
return 0; |
return 0; |
} |
} |
|
|
|
|
for (c = Togglelist; c->name; c++) { |
for (c = Togglelist; c->name; c++) { |
if (c->help) { |
if (c->help) { |
if (*c->help) |
if (*c->help) |
printf("%-15s %s %s\n", c->name, set ? "enable" : "disable", |
printf("%-15s %s %s\r\n", c->name, set ? "enable" : "disable", |
c->help); |
c->help); |
else |
else |
printf("\n"); |
printf("\r\n"); |
} |
} |
} |
} |
} |
} |
|
|
|
|
if (argc < 2) { |
if (argc < 2) { |
fprintf(stderr, |
fprintf(stderr, |
"Need an argument to 'toggle' command. 'toggle ?' for help.\n"); |
"Need an argument to 'toggle' command. 'toggle ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
argc--; |
argc--; |
|
|
name = *argv++; |
name = *argv++; |
c = GETTOGGLE(name); |
c = GETTOGGLE(name); |
if (Ambiguous(c)) { |
if (Ambiguous(c)) { |
fprintf(stderr, "'%s': ambiguous argument ('toggle ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('toggle ?' for help).\r\n", |
name); |
name); |
return 0; |
return 0; |
} else if (c == 0) { |
} else if (c == 0) { |
fprintf(stderr, "'%s': unknown argument ('toggle ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('toggle ?' for help).\r\n", |
name); |
name); |
return 0; |
return 0; |
} else if (!connected && c->needconnect) { |
} else if (!connected && c->needconnect) { |
printf("?Need to be connected first.\n"); |
printf("?Need to be connected first.\r\n"); |
printf("'send ?' for help\n"); |
printf("'send ?' for help\r\n"); |
return 0; |
return 0; |
} else { |
} else { |
if (c->variable) { |
if (c->variable) { |
*c->variable = !*c->variable; /* invert it */ |
*c->variable = !*c->variable; /* invert it */ |
if (c->actionexplanation) { |
if (c->actionexplanation) { |
printf("%s %s.\n", *c->variable? "Will" : "Won't", |
printf("%s %s.\r\n", *c->variable? "Will" : "Won't", |
c->actionexplanation); |
c->actionexplanation); |
} |
} |
} |
} |
|
|
*/ |
*/ |
|
|
#ifdef USE_TERMIO |
#ifdef USE_TERMIO |
struct termio new_tc = { 0 }; |
struct termios new_tc = { 0 }; |
#endif |
#endif |
|
|
struct setlist { |
struct setlist { |
|
|
{ "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile}, |
{ "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile}, |
{ " ", "" }, |
{ " ", "" }, |
{ " ", "The following need 'localchars' to be toggled true", 0, 0 }, |
{ " ", "The following need 'localchars' to be toggled true", 0, 0 }, |
{ "flushoutput", "character to cause an Abort Output", 0, termFlushCharp }, |
{ "flushoutput", "character to cause an Abort Output", 0, &termFlushChar }, |
{ "interrupt", "character to cause an Interrupt Process", 0, termIntCharp }, |
{ "interrupt", "character to cause an Interrupt Process", 0, &termIntChar }, |
{ "quit", "character to cause an Abort process", 0, termQuitCharp }, |
{ "quit", "character to cause an Abort process", 0, &termQuitChar }, |
{ "eof", "character to cause an EOF ", 0, termEofCharp }, |
{ "eof", "character to cause an EOF ", 0, &termEofChar }, |
{ " ", "" }, |
{ " ", "" }, |
{ " ", "The following are for local editing in linemode", 0, 0 }, |
{ " ", "The following are for local editing in linemode", 0, 0 }, |
{ "erase", "character to use to erase a character", 0, termEraseCharp }, |
{ "erase", "character to use to erase a character", 0, &termEraseChar }, |
{ "kill", "character to use to erase a line", 0, termKillCharp }, |
{ "kill", "character to use to erase a line", 0, &termKillChar }, |
{ "lnext", "character to use for literal next", 0, termLiteralNextCharp }, |
{ "lnext", "character to use for literal next", 0, &termLiteralNextChar }, |
{ "susp", "character to cause a Suspend Process", 0, termSuspCharp }, |
{ "susp", "character to cause a Suspend Process", 0, &termSuspChar }, |
{ "reprint", "character to use for line reprint", 0, termRprntCharp }, |
{ "reprint", "character to use for line reprint", 0, &termRprntChar }, |
{ "worderase", "character to use to erase a word", 0, termWerasCharp }, |
{ "worderase", "character to use to erase a word", 0, &termWerasChar }, |
{ "start", "character to use for XON", 0, termStartCharp }, |
{ "start", "character to use for XON", 0, &termStartChar }, |
{ "stop", "character to use for XOFF", 0, termStopCharp }, |
{ "stop", "character to use for XOFF", 0, &termStopChar }, |
{ "forw1", "alternate end of line character", 0, termForw1Charp }, |
{ "forw1", "alternate end of line character", 0, &termForw1Char }, |
{ "forw2", "alternate end of line character", 0, termForw2Charp }, |
{ "forw2", "alternate end of line character", 0, &termForw2Char }, |
{ "ayt", "alternate AYT character", 0, termAytCharp }, |
{ "ayt", "alternate AYT character", 0, &termAytChar }, |
{ 0 } |
{ 0 } |
}; |
}; |
|
|
#if defined(CRAY) && !defined(__STDC__) |
|
/* Work around compiler bug in pcc 4.1.5 */ |
|
void |
|
_setlist_init() |
|
{ |
|
#ifndef KLUDGELINEMODE |
|
#define N 5 |
|
#else |
|
#define N 6 |
|
#endif |
|
Setlist[N+0].charp = &termFlushChar; |
|
Setlist[N+1].charp = &termIntChar; |
|
Setlist[N+2].charp = &termQuitChar; |
|
Setlist[N+3].charp = &termEofChar; |
|
Setlist[N+6].charp = &termEraseChar; |
|
Setlist[N+7].charp = &termKillChar; |
|
Setlist[N+8].charp = &termLiteralNextChar; |
|
Setlist[N+9].charp = &termSuspChar; |
|
Setlist[N+10].charp = &termRprntChar; |
|
Setlist[N+11].charp = &termWerasChar; |
|
Setlist[N+12].charp = &termStartChar; |
|
Setlist[N+13].charp = &termStopChar; |
|
Setlist[N+14].charp = &termForw1Char; |
|
Setlist[N+15].charp = &termForw2Char; |
|
Setlist[N+16].charp = &termAytChar; |
|
#undef N |
|
} |
|
#endif /* defined(CRAY) && !defined(__STDC__) */ |
|
|
|
static struct setlist * |
static struct setlist * |
getset(name) |
getset(name) |
char *name; |
char *name; |
|
|
{ |
{ |
if (rlogin != _POSIX_VDISABLE) { |
if (rlogin != _POSIX_VDISABLE) { |
rlogin = (s && *s) ? special(s) : _POSIX_VDISABLE; |
rlogin = (s && *s) ? special(s) : _POSIX_VDISABLE; |
printf("Telnet rlogin escape character is '%s'.\n", |
printf("Telnet rlogin escape character is '%s'.\r\n", |
control(rlogin)); |
control(rlogin)); |
} else { |
} else { |
escape = (s && *s) ? special(s) : _POSIX_VDISABLE; |
escape = (s && *s) ? special(s) : _POSIX_VDISABLE; |
printf("Telnet escape character is '%s'.\n", control(escape)); |
printf("Telnet escape character is '%s'.\r\n", control(escape)); |
} |
} |
} |
} |
|
|
|
|
struct togglelist *c; |
struct togglelist *c; |
|
|
if (argc < 2 || argc > 3) { |
if (argc < 2 || argc > 3) { |
printf("Format is 'set Name Value'\n'set ?' for help.\n"); |
printf("Format is 'set Name Value'\r\n'set ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
if ((argc == 2) && (isprefix(argv[1], "?") || isprefix(argv[1], "help"))) { |
if ((argc == 2) && (isprefix(argv[1], "?") || isprefix(argv[1], "help"))) { |
for (ct = Setlist; ct->name; ct++) |
for (ct = Setlist; ct->name; ct++) |
printf("%-15s %s\n", ct->name, ct->help); |
printf("%-15s %s\r\n", ct->name, ct->help); |
printf("\n"); |
printf("\r\n"); |
settogglehelp(1); |
settogglehelp(1); |
printf("%-15s %s\n", "?", "display help information"); |
printf("%-15s %s\r\n", "?", "display help information"); |
return 0; |
return 0; |
} |
} |
|
|
|
|
if (ct == 0) { |
if (ct == 0) { |
c = GETTOGGLE(argv[1]); |
c = GETTOGGLE(argv[1]); |
if (c == 0) { |
if (c == 0) { |
fprintf(stderr, "'%s': unknown argument ('set ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('set ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} else if (Ambiguous(c)) { |
} else if (Ambiguous(c)) { |
fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} else if (!connected && c->needconnect) { |
} else if (!connected && c->needconnect) { |
printf("?Need to be connected first.\n"); |
printf("?Need to be connected first.\r\n"); |
printf("'send ?' for help\n"); |
printf("'send ?' for help\r\n"); |
return 0; |
return 0; |
} |
} |
|
|
|
|
else if (strcmp("off", argv[2]) == 0) |
else if (strcmp("off", argv[2]) == 0) |
*c->variable = 0; |
*c->variable = 0; |
else { |
else { |
printf("Format is 'set togglename [on|off]'\n'set ?' for help.\n"); |
printf("Format is 'set togglename [on|off]'\r\n'set ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
if (c->actionexplanation) { |
if (c->actionexplanation) { |
printf("%s %s.\n", *c->variable? "Will" : "Won't", |
printf("%s %s.\r\n", *c->variable? "Will" : "Won't", |
c->actionexplanation); |
c->actionexplanation); |
} |
} |
} |
} |
if (c->handler) |
if (c->handler) |
(*c->handler)(1); |
(*c->handler)(1); |
} else if (argc != 3) { |
} else if (argc != 3) { |
printf("Format is 'set Name Value'\n'set ?' for help.\n"); |
printf("Format is 'set Name Value'\r\n'set ?' for help.\r\n"); |
return 0; |
return 0; |
} else if (Ambiguous(ct)) { |
} else if (Ambiguous(ct)) { |
fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} else if (ct->handler) { |
} else if (ct->handler) { |
(*ct->handler)(argv[2]); |
(*ct->handler)(argv[2]); |
printf("%s set to \"%s\".\n", ct->name, (char *)ct->charp); |
printf("%s set to \"%s\".\r\n", ct->name, (char *)ct->charp); |
} else { |
} else { |
if (strcmp("off", argv[2])) { |
if (strcmp("off", argv[2])) { |
value = special(argv[2]); |
value = special(argv[2]); |
|
|
value = _POSIX_VDISABLE; |
value = _POSIX_VDISABLE; |
} |
} |
*(ct->charp) = (cc_t)value; |
*(ct->charp) = (cc_t)value; |
printf("%s character is '%s'.\n", ct->name, control(*(ct->charp))); |
printf("%s character is '%s'.\r\n", ct->name, control(*(ct->charp))); |
} |
} |
slc_check(); |
slc_check(); |
return 1; |
return 1; |
|
|
|
|
if (argc < 2) { |
if (argc < 2) { |
fprintf(stderr, |
fprintf(stderr, |
"Need an argument to 'unset' command. 'unset ?' for help.\n"); |
"Need an argument to 'unset' command. 'unset ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
if (isprefix(argv[1], "?") || isprefix(argv[1], "help")) { |
if (isprefix(argv[1], "?") || isprefix(argv[1], "help")) { |
for (ct = Setlist; ct->name; ct++) |
for (ct = Setlist; ct->name; ct++) |
printf("%-15s %s\n", ct->name, ct->help); |
printf("%-15s %s\r\n", ct->name, ct->help); |
printf("\n"); |
printf("\r\n"); |
settogglehelp(0); |
settogglehelp(0); |
printf("%-15s %s\n", "?", "display help information"); |
printf("%-15s %s\r\n", "?", "display help information"); |
return 0; |
return 0; |
} |
} |
|
|
|
|
if (ct == 0) { |
if (ct == 0) { |
c = GETTOGGLE(name); |
c = GETTOGGLE(name); |
if (c == 0) { |
if (c == 0) { |
fprintf(stderr, "'%s': unknown argument ('unset ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('unset ?' for help).\r\n", |
name); |
name); |
return 0; |
return 0; |
} else if (Ambiguous(c)) { |
} else if (Ambiguous(c)) { |
fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\r\n", |
name); |
name); |
return 0; |
return 0; |
} |
} |
if (c->variable) { |
if (c->variable) { |
*c->variable = 0; |
*c->variable = 0; |
if (c->actionexplanation) { |
if (c->actionexplanation) { |
printf("%s %s.\n", *c->variable? "Will" : "Won't", |
printf("%s %s.\r\n", *c->variable? "Will" : "Won't", |
c->actionexplanation); |
c->actionexplanation); |
} |
} |
} |
} |
if (c->handler) |
if (c->handler) |
(*c->handler)(0); |
(*c->handler)(0); |
} else if (Ambiguous(ct)) { |
} else if (Ambiguous(ct)) { |
fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\r\n", |
name); |
name); |
return 0; |
return 0; |
} else if (ct->handler) { |
} else if (ct->handler) { |
(*ct->handler)(0); |
(*ct->handler)(0); |
printf("%s reset to \"%s\".\n", ct->name, (char *)ct->charp); |
printf("%s reset to \"%s\".\r\n", ct->name, (char *)ct->charp); |
} else { |
} else { |
*(ct->charp) = _POSIX_VDISABLE; |
*(ct->charp) = _POSIX_VDISABLE; |
printf("%s character is '%s'.\n", ct->name, control(*(ct->charp))); |
printf("%s character is '%s'.\r\n", ct->name, control(*(ct->charp))); |
} |
} |
} |
} |
return 1; |
return 1; |
|
|
send_wont(TELOPT_LINEMODE, 1); |
send_wont(TELOPT_LINEMODE, 1); |
send_dont(TELOPT_SGA, 1); |
send_dont(TELOPT_SGA, 1); |
send_dont(TELOPT_ECHO, 1); |
send_dont(TELOPT_ECHO, 1); |
|
return 1; |
} |
} |
#endif |
#endif |
|
|
|
|
extern int linemode; |
extern int linemode; |
|
|
if (my_want_state_is_wont(TELOPT_LINEMODE)) { |
if (my_want_state_is_wont(TELOPT_LINEMODE)) { |
printf("?Need to have LINEMODE option enabled first.\n"); |
printf("?Need to have LINEMODE option enabled first.\r\n"); |
printf("'mode ?' for help.\n"); |
printf("'mode ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
|
|
|
|
} |
} |
|
|
int |
int |
setmode(bit) |
tn_setmode(bit) |
{ |
{ |
return dolmmode(bit, 1); |
return dolmmode(bit, 1); |
} |
} |
|
|
int |
int |
clearmode(bit) |
tn_clearmode(bit) |
{ |
{ |
return dolmmode(bit, 0); |
return dolmmode(bit, 0); |
} |
} |
|
|
int arg1; |
int arg1; |
}; |
}; |
|
|
extern int modehelp(); |
static int modehelp __P((void)); |
|
|
static struct modelist ModeList[] = { |
static struct modelist ModeList[] = { |
{ "character", "Disable LINEMODE option", docharmode, 1 }, |
{ "character", "Disable LINEMODE option", docharmode, 1 }, |
|
|
#endif |
#endif |
{ "", "", 0 }, |
{ "", "", 0 }, |
{ "", "These require the LINEMODE option to be enabled", 0 }, |
{ "", "These require the LINEMODE option to be enabled", 0 }, |
{ "isig", "Enable signal trapping", setmode, 1, MODE_TRAPSIG }, |
{ "isig", "Enable signal trapping", tn_setmode, 1, MODE_TRAPSIG }, |
{ "+isig", 0, setmode, 1, MODE_TRAPSIG }, |
{ "+isig", 0, tn_setmode, 1, MODE_TRAPSIG }, |
{ "-isig", "Disable signal trapping", clearmode, 1, MODE_TRAPSIG }, |
{ "-isig", "Disable signal trapping", tn_clearmode, 1, MODE_TRAPSIG }, |
{ "edit", "Enable character editing", setmode, 1, MODE_EDIT }, |
{ "edit", "Enable character editing", tn_setmode, 1, MODE_EDIT }, |
{ "+edit", 0, setmode, 1, MODE_EDIT }, |
{ "+edit", 0, tn_setmode, 1, MODE_EDIT }, |
{ "-edit", "Disable character editing", clearmode, 1, MODE_EDIT }, |
{ "-edit", "Disable character editing", tn_clearmode, 1, MODE_EDIT }, |
{ "softtabs", "Enable tab expansion", setmode, 1, MODE_SOFT_TAB }, |
{ "softtabs", "Enable tab expansion", tn_setmode, 1, MODE_SOFT_TAB }, |
{ "+softtabs", 0, setmode, 1, MODE_SOFT_TAB }, |
{ "+softtabs", 0, tn_setmode, 1, MODE_SOFT_TAB }, |
{ "-softtabs", "Disable character editing", clearmode, 1, MODE_SOFT_TAB }, |
{ "-softtabs", "Disable character editing", tn_clearmode, 1, MODE_SOFT_TAB }, |
{ "litecho", "Enable literal character echo", setmode, 1, MODE_LIT_ECHO }, |
{ "litecho", "Enable literal character echo", tn_setmode, 1, MODE_LIT_ECHO }, |
{ "+litecho", 0, setmode, 1, MODE_LIT_ECHO }, |
{ "+litecho", 0, tn_setmode, 1, MODE_LIT_ECHO }, |
{ "-litecho", "Disable literal character echo", clearmode, 1, MODE_LIT_ECHO }, |
{ "-litecho", "Disable literal character echo", tn_clearmode, 1, MODE_LIT_ECHO }, |
{ "help", 0, modehelp, 0 }, |
{ "help", 0, modehelp, 0 }, |
#ifdef KLUDGELINEMODE |
#ifdef KLUDGELINEMODE |
{ "kludgeline", 0, dokludgemode, 1 }, |
{ "kludgeline", 0, dokludgemode, 1 }, |
|
|
}; |
}; |
|
|
|
|
int |
static int |
modehelp() |
modehelp() |
{ |
{ |
struct modelist *mt; |
struct modelist *mt; |
|
|
printf("format is: 'mode Mode', where 'Mode' is one of:\n\n"); |
printf("format is: 'mode Mode', where 'Mode' is one of:\r\n\r\n"); |
for (mt = ModeList; mt->name; mt++) { |
for (mt = ModeList; mt->name; mt++) { |
if (mt->help) { |
if (mt->help) { |
if (*mt->help) |
if (*mt->help) |
printf("%-15s %s\n", mt->name, mt->help); |
printf("%-15s %s\r\n", mt->name, mt->help); |
else |
else |
printf("\n"); |
printf("\r\n"); |
} |
} |
} |
} |
return 0; |
return 0; |
|
|
struct modelist *mt; |
struct modelist *mt; |
|
|
if (argc != 2) { |
if (argc != 2) { |
printf("'mode' command requires an argument\n"); |
printf("'mode' command requires an argument\r\n"); |
printf("'mode ?' for help.\n"); |
printf("'mode ?' for help.\r\n"); |
} else if ((mt = GETMODECMD(argv[1])) == 0) { |
} else if ((mt = GETMODECMD(argv[1])) == 0) { |
fprintf(stderr, "Unknown mode '%s' ('mode ?' for help).\n", argv[1]); |
fprintf(stderr, "Unknown mode '%s' ('mode ?' for help).\r\n", argv[1]); |
} else if (Ambiguous(mt)) { |
} else if (Ambiguous(mt)) { |
fprintf(stderr, "Ambiguous mode '%s' ('mode ?' for help).\n", argv[1]); |
fprintf(stderr, "Ambiguous mode '%s' ('mode ?' for help).\r\n", argv[1]); |
} else if (mt->needconnect && !connected) { |
} else if (mt->needconnect && !connected) { |
printf("?Need to be connected first.\n"); |
printf("?Need to be connected first.\r\n"); |
printf("'mode ?' for help.\n"); |
printf("'mode ?' for help.\r\n"); |
} else if (mt->handler) { |
} else if (mt->handler) { |
return (*mt->handler)(mt->arg1); |
return (*mt->handler)(mt->arg1); |
} |
} |
|
|
} else { \ |
} else { \ |
printf("won't"); \ |
printf("won't"); \ |
} \ |
} \ |
printf(" %s.\n", tl->actionexplanation); \ |
printf(" %s.\r\n", tl->actionexplanation); \ |
} |
} |
|
|
#define doset(sl) if (sl->name && *sl->name != ' ') { \ |
#define doset(sl) if (sl->name && *sl->name != ' ') { \ |
if (sl->handler == 0) \ |
if (sl->handler == 0) \ |
printf("%-15s [%s]\n", sl->name, control(*sl->charp)); \ |
printf("%-15s [%s]\r\n", sl->name, control(*sl->charp)); \ |
else \ |
else \ |
printf("%-15s \"%s\"\n", sl->name, (char *)sl->charp); \ |
printf("%-15s \"%s\"\r\n", sl->name, (char *)sl->charp); \ |
} |
} |
|
|
if (argc == 1) { |
if (argc == 1) { |
for (tl = Togglelist; tl->name; tl++) { |
for (tl = Togglelist; tl->name; tl++) { |
dotog(tl); |
dotog(tl); |
} |
} |
printf("\n"); |
printf("\r\n"); |
for (sl = Setlist; sl->name; sl++) { |
for (sl = Setlist; sl->name; sl++) { |
doset(sl); |
doset(sl); |
} |
} |
|
|
sl = getset(argv[i]); |
sl = getset(argv[i]); |
tl = GETTOGGLE(argv[i]); |
tl = GETTOGGLE(argv[i]); |
if (Ambiguous(sl) || Ambiguous(tl)) { |
if (Ambiguous(sl) || Ambiguous(tl)) { |
printf("?Ambiguous argument '%s'.\n", argv[i]); |
printf("?Ambiguous argument '%s'.\r\n", argv[i]); |
return 0; |
return 0; |
} else if (!sl && !tl) { |
} else if (!sl && !tl) { |
printf("?Unknown argument '%s'.\n", argv[i]); |
printf("?Unknown argument '%s'.\r\n", argv[i]); |
return 0; |
return 0; |
} else { |
} else { |
if (tl) { |
if (tl) { |
|
|
} |
} |
} |
} |
/*@*/optionstatus(); |
/*@*/optionstatus(); |
|
#if defined(ENCRYPTION) |
|
EncryptStatus(); |
|
#endif |
return 1; |
return 1; |
#undef doset |
#undef doset |
#undef dotog |
#undef dotog |
} |
} |
|
|
/* |
/* |
* The following are the data structures, and many of the routines, |
* The following are the data structures, and many of the routines, |
* relating to command processing. |
* relating to command processing. |
|
|
char buf[50]; |
char buf[50]; |
|
|
printf( |
printf( |
"Deprecated usage - please use 'set escape%s%s' in the future.\n", |
"Deprecated usage - please use 'set escape%s%s' in the future.\r\n", |
(argc > 2)? " ":"", (argc > 2)? argv[1]: ""); |
(argc > 2)? " ":"", (argc > 2)? argv[1]: ""); |
if (argc > 2) |
if (argc > 2) |
arg = argv[1]; |
arg = argv[1]; |
|
|
if (arg[0] != '\0') |
if (arg[0] != '\0') |
escape = arg[0]; |
escape = arg[0]; |
if (!In3270) { |
if (!In3270) { |
printf("Escape character is '%s'.\n", control(escape)); |
printf("Escape character is '%s'.\r\n", control(escape)); |
} |
} |
(void) fflush(stdout); |
(void) fflush(stdout); |
return 1; |
return 1; |
|
|
togcrmod() |
togcrmod() |
{ |
{ |
crmod = !crmod; |
crmod = !crmod; |
printf("Deprecated usage - please use 'toggle crmod' in the future.\n"); |
printf("Deprecated usage - please use 'toggle crmod' in the future.\r\n"); |
printf("%s map carriage return on output.\n", crmod ? "Will" : "Won't"); |
printf("%s map carriage return on output.\r\n", crmod ? "Will" : "Won't"); |
(void) fflush(stdout); |
(void) fflush(stdout); |
return 1; |
return 1; |
} |
} |
|
|
/*VARARGS*/ |
/*VARARGS*/ |
int |
static int |
suspend() |
telnetsuspend() |
{ |
{ |
#ifdef SIGTSTP |
#ifdef SIGTSTP |
setcommandmode(); |
setcommandmode(); |
|
|
TerminalSaveState(); |
TerminalSaveState(); |
setconnmode(0); |
setconnmode(0); |
#else |
#else |
printf("Suspend is not supported. Try the '!' command instead\n"); |
printf("Suspend is not supported. Try the '!' command instead\r\n"); |
#endif |
#endif |
return 1; |
return 1; |
} |
} |
|
|
err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0; |
err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0; |
switch(vfork()) { |
switch(vfork()) { |
case -1: |
case -1: |
perror("Fork failed\n"); |
perror("Fork failed\r\n"); |
break; |
break; |
|
|
case 0: |
case 0: |
|
|
* Fire up the shell in the child. |
* Fire up the shell in the child. |
*/ |
*/ |
register char *shellp, *shellname; |
register char *shellp, *shellname; |
extern char *strrchr(); |
|
|
|
shellp = getenv("SHELL"); |
shellp = getenv("SHELL"); |
if (shellp == NULL) |
if (shellp == NULL) |
|
|
|
|
if (connected) { |
if (connected) { |
(void) shutdown(net, 2); |
(void) shutdown(net, 2); |
printf("Connection closed.\n"); |
printf("Connection closed.\r\n"); |
(void) NetClose(net); |
(void) NetClose(net); |
connected = 0; |
connected = 0; |
resettermname = 1; |
resettermname = 1; |
#if defined(AUTHENTICATION) |
#if defined(AUTHENTICATION) || defined(ENCRYPTION) |
auth_encrypt_connect(connected); |
auth_encrypt_connect(connected); |
#endif /* defined(AUTHENTICATION) */ |
#endif /* defined(AUTHENTICATION) */ |
/* reset options */ |
/* reset options */ |
|
|
longjmp(toplevel, 1); |
longjmp(toplevel, 1); |
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
return 1; /* Keep lint, etc., happy */ |
return 0; /* NOTREACHED */ |
} |
} |
|
|
/*VARARGS*/ |
/*VARARGS*/ |
|
int |
quit() |
quit() |
{ |
{ |
(void) call(bye, "bye", "fromquit", 0); |
(void) call(bye, "bye", "fromquit", 0); |
Exit(0); |
Exit(0); |
/*NOTREACHED*/ |
return 0; /*NOTREACHED*/ |
} |
} |
|
|
/*VARARGS*/ |
/*VARARGS*/ |
int |
static int |
logout() |
logout() |
{ |
{ |
send_do(TELOPT_LOGOUT, 1); |
send_do(TELOPT_LOGOUT, 1); |
|
|
for (c = SlcList; c->name; c++) { |
for (c = SlcList; c->name; c++) { |
if (c->help) { |
if (c->help) { |
if (*c->help) |
if (*c->help) |
printf("%-15s %s\n", c->name, c->help); |
printf("%-15s %s\r\n", c->name, c->help); |
else |
else |
printf("\n"); |
printf("\r\n"); |
} |
} |
} |
} |
} |
} |
|
|
|
|
if (argc != 2) { |
if (argc != 2) { |
fprintf(stderr, |
fprintf(stderr, |
"Need an argument to 'slc' command. 'slc ?' for help.\n"); |
"Need an argument to 'slc' command. 'slc ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
c = getslc(argv[1]); |
c = getslc(argv[1]); |
if (c == 0) { |
if (c == 0) { |
fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} |
} |
if (Ambiguous(c)) { |
if (Ambiguous(c)) { |
fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} |
} |
|
|
int narg; |
int narg; |
}; |
}; |
|
|
extern struct env_lst * |
static void env_help P((void)); |
env_define P((unsigned char *, unsigned char *)); |
|
extern void |
|
env_undefine P((unsigned char *)), |
|
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)); |
|
|
|
struct envlist EnvList[] = { |
struct envlist EnvList[] = { |
{ "define", "Define an environment variable", |
{ "define", "Define an environment variable", |
|
|
for (c = EnvList; c->name; c++) { |
for (c = EnvList; c->name; c++) { |
if (c->help) { |
if (c->help) { |
if (*c->help) |
if (*c->help) |
printf("%-15s %s\n", c->name, c->help); |
printf("%-15s %s\r\n", c->name, c->help); |
else |
else |
printf("\n"); |
printf("\r\n"); |
} |
} |
} |
} |
} |
} |
|
|
|
|
if (argc < 2) { |
if (argc < 2) { |
fprintf(stderr, |
fprintf(stderr, |
"Need an argument to 'environ' command. 'environ ?' for help.\n"); |
"Need an argument to 'environ' command. 'environ ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
c = getenvcmd(argv[1]); |
c = getenvcmd(argv[1]); |
if (c == 0) { |
if (c == 0) { |
fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} |
} |
if (Ambiguous(c)) { |
if (Ambiguous(c)) { |
fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} |
} |
if (c->narg + 2 != argc) { |
if (c->narg + 2 != argc) { |
fprintf(stderr, |
fprintf(stderr, |
"Need %s%d argument%s to 'environ %s' command. 'environ ?' for help.\n", |
"Need %s%d argument%s to 'environ %s' command. 'environ ?' for help.\r\n", |
c->narg < argc + 2 ? "only " : "", |
c->narg < argc + 2 ? "only " : "", |
c->narg, c->narg == 1 ? "" : "s", c->name); |
c->narg, c->narg == 1 ? "" : "s", c->name); |
return 0; |
return 0; |
|
|
env_init() |
env_init() |
{ |
{ |
extern char **environ; |
extern char **environ; |
register char **epp, *cp; |
char **epp, *cp; |
register struct env_lst *ep; |
struct env_lst *ep; |
extern char *strchr(); |
|
|
|
for (epp = environ; *epp; epp++) { |
for (epp = environ; *epp; epp++) { |
if (cp = strchr(*epp, '=')) { |
if ((cp = strchr(*epp, '='))) { |
*cp = '\0'; |
*cp = '\0'; |
ep = env_define((unsigned char *)*epp, |
ep = env_define((unsigned char *)*epp, |
(unsigned char *)cp+1); |
(unsigned char *)cp+1); |
|
|
|
|
gethostname(hbuf, 256); |
gethostname(hbuf, 256); |
hbuf[256] = '\0'; |
hbuf[256] = '\0'; |
cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1); |
|
sprintf((char *)cp, "%s%s", hbuf, cp2); |
/* If this is not the full name, try to get it via DNS */ |
|
if (strchr(hbuf, '.') == 0) { |
|
struct hostent *he = gethostbyname(hbuf); |
|
if (he != 0) |
|
strncpy(hbuf, he->h_name, 256); |
|
hbuf[256] = '\0'; |
|
} |
|
|
|
asprintf (&cp, "%s%s", hbuf, cp2); |
|
|
free(ep->value); |
free(ep->value); |
ep->value = (unsigned char *)cp; |
ep->value = (unsigned char *)cp; |
} |
} |
|
|
} |
} |
env_export((unsigned char *)"DISPLAY"); |
env_export((unsigned char *)"DISPLAY"); |
env_export((unsigned char *)"PRINTER"); |
env_export((unsigned char *)"PRINTER"); |
|
env_export((unsigned char *)"XAUTHORITY"); |
} |
} |
|
|
struct env_lst * |
struct env_lst * |
|
|
{ |
{ |
register struct env_lst *ep; |
register struct env_lst *ep; |
|
|
if (ep = env_find(var)) { |
if ((ep = env_find(var))) { |
if (ep->var) |
if (ep->var) |
free(ep->var); |
free(ep->var); |
if (ep->value) |
if (ep->value) |
|
|
if (ep->next) |
if (ep->next) |
ep->next->prev = ep; |
ep->next->prev = ep; |
} |
} |
ep->welldefined = opt_welldefined(var); |
ep->welldefined = opt_welldefined((char *)var); |
ep->export = 1; |
ep->export = 1; |
ep->var = (unsigned char *)strdup((char *)var); |
ep->var = (unsigned char *)strdup((char *)var); |
ep->value = (unsigned char *)strdup((char *)value); |
ep->value = (unsigned char *)strdup((char *)value); |
|
|
{ |
{ |
register struct env_lst *ep; |
register struct env_lst *ep; |
|
|
if (ep = env_find(var)) { |
if ((ep = env_find(var))) { |
ep->prev->next = ep->next; |
ep->prev->next = ep->next; |
if (ep->next) |
if (ep->next) |
ep->next->prev = ep->prev; |
ep->next->prev = ep->prev; |
|
|
{ |
{ |
register struct env_lst *ep; |
register struct env_lst *ep; |
|
|
if (ep = env_find(var)) |
if ((ep = env_find(var))) |
ep->export = 1; |
ep->export = 1; |
} |
} |
|
|
|
|
#endif |
#endif |
) { |
) { |
fprintf(stderr, |
fprintf(stderr, |
"Cannot send '%s': Telnet ENVIRON option not enabled\n", |
"Cannot send '%s': Telnet ENVIRON option not enabled\r\n", |
var); |
var); |
return; |
return; |
} |
} |
ep = env_find(var); |
ep = env_find(var); |
if (ep == 0) { |
if (ep == 0) { |
fprintf(stderr, "Cannot send '%s': variable not defined\n", |
fprintf(stderr, "Cannot send '%s': variable not defined\r\n", |
var); |
var); |
return; |
return; |
} |
} |
|
|
register struct env_lst *ep; |
register struct env_lst *ep; |
|
|
for (ep = envlisthead.next; ep; ep = ep->next) { |
for (ep = envlisthead.next; ep; ep = ep->next) { |
printf("%c %-20s %s\n", ep->export ? '*' : ' ', |
printf("%c %-20s %s\r\n", ep->export ? '*' : ' ', |
ep->var, ep->value); |
ep->var, ep->value); |
} |
} |
} |
} |
|
|
|
|
if (init) { |
if (init) { |
nep = &envlisthead; |
nep = &envlisthead; |
return; |
return NULL; |
} |
} |
if (nep) { |
if (nep) { |
while (nep = nep->next) { |
while ((nep = nep->next)) { |
if (nep->export && (nep->welldefined == welldefined)) |
if (nep->export && (nep->welldefined == welldefined)) |
return(nep->var); |
return(nep->var); |
} |
} |
|
|
{ |
{ |
register struct env_lst *ep; |
register struct env_lst *ep; |
|
|
if (ep = env_find(var)) |
if ((ep = env_find(var))) |
return(ep->value); |
return(ep->value); |
return(NULL); |
return(NULL); |
} |
} |
|
|
if (strncasecmp((char *)what, "status", len) == 0) { |
if (strncasecmp((char *)what, "status", len) == 0) { |
if (env_auto) |
if (env_auto) |
printf("%s%s", "VAR and VALUE are/will be ", |
printf("%s%s", "VAR and VALUE are/will be ", |
"determined automatically\n"); |
"determined automatically\r\n"); |
if (old_env_var == OLD_ENV_VAR) |
if (old_env_var == OLD_ENV_VAR) |
printf("VAR and VALUE set to correct definitions\n"); |
printf("VAR and VALUE set to correct definitions\r\n"); |
else |
else |
printf("VAR and VALUE definitions are reversed\n"); |
printf("VAR and VALUE definitions are reversed\r\n"); |
} else if (strncasecmp((char *)what, "auto", len) == 0) { |
} else if (strncasecmp((char *)what, "auto", len) == 0) { |
env_auto = 1; |
env_auto = 1; |
old_env_var = OLD_ENV_VALUE; |
old_env_var = OLD_ENV_VALUE; |
|
|
old_env_value = OLD_ENV_VAR; |
old_env_value = OLD_ENV_VAR; |
} else { |
} else { |
unknown: |
unknown: |
printf("Unknown \"varval\" command. (\"auto\", \"right\", \"wrong\", \"status\")\n"); |
printf("Unknown \"varval\" command. (\"auto\", \"right\", \"wrong\", \"status\")\r\n"); |
} |
} |
} |
} |
#endif |
#endif |
|
|
int narg; |
int narg; |
}; |
}; |
|
|
extern int |
|
auth_enable P((char *)), |
|
auth_disable P((char *)), |
|
auth_status P((void)); |
|
static int |
static int |
auth_help P((void)); |
auth_help P((void)); |
|
|
|
|
for (c = AuthList; c->name; c++) { |
for (c = AuthList; c->name; c++) { |
if (c->help) { |
if (c->help) { |
if (*c->help) |
if (*c->help) |
printf("%-15s %s\n", c->name, c->help); |
printf("%-15s %s\r\n", c->name, c->help); |
else |
else |
printf("\n"); |
printf("\r\n"); |
} |
} |
} |
} |
return 0; |
return 0; |
|
|
|
|
if (argc < 2) { |
if (argc < 2) { |
fprintf(stderr, |
fprintf(stderr, |
"Need an argument to 'auth' command. 'auth ?' for help.\n"); |
"Need an argument to 'auth' command. 'auth ?' for help.\r\n"); |
return 0; |
return 0; |
} |
} |
|
|
c = (struct authlist *) |
c = (struct authlist *) |
genget(argv[1], (char **) AuthList, sizeof(struct authlist)); |
genget(argv[1], (char **) AuthList, sizeof(struct authlist)); |
if (c == 0) { |
if (c == 0) { |
fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n", |
fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} |
} |
if (Ambiguous(c)) { |
if (Ambiguous(c)) { |
fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n", |
fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\r\n", |
argv[1]); |
argv[1]); |
return 0; |
return 0; |
} |
} |
if (c->narg + 2 != argc) { |
if (c->narg + 2 != argc) { |
fprintf(stderr, |
fprintf(stderr, |
"Need %s%d argument%s to 'auth %s' command. 'auth ?' for help.\n", |
"Need %s%d argument%s to 'auth %s' command. 'auth ?' for help.\r\n", |
c->narg < argc + 2 ? "only " : "", |
c->narg < argc + 2 ? "only " : "", |
c->narg, c->narg == 1 ? "" : "s", c->name); |
c->narg, c->narg == 1 ? "" : "s", c->name); |
return 0; |
return 0; |
|
|
} |
} |
#endif |
#endif |
|
|
|
#if defined(ENCRYPTION) |
|
/* |
|
* The ENCRYPT command. |
|
*/ |
|
|
|
struct encryptlist { |
|
char *name; |
|
char *help; |
|
int (*handler)(); |
|
int needconnect; |
|
int minarg; |
|
int maxarg; |
|
}; |
|
|
|
static int |
|
EncryptHelp (void); |
|
|
|
struct encryptlist EncryptList[] = { |
|
{ "enable", "Enable encryption. ('encrypt enable ?' for more)", |
|
EncryptEnable, 1, 1, 2 }, |
|
{ "disable", "Disable encryption. ('encrypt enable ?' for more)", |
|
EncryptDisable, 0, 1, 2 }, |
|
{ "type", "Set encryptiong type. ('encrypt type ?' for more)", |
|
EncryptType, 0, 1, 1 }, |
|
{ "start", "Start encryption. ('encrypt start ?' for more)", |
|
EncryptStart, 1, 0, 1 }, |
|
{ "stop", "Stop encryption. ('encrypt stop ?' for more)", |
|
EncryptStop, 1, 0, 1 }, |
|
{ "input", "Start encrypting the input stream", |
|
EncryptStartInput, 1, 0, 0 }, |
|
{ "-input", "Stop encrypting the input stream", |
|
EncryptStopInput, 1, 0, 0 }, |
|
{ "output", "Start encrypting the output stream", |
|
EncryptStartOutput, 1, 0, 0 }, |
|
{ "-output", "Stop encrypting the output stream", |
|
EncryptStopOutput, 1, 0, 0 }, |
|
|
|
{ "status", "Display current status of authentication information", |
|
EncryptStatus, 0, 0, 0 }, |
|
{ "help", 0, EncryptHelp, 0, 0, 0 }, |
|
{ "?", "Print help information", EncryptHelp, 0, 0, 0 }, |
|
{ 0 }, |
|
}; |
|
|
|
static int |
|
EncryptHelp() |
|
{ |
|
struct encryptlist *c; |
|
|
|
for (c = EncryptList; c->name; c++) { |
|
if (c->help) { |
|
if (*c->help) |
|
printf("%-15s %s\r\n", c->name, c->help); |
|
else |
|
printf("\r\n"); |
|
} |
|
} |
|
return 0; |
|
} |
|
|
|
static int |
|
encrypt_cmd(int argc, char **argv) |
|
{ |
|
struct encryptlist *c; |
|
c = (struct encryptlist *) |
|
genget(argv[1], (char **) EncryptList, sizeof(struct encryptlist)); |
|
if (c == 0) { |
|
fprintf(stderr, "'%s': unknown argument ('encrypt ?' for help).\r\n", |
|
argv[1]); |
|
return 0; |
|
} |
|
if (Ambiguous(c)) { |
|
fprintf(stderr, "'%s': ambiguous argument ('encrypt ?' for help).\r\n", |
|
argv[1]); |
|
return 0; |
|
} |
|
argc -= 2; |
|
if (argc < c->minarg || argc > c->maxarg) { |
|
if (c->minarg == c->maxarg) { |
|
fprintf(stderr, "Need %s%d argument%s ", |
|
c->minarg < argc ? "only " : "", c->minarg, |
|
c->minarg == 1 ? "" : "s"); |
|
} else { |
|
fprintf(stderr, "Need %s%d-%d arguments ", |
|
c->maxarg < argc ? "only " : "", c->minarg, c->maxarg); |
|
} |
|
fprintf(stderr, "to 'encrypt %s' command. 'encrypt ?' for help.\r\n", |
|
c->name); |
|
return 0; |
|
} |
|
if (c->needconnect && !connected) { |
|
if (!(argc && (isprefix(argv[2], "help") || isprefix(argv[2], "?")))) { |
|
printf("?Need to be connected first.\r\n"); |
|
return 0; |
|
} |
|
} |
|
return ((*c->handler)(argc > 0 ? argv[2] : 0, |
|
argc > 1 ? argv[3] : 0, |
|
argc > 2 ? argv[4] : 0)); |
|
} |
|
#endif |
|
|
#if defined(unix) && defined(TN3270) |
#if defined(unix) && defined(TN3270) |
static void |
static void |
filestuff(fd) |
filestuff(fd) |
|
|
perror("fcntl"); |
perror("fcntl"); |
return; |
return; |
} |
} |
printf("\tOwner is %d.\n", res); |
printf("\tOwner is %d.\r\n", res); |
#endif |
#endif |
|
|
setconnmode(0); |
setconnmode(0); |
|
|
return; |
return; |
} |
} |
#ifdef notdef |
#ifdef notdef |
printf("\tFlags are 0x%x: %s\n", res, decodeflags(res)); |
printf("\tFlags are 0x%x: %s\r\n", res, decodeflags(res)); |
#endif |
#endif |
} |
} |
#endif /* defined(unix) && defined(TN3270) */ |
#endif /* defined(unix) && defined(TN3270) */ |
|
|
char *argv[]; |
char *argv[]; |
{ |
{ |
if (connected) { |
if (connected) { |
printf("Connected to %s.\n", hostname); |
printf("Connected to %s.\r\n", hostname); |
if ((argc < 2) || strcmp(argv[1], "notmuch")) { |
if ((argc < 2) || strcmp(argv[1], "notmuch")) { |
int mode = getconnmode(); |
int mode = getconnmode(); |
|
|
if (my_want_state_is_will(TELOPT_LINEMODE)) { |
if (my_want_state_is_will(TELOPT_LINEMODE)) { |
printf("Operating with LINEMODE option\n"); |
printf("Operating with LINEMODE option\r\n"); |
printf("%s line editing\n", (mode&MODE_EDIT) ? "Local" : "No"); |
printf("%s line editing\r\n", (mode&MODE_EDIT) ? "Local" : "No"); |
printf("%s catching of signals\n", |
printf("%s catching of signals\r\n", |
(mode&MODE_TRAPSIG) ? "Local" : "No"); |
(mode&MODE_TRAPSIG) ? "Local" : "No"); |
slcstate(); |
slcstate(); |
#ifdef KLUDGELINEMODE |
#ifdef KLUDGELINEMODE |
} else if (kludgelinemode && my_want_state_is_dont(TELOPT_SGA)) { |
} else if (kludgelinemode && my_want_state_is_dont(TELOPT_SGA)) { |
printf("Operating in obsolete linemode\n"); |
printf("Operating in obsolete linemode\r\n"); |
#endif |
#endif |
} else { |
} else { |
printf("Operating in single character mode\n"); |
printf("Operating in single character mode\r\n"); |
if (localchars) |
if (localchars) |
printf("Catching signals locally\n"); |
printf("Catching signals locally\r\n"); |
} |
} |
printf("%s character echo\n", (mode&MODE_ECHO) ? "Local" : "Remote"); |
printf("%s character echo\r\n", (mode&MODE_ECHO) ? "Local" : "Remote"); |
if (my_want_state_is_will(TELOPT_LFLOW)) |
if (my_want_state_is_will(TELOPT_LFLOW)) |
printf("%s flow control\n", (mode&MODE_FLOW) ? "Local" : "No"); |
printf("%s flow control\r\n", (mode&MODE_FLOW) ? "Local" : "No"); |
|
#if defined(ENCRYPTION) |
|
encrypt_display(); |
|
#endif |
} |
} |
} else { |
} else { |
printf("No connection.\n"); |
printf("No connection.\r\n"); |
} |
} |
# if !defined(TN3270) |
# if !defined(TN3270) |
printf("Escape character is '%s'.\n", control(escape)); |
printf("Escape character is '%s'.\r\n", control(escape)); |
(void) fflush(stdout); |
(void) fflush(stdout); |
# else /* !defined(TN3270) */ |
# else /* !defined(TN3270) */ |
if ((!In3270) && ((argc < 2) || strcmp(argv[1], "notmuch"))) { |
if ((!In3270) && ((argc < 2) || strcmp(argv[1], "notmuch"))) { |
printf("Escape character is '%s'.\n", control(escape)); |
printf("Escape character is '%s'.\r\n", control(escape)); |
} |
} |
# if defined(unix) |
# if defined(unix) |
if ((argc >= 2) && !strcmp(argv[1], "everything")) { |
if ((argc >= 2) && !strcmp(argv[1], "everything")) { |
printf("SIGIO received %d time%s.\n", |
printf("SIGIO received %d time%s.\r\n", |
sigiocount, (sigiocount == 1)? "":"s"); |
sigiocount, (sigiocount == 1)? "":"s"); |
if (In3270) { |
if (In3270) { |
printf("Process ID %d, process group %d.\n", |
printf("Process ID %d, process group %d.\r\n", |
getpid(), getpgrp(getpid())); |
getpid(), getpgrp(getpid())); |
printf("Terminal input:\n"); |
printf("Terminal input:\r\n"); |
filestuff(tin); |
filestuff(tin); |
printf("Terminal output:\n"); |
printf("Terminal output:\r\n"); |
filestuff(tout); |
filestuff(tout); |
printf("Network socket:\n"); |
printf("Network socket:\r\n"); |
filestuff(net); |
filestuff(net); |
} |
} |
} |
} |
if (In3270 && transcom) { |
if (In3270 && transcom) { |
printf("Transparent mode command is '%s'.\n", transcom); |
printf("Transparent mode command is '%s'.\r\n", transcom); |
} |
} |
# endif /* defined(unix) */ |
# endif /* defined(unix) */ |
(void) fflush(stdout); |
(void) fflush(stdout); |
|
|
return 0; |
return 0; |
} |
} |
# endif /* defined(TN3270) */ |
# endif /* defined(TN3270) */ |
|
fflush(stdout); |
return 1; |
return 1; |
} |
} |
|
|
|
|
/* |
/* |
* Function that gets called when SIGINFO is received. |
* Function that gets called when SIGINFO is received. |
*/ |
*/ |
|
void |
ayt_status() |
ayt_status() |
{ |
{ |
(void) call(status, "status", "notmuch", 0); |
(void) call(status, "status", "notmuch", 0); |
} |
} |
#endif |
#endif |
|
|
unsigned long inet_addr(); |
static Command *getcmd(char *name); |
|
|
|
static void |
|
cmdrc(char *m1, char *m2) |
|
{ |
|
static char rcname[128]; |
|
Command *c; |
|
FILE *rcfile; |
|
int gotmachine = 0; |
|
int l1 = strlen(m1); |
|
int l2 = strlen(m2); |
|
char m1save[64]; |
|
|
|
if (skiprc) |
|
return; |
|
|
|
strcpy(m1save, m1); |
|
m1 = m1save; |
|
|
|
if (rcname[0] == 0) { |
|
char *home = getenv("HOME"); |
|
|
|
snprintf (rcname, sizeof(rcname), "%s/.telnetrc", |
|
home ? home : ""); |
|
} |
|
|
|
if ((rcfile = fopen(rcname, "r")) == 0) { |
|
return; |
|
} |
|
|
|
for (;;) { |
|
if (fgets(line, sizeof(line), rcfile) == NULL) |
|
break; |
|
if (line[0] == 0) |
|
break; |
|
if (line[0] == '#') |
|
continue; |
|
if (gotmachine) { |
|
if (!isspace(line[0])) |
|
gotmachine = 0; |
|
} |
|
if (gotmachine == 0) { |
|
if (isspace(line[0])) |
|
continue; |
|
if (strncasecmp(line, m1, l1) == 0) |
|
strncpy(line, &line[l1], sizeof(line) - l1); |
|
else if (strncasecmp(line, m2, l2) == 0) |
|
strncpy(line, &line[l2], sizeof(line) - l2); |
|
else if (strncasecmp(line, "DEFAULT", 7) == 0) |
|
strncpy(line, &line[7], sizeof(line) - 7); |
|
else |
|
continue; |
|
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n') |
|
continue; |
|
gotmachine = 1; |
|
} |
|
makeargv(); |
|
if (margv[0] == 0) |
|
continue; |
|
c = getcmd(margv[0]); |
|
if (Ambiguous(c)) { |
|
printf("?Ambiguous command: %s\r\n", margv[0]); |
|
continue; |
|
} |
|
if (c == 0) { |
|
printf("?Invalid command: %s\r\n", margv[0]); |
|
continue; |
|
} |
|
/* |
|
* This should never happen... |
|
*/ |
|
if (c->needconnect && !connected) { |
|
printf("?Need to be connected first for %s.\r\n", margv[0]); |
|
continue; |
|
} |
|
(*c->handler)(margc, margv); |
|
} |
|
fclose(rcfile); |
|
} |
|
|
|
|
int |
int |
tn(argc, argv) |
tn(argc, argv) |
int argc; |
int argc; |
char *argv[]; |
char *argv[]; |
{ |
{ |
register struct hostent *host = 0, *alias = 0; |
register struct hostent *host = 0, *alias = 0; |
|
#if defined(AF_INET6) |
|
struct sockaddr_in6 sin6; |
|
#endif |
struct sockaddr_in sin; |
struct sockaddr_in sin; |
struct sockaddr_in ladr; |
struct sockaddr_in ladr; |
|
struct sockaddr *sa; |
|
int sa_size; |
struct servent *sp = 0; |
struct servent *sp = 0; |
unsigned long temp; |
unsigned long temp; |
extern char *inet_ntoa(); |
extern char *inet_ntoa(); |
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) |
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) |
char *srp = 0, *strrchr(); |
char *srp = 0; |
unsigned long sourceroute(), srlen; |
int srlen; |
#endif |
#endif |
char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0; |
char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0; |
|
int family, port; |
|
|
/* clear the socket address prior to use */ |
/* clear the socket address prior to use */ |
memset((char *)&sin, 0, sizeof(sin)); |
memset((char *)&sin, 0, sizeof(sin)); |
|
|
if (connected) { |
if (connected) { |
printf("?Already connected to %s\n", hostname); |
printf("?Already connected to %s\r\n", hostname); |
seteuid(getuid()); |
seteuid(getuid()); |
setuid(getuid()); |
setuid(getuid()); |
return 0; |
return 0; |
|
|
--argc; ++argv; |
--argc; ++argv; |
if (argc == 0) |
if (argc == 0) |
goto usage; |
goto usage; |
user = *argv++; |
user = strdup(*argv++); |
--argc; |
--argc; |
continue; |
continue; |
} |
} |
|
|
continue; |
continue; |
} |
} |
usage: |
usage: |
printf("usage: %s [-l user] [-a] host-name [port]\n", cmd); |
printf("usage: %s [-l user] [-a] host-name [port]\r\n", cmd); |
seteuid(getuid()); |
seteuid(getuid()); |
setuid(getuid()); |
setuid(getuid()); |
return 0; |
return 0; |
|
|
setuid(getuid()); |
setuid(getuid()); |
return 0; |
return 0; |
} else if (temp == -1) { |
} else if (temp == -1) { |
printf("Bad source route option: %s\n", hostp); |
printf("Bad source route option: %s\r\n", hostp); |
seteuid(getuid()); |
seteuid(getuid()); |
setuid(getuid()); |
setuid(getuid()); |
return 0; |
return 0; |
} else { |
} else { |
sin.sin_addr.s_addr = temp; |
abort(); |
sin.sin_family = AF_INET; |
|
} |
} |
} else { |
} else { |
#endif |
#endif |
temp = inet_addr(hostp); |
memset (&sin, 0, sizeof(sin)); |
if (temp != INADDR_NONE) { |
#if defined(HAVE_INET_PTON) && defined(AF_INET6) |
sin.sin_addr.s_addr = temp; |
memset (&sin6, 0, sizeof(sin6)); |
sin.sin_family = AF_INET; |
|
host = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET); |
if(inet_pton(AF_INET6, hostp, &sin6.sin6_addr)) { |
if (host) |
sin6.sin6_family = family = AF_INET6; |
(void) strcpy(_hostname, host->h_name); |
strcpy(_hostname, hostp); |
else |
hostname =_hostname; |
(void) strcpy(_hostname, hostp); |
} else |
hostname = _hostname; |
#endif |
} else { |
if(inet_aton(hostp, &sin.sin_addr)){ |
host = gethostbyname(hostp); |
sin.sin_family = family = AF_INET; |
if (host) { |
strcpy(_hostname, hostp); |
sin.sin_family = host->h_addrtype; |
|
#if defined(h_addr) /* In 4.3, this is a #define */ |
|
memmove((caddr_t)&sin.sin_addr, |
|
host->h_addr_list[0], host->h_length); |
|
#else /* defined(h_addr) */ |
|
memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); |
|
#endif /* defined(h_addr) */ |
|
strncpy(_hostname, host->h_name, sizeof(_hostname)); |
|
_hostname[sizeof(_hostname)-1] = '\0'; |
|
hostname = _hostname; |
hostname = _hostname; |
} else { |
} else { |
herror(hostp); |
#ifdef HAVE_GETHOSTBYNAME2 |
seteuid(getuid()); |
host = gethostbyname2(hostp, AF_INET6); |
setuid(getuid()); |
if(host == NULL) |
return 0; |
host = gethostbyname2(hostp, AF_INET); |
|
#else |
|
host = gethostbyname(hostp); |
|
#endif |
|
if (host) { |
|
strncpy(_hostname, host->h_name, sizeof(_hostname)); |
|
family = host->h_addrtype; |
|
|
|
switch(family) { |
|
case AF_INET: |
|
memset(&sin, 0, sizeof(sin)); |
|
sa_size = sizeof(sin); |
|
sa = (struct sockaddr *)&sin; |
|
sin.sin_family = family; |
|
sin.sin_addr = *((struct in_addr *)(*host->h_addr_list)); |
|
break; |
|
#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6) |
|
case AF_INET6: |
|
memset(&sin6, 0, sizeof(sin6)); |
|
sa_size = sizeof(sin6); |
|
sa = (struct sockaddr *)&sin6; |
|
sin6.sin6_family = family; |
|
sin6.sin6_addr = *((struct in6_addr *)(*host->h_addr_list)); |
|
break; |
|
#endif |
|
default: |
|
fprintf(stderr, "Bad address family: %d\n", family); |
|
return 0; |
|
} |
|
|
|
_hostname[sizeof(_hostname)-1] = '\0'; |
|
hostname = _hostname; |
|
} else { |
|
herror(hostp); |
|
seteuid(getuid()); |
|
setuid(getuid()); |
|
fprintf (stderr, "%s: %s\r\n", hostp ? hostp : "", |
|
"unknown error"); |
|
return 0; |
|
} |
} |
} |
} |
|
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) |
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) |
} |
} |
#endif |
#endif |
|
|
telnetport = 1; |
telnetport = 1; |
} else |
} else |
telnetport = 0; |
telnetport = 0; |
sin.sin_port = atoi(portp); |
port = atoi(portp); |
if (sin.sin_port == 0) { |
if (port == 0) { |
sp = getservbyname(portp, "tcp"); |
sp = getservbyname(portp, "tcp"); |
if (sp) |
if (sp) |
sin.sin_port = sp->s_port; |
port = sp->s_port; |
else { |
else { |
printf("%s: bad port number\n", portp); |
printf("%s: bad port number\r\n", portp); |
seteuid(getuid()); |
seteuid(getuid()); |
setuid(getuid()); |
setuid(getuid()); |
return 0; |
return 0; |
} |
} |
} else { |
} else { |
#if !defined(htons) |
port = htons(port); |
u_short htons P((unsigned short)); |
|
#endif /* !defined(htons) */ |
|
sin.sin_port = htons(sin.sin_port); |
|
} |
} |
} else { |
} else { |
if (sp == 0) { |
if (sp == 0) { |
sp = getservbyname("telnet", "tcp"); |
sp = getservbyname("telnet", "tcp"); |
if (sp == 0) { |
if (sp == 0) { |
fprintf(stderr, "telnet: tcp/telnet: unknown service\n"); |
fprintf(stderr, "telnet: tcp/telnet: unknown service\r\n"); |
seteuid(getuid()); |
seteuid(getuid()); |
setuid(getuid()); |
setuid(getuid()); |
return 0; |
return 0; |
} |
} |
sin.sin_port = sp->s_port; |
port = sp->s_port; |
} |
} |
telnetport = 1; |
telnetport = 1; |
} |
} |
printf("Trying %s...\n", inet_ntoa(sin.sin_addr)); |
switch(family) { |
|
case AF_INET: |
|
sin.sin_port = port; |
|
printf("Trying %s...\r\n", inet_ntoa(sin.sin_addr)); |
|
break; |
|
#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6) |
|
case AF_INET6: { |
|
#ifndef INET6_ADDRSTRLEN |
|
#define INET6_ADDRSTRLEN 46 |
|
#endif |
|
|
|
char buf[INET6_ADDRSTRLEN]; |
|
|
|
sin6.sin6_port = port; |
|
#ifdef HAVE_INET_NTOP |
|
printf("Trying %s...\r\n", inet_ntop(AF_INET6, |
|
&sin6.sin6_addr, |
|
buf, |
|
sizeof(buf))); |
|
#endif |
|
break; |
|
} |
|
#endif |
|
default: |
|
abort(); |
|
} |
|
|
do { |
do { |
net = socket(AF_INET, SOCK_STREAM, 0); |
net = socket(family, SOCK_STREAM, 0); |
seteuid(getuid()); |
seteuid(getuid()); |
setuid(getuid()); |
setuid(getuid()); |
if (net < 0) { |
if (net < 0) { |
|
|
tos = IPTOS_LOWDELAY; /* Low Delay bit */ |
tos = IPTOS_LOWDELAY; /* Low Delay bit */ |
if (tos |
if (tos |
&& (setsockopt(net, IPPROTO_IP, IP_TOS, |
&& (setsockopt(net, IPPROTO_IP, IP_TOS, |
(char *)&tos, sizeof(int)) < 0) |
(void *)&tos, sizeof(int)) < 0) |
&& (errno != ENOPROTOOPT)) |
&& (errno != ENOPROTOOPT)) |
perror("telnet: setsockopt (IP_TOS) (ignored)"); |
perror("telnet: setsockopt (IP_TOS) (ignored)"); |
} |
} |
|
|
perror("setsockopt (SO_DEBUG)"); |
perror("setsockopt (SO_DEBUG)"); |
} |
} |
|
|
if (connect(net, (struct sockaddr *)&sin, sizeof (sin)) < 0) { |
if (connect(net, sa, sa_size) < 0) { |
#if defined(h_addr) /* In 4.3, this is a #define */ |
|
if (host && host->h_addr_list[1]) { |
if (host && host->h_addr_list[1]) { |
int oerrno = errno; |
int oerrno = errno; |
|
|
fprintf(stderr, "telnet: connect to address %s: ", |
switch(family) { |
inet_ntoa(sin.sin_addr)); |
case AF_INET : |
|
fprintf(stderr, "telnet: connect to address %s: ", |
|
inet_ntoa(sin.sin_addr)); |
|
sin.sin_addr = *((struct in_addr *)(*++host->h_addr_list)); |
|
break; |
|
#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6) |
|
case AF_INET6: { |
|
char buf[INET6_ADDRSTRLEN]; |
|
|
|
fprintf(stderr, "telnet: connect to address %s: ", |
|
inet_ntop(AF_INET6, &sin6.sin6_addr, buf, |
|
sizeof(buf))); |
|
sin6.sin6_addr = *((struct in6_addr *)(*++host->h_addr_list)); |
|
break; |
|
} |
|
#endif |
|
default: |
|
abort(); |
|
} |
|
|
errno = oerrno; |
errno = oerrno; |
perror((char *)0); |
perror(NULL); |
host->h_addr_list++; |
host->h_addr_list++; |
memmove((caddr_t)&sin.sin_addr, |
memmove((caddr_t)&sin.sin_addr, |
host->h_addr_list[0], host->h_length); |
host->h_addr_list[0], host->h_length); |
(void) NetClose(net); |
(void) NetClose(net); |
continue; |
continue; |
} |
} |
#endif /* defined(h_addr) */ |
|
perror("telnet: Unable to connect to remote host"); |
perror("telnet: Unable to connect to remote host"); |
return 0; |
return 0; |
} |
} |
connected++; |
connected++; |
#if defined(AUTHENTICATION) |
#if defined(AUTHENTICATION) || defined(ENCRYPTION) |
auth_encrypt_connect(connected); |
auth_encrypt_connect(connected); |
#endif /* defined(AUTHENTICATION) */ |
#endif /* defined(AUTHENTICATION) */ |
} while (connected == 0); |
} while (connected == 0); |
|
|
if (setjmp(peerdied) == 0) |
if (setjmp(peerdied) == 0) |
telnet(user); |
telnet(user); |
(void) NetClose(net); |
(void) NetClose(net); |
ExitString("Connection closed by foreign host.\n",1); |
ExitString("Connection closed by foreign host.\r\n",1); |
/*NOTREACHED*/ |
/*NOTREACHED*/ |
|
return 0; |
} |
} |
|
|
#define HELPINDENT (sizeof ("connect")) |
#define HELPINDENT (sizeof ("connect")) |
|
|
#if defined(AUTHENTICATION) |
#if defined(AUTHENTICATION) |
authhelp[] = "turn on (off) authentication ('auth ?' for more)", |
authhelp[] = "turn on (off) authentication ('auth ?' for more)", |
#endif |
#endif |
#if defined(unix) |
#if defined(ENCRYPTION) |
|
encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)", |
|
#endif |
zhelp[] = "suspend telnet", |
zhelp[] = "suspend telnet", |
#endif /* defined(unix) */ |
|
shellhelp[] = "invoke a subshell", |
shellhelp[] = "invoke a subshell", |
envhelp[] = "change environment variables ('environ ?' for more)", |
envhelp[] = "change environment variables ('environ ?' for more)", |
modestring[] = "try to enter line or character mode ('mode ?' for more)"; |
modestring[] = "try to enter line or character mode ('mode ?' for more)"; |
|
|
static int help(); |
static int help __P((int, char**)); |
|
|
static Command cmdtab[] = { |
static Command cmdtab[] = { |
{ "close", closehelp, bye, 1 }, |
{ "close", closehelp, bye, 1 }, |
|
|
#if defined(AUTHENTICATION) |
#if defined(AUTHENTICATION) |
{ "auth", authhelp, auth_cmd, 0 }, |
{ "auth", authhelp, auth_cmd, 0 }, |
#endif |
#endif |
#if defined(unix) |
#if defined(ENCRYPTION) |
{ "z", zhelp, suspend, 0 }, |
{ "encrypt", encrypthelp, encrypt_cmd, 0 }, |
#endif /* defined(unix) */ |
#endif |
|
|
|
{ "z", zhelp, telnetsuspend, 0 }, |
#if defined(TN3270) |
#if defined(TN3270) |
{ "!", shellhelp, shell, 1 }, |
{ "!", shellhelp, shell, 1 }, |
#else |
#else |
|
|
#if defined(SKEY) |
#if defined(SKEY) |
{ "skey", NULL, skey_calc, 0 }, |
{ "skey", NULL, skey_calc, 0 }, |
#endif |
#endif |
0 |
{ 0, 0, 0, 0 } |
}; |
}; |
|
|
static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead"; |
static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead"; |
|
|
{ "help", 0, help, 0 }, |
{ "help", 0, help, 0 }, |
{ "escape", escapehelp, setescape, 0 }, |
{ "escape", escapehelp, setescape, 0 }, |
{ "crmod", crmodhelp, togcrmod, 0 }, |
{ "crmod", crmodhelp, togcrmod, 0 }, |
0 |
{ 0, 0, 0, 0 } |
}; |
}; |
|
|
|
|
|
|
*/ |
*/ |
|
|
/*VARARGS1*/ |
/*VARARGS1*/ |
static |
static int |
call(va_alist) |
call(intrtn_t routine, ...) |
va_dcl |
|
{ |
{ |
va_list ap; |
va_list ap; |
typedef int (*intrtn_t)(); |
|
intrtn_t routine; |
|
char *args[100]; |
char *args[100]; |
int argno = 0; |
int argno = 0; |
|
|
va_start(ap); |
va_start(ap, routine); |
routine = (va_arg(ap, intrtn_t)); |
while ((args[argno++] = va_arg(ap, char *)) != 0); |
while ((args[argno++] = va_arg(ap, char *)) != 0) { |
|
; |
|
} |
|
va_end(ap); |
va_end(ap); |
return (*routine)(argno-1, args); |
return (*routine)(argno-1, args); |
} |
} |
|
|
{ |
{ |
Command *cm; |
Command *cm; |
|
|
if (cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command))) |
if ((cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command)))) |
return cm; |
return cm; |
return (Command *) genget(name, (char **) cmdtab2, sizeof(Command)); |
return (Command *) genget(name, (char **) cmdtab2, sizeof(Command)); |
} |
} |
|
|
goto getline; |
goto getline; |
*cp = '\0'; |
*cp = '\0'; |
if (rlogin == _POSIX_VDISABLE) |
if (rlogin == _POSIX_VDISABLE) |
printf("%s\n", line); |
printf("%s\r\n", line); |
} else { |
} else { |
getline: |
getline: |
if (rlogin != _POSIX_VDISABLE) |
if (rlogin != _POSIX_VDISABLE) |
|
|
} |
} |
c = getcmd(margv[0]); |
c = getcmd(margv[0]); |
if (Ambiguous(c)) { |
if (Ambiguous(c)) { |
printf("?Ambiguous command\n"); |
printf("?Ambiguous command\r\n"); |
continue; |
continue; |
} |
} |
if (c == 0) { |
if (c == 0) { |
printf("?Invalid command\n"); |
printf("?Invalid command\r\n"); |
continue; |
continue; |
} |
} |
if (c->needconnect && !connected) { |
if (c->needconnect && !connected) { |
printf("?Need to be connected first.\n"); |
printf("?Need to be connected first.\r\n"); |
continue; |
continue; |
} |
} |
if ((*c->handler)(margc, margv)) { |
if ((*c->handler)(margc, margv)) { |
|
|
register Command *c; |
register Command *c; |
|
|
if (argc == 1) { |
if (argc == 1) { |
printf("Commands may be abbreviated. Commands are:\n\n"); |
printf("Commands may be abbreviated. Commands are:\r\n\r\n"); |
for (c = cmdtab; c->name; c++) |
for (c = cmdtab; c->name; c++) |
if (c->help) { |
if (c->help) { |
printf("%-*s\t%s\n", HELPINDENT, c->name, |
printf("%-*s\t%s\r\n", HELPINDENT, c->name, |
c->help); |
c->help); |
} |
} |
return 0; |
return 0; |
|
|
arg = *++argv; |
arg = *++argv; |
c = getcmd(arg); |
c = getcmd(arg); |
if (Ambiguous(c)) |
if (Ambiguous(c)) |
printf("?Ambiguous help command %s\n", arg); |
printf("?Ambiguous help command %s\r\n", arg); |
else if (c == (Command *)0) |
else if (c == (Command *)0) |
printf("?Invalid help command %s\n", arg); |
printf("?Invalid help command %s\r\n", arg); |
else |
else |
printf("%s\n", c->help); |
printf("%s\r\n", c->help); |
} |
} |
return 0; |
return 0; |
} |
} |
|
|
static char *rcname = 0; |
static char *rcname = 0; |
static char rcbuf[128]; |
static char rcbuf[128]; |
|
|
cmdrc(m1, m2) |
|
char *m1, *m2; |
|
{ |
|
register Command *c; |
|
FILE *rcfile; |
|
int gotmachine = 0; |
|
int l1 = strlen(m1); |
|
int l2 = strlen(m2); |
|
char m1save[64]; |
|
|
|
if (skiprc) |
|
return; |
|
|
|
strcpy(m1save, m1); |
|
m1 = m1save; |
|
|
|
if (rcname == 0) { |
|
rcname = getenv("HOME"); |
|
if (rcname && (strlen(rcname) + 10) < sizeof(rcbuf)) |
|
strcpy(rcbuf, rcname); |
|
else |
|
rcbuf[0] = '\0'; |
|
strcat(rcbuf, "/.telnetrc"); |
|
rcname = rcbuf; |
|
} |
|
|
|
if ((rcfile = fopen(rcname, "r")) == 0) { |
|
return; |
|
} |
|
|
|
for (;;) { |
|
if (fgets(line, sizeof(line), rcfile) == NULL) |
|
break; |
|
if (line[0] == 0) |
|
break; |
|
if (line[0] == '#') |
|
continue; |
|
if (gotmachine) { |
|
if (!isspace(line[0])) |
|
gotmachine = 0; |
|
} |
|
if (gotmachine == 0) { |
|
if (isspace(line[0])) |
|
continue; |
|
if (strncasecmp(line, m1, l1) == 0) |
|
strncpy(line, &line[l1], sizeof(line) - l1); |
|
else if (strncasecmp(line, m2, l2) == 0) |
|
strncpy(line, &line[l2], sizeof(line) - l2); |
|
else if (strncasecmp(line, "DEFAULT", 7) == 0) |
|
strncpy(line, &line[7], sizeof(line) - 7); |
|
else |
|
continue; |
|
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n') |
|
continue; |
|
gotmachine = 1; |
|
} |
|
makeargv(); |
|
if (margv[0] == 0) |
|
continue; |
|
c = getcmd(margv[0]); |
|
if (Ambiguous(c)) { |
|
printf("?Ambiguous command: %s\n", margv[0]); |
|
continue; |
|
} |
|
if (c == 0) { |
|
printf("?Invalid command: %s\n", margv[0]); |
|
continue; |
|
} |
|
/* |
|
* This should never happen... |
|
*/ |
|
if (c->needconnect && !connected) { |
|
printf("?Need to be connected first for %s.\n", margv[0]); |
|
continue; |
|
} |
|
(*c->handler)(margc, margv); |
|
} |
|
fclose(rcfile); |
|
} |
|
|
|
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) |
#if defined(IP_OPTIONS) && defined(IPPROTO_IP) |
|
|
/* |
/* |
|
|
for (c = 0;;) { |
for (c = 0;;) { |
if (c == ':') |
if (c == ':') |
cp2 = 0; |
cp2 = 0; |
else for (cp2 = cp; c = *cp2; cp2++) { |
else for (cp2 = cp; (c = *cp2); cp2++) { |
if (c == ',') { |
if (c == ',') { |
*cp2++ = '\0'; |
*cp2++ = '\0'; |
if (*cp2 == '@') |
if (*cp2 == '@') |
|
|
if (!c) |
if (!c) |
cp2 = 0; |
cp2 = 0; |
|
|
if ((tmp = inet_addr(cp)) != INADDR_NONE) { |
if ((tmp = inet_addr(cp)) != -1) { |
sin_addr.s_addr = tmp; |
sin_addr.s_addr = tmp; |
} else if (host = gethostbyname(cp)) { |
} else if ((host = gethostbyname(cp))) { |
#if defined(h_addr) |
#if defined(h_addr) |
memmove((caddr_t)&sin_addr, |
memmove((caddr_t)&sin_addr, |
host->h_addr_list[0], host->h_length); |
host->h_addr_list[0], |
|
sizeof(sin_addr)); |
#else |
#else |
memmove((caddr_t)&sin_addr, host->h_addr, host->h_length); |
memmove((caddr_t)&sin_addr, host->h_addr, |
|
sizeof(sin_addr)); |
#endif |
#endif |
} else { |
} else { |
*cpp = cp; |
*cpp = cp; |