-/* $OpenBSD: commands.c,v 1.66 2014/07/20 10:18:10 guenther Exp $ */
+/* $OpenBSD: commands.c,v 1.67 2014/07/20 10:55:26 guenther Exp $ */
/* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */
/*
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 */
if (connected) {
(void) shutdown(net, 2);
printf("Connection closed.\r\n");
- (void) NetClose(net);
+ (void)close(net);
connected = 0;
resettermname = 1;
/* reset options */
};
static void env_help(void);
+static void env_undefine(unsigned char *);
+static void env_export(unsigned char *);
+static void env_unexport(unsigned char *);
+static void env_send(unsigned char *);
+static void env_list(void);
+static struct env_lst *env_find(unsigned char *var);
struct envlist EnvList[] = {
{ "define", "Define an environment variable",
{ 0 },
};
- static void
+static void
env_help()
{
struct envlist *c;
}
}
- static struct envlist *
+static struct envlist *
getenvcmd(name)
char *name;
{
genget(name, (char **) EnvList, sizeof(struct envlist));
}
- int
+static int
env_cmd(argc, argv)
int argc;
char *argv[];
struct env_lst envlisthead;
- struct env_lst *
+static struct env_lst *
env_find(var)
unsigned char *var;
{
return(ep);
}
- void
+static void
env_undefine(var)
unsigned char *var;
{
}
}
- void
+static void
env_export(var)
unsigned char *var;
{
ep->export = 1;
}
- void
+static void
env_unexport(var)
unsigned char *var;
{
ep->export = 0;
}
- void
+static void
env_send(var)
unsigned char *var;
{
env_opt_end(0);
}
- void
+static void
env_list()
{
struct env_lst *ep;
(void) call(status, "status", "notmuch", 0);
if (setjmp(peerdied) == 0)
telnet(user);
- (void) NetClose(net);
+ (void)close(net);
ExitString("Connection closed by foreign host.\r\n",1);
}
* pointed to by *cpp is.
*
*/
- unsigned long
+
+static unsigned long
sourceroute(arg, cpp, lenp)
char *arg;
char **cpp;
-/* $OpenBSD: externs.h,v 1.25 2014/07/20 10:18:10 guenther Exp $ */
+/* $OpenBSD: externs.h,v 1.26 2014/07/20 10:55:26 guenther Exp $ */
/* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
/*
/* commands.c */
struct env_lst *env_define (unsigned char *, unsigned char *);
-struct env_lst *env_find(unsigned char *var);
void env_init (void);
-void env_undefine (unsigned char *);
-void env_export (unsigned char *);
-void env_unexport (unsigned char *);
-void env_send (unsigned char *);
-void env_list (void);
unsigned char * env_default(int init, int welldefined);
unsigned char * env_getvalue(unsigned char *var, int exported_only);
void set_escape_char(char *s);
-unsigned long sourceroute(char *arg, char **cpp, int *lenp);
#ifdef SIGINFO
void ayt_status(void);
cc_t *tcval(int func);
void TerminalSpeeds(long *input_speed, long *output_speed);
int TerminalWindowSize(long *rows, long *cols);
-int NetClose(int fd);
-void NetNonblockingIO(int fd, int onoff);
+void TerminalNewMode(int);
+void TerminalSaveState(void);
+void sys_telnet_init(void);
int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
int poll);
void tel_leave_binary(int rw);
void tel_enter_binary(int rw);
int opt_welldefined(char *ep);
+void telnet(char *);
int telrcv(void);
int rlogin_susp(void);
void intp(void);
void sendsusp(void);
void sendeof(void);
void sendayt(void);
+void sendnaws(void);
void xmitAO(void);
void xmitEL(void);
void xmitEC(void);
-
-void Dump (char, unsigned char *, int);
-void printoption (char *, int, int);
-void sendnaws (void);
-void setconnmode (int);
-void setcommandmode (void);
-void setneturg (void);
-void sys_telnet_init (void);
-void telnet (char *);
-void tel_enter_binary (int);
-void TerminalNewMode (int);
-void TerminalRestoreState (void);
-void TerminalSaveState (void);
-void tninit (void);
-void willoption (int);
-void wontoption (int);
-
-
void send_do (int, int);
void send_dont (int, int);
void send_will (int, int);
void send_wont (int, int);
-void lm_will (unsigned char *, int);
-void lm_wont (unsigned char *, int);
-void lm_do (unsigned char *, int);
-void lm_dont (unsigned char *, int);
void lm_mode (unsigned char *, int, int);
-void slc_init (void);
void slcstate (void);
void slc_mode_export (int);
void slc_mode_import (int);
-void slc_import (int);
-void slc_export (void);
-void slc (unsigned char *, int);
void slc_check (void);
-void slc_start_reply (void);
-void slc_add_reply (unsigned char, unsigned char, cc_t);
-void slc_end_reply (void);
-int slc_update (void);
-void env_opt (unsigned char *, int);
-void env_opt_start (void);
void env_opt_start_info (void);
void env_opt_add (unsigned char *);
void env_opt_end (int);
void init_terminal(void);
int ttyflush(int drop);
int getconnmode(void);
+void setconnmode(int);
+void setcommandmode(void);
/* utilities.c */
-/* $OpenBSD: network.c,v 1.15 2014/07/20 10:18:10 guenther Exp $ */
+/* $OpenBSD: network.c,v 1.16 2014/07/20 10:55:26 guenther Exp $ */
/* $NetBSD: network.c,v 1.5 1996/02/28 21:04:06 thorpej Exp $ */
/*
#include <sys/socket.h>
#include <errno.h>
#include <poll.h>
+#include <unistd.h>
Ring netoring, netiring;
unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ];
if (errno != ENOBUFS && errno != EWOULDBLOCK) {
setcommandmode();
perror(hostname);
- (void)NetClose(net);
+ (void)close(net);
ring_clear_mark(&netoring);
longjmp(peerdied, -1);
}
-/* $OpenBSD: sys_bsd.c,v 1.24 2014/07/20 10:18:10 guenther Exp $ */
+/* $OpenBSD: sys_bsd.c,v 1.25 2014/07/20 10:55:26 guenther Exp $ */
/* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */
/*
return 0;
}
- int
-NetClose(fd)
- int fd;
-{
- return close(fd);
-}
-
-
- void
-NetNonblockingIO(fd, onoff)
- int fd;
- int onoff;
-{
- ioctl(fd, FIONBIO, (char *)&onoff);
-}
-
-\f
/*
* Various signal handling routines.
*/
setconnmode(0);
- NetNonblockingIO(net, 1);
-
+ /*
+ * Mark the socket as non-blocking and receive urgent data inline.
+ * (The latter is required for correct telnet operation when a
+ * second urgent is sent before telnet can process the first.)
+ */
+ ioctl(net, FIONBIO, &one);
if (setsockopt(net, SOL_SOCKET, SO_OOBINLINE, &one, sizeof(one)) == -1) {
perror("setsockopt");
}
-/* $OpenBSD: telnet.c,v 1.27 2014/07/20 10:32:23 jsg Exp $ */
+/* $OpenBSD: telnet.c,v 1.28 2014/07/20 10:55:26 guenther Exp $ */
/* $NetBSD: telnet.c,v 1.7 1996/02/28 21:04:15 thorpej Exp $ */
/*
#define SB_EOF() (subpointer >= subend)
#define SB_LEN() (subend - subpointer)
+static void lm_will(unsigned char *, int);
+static void lm_wont(unsigned char *, int);
+static void lm_do(unsigned char *, int);
+static void lm_dont(unsigned char *, int);
+
+static void slc_init(void);
+static void slc_import(int);
+static void slc_export(void);
+static void slc_start_reply(void);
+static void slc_add_reply(unsigned char, unsigned char, cc_t);
+static void slc_end_reply(void);
+static void slc(unsigned char *, int);
+static int slc_update(void);
+
+static void env_opt(unsigned char *, int);
+static void env_opt_start(void);
+
char options[256]; /* The combined options */
char do_dont_resp[256];
char will_wont_resp[256];
}
- void
+static void
willoption(option)
int option;
{
}
- void
+static void
wontoption(option)
int option;
{
set_my_state_dont(option);
}
- static void
+static void
dooption(option)
int option;
{
set_my_state_will(option);
}
- static void
+static void
dontoption(option)
int option;
{
static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE };
- void
+static void
lm_will(cmd, len)
unsigned char *cmd;
int len;
}
}
- void
+static void
lm_wont(cmd, len)
unsigned char *cmd;
int len;
}
}
- void
+static void
lm_do(cmd, len)
unsigned char *cmd;
int len;
}
}
- void
+static void
lm_dont(cmd, len)
unsigned char *cmd;
int len;
#define SLC_RVALUE 2
static int slc_mode = SLC_EXPORT;
- void
+static void
slc_init()
{
struct spc *spcp;
IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE
};
- void
+static void
slc_import(def)
int def;
{
/*@*/ else printf("slc_import: not enough room\n");
}
- void
+static void
slc_export()
{
struct spc *spcp;
setconnmode(1); /* Make sure the character values are set */
}
- void
+static void
slc(cp, len)
unsigned char *cp;
int len;
return *slc_replyp++ = ch;
}
- void
+static void
slc_start_reply()
{
slc_replyp = slc_reply;
slc_add(LM_SLC);
}
- void
+static void
slc_add_reply(func, flags, value)
unsigned char func;
unsigned char flags;
slc_add(IAC);
}
- void
+static void
slc_end_reply()
{
int len;
/*@*/else printf("slc_end_reply: not enough room\n");
}
- int
+static int
slc_update()
{
struct spc *spcp;
return(need_update);
}
- void
+static void
env_opt(buf, len)
unsigned char *buf;
int len;
return;
*opt_replyp++ = ch;
}
- void
+static void
env_opt_start()
{
unsigned char *p;