summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/telnet/commands.c158
-rw-r--r--usr.bin/telnet/externs.h10
-rw-r--r--usr.bin/telnet/sys_bsd.c12
-rw-r--r--usr.bin/telnet/terminal.c6
-rw-r--r--usr.bin/telnet/utilities.c4
5 files changed, 87 insertions, 103 deletions
diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c
index 4723509c84b..caf8a775767 100644
--- a/usr.bin/telnet/commands.c
+++ b/usr.bin/telnet/commands.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commands.c,v 1.67 2014/07/20 10:55:26 guenther Exp $ */
+/* $OpenBSD: commands.c,v 1.68 2014/07/20 12:08:55 guenther Exp $ */
/* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */
/*
@@ -48,14 +48,17 @@
#include <string.h>
#include <unistd.h>
+#ifdef SKEY
+#include <sys/wait.h>
+#define PATH_SKEY "/usr/bin/skey"
+#endif
+
+static unsigned long sourceroute(char *arg, char **cpp, int *lenp);
+
int tos = -1;
char *hostname;
-typedef int (*intrtn_t)(int, char**);
-static int call(intrtn_t, ...);
-static unsigned long sourceroute(char *arg, char **cpp, int *lenp);
-
typedef struct {
char *name; /* command name */
char *help; /* help string (NULL for no help) */
@@ -68,9 +71,7 @@ static char saveline[256];
static int margc;
static char *margv[20];
-#if defined(SKEY)
-#include <sys/wait.h>
-#define PATH_SKEY "/usr/bin/skey"
+#ifdef SKEY
int
skey_calc(argc, argv)
int argc;
@@ -994,8 +995,6 @@ unsetcmd(argc, argv)
* 'mode' command.
*/
#ifdef KLUDGELINEMODE
-extern int kludgelinemode;
-
static int
dokludgemode()
{
@@ -1037,7 +1036,6 @@ dolmmode(bit, on)
int bit, on;
{
unsigned char c;
- extern int linemode;
if (my_want_state_is_wont(TELOPT_LINEMODE)) {
printf("?Need to have LINEMODE option enabled first.\r\n");
@@ -1332,31 +1330,33 @@ shell(argc, argv)
return 1;
}
- static int
+static void
+close_connection(void)
+{
+ if (connected) {
+ (void) shutdown(net, 2);
+ printf("Connection closed.\r\n");
+ (void)close(net);
+ connected = 0;
+ resettermname = 1;
+ /* reset options */
+ tninit();
+ }
+}
+
+static int
bye(argc, argv)
int argc; /* Number of arguments */
char *argv[]; /* arguments */
{
- extern int resettermname;
-
- if (connected) {
- (void) shutdown(net, 2);
- printf("Connection closed.\r\n");
- (void)close(net);
- connected = 0;
- resettermname = 1;
- /* reset options */
- tninit();
- }
- if ((argc != 2) || (strcmp(argv[1], "fromquit") != 0))
+ close_connection();
longjmp(toplevel, 1);
- return 0;
}
void
quit(void)
{
- (void) call(bye, "bye", "fromquit", 0);
+ close_connection();
Exit(0);
}
@@ -1758,45 +1758,54 @@ env_getvalue(var, exported_only)
return(NULL);
}
-/*
- * Print status about the connection.
- */
- static int
-status(argc, argv)
- int argc;
- char *argv[];
+static void
+connection_status(int local_only)
{
- if (connected) {
- printf("Connected to %s.\r\n", hostname);
- if ((argc < 2) || strcmp(argv[1], "notmuch")) {
- int mode = getconnmode();
-
- if (my_want_state_is_will(TELOPT_LINEMODE)) {
- printf("Operating with LINEMODE option\r\n");
- printf("%s line editing\r\n", (mode&MODE_EDIT) ? "Local" : "No");
- printf("%s catching of signals\r\n",
- (mode&MODE_TRAPSIG) ? "Local" : "No");
- slcstate();
+ if (!connected)
+ printf("No connection.\r\n");
+ else {
+ printf("Connected to %s.\r\n", hostname);
+ if (!local_only) {
+ int mode = getconnmode();
+
+ printf("Operating ");
+ if (my_want_state_is_will(TELOPT_LINEMODE)) {
+ printf("with LINEMODE option\r\n"
+ "%s line editing\r\n"
+ "%s catching of signals\r\n",
+ (mode & MODE_EDIT) ? "Local" : "No",
+ (mode & MODE_TRAPSIG) ? "Local" : "No");
+ slcstate();
#ifdef KLUDGELINEMODE
- } else if (kludgelinemode && my_want_state_is_dont(TELOPT_SGA)) {
- printf("Operating in obsolete linemode\r\n");
+ } else if (kludgelinemode &&
+ my_want_state_is_dont(TELOPT_SGA)) {
+ printf("in obsolete linemode\r\n");
#endif
- } else {
- printf("Operating in single character mode\r\n");
- if (localchars)
- printf("Catching signals locally\r\n");
- }
- printf("%s character echo\r\n", (mode&MODE_ECHO) ? "Local" : "Remote");
- if (my_want_state_is_will(TELOPT_LFLOW))
- printf("%s flow control\r\n", (mode&MODE_FLOW) ? "Local" : "No");
+ } else {
+ printf("in single character mode\r\n");
+ if (localchars)
+ printf("Catching signals locally\r\n");
+ }
+
+ printf("%s character echo\r\n",
+ (mode & MODE_ECHO) ? "Local" : "Remote");
+ if (my_want_state_is_will(TELOPT_LFLOW))
+ printf("%s flow control\r\n",
+ (mode & MODE_FLOW) ? "Local" : "No");
+ }
}
- } else {
- printf("No connection.\r\n");
- }
- printf("Escape character is '%s'.\r\n", control(escape));
- (void) fflush(stdout);
- fflush(stdout);
- return 1;
+ printf("Escape character is '%s'.\r\n", control(escape));
+ (void) fflush(stdout);
+}
+
+/*
+ * Print status about the connection.
+ */
+static int
+status(int argc, char *argv[])
+{
+ connection_status(0);
+ return 1;
}
#ifdef SIGINFO
@@ -1804,9 +1813,9 @@ status(argc, argv)
* Function that gets called when SIGINFO is received.
*/
void
-ayt_status()
+ayt_status(int sig)
{
- (void) call(status, "status", "notmuch", 0);
+ connection_status(1);
}
#endif
@@ -2113,7 +2122,7 @@ tn(argc, argv)
env_define((unsigned char *)"USER", (unsigned char *)user);
env_export((unsigned char *)"USER");
}
- (void) call(status, "status", "notmuch", 0);
+ connection_status(1);
if (setjmp(peerdied) == 0)
telnet(user);
(void)close(net);
@@ -2163,7 +2172,7 @@ static Command cmdtab[] = {
{ "!", shellhelp, shell, 0 },
{ "environ", envhelp, env_cmd, 0 },
{ "?", helphelp, help, 0 },
-#if defined(SKEY)
+#ifdef SKEY
{ "skey", skeyhelp, skey_calc, 0 },
#endif
{ 0, 0, 0, 0 }
@@ -2180,25 +2189,6 @@ static Command cmdtab2[] = {
};
-/*
- * Call routine with argc, argv set from args (terminated by 0).
- */
-
- /*VARARGS1*/
- static int
-call(intrtn_t routine, ...)
-{
- va_list ap;
- char *args[100];
- int argno = 0;
-
- va_start(ap, routine);
- while ((args[argno++] = va_arg(ap, char *)) != 0);
- va_end(ap);
- return (*routine)(argno-1, args);
-}
-
-
static Command *
getcmd(name)
char *name;
diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h
index 1d25f09b379..9d51a2497b2 100644
--- a/usr.bin/telnet/externs.h
+++ b/usr.bin/telnet/externs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: externs.h,v 1.26 2014/07/20 10:55:26 guenther Exp $ */
+/* $OpenBSD: externs.h,v 1.27 2014/07/20 12:08:55 guenther Exp $ */
/* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
/*
@@ -62,6 +62,10 @@ extern int
netdata, /* Print out network data flow */
prettydump, /* Print "netdata" output in user readable format */
termdata, /* Print out terminal data flow */
+ resettermname,
+ linemode,
+ kludgelinemode,
+ want_status_response,
debug; /* Debug level */
extern cc_t escape; /* Escape to command mode */
@@ -78,6 +82,8 @@ extern char
dont[],
will[],
wont[],
+ will_wont_resp[],
+ do_dont_resp[],
options[], /* All the little options */
*hostname; /* Who are we connected to? */
@@ -165,7 +171,7 @@ unsigned char * env_getvalue(unsigned char *var, int exported_only);
void set_escape_char(char *s);
#ifdef SIGINFO
-void ayt_status(void);
+void ayt_status(int sig);
#endif
int tn(int argc, char **argv);
void command(int top, char *tbuf, int cnt);
diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c
index 5587df0ceea..585f8438dba 100644
--- a/usr.bin/telnet/sys_bsd.c
+++ b/usr.bin/telnet/sys_bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_bsd.c,v 1.25 2014/07/20 10:55:26 guenther Exp $ */
+/* $OpenBSD: sys_bsd.c,v 1.26 2014/07/20 12:08:55 guenther Exp $ */
/* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */
/*
@@ -56,7 +56,6 @@ int
#define TELNET_FD_NUM 3
struct termios old_tc = { 0 };
-extern struct termios new_tc;
void
init_sys()
@@ -68,9 +67,6 @@ init_sys()
}
-#ifdef KLUDGELINEMODE
-extern int kludgelinemode;
-#endif
/*
* TerminalSpecialChars()
*
@@ -413,9 +409,7 @@ TerminalNewMode(f)
} else {
sigset_t mask;
#ifdef SIGINFO
- void ayt_status();
-
- (void) signal(SIGINFO, (void (*)(int))ayt_status);
+ (void) signal(SIGINFO, ayt_status);
#endif
(void) signal(SIGTSTP, SIG_DFL);
sigemptyset(&mask);
@@ -610,7 +604,7 @@ ayt(sig)
if (connected)
sendayt();
else
- ayt_status();
+ ayt_status(sig);
}
#endif
diff --git a/usr.bin/telnet/terminal.c b/usr.bin/telnet/terminal.c
index f26cd89e66f..a7f893b7521 100644
--- a/usr.bin/telnet/terminal.c
+++ b/usr.bin/telnet/terminal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: terminal.c,v 1.11 2014/07/20 09:31:25 guenther Exp $ */
+/* $OpenBSD: terminal.c,v 1.12 2014/07/20 12:08:55 guenther Exp $ */
/* $NetBSD: terminal.c,v 1.5 1996/02/28 21:04:17 thorpej Exp $ */
/*
@@ -153,11 +153,7 @@ ttyflush(drop)
int
getconnmode()
{
- extern int linemode;
int mode = 0;
-#ifdef KLUDGELINEMODE
- extern int kludgelinemode;
-#endif
if (my_want_state_is_dont(TELOPT_ECHO))
mode |= MODE_ECHO;
diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c
index 1785f17a6e3..1ef67e3f10a 100644
--- a/usr.bin/telnet/utilities.c
+++ b/usr.bin/telnet/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.18 2014/07/20 09:20:48 guenther Exp $ */
+/* $OpenBSD: utilities.c,v 1.19 2014/07/20 12:08:55 guenther Exp $ */
/* $NetBSD: utilities.c,v 1.5 1996/02/28 21:04:21 thorpej Exp $ */
/*
@@ -177,7 +177,6 @@ printoption(direction, cmd, option)
optionstatus()
{
int i;
- extern char will_wont_resp[], do_dont_resp[];
for (i = 0; i < 256; i++) {
if (do_dont_resp[i]) {
@@ -257,7 +256,6 @@ printsub(direction, pointer, length)
int length; /* length of suboption data */
{
int i;
- extern int want_status_response;
if (showoptions || direction == 0 ||
(want_status_response && (pointer[0] == TELOPT_STATUS))) {