From c4fad9a3d06f44a84e1265de1b3b31c04e3b3e77 Mon Sep 17 00:00:00 2001 From: jsg Date: Tue, 22 Jul 2014 07:30:24 +0000 Subject: [PATCH] use ansi style function declarations with suggestions from and ok guenther@ --- usr.bin/telnet/commands.c | 291 ++++++++++++++----------------------- usr.bin/telnet/externs.h | 4 +- usr.bin/telnet/main.c | 12 +- usr.bin/telnet/network.c | 17 +-- usr.bin/telnet/ring.c | 65 +++------ usr.bin/telnet/sys_bsd.c | 80 +++++----- usr.bin/telnet/telnet.c | 242 +++++++++++++----------------- usr.bin/telnet/terminal.c | 26 ++-- usr.bin/telnet/utilities.c | 53 +++---- 9 files changed, 316 insertions(+), 474 deletions(-) diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index caf8a775767..4a07226dc19 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.68 2014/07/20 12:08:55 guenther Exp $ */ +/* $OpenBSD: commands.c,v 1.69 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -72,10 +72,8 @@ static int margc; static char *margv[20]; #ifdef SKEY - int -skey_calc(argc, argv) - int argc; - char **argv; +int +skey_calc(int argc, char **argv) { int status; @@ -99,11 +97,9 @@ skey_calc(argc, argv) } } #endif - - - static void -makeargv() +static void +makeargv(void) { char *cp, *cp2, c; char **argp = margv; @@ -159,9 +155,8 @@ makeargv() * Todo: 1. Could take random integers (12, 0x12, 012, 0b1). */ - static char -special(s) - char *s; +static char +special(char *s) { char c; char b; @@ -186,9 +181,8 @@ special(s) * Construct a control character sequence * for a special character. */ - static char * -control(c) - cc_t c; +static char * +control(cc_t c) { static char buf[5]; /* @@ -222,8 +216,6 @@ control(c) return (buf); } - - /* * The following are data structures and routines for * the "send" command. @@ -281,10 +273,8 @@ static struct sendlist Sendlist[] = { #define GETSEND(name) ((struct sendlist *) genget(name, (char **) Sendlist, \ sizeof(struct sendlist))) - static int -sendcmd(argc, argv) - int argc; - char **argv; +static int +sendcmd(int argc, char **argv) { int count; /* how many bytes we are going to need to send */ int i; @@ -363,46 +353,41 @@ sendcmd(argc, argv) return (count == success); } - static int -send_tncmd(void (*func)(), char *cmd, char *name); +static int send_tncmd(void (*func)(int, int), char *cmd, char *name); - static int -send_esc() +static int +send_esc(void) { NETADD(escape); return 1; } - static int -send_docmd(name) - char *name; +static int +send_docmd(char *name) { return(send_tncmd(send_do, "do", name)); } - static int -send_dontcmd(name) - char *name; +static int +send_dontcmd(char *name) { return(send_tncmd(send_dont, "dont", name)); } - static int -send_willcmd(name) - char *name; + +static int +send_willcmd(char *name) { return(send_tncmd(send_will, "will", name)); } - static int -send_wontcmd(name) - char *name; + +static int +send_wontcmd(char *name) { return(send_tncmd(send_wont, "wont", name)); } - int -send_tncmd(func, cmd, name) - void (*func)(); - char *cmd, *name; +int +send_tncmd(void (*func)(int, int), char *cmd, char *name) { char **cpp; extern char *telopts[]; @@ -462,8 +447,8 @@ send_tncmd(func, cmd, name) return 1; } - static int -send_help() +static int +send_help(void) { struct sendlist *s; /* pointer to current command */ for (s = Sendlist; s->name; s++) { @@ -478,15 +463,15 @@ send_help() * to by the arguments to the "toggle" command. */ - static int -lclchars() +static int +lclchars(int unused) { donelclchars = 1; return 1; } - static int -togdebug() +static int +togdebug(int unused) { if (net > 0 && (setsockopt(net, SOL_SOCKET, SO_DEBUG, &debug, sizeof(debug))) == -1) { @@ -495,9 +480,8 @@ togdebug() return 1; } - - static int -togcrlf() +static int +togcrlf(int unused) { if (crlf) { printf("Will send carriage returns as telnet .\r\n"); @@ -509,9 +493,8 @@ togcrlf() int binmode; - static int -togbinary(val) - int val; +static int +togbinary(int val) { donebinarytoggle = 1; @@ -548,9 +531,8 @@ togbinary(val) return 1; } - static int -togrbinary(val) - int val; +static int +togrbinary(int val) { donebinarytoggle = 1; @@ -575,9 +557,8 @@ togrbinary(val) return 1; } - static int -togxbinary(val) - int val; +static int +togxbinary(int val) { donebinarytoggle = 1; @@ -700,7 +681,7 @@ static struct togglelist Togglelist[] = { { 0 } }; - static int +static int togglehelp(int unused) { struct togglelist *c; @@ -718,9 +699,8 @@ togglehelp(int unused) return 0; } - static void -settogglehelp(set) - int set; +static void +settogglehelp(int set) { struct togglelist *c; @@ -738,10 +718,8 @@ settogglehelp(set) #define GETTOGGLE(name) (struct togglelist *) \ genget(name, (char **) Togglelist, sizeof(struct togglelist)) - static int -toggle(argc, argv) - int argc; - char *argv[]; +static int +toggle(int argc, char *argv[]) { int retval = 1; char *name; @@ -827,17 +805,15 @@ static struct setlist Setlist[] = { { 0 } }; - static struct setlist * -getset(name) - char *name; +static struct setlist * +getset(char *name) { return (struct setlist *) genget(name, (char **) Setlist, sizeof(struct setlist)); } - void -set_escape_char(s) - char *s; +void +set_escape_char(char *s) { if (rlogin != _POSIX_VDISABLE) { rlogin = (s && *s) ? special(s) : _POSIX_VDISABLE; @@ -849,10 +825,8 @@ set_escape_char(s) } } - static int -setcmd(argc, argv) - int argc; - char *argv[]; +static int +setcmd(int argc, char *argv[]) { int value; struct setlist *ct; @@ -927,10 +901,8 @@ setcmd(argc, argv) return 1; } - static int -unsetcmd(argc, argv) - int argc; - char *argv[]; +static int +unsetcmd(int argc, char *argv[]) { struct setlist *ct; struct togglelist *c; @@ -995,8 +967,8 @@ unsetcmd(argc, argv) * 'mode' command. */ #ifdef KLUDGELINEMODE - static int -dokludgemode() +static int +dokludgemode(int unused) { kludgelinemode = 1; send_wont(TELOPT_LINEMODE, 1); @@ -1006,8 +978,8 @@ dokludgemode() } #endif - static int -dolinemode() +static int +dolinemode(int unused) { #ifdef KLUDGELINEMODE if (kludgelinemode) @@ -1018,8 +990,8 @@ dolinemode() return 1; } - static int -docharmode() +static int +docharmode(int unused) { #ifdef KLUDGELINEMODE if (kludgelinemode) @@ -1031,9 +1003,8 @@ docharmode() return 1; } - static int -dolmmode(bit, on) - int bit, on; +static int +dolmmode(int bit, int on) { unsigned char c; @@ -1051,14 +1022,14 @@ dolmmode(bit, on) return 1; } - int -tn_setmode(bit) +int +tn_setmode(int bit) { return dolmmode(bit, 1); } - int -tn_clearmode(bit) +int +tn_clearmode(int bit) { return dolmmode(bit, 0); } @@ -1105,8 +1076,7 @@ static struct modelist ModeList[] = { { 0 }, }; - - static int +static int modehelp(int unused) { struct modelist *mt; @@ -1126,10 +1096,8 @@ modehelp(int unused) #define GETMODECMD(name) (struct modelist *) \ genget(name, (char **) ModeList, sizeof(struct modelist)) - static int -modecmd(argc, argv) - int argc; - char *argv[]; +static int +modecmd(int argc, char *argv[]) { struct modelist *mt; @@ -1154,10 +1122,8 @@ modecmd(argc, argv) * "display" command. */ - static int -display(argc, argv) - int argc; - char *argv[]; +static int +display(int argc, char *argv[]) { struct togglelist *tl; struct setlist *sl; @@ -1222,10 +1188,8 @@ display(argc, argv) /* * Set the escape character. */ - static int -setescape(argc, argv) - int argc; - char *argv[]; +static int +setescape(int argc, char *argv[]) { char *arg; char buf[50]; @@ -1247,8 +1211,8 @@ setescape(argc, argv) return 1; } - static int -togcrmod() +static int +togcrmod(int unused1, char *unused2[]) { crmod = !crmod; printf("Deprecated usage - please use 'toggle crmod' in the future.\r\n"); @@ -1257,8 +1221,8 @@ togcrmod() return 1; } - int -telnetsuspend() +int +telnetsuspend(int unused1, char *unused2[]) { setcommandmode(); { @@ -1282,10 +1246,8 @@ telnetsuspend() return 1; } - int -shell(argc, argv) - int argc; - char *argv[]; +int +shell(int argc, char *argv[]) { long oldrows, oldcols, newrows, newcols, err; @@ -1345,9 +1307,7 @@ close_connection(void) } static int -bye(argc, argv) - int argc; /* Number of arguments */ - char *argv[]; /* arguments */ +bye(int argc, char *argv[]) { close_connection(); longjmp(toplevel, 1); @@ -1366,8 +1326,8 @@ quitcmd(int unused1, char *unused2[]) quit(); } - static int -logout() +static int +logout(int unused1, char *unused2[]) { send_do(TELOPT_LOGOUT, 1); (void) netflush(); @@ -1400,7 +1360,7 @@ struct slclist SlcList[] = { { 0 }, }; - static void +static void slc_help(int unused) { struct slclist *c; @@ -1415,18 +1375,15 @@ slc_help(int unused) } } - static struct slclist * -getslc(name) - char *name; +static struct slclist * +getslc(char *name) { return (struct slclist *) genget(name, (char **) SlcList, sizeof(struct slclist)); } - static int -slccmd(argc, argv) - int argc; - char *argv[]; +static int +slccmd(int argc, char *argv[]) { struct slclist *c; @@ -1488,7 +1445,7 @@ struct envlist EnvList[] = { }; static void -env_help() +env_help(void) { struct envlist *c; @@ -1503,17 +1460,14 @@ env_help() } static struct envlist * -getenvcmd(name) - char *name; +getenvcmd(char *name) { return (struct envlist *) genget(name, (char **) EnvList, sizeof(struct envlist)); } static int -env_cmd(argc, argv) - int argc; - char *argv[]; +env_cmd(int argc, char *argv[]) { struct envlist *c; @@ -1556,8 +1510,7 @@ struct env_lst { struct env_lst envlisthead; static struct env_lst * -env_find(var) - unsigned char *var; +env_find(unsigned char *var) { struct env_lst *ep; @@ -1568,8 +1521,8 @@ env_find(var) return(NULL); } - void -env_init() +void +env_init(void) { extern char **environ; char **epp, *cp; @@ -1625,9 +1578,8 @@ env_init() env_export((unsigned char *)"XAUTHORITY"); } - struct env_lst * -env_define(var, value) - unsigned char *var, *value; +struct env_lst * +env_define(unsigned char *var, unsigned char *value) { struct env_lst *ep; @@ -1655,8 +1607,7 @@ env_define(var, value) } static void -env_undefine(var) - unsigned char *var; +env_undefine(unsigned char *var) { struct env_lst *ep; @@ -1673,8 +1624,7 @@ env_undefine(var) } static void -env_export(var) - unsigned char *var; +env_export(unsigned char *var) { struct env_lst *ep; @@ -1683,8 +1633,7 @@ env_export(var) } static void -env_unexport(var) - unsigned char *var; +env_unexport(unsigned char *var) { struct env_lst *ep; @@ -1693,8 +1642,7 @@ env_unexport(var) } static void -env_send(var) - unsigned char *var; +env_send(unsigned char *var) { struct env_lst *ep; @@ -1717,7 +1665,7 @@ env_send(var) } static void -env_list() +env_list(void) { struct env_lst *ep; @@ -1727,9 +1675,8 @@ env_list() } } - unsigned char * -env_default(init, welldefined) - int init; +unsigned char * +env_default(int init, int welldefined) { static struct env_lst *nep = NULL; @@ -1746,10 +1693,8 @@ env_default(init, welldefined) return(NULL); } - unsigned char * -env_getvalue(var, exported_only) - unsigned char *var; - int exported_only; +unsigned char * +env_getvalue(unsigned char *var, int exported_only) { struct env_lst *ep; @@ -1901,11 +1846,8 @@ cmdrc(char *m1, char *m2) fclose(rcfile); } - - int -tn(argc, argv) - int argc; - char *argv[]; +int +tn(int argc, char *argv[]) { struct addrinfo hints, *res, *res0; int error; @@ -2189,9 +2131,8 @@ static Command cmdtab2[] = { }; - static Command * -getcmd(name) - char *name; +static Command * +getcmd(char *name) { Command *cm; @@ -2200,11 +2141,8 @@ getcmd(name) return (Command *) genget(name, (char **) cmdtab2, sizeof(Command)); } - void -command(top, tbuf, cnt) - int top; - char *tbuf; - int cnt; +void +command(int top, char *tbuf, int cnt) { Command *c; @@ -2272,10 +2210,8 @@ command(top, tbuf, cnt) /* * Help command. */ - static int -help(argc, argv) - int argc; - char *argv[]; +static int +help(int argc, char *argv[]) { Command *c; @@ -2343,10 +2279,7 @@ help(argc, argv) */ static unsigned long -sourceroute(arg, cpp, lenp) - char *arg; - char **cpp; - int *lenp; +sourceroute(char *arg, char **cpp, int *lenp) { static char lsr[44]; char *cp, *cp2, *lsrp, *lsrep; diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h index 9d51a2497b2..1078945bff4 100644 --- a/usr.bin/telnet/externs.h +++ b/usr.bin/telnet/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.27 2014/07/20 12:08:55 guenther Exp $ */ +/* $OpenBSD: externs.h,v 1.28 2014/07/22 07:30:24 jsg Exp $ */ /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */ /* @@ -269,7 +269,7 @@ void SetNetTrace(char *file); void Dump(char direction, unsigned char *buffer, int length); void printoption(char *direction, int cmd, int option); void optionstatus(void); -void printsub(int direction, unsigned char *pointer, int length); +void printsub(char direction, unsigned char *pointer, int length); void EmptyTerminal(void); void SetForExit(void); __dead void Exit(int returnCode); diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index 4843ec7ae59..2f69bd61f80 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.29 2014/07/20 11:20:52 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.30 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $ */ /* @@ -43,8 +43,8 @@ int rtableid = -1; /* * Initialize variables. */ - void -tninit() +void +tninit(void) { init_terminal(); @@ -73,10 +73,8 @@ usage(void) * main. Parse arguments, invoke the protocol or command parser. */ - int -main(argc, argv) - int argc; - char *argv[]; +int +main(int argc, char *argv[]) { int ch; char *user, *alias; diff --git a/usr.bin/telnet/network.c b/usr.bin/telnet/network.c index 79d9d511dc5..a225b57ca97 100644 --- a/usr.bin/telnet/network.c +++ b/usr.bin/telnet/network.c @@ -1,4 +1,4 @@ -/* $OpenBSD: network.c,v 1.16 2014/07/20 10:55:26 guenther Exp $ */ +/* $OpenBSD: network.c,v 1.17 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: network.c,v 1.5 1996/02/28 21:04:06 thorpej Exp $ */ /* @@ -58,8 +58,8 @@ init_network(void) * Telnet "synch" processing). */ - int -stilloob() +int +stilloob(void) { struct pollfd pfd[1]; int value; @@ -80,20 +80,18 @@ stilloob() return 0; } - /* * setneturg() * * Sets "neturg" to the current location. */ - void -setneturg() +void +setneturg(void) { ring_mark(&netoring); } - /* * netflush * Send as much data as possible to the network, @@ -103,9 +101,8 @@ setneturg() * useful work. */ - - int -netflush() +int +netflush(void) { int n, n1; diff --git a/usr.bin/telnet/ring.c b/usr.bin/telnet/ring.c index 92efb304b90..fd9bfdcd7ba 100644 --- a/usr.bin/telnet/ring.c +++ b/usr.bin/telnet/ring.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ring.c,v 1.10 2014/07/20 10:32:23 jsg Exp $ */ +/* $OpenBSD: ring.c,v 1.11 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: ring.c,v 1.7 1996/02/28 21:04:07 thorpej Exp $ */ /* @@ -71,16 +71,10 @@ static unsigned long ring_clock = 0; ((d)->supplytime > (d)->consumetime)) - - - /* Buffer state transition routines */ void -ring_init(ring, buffer, count) - Ring *ring; - unsigned char *buffer; - int count; +ring_init(Ring *ring, unsigned char *buffer, int count) { memset(ring, 0, sizeof *ring); @@ -97,9 +91,8 @@ ring_init(ring, buffer, count) * Mark the most recently supplied byte. */ - void -ring_mark(ring) - Ring *ring; +void +ring_mark(Ring *ring) { ring->mark = ring_decrement(ring, ring->supply, 1); } @@ -108,9 +101,8 @@ ring_mark(ring) * Is the ring pointing to the mark? */ - int -ring_at_mark(ring) - Ring *ring; +int +ring_at_mark(Ring *ring) { if (ring->mark == ring->consume) { return 1; @@ -123,9 +115,8 @@ ring_at_mark(ring) * Clear any mark set on the ring. */ - void -ring_clear_mark(ring) - Ring *ring; +void +ring_clear_mark(Ring *ring) { ring->mark = NULL; } @@ -133,10 +124,8 @@ ring_clear_mark(ring) /* * Add characters from current segment to ring buffer. */ - void -ring_supplied(ring, count) - Ring *ring; - int count; +void +ring_supplied(Ring *ring, int count) { ring->supply = ring_increment(ring, ring->supply, count); ring->supplytime = ++ring_clock; @@ -145,10 +134,8 @@ ring_supplied(ring, count) /* * We have just consumed "c" bytes. */ - void -ring_consumed(ring, count) - Ring *ring; - int count; +void +ring_consumed(Ring *ring, int count) { if (count == 0) /* don't update anything */ return; @@ -168,14 +155,12 @@ ring_consumed(ring, count) } - /* Buffer state query routines */ /* Number of bytes that may be supplied */ - int -ring_empty_count(ring) - Ring *ring; +int +ring_empty_count(Ring *ring) { if (ring_empty(ring)) { /* if empty */ return ring->size; @@ -185,9 +170,8 @@ ring_empty_count(ring) } /* number of CONSECUTIVE bytes that may be supplied */ - int -ring_empty_consecutive(ring) - Ring *ring; +int +ring_empty_consecutive(Ring *ring) { if ((ring->consume < ring->supply) || ring_empty(ring)) { /* @@ -207,9 +191,8 @@ ring_empty_consecutive(ring) * (but don't give more than enough to get to cross over set mark) */ - int -ring_full_count(ring) - Ring *ring; +int +ring_full_count(Ring *ring) { if ((ring->mark == NULL) || (ring->mark == ring->consume)) { if (ring_full(ring)) { @@ -226,9 +209,8 @@ ring_full_count(ring) * Return the number of CONSECUTIVE bytes available for consuming. * However, don't return more than enough to cross over set mark. */ - int -ring_full_consecutive(ring) - Ring *ring; +int +ring_full_consecutive(Ring *ring) { if ((ring->mark == NULL) || (ring->mark == ring->consume)) { if ((ring->supply < ring->consume) || ring_full(ring)) { @@ -248,11 +230,8 @@ ring_full_consecutive(ring) /* * Move data into the "supply" portion of of the ring buffer. */ - void -ring_supply_data(ring, buffer, count) - Ring *ring; - unsigned char *buffer; - int count; +void +ring_supply_data(Ring *ring, unsigned char *buffer, int count) { int i; diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index 585f8438dba..8bc4813242c 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.26 2014/07/20 12:08:55 guenther Exp $ */ +/* $OpenBSD: sys_bsd.c,v 1.27 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */ /* @@ -57,8 +57,8 @@ int struct termios old_tc = { 0 }; - void -init_sys() +void +init_sys(void) { tout = fileno(stdout); tin = fileno(stdin); @@ -79,9 +79,8 @@ init_sys() * 1 Do add this character */ - int -TerminalSpecialChars(c) - int c; +int +TerminalSpecialChars(int c) { if (c == termIntChar) { intp(); @@ -118,8 +117,8 @@ TerminalSpecialChars(c) return 1; } - void -TerminalSaveState() +void +TerminalSaveState(void) { tcgetattr(0, &old_tc); @@ -148,9 +147,8 @@ TerminalSaveState() #endif } - cc_t * -tcval(func) - int func; +cc_t * +tcval(int func) { switch(func) { case SLC_IP: return(&termIntChar); @@ -187,8 +185,8 @@ tcval(func) } } - void -TerminalDefaultChars() +void +TerminalDefaultChars(void) { memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc)); # ifndef VDISCARD @@ -241,9 +239,8 @@ static void susp(); static void ayt(); #endif - void -TerminalNewMode(f) - int f; +void +TerminalNewMode(int f) { static int prevmode = 0; struct termios tmp_tc; @@ -489,10 +486,8 @@ struct termspeeds { }; #endif /* DECODE_BAUD */ - void -TerminalSpeeds(ispeed, ospeed) - long *ispeed; - long *ospeed; +void +TerminalSpeeds(long *ispeed, long *ospeed) { #ifdef DECODE_BAUD struct termspeeds *tp; @@ -520,9 +515,8 @@ TerminalSpeeds(ispeed, ospeed) #endif /* DECODE_BAUD */ } - int -TerminalWindowSize(rows, cols) - long *rows, *cols; +int +TerminalWindowSize(long *rows, long *cols) { #ifdef TIOCGWINSZ struct winsize ws; @@ -540,17 +534,15 @@ TerminalWindowSize(rows, cols) * Various signal handling routines. */ - void -deadpeer(sig) - int sig; +void +deadpeer(int sig) { setcommandmode(); longjmp(peerdied, -1); } - void -intr(sig) - int sig; +void +intr(int sig) { if (localchars) { intp(); @@ -560,9 +552,8 @@ intr(sig) longjmp(toplevel, -1); } - void -intr2(sig) - int sig; +void +intr2(int sig) { if (localchars) { #ifdef KLUDGELINEMODE @@ -575,9 +566,8 @@ intr2(sig) } } - void -susp(sig) - int sig; +void +susp(int sig) { if ((rlogin != _POSIX_VDISABLE) && rlogin_susp()) return; @@ -586,9 +576,8 @@ susp(sig) } #ifdef SIGWINCH - void -sendwin(sig) - int sig; +void +sendwin(int sig) { if (connected) { sendnaws(); @@ -597,9 +586,8 @@ sendwin(sig) #endif #ifdef SIGINFO - void -ayt(sig) - int sig; +void +ayt(int sig) { if (connected) sendayt(); @@ -609,8 +597,8 @@ ayt(sig) #endif - void -sys_telnet_init() +void +sys_telnet_init(void) { int one = 1; @@ -649,9 +637,9 @@ sys_telnet_init() * The return value is 1 if something happened, 0 if not. */ - int -process_rings(netin, netout, netex, ttyin, ttyout, dopoll) - int dopoll; /* If 0, then block until something to do */ +int +process_rings(int netin, int netout, int netex, int ttyin, int ttyout, + int dopoll) /* If 0, then block until something to do */ { int c; /* One wants to be a bit careful about setting returnValue diff --git a/usr.bin/telnet/telnet.c b/usr.bin/telnet/telnet.c index a559d43d878..ca6d88268c0 100644 --- a/usr.bin/telnet/telnet.c +++ b/usr.bin/telnet/telnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: telnet.c,v 1.28 2014/07/20 10:55:26 guenther Exp $ */ +/* $OpenBSD: telnet.c,v 1.29 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: telnet.c,v 1.7 1996/02/28 21:04:15 thorpej Exp $ */ /* @@ -149,8 +149,8 @@ Clocks clocks; * Initialize telnet environment. */ - void -init_telnet() +void +init_telnet(void) { env_init(); @@ -181,9 +181,8 @@ init_telnet() * is in disagreement as to what the current state should be. */ - void -send_do(c, init) - int c, init; +void +send_do(int c, int init) { if (init) { if (((do_dont_resp[c] == 0) && my_state_is_do(c)) || @@ -197,9 +196,8 @@ send_do(c, init) printoption("SENT",DO, c); } - void -send_dont(c, init) - int c, init; +void +send_dont(int c, int init) { if (init) { if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) || @@ -213,9 +211,8 @@ send_dont(c, init) printoption("SENT", DONT, c); } - void -send_will(c, init) - int c, init; +void +send_will(int c, int init) { if (init) { if (((will_wont_resp[c] == 0) && my_state_is_will(c)) || @@ -229,9 +226,8 @@ send_will(c, init) printoption("SENT", WILL, c); } - void -send_wont(c, init) - int c, init; +void +send_wont(int c, int init) { if (init) { if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) || @@ -245,10 +241,8 @@ send_wont(c, init) printoption("SENT", WONT, c); } - static void -willoption(option) - int option; +willoption(int option) { int new_state_ok = 0; @@ -301,8 +295,7 @@ willoption(option) } static void -wontoption(option) - int option; +wontoption(int option) { if (do_dont_resp[option]) { --do_dont_resp[option]; @@ -350,8 +343,7 @@ wontoption(option) } static void -dooption(option) - int option; +dooption(int option) { int new_state_ok = 0; @@ -440,8 +432,7 @@ dooption(option) } static void -dontoption(option) - int option; +dontoption(int option) { if (will_wont_resp[option]) { @@ -476,9 +467,8 @@ int is_unique(char *, char **, char **); static char *name_unknown = "UNKNOWN"; static char *unknown[] = { NULL, NULL }; - char ** -mklist(buf, name) - char *buf, *name; +char ** +mklist(char *buf, char *name) { int n; char c, *cp, **argvp, *cp2, **argv, **avt; @@ -588,9 +578,8 @@ mklist(buf, name) return(unknown); } - int -is_unique(name, as, ae) - char *name, **as, **ae; +int +is_unique(char *name, char **as, char **ae) { char **ap; int n; @@ -604,8 +593,8 @@ is_unique(name, as, ae) int resettermname = 1; - char * -gettermname() +char * +gettermname(void) { char *tname; static char **tnamep = NULL; @@ -633,6 +622,7 @@ gettermname() next = tnamep; return(*next++); } + /* * suboption() * @@ -647,8 +637,8 @@ gettermname() * Linemode */ - static void -suboption() +static void +suboption(void) { unsigned char subchar; @@ -812,9 +802,7 @@ suboption() static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE }; static void -lm_will(cmd, len) - unsigned char *cmd; - int len; +lm_will(unsigned char *cmd, int len) { if (len < 1) { /*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */ @@ -835,9 +823,7 @@ lm_will(cmd, len) } static void -lm_wont(cmd, len) - unsigned char *cmd; - int len; +lm_wont(unsigned char *cmd, int len) { if (len < 1) { /*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */ @@ -852,9 +838,7 @@ lm_wont(cmd, len) } static void -lm_do(cmd, len) - unsigned char *cmd; - int len; +lm_do(unsigned char *cmd, int len) { if (len < 1) { /*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */ @@ -875,9 +859,7 @@ lm_do(cmd, len) } static void -lm_dont(cmd, len) - unsigned char *cmd; - int len; +lm_dont(unsigned char *cmd, int len) { if (len < 1) { /*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */ @@ -895,10 +877,8 @@ static unsigned char str_lm_mode[] = { IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE }; - void -lm_mode(cmd, len, init) - unsigned char *cmd; - int len, init; +void +lm_mode(unsigned char *cmd, int len, int init) { if (len != 1) return; @@ -938,7 +918,7 @@ struct spc { static int slc_mode = SLC_EXPORT; static void -slc_init() +slc_init(void) { struct spc *spcp; @@ -989,8 +969,8 @@ slc_init() } - void -slcstate() +void +slcstate(void) { printf("Special characters are %s values\n", slc_mode == SLC_IMPORT ? "remote default" : @@ -998,7 +978,7 @@ slcstate() "remote"); } - void +void slc_mode_export(int unused) { slc_mode = SLC_EXPORT; @@ -1006,9 +986,8 @@ slc_mode_export(int unused) slc_export(); } - void -slc_mode_import(def) - int def; +void +slc_mode_import(int def) { slc_mode = def ? SLC_IMPORT : SLC_RVALUE; if (my_state_is_will(TELOPT_LINEMODE)) @@ -1023,8 +1002,7 @@ unsigned char slc_import_def[] = { }; static void -slc_import(def) - int def; +slc_import(int def) { if (NETROOM() > sizeof(slc_import_val)) { if (def) { @@ -1039,7 +1017,7 @@ slc_import(def) } static void -slc_export() +slc_export(void) { struct spc *spcp; @@ -1063,9 +1041,7 @@ slc_export() } static void -slc(cp, len) - unsigned char *cp; - int len; +slc(unsigned char *cp, int len) { struct spc *spcp; int func,level; @@ -1132,8 +1108,8 @@ slc(cp, len) setconnmode(1); /* set the new character values */ } - void -slc_check() +void +slc_check(void) { struct spc *spcp; @@ -1156,7 +1132,7 @@ slc_check() static unsigned char slc_reply[2 * SUBBUFSIZE]; static unsigned char *slc_replyp; - unsigned char +unsigned char slc_add(unsigned char ch) { if (slc_replyp == slc_reply + sizeof(slc_reply)) @@ -1165,7 +1141,7 @@ slc_add(unsigned char ch) } static void -slc_start_reply() +slc_start_reply(void) { slc_replyp = slc_reply; slc_add(IAC); @@ -1175,10 +1151,7 @@ slc_start_reply() } static void -slc_add_reply(func, flags, value) - unsigned char func; - unsigned char flags; - cc_t value; +slc_add_reply(unsigned char func, unsigned char flags, cc_t value) { if (slc_replyp + 6 >= slc_reply + sizeof(slc_reply)) { printf("slc_add_reply: not enough room\n"); @@ -1193,7 +1166,7 @@ slc_add_reply(func, flags, value) } static void -slc_end_reply() +slc_end_reply(void) { int len; @@ -1215,7 +1188,7 @@ slc_end_reply() } static int -slc_update() +slc_update(void) { struct spc *spcp; int need_update = 0; @@ -1233,9 +1206,7 @@ slc_update() } static void -env_opt(buf, len) - unsigned char *buf; - int len; +env_opt(unsigned char *buf, int len) { unsigned char *ep = 0, *epc = 0; int i; @@ -1286,15 +1257,16 @@ static unsigned char *opt_reply; static unsigned char *opt_replyp; static unsigned char *opt_replyend; - void +void opt_add(unsigned char ch) { if (opt_replyp == opt_replyend) return; *opt_replyp++ = ch; } + static void -env_opt_start() +env_opt_start(void) { unsigned char *p; @@ -1315,17 +1287,16 @@ env_opt_start() opt_add(TELQUAL_IS); } - void -env_opt_start_info() +void +env_opt_start_info(void) { env_opt_start(); if (opt_replyp) opt_replyp[-1] = TELQUAL_INFO; } - void -env_opt_add(ep) - unsigned char *ep; +void +env_opt_add(unsigned char *ep) { unsigned char *vp, c; @@ -1394,9 +1365,8 @@ env_opt_add(ep) } } - int -opt_welldefined(ep) - char *ep; +int +opt_welldefined(char *ep) { if ((strcmp(ep, "USER") == 0) || (strcmp(ep, "DISPLAY") == 0) || @@ -1407,9 +1377,9 @@ opt_welldefined(ep) return(1); return(0); } - void -env_opt_end(emptyok) - int emptyok; + +void +env_opt_end(int emptyok) { int len; @@ -1431,8 +1401,8 @@ env_opt_end(emptyok) - int -telrcv() +int +telrcv(void) { int c; int scc; @@ -1648,8 +1618,8 @@ process_iac: static int bol = 1, local = 0; - int -rlogin_susp() +int +rlogin_susp(void) { if (local) { local = 0; @@ -1660,8 +1630,8 @@ rlogin_susp() return(0); } - static int -telsnd() +static int +telsnd(void) { int tcc; int count; @@ -1810,10 +1780,8 @@ telsnd() * */ - - int -Scheduler(block) - int block; /* should we block in the select ? */ +int +Scheduler(int block) /* should we block in the select ? */ { /* One wants to be a bit careful about setting returnValue * to one, since a one implies we did some useful work, @@ -1866,9 +1834,8 @@ Scheduler(block) /* * Select from tty and network... */ - void -telnet(user) - char *user; +void +telnet(char *user) { sys_telnet_init(); @@ -1916,9 +1883,8 @@ telnet(user) * character. */ - static char * -nextitem(current) - char *current; +static char * +nextitem(char *current) { if ((*current&0xff) != IAC) { return current+1; @@ -1964,8 +1930,8 @@ nextitem(current) * us in any case. */ - static void -netclear() +static void +netclear(void) { #if 0 /* XXX */ char *thisitem, *next; @@ -2007,8 +1973,8 @@ netclear() * These routines add various telnet commands to the data stream. */ - static void -doflush() +static void +doflush(void) { NET2ADD(IAC, DO); NETADD(TELOPT_TM); @@ -2019,8 +1985,8 @@ doflush() printoption("SENT", DO, TELOPT_TM); } - void -xmitAO() +void +xmitAO(void) { NET2ADD(IAC, AO); printoption("SENT", IAC, AO); @@ -2030,23 +1996,23 @@ xmitAO() } - void -xmitEL() +void +xmitEL(void) { NET2ADD(IAC, EL); printoption("SENT", IAC, EL); } - void -xmitEC() +void +xmitEC(void) { NET2ADD(IAC, EC); printoption("SENT", IAC, EC); } - int -dosynch() +int +dosynch(void) { netclear(); /* clear the path to the network */ NETADD(IAC); @@ -2058,8 +2024,8 @@ dosynch() int want_status_response = 0; - int -get_status() +int +get_status(void) { unsigned char tmp[16]; unsigned char *cp; @@ -2084,8 +2050,8 @@ get_status() return 1; } - void -intp() +void +intp(void) { NET2ADD(IAC, IP); printoption("SENT", IAC, IP); @@ -2098,8 +2064,8 @@ intp() } } - void -sendbrk() +void +sendbrk(void) { NET2ADD(IAC, BREAK); printoption("SENT", IAC, BREAK); @@ -2112,8 +2078,8 @@ sendbrk() } } - void -sendabort() +void +sendabort(void) { NET2ADD(IAC, ABORT); printoption("SENT", IAC, ABORT); @@ -2126,8 +2092,8 @@ sendabort() } } - void -sendsusp() +void +sendsusp(void) { NET2ADD(IAC, SUSP); printoption("SENT", IAC, SUSP); @@ -2140,15 +2106,15 @@ sendsusp() } } - void -sendeof() +void +sendeof(void) { NET2ADD(IAC, xEOF); printoption("SENT", IAC, xEOF); } - void -sendayt() +void +sendayt(void) { NET2ADD(IAC, AYT); printoption("SENT", IAC, AYT); @@ -2158,8 +2124,8 @@ sendayt() * Send a window size update to the remote system. */ - void -sendnaws() +void +sendnaws(void) { long rows, cols; unsigned char tmp[16]; @@ -2190,9 +2156,8 @@ sendnaws() } } - void -tel_enter_binary(rw) - int rw; +void +tel_enter_binary(int rw) { if (rw&1) send_do(TELOPT_BINARY, 1); @@ -2200,9 +2165,8 @@ tel_enter_binary(rw) send_will(TELOPT_BINARY, 1); } - void -tel_leave_binary(rw) - int rw; +void +tel_leave_binary(int rw) { if (rw&1) send_dont(TELOPT_BINARY, 1); diff --git a/usr.bin/telnet/terminal.c b/usr.bin/telnet/terminal.c index a7f893b7521..5f6ca213226 100644 --- a/usr.bin/telnet/terminal.c +++ b/usr.bin/telnet/terminal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.c,v 1.12 2014/07/20 12:08:55 guenther Exp $ */ +/* $OpenBSD: terminal.c,v 1.13 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: terminal.c,v 1.5 1996/02/28 21:04:17 thorpej Exp $ */ /* @@ -74,7 +74,7 @@ cc_t termAytChar; */ void -init_terminal() +init_terminal(void) { struct termios tc; @@ -85,7 +85,6 @@ init_terminal() autoflush = (tc.c_lflag & NOFLSH) == 0; } - /* * Send as much data as possible to the terminal. * @@ -96,10 +95,8 @@ init_terminal() * n: All data - n was written out. */ - - int -ttyflush(drop) - int drop; +int +ttyflush(int drop) { int n, n0, n1; @@ -149,9 +146,8 @@ ttyflush(drop) * of various global variables). */ - - int -getconnmode() +int +getconnmode(void) { int mode = 0; @@ -185,9 +181,8 @@ getconnmode() return(mode); } - void -setconnmode(force) - int force; +void +setconnmode(int force) { int newmode; @@ -196,9 +191,8 @@ setconnmode(force) TerminalNewMode(newmode); } - - void -setcommandmode() +void +setcommandmode(void) { TerminalNewMode(-1); } diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c index 1ef67e3f10a..76eb0f0f2c8 100644 --- a/usr.bin/telnet/utilities.c +++ b/usr.bin/telnet/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.19 2014/07/20 12:08:55 guenther Exp $ */ +/* $OpenBSD: utilities.c,v 1.20 2014/07/22 07:30:24 jsg Exp $ */ /* $NetBSD: utilities.c,v 1.5 1996/02/28 21:04:21 thorpej Exp $ */ /* @@ -68,9 +68,8 @@ upcase(char *argument) unsigned char NetTraceFile[PATH_MAX] = "(standard output)"; - void -SetNetTrace(file) - char *file; +void +SetNetTrace(char *file) { if (NetTrace && NetTrace != stdout) fclose(NetTrace); @@ -86,11 +85,8 @@ SetNetTrace(file) strlcpy((char *)NetTraceFile, "(standard output)", sizeof(NetTraceFile)); } - void -Dump(direction, buffer, length) - char direction; - unsigned char *buffer; - int length; +void +Dump(char direction, unsigned char *buffer, int length) { # define BYTES_PER_LINE 32 # define min(x,y) ((x' */ - unsigned char *pointer; /* where suboption data sits */ - int length; /* length of suboption data */ +void +printsub(char direction, /* '<' or '>' */ + unsigned char *pointer, /* where suboption data sits */ + int length) /* length of suboption data */ { int i; @@ -656,8 +648,8 @@ printsub(direction, pointer, length) * way to the kernel (thus the poll). */ - void -EmptyTerminal() +void +EmptyTerminal(void) { struct pollfd pfd[1]; @@ -674,8 +666,8 @@ EmptyTerminal() } } - void -SetForExit() +void +SetForExit(void) { setconnmode(0); do { @@ -690,18 +682,15 @@ SetForExit() setcommandmode(); } - void -Exit(returnCode) - int returnCode; +void +Exit(int returnCode) { SetForExit(); exit(returnCode); } - void -ExitString(string, returnCode) - char *string; - int returnCode; +void +ExitString(char *string, int returnCode) { SetForExit(); fwrite(string, 1, strlen(string), stderr); -- 2.20.1