From: guenther Date: Sun, 20 Jul 2014 10:55:26 +0000 (+0000) Subject: Mark a slurry of functions as static X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=936ccdd11da52694d6abf0b12698130a5dec894a;p=openbsd Mark a slurry of functions as static Eliminate two more trivial wrappers --- diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index efce4e4dfaa..4723509c84b 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -54,6 +54,7 @@ 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 */ @@ -1341,7 +1342,7 @@ bye(argc, argv) if (connected) { (void) shutdown(net, 2); printf("Connection closed.\r\n"); - (void) NetClose(net); + (void)close(net); connected = 0; resettermname = 1; /* reset options */ @@ -1462,6 +1463,12 @@ struct envlist { }; 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", @@ -1480,7 +1487,7 @@ struct envlist EnvList[] = { { 0 }, }; - static void +static void env_help() { struct envlist *c; @@ -1495,7 +1502,7 @@ env_help() } } - static struct envlist * +static struct envlist * getenvcmd(name) char *name; { @@ -1503,7 +1510,7 @@ getenvcmd(name) genget(name, (char **) EnvList, sizeof(struct envlist)); } - int +static int env_cmd(argc, argv) int argc; char *argv[]; @@ -1548,7 +1555,7 @@ struct env_lst { struct env_lst envlisthead; - struct env_lst * +static struct env_lst * env_find(var) unsigned char *var; { @@ -1647,7 +1654,7 @@ env_define(var, value) return(ep); } - void +static void env_undefine(var) unsigned char *var; { @@ -1665,7 +1672,7 @@ env_undefine(var) } } - void +static void env_export(var) unsigned char *var; { @@ -1675,7 +1682,7 @@ env_export(var) ep->export = 1; } - void +static void env_unexport(var) unsigned char *var; { @@ -1685,7 +1692,7 @@ env_unexport(var) ep->export = 0; } - void +static void env_send(var) unsigned char *var; { @@ -1709,7 +1716,7 @@ env_send(var) env_opt_end(0); } - void +static void env_list() { struct env_lst *ep; @@ -2109,7 +2116,7 @@ tn(argc, argv) (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); } @@ -2344,7 +2351,8 @@ help(argc, argv) * pointed to by *cpp is. * */ - unsigned long + +static unsigned long sourceroute(arg, cpp, lenp) char *arg; char **cpp; diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h index 0aa9c6a10a9..1d25f09b379 100644 --- a/usr.bin/telnet/externs.h +++ b/usr.bin/telnet/externs.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -158,18 +158,11 @@ extern jmp_buf /* 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); @@ -196,8 +189,9 @@ void TerminalDefaultChars(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); @@ -208,6 +202,7 @@ void init_telnet(void); 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); @@ -216,55 +211,24 @@ void sendabort(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); @@ -290,6 +254,8 @@ int Ambiguous(void *s); void init_terminal(void); int ttyflush(int drop); int getconnmode(void); +void setconnmode(int); +void setcommandmode(void); /* utilities.c */ diff --git a/usr.bin/telnet/network.c b/usr.bin/telnet/network.c index 39a3f766ced..79d9d511dc5 100644 --- a/usr.bin/telnet/network.c +++ b/usr.bin/telnet/network.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -35,6 +35,7 @@ #include #include #include +#include Ring netoring, netiring; unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ]; @@ -127,7 +128,7 @@ netflush() if (errno != ENOBUFS && errno != EWOULDBLOCK) { setcommandmode(); perror(hostname); - (void)NetClose(net); + (void)close(net); ring_clear_mark(&netoring); longjmp(peerdied, -1); } diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index 2ac91941b08..5587df0ceea 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.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 $ */ /* @@ -542,23 +542,6 @@ TerminalWindowSize(rows, cols) return 0; } - int -NetClose(fd) - int fd; -{ - return close(fd); -} - - - void -NetNonblockingIO(fd, onoff) - int fd; - int onoff; -{ - ioctl(fd, FIONBIO, (char *)&onoff); -} - - /* * Various signal handling routines. */ @@ -650,8 +633,12 @@ sys_telnet_init() 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"); } diff --git a/usr.bin/telnet/telnet.c b/usr.bin/telnet/telnet.c index e1cde5fc4a8..a559d43d878 100644 --- a/usr.bin/telnet/telnet.c +++ b/usr.bin/telnet/telnet.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -54,6 +54,23 @@ static unsigned char subbuffer[SUBBUFSIZE], #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]; @@ -229,7 +246,7 @@ send_wont(c, init) } - void +static void willoption(option) int option; { @@ -283,7 +300,7 @@ willoption(option) } - void +static void wontoption(option) int option; { @@ -332,7 +349,7 @@ wontoption(option) set_my_state_dont(option); } - static void +static void dooption(option) int option; { @@ -422,7 +439,7 @@ dooption(option) set_my_state_will(option); } - static void +static void dontoption(option) int option; { @@ -794,7 +811,7 @@ suboption() 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; @@ -817,7 +834,7 @@ lm_will(cmd, len) } } - void +static void lm_wont(cmd, len) unsigned char *cmd; int len; @@ -834,7 +851,7 @@ lm_wont(cmd, len) } } - void +static void lm_do(cmd, len) unsigned char *cmd; int len; @@ -857,7 +874,7 @@ lm_do(cmd, len) } } - void +static void lm_dont(cmd, len) unsigned char *cmd; int len; @@ -920,7 +937,7 @@ struct spc { #define SLC_RVALUE 2 static int slc_mode = SLC_EXPORT; - void +static void slc_init() { struct spc *spcp; @@ -1005,7 +1022,7 @@ unsigned char slc_import_def[] = { IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE }; - void +static void slc_import(def) int def; { @@ -1021,7 +1038,7 @@ slc_import(def) /*@*/ else printf("slc_import: not enough room\n"); } - void +static void slc_export() { struct spc *spcp; @@ -1045,7 +1062,7 @@ slc_export() setconnmode(1); /* Make sure the character values are set */ } - void +static void slc(cp, len) unsigned char *cp; int len; @@ -1147,7 +1164,7 @@ slc_add(unsigned char ch) return *slc_replyp++ = ch; } - void +static void slc_start_reply() { slc_replyp = slc_reply; @@ -1157,7 +1174,7 @@ slc_start_reply() slc_add(LM_SLC); } - void +static void slc_add_reply(func, flags, value) unsigned char func; unsigned char flags; @@ -1175,7 +1192,7 @@ slc_add_reply(func, flags, value) slc_add(IAC); } - void +static void slc_end_reply() { int len; @@ -1197,7 +1214,7 @@ slc_end_reply() /*@*/else printf("slc_end_reply: not enough room\n"); } - int +static int slc_update() { struct spc *spcp; @@ -1215,7 +1232,7 @@ slc_update() return(need_update); } - void +static void env_opt(buf, len) unsigned char *buf; int len; @@ -1276,7 +1293,7 @@ opt_add(unsigned char ch) return; *opt_replyp++ = ch; } - void +static void env_opt_start() { unsigned char *p;