Commit Diff


commit - c01470d76de8add2ac75ff1569941b9f997eaf06
commit + 01bc5d48c9c87c8feffb618640ae989586f58c09
blob - 81e527b15bf334d83848c0a41170935fb559e1f4
blob + a6030ec3030e55cb93190ae6502044171e9eb406
--- arp.c
+++ arp.c
@@ -160,7 +160,7 @@ rtget(struct sockaddr_inarp **sinp, struct sockaddr_dl
  * Set an individual arp entry
  */
 int
-arpset(int argc, char *argv[])
+arpset(int argc, char *argv[], ...)
 {
 	struct sockaddr_inarp *sin;
 	struct sockaddr_dl *sdl;
blob - 2a3c298673f93f97a419f91e4124069c9e698f95
blob + a6b11b3e6eb64a9ed76aba8e13c055b4c2c90bb4
--- bgpnsh/bgpnsh.c
+++ bgpnsh/bgpnsh.c
@@ -74,7 +74,7 @@ Menu showlist[] = {
 };
 
 static int
-showcmd(int argc, char **argv)
+showcmd(int argc, char **argv, ...)
 {
 	Menu *s;	/* pointer to current command */
 
@@ -106,7 +106,7 @@ showcmd(int argc, char **argv)
 }
 
 int
-quit(void)
+quit(int argc, char **argv, ...)
 {
 	printf("%% Session terminated.\n");
 	exit(0);
blob - d1c00fab01ebd7b6d21509c07078eeb7d1141720
blob + 73f5434c3d252691502815908f2a4f3b33978c03
--- bridge.c
+++ bridge.c
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <stdarg.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <sys/param.h>
@@ -115,10 +116,18 @@ static struct brc brps[] = {
 };
 
 int
-brport(char *ifname, int ifs, int argc, char **argv)
+brport(int argc, char **argv, ...)
 {
 	int set, i;
 	struct brc *x;
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	if (NO_ARG(argv[0])) {
 		set = 0;
@@ -222,13 +231,21 @@ static struct brc brvs[] = {
 };
 
 int
-brval(char *ifname, int ifs, int argc, char **argv)
+brval(int argc, char **argv, ...)
 {
 	int set;
 	u_int32_t val = 0;
 	const char *errmsg = NULL;
 	struct brc *x;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -323,8 +340,17 @@ brval(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-brrule(char *ifname, int ifs, int argc, char **argv)
+brrule(int argc, char **argv, ...)
 {
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		printf("%% all rules for a member must be applied in order\n");
 		printf("%% use flush bridge-rules <bridge> <member>\n");
@@ -345,10 +371,18 @@ brrule(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-brstatic(char *ifname, int ifs, int argc, char **argv)
+brstatic(int argc, char **argv, ...)
 {
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -387,12 +421,20 @@ static struct brd brds[] = {
 };
 
 int
-brpri(char *ifname, int ifs, int argc, char **argv)
+brpri(int argc, char **argv, ...)
 {
 	int set, val;
 	const char *errmsg = NULL;
 	struct brd *x;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -469,10 +511,16 @@ brpri(char *ifname, int ifs, int argc, char **argv)
  * flush wrappers here
  */
 int
-flush_bridgedyn(char *brdg)
+flush_bridgedyn(int argc, char **argv, ...)
 {
+	va_list ap;
+	char *brdg;
 	int ifs;
 
+	va_start(ap, argv);
+	brdg = va_arg(ap, char *);
+	va_end (ap);
+
 	ifs = socket(AF_INET, SOCK_DGRAM, 0);
 	if (ifs < 0) {
 		printf("%% socket: %s\n", strerror(errno));
@@ -492,9 +540,15 @@ flush_bridgedyn(char *brdg)
 }
 
 int
-flush_bridgeall(char *brdg)
+flush_bridgeall(int argc, char **argv, ...)
 {
+	va_list ap;
+	char *brdg;
 	int ifs;
+
+	va_start(ap, argv);
+	brdg = va_arg(ap, char *);
+	va_end(ap);
 
 	ifs = socket(AF_INET, SOCK_DGRAM, 0);
 	if (ifs < 0) {
@@ -515,10 +569,17 @@ flush_bridgeall(char *brdg)
 }
 
 int
-flush_bridgerule(char *brdg, char *member)
+flush_bridgerule(int argc, char **argv, ...)
 {
+	va_list ap;
+	char *brdg, *member;
 	int ifs;
 
+	va_start(ap, argv);
+	brdg = va_arg(ap, char *);
+	member = va_arg(ap, char *);
+	va_end(ap);
+
 	ifs = socket(AF_INET, SOCK_DGRAM, 0);
 	if (ifs < 0) {
 		printf("%% socket: %s\n", strerror(errno));
@@ -1625,10 +1686,18 @@ brprotect_usage(void)
 }
 
 int
-brprotect(char *ifname, int ifs, int argc, char **argv)
+brprotect(int argc, char **argv, ...)
 {
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -1755,7 +1824,7 @@ out:
 }
 
 int
-show_bridges(int argc, char **argv)
+show_bridges(int argc, char **argv, ...)
 {
 	switch (argc) {
 	case 2:
blob - 00d468e4f2977eda1ed8ea03f5c1659914056b36
blob + 7e74fed9a973e2c2fe7f76aa50d48faf1ca39404
--- carp.c
+++ carp.c
@@ -16,6 +16,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include <errno.h>
 #include <sys/limits.h>
@@ -46,14 +47,22 @@ static struct intc {
 static const char *carp_bal_modes[] = { CARP_BAL_MODES };
 
 int
-intcarp(char *ifname, int ifs, int argc, char **argv)
+intcarp(int argc, char **argv, ...)
 {
 	const char *errmsg = NULL;
 	struct ifreq ifr;
 	struct carpreq creq;
 	int set, bal_mode = 0, val = 0;
 	struct intc *x;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -196,12 +205,20 @@ intcarp(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intcpass(char *ifname, int ifs, int argc, char **argv)
+intcpass(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct carpreq creq;
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -238,13 +255,21 @@ intcpass(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intcnode(char *ifname, int ifs, int argc, char **argv)
+intcnode(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct carpreq creq;
 	const char *errmsg = NULL;
 	int set, i, last;
 	u_int vhid, advskew;
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	if (NO_ARG(argv[0])) {
 		set = 0;
@@ -428,12 +453,20 @@ carp_state(int s, char *ifname, FILE *outfile)
 }
 
 int
-intcdev(char *ifname, int ifs, int argc, char **argv)
+intcdev(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct carpreq creq;
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
blob - 5287c97ee9c9f53122b0ca88867d57acadfbe2da
blob + 58e53e15ac18acf7bfeb34903c17c935f6a4da37
--- commands.c
+++ commands.c
@@ -49,6 +49,7 @@
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
+#include <stdarg.h>
 #include <sys/fcntl.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -78,81 +79,81 @@ pid_t	child;
 
 extern volatile sig_atomic_t caught_sigwinch;
 
-static int	disable(void);
-static int      clear(void);
-static int	doverbose(int, char**);
-static int	doediting(int, char**);
-static int	doconfig(int, char**);
-static int	exitconfig(int, char**);
-int		rtable(int, char**);
-int		group(int, char**);
-static int	pr_crontab(int, char **, FILE *);
-static int	pr_routes(int, char **);
-static int	pr_routes6(int, char **);
-static int	pr_arp(int, char **);
-static int	pr_ndp(int, char **);
-static int	pr_sadb(int, char **);
-static int	pr_kernel(int, char **);
-static int	pr_dhcp(int, char **);
-static int	pr_conf(int, char **);
-static int	pr_s_conf(int, char **);
-static int	pr_a_conf(int, char **);
-static int	pr_conf_diff(int, char **);
-static int	pr_environment(int, char **);
-static int	show_hostname(int, char **);
-static int	wr_startup(void);
+static int	disable(int, char **, ...);
+static int      clear(int, char **, ...);
+static int	doverbose(int, char**, ...);
+static int	doediting(int, char**, ...);
+static int	doconfig(int, char**, ...);
+static int	exitconfig(int, char **, ...);
+static int	rtable(int, char**, ...);
+static int	pr_crontab(int, char **, ...);
+static int	pr_routes(int, char **, ...);
+static int	pr_routes6(int, char **, ...);
+static int	pr_arp(int, char **, ...);
+static int	pr_ndp(int, char **, ...);
+static int	pr_sadb(int, char **, ...);
+static int	pr_kernel(int, char **, ...);
+static int	pr_dhcp(int, char **, ...);
+static int	pr_conf(int, char **, ...);
+static int	pr_s_conf(int, char **, ...);
+static int	pr_a_conf(int, char **, ...);
+static int	pr_conf_diff(int, char **, ...);
+static int	pr_environment(int, char **, ...);
+static int	show_hostname(int, char **, ...);
+static int	wr_startup(int, char **, ...);
 static int	wr_conf(char *);
-static int	sysctlhelp(int, char **, char **, int);
-static int	flush_pf(char *);
-static int	flush_help(void);
-static int	flush_line(char *);
-static int	flush_ip_routes(void);
-static int	flush_arp_cache(void);
-static int	flush_ndp_cache(void);
-static int	flush_history(void);
+static int	sysctlhelp(int, char **, ...);
+static int	flush_pf(int, char **, ...);
+static int	flush_help(int, char **, ...);
+static int	flush_line(int, char **, ...);
+static int	flush_ip_routes(int, char **, ...);
+static int	flush_arp_cache(int, char **, ...);
+static int	flush_ndp_cache(int, char **, ...);
+static int	flush_history(int, char **, ...);
 static int	is_bad_input(const char *, size_t);
 static int	read_command_line(EditLine *, History *);
-static int 	int_logger(char *, int, int, char **);
-static int	int_ping(char *, int, int, char **);
-static int	int_ping6(char *, int, int, char **);
-static int	int_traceroute(char *, int, int, char **);
-static int	int_traceroute6(char *, int, int, char **);
-static int	int_ssh(char *, int, int, char **);
-static int	int_telnet(char *, int, int, char **);
-static int	int_do(char *, int, int, char **);
-static int	int_setenv(char *, int, int, char **);
-static int	int_unsetenv(char *, int, int, char **);
-static int	int_saveenv(char *, int, int, char **);
-static int	int_show(char *, int, int, char **);
-static int	int_who(char *, int, int, char **);
-static int	int_doverbose(char *, int, int, char **);
-static int	int_doediting(char *, int, int, char **);
-static int	int_manual(char *, int, int, char **);
-static int	int_shell(char *, int, int, char **);
-static int      int_clear(void);
-static int	int_help(void);
-static int	int_exit(void);
-static int	hostname(int, char **);
-static int      logger(int, char **);
-static int	manual(int, char**);
-static int	nocmd(int, char **);
-static int	docmd(int, char **);
-static int	setenvcmd(int, char **);
-static int	unsetenvcmd(int, char **);
-static int	saveenvcmd(int, char **);
-static int	shell(int, char*[]);
-static int	ping(int, char*[]);
-static int	ping6(int, char*[]);
-static int	traceroute(int, char*[]);
-static int	traceroute6(int, char*[]);
-static int	ssh(int, char*[]);
-static int	telnet(int, char*[]);
-       void	p_argv(int, char **);
-static int 	nreboot(void);
-static int 	halt(void);
-static int 	powerdown(void);
+static int 	int_logger(int, char **, ...);
+static int	int_ping(int, char **, ...);
+static int	int_ping6(int, char **, ...);
+static int	int_traceroute(int, char **, ...);
+static int	int_traceroute6(int, char **, ...);
+static int	int_ssh(int, char **, ...);
+static int	int_telnet(int, char **, ...);
+static int	int_do(int, char **, ...);
+static int	int_setenv(int, char **, ...);
+static int	int_unsetenv(int, char **, ...);
+static int	int_saveenv(int, char **, ...);
+static int	int_show(int, char **, ...);
+static int	int_who(int, char **, ...);
+static int	int_doverbose(int, char **, ...);
+static int	int_doediting(int, char **, ...);
+static int	int_manual(int, char **, ...);
+static int	int_shell(int, char ** ,...);
+static int      int_clear(int, char **, ...);
+static int	int_help(int, char **, ...);
+static int	int_exit(int, char **, ...);
+static int	hostname(int, char **, ...);
+static int      logger(int, char **, ...);
+static int	manual(int, char**, ...);
+static int	nocmd(int, char **, ...);
+static int	docmd(int, char **, ...);
+static int	setenvcmd(int, char **, ...);
+static int	unsetenvcmd(int, char **, ...);
+static int	saveenvcmd(int, char **, ...);
+static int	shell(int, char **, ...);
+static int	ping(int, char **, ...);
+static int	ping6(int, char**, ...);
+static int	traceroute(int, char**, ...);
+static int	traceroute6(int, char**, ...);
+static int	ssh(int, char**, ...);
+static int	telnet(int, char**, ...);
+       void	p_argv(int, char **);
+static int 	nreboot(int, char **, ...);
+static int 	halt(int, char **, ...);
+static int 	powerdown(int, char **, ...);
 static void	pf_stats(void);
-static int	int_interface(char *, int, int, char **);
+static int	interface(int, char **, ...);
+static int	int_interface(int, char **, ...);
 
 #include "commands.h"
 
@@ -431,7 +432,7 @@ struct prot prots[] = {
  */
 
 int
-quit(void)
+quit(int argc, char **argv, ...)
 {
 	if (privexec) {
 		exit(NSH_REXEC_EXIT_CODE_QUIT);
@@ -518,7 +519,7 @@ Menu showlist[] = {
 };
 
 static int
-showcmd(int argc, char **argv)
+showcmd(int argc, char **argv, ...)
 {
 	Menu *s;	/* pointer to current command */
 	int error = 0, outfd = -1;
@@ -943,7 +944,7 @@ Menu pipextab[] = {
 };
 
 static int
-ipcmd(int argc, char **argv)
+ipcmd(int argc, char **argv, ...)
 {
 	Menu *i;     /* pointer to current command */
 	struct sysctltab *stab;
@@ -992,18 +993,27 @@ ipcmd(int argc, char **argv)
 	}
 
 	if (i->handler)
-		success = (*i->handler)(set, argv[1],
+		success = (*i->handler)(set, &argv[1],
 		    (i->maxarg > 0) ? argv[2] : 0, stab->pf);
 	return(success);
 }
 
 static int
-sysctlhelp(int unused1, char **unused2, char **unused3, int type)
+sysctlhelp(int unused1, char **unused2, ...)
 {
 	Menu *i = NULL, *j = NULL; /* pointer to current command */
 	char *prefix = NULL;
 	u_int z = 0;
 	struct sysctltab *stab;
+	va_list ap;
+	char **unused3 = NULL;
+	int type;
+
+	va_start(ap, unused2);
+	unused3 = va_arg(ap, char **);
+	if (unused3) { /* silence "unused variable" compiler warning */ }
+	type = va_arg(ap, int);
+	va_end(ap);
 
 	for (stab = sysctls; stab->name != NULL; stab++)
 		if (stab->pf == type) {
@@ -1051,12 +1061,12 @@ Menu flushlist[] = {
 };
 
 static int
-flushcmd(int argc, char **argv)
+flushcmd(int argc, char **argv, ...)
 {
 	Menu *f;
 
 	if (argc < 2) {
-		flush_help();
+		flush_help(argc, argv);
 		return 0;
 	}
 
@@ -1077,22 +1087,30 @@ flushcmd(int argc, char **argv)
 		return 0;
 	}
 	if (f->handler)
-		(*f->handler)((f->maxarg > 0) ? argv[2] : 0,
+		(*f->handler)(0, NULL, (f->maxarg > 0) ? argv[2] : 0,
 		    (f->maxarg > 1) ? argv[3] : 0);
 
 	return(1);
 }
 
 static int
-flush_line(char *line)
+flush_line(int argc, char **argv, ...)
 {
-	char *argv[] = { PKILL, "-9", "-t", line, NULL };
-	cmdargs(PKILL, argv);
+	va_list ap;
+	char *line;
+	char * args[5] = { PKILL, "-9", "-t", /* line */ NULL, NULL };
+
+	va_start(ap, argv);
+	line = va_arg(ap, char *);
+	va_end(ap);
+
+	args[3] = line;
+	cmdargs(PKILL, args);
 	return (1);
 }
 
 static int
-flush_help(void)
+flush_help(int argc, char **argv, ...)
 {
 	Menu *f;
 	u_int z = 0;
@@ -1378,14 +1396,20 @@ read_command_line(EditLine *el, History *hist)
  * interface/bridge is being configured.
  */
 static int
-interface(int argc, char **argv, char *modhvar)
+interface(int argc, char **argv, ...)
 {
 	int ifs, set = 1;
 	char *tmp;
 	char *ifunit = NULL;
 	struct intlist *i;	/* pointer to current command */
 	struct ifreq ifr;
+	va_list ap;
+	char *modhvar;
 
+	va_start(ap, argv);
+	modhvar = va_arg(ap, char *);
+	va_end(ap);
+
 	if (!modhvar) {
 		if (NO_ARG(argv[0])) {
 			argv++;
@@ -1522,7 +1546,7 @@ interface(int argc, char **argv, char *modhvar)
 			if (cli_rtable != 0 && nsh_setrtable(0) == 0)
 				cli_rtable = 0;
 	
-			((*i->handler) (ifname, ifs, argc, argv));
+			(*i->handler)(argc, argv, ifname, ifs);
 
 			if (save_cli_rtable != cli_rtable &&
 			    nsh_setrtable(cli_rtable) == 0)
@@ -1604,7 +1628,7 @@ interface(int argc, char **argv, char *modhvar)
 			if (cli_rtable != 0 && nsh_setrtable(0) == 0)
 				cli_rtable = 0;
 
-			ret = (*i->handler) (ifname, ifs, margc, margv);
+			ret = (*i->handler)(margc, margv, ifname, ifs);
 
 			if (cli_rtable != save_cli_rtable &&
 			    nsh_setrtable(cli_rtable) == 0)
@@ -1636,11 +1660,19 @@ interface(int argc, char **argv, char *modhvar)
 }
 
 static int
-int_interface(char *old_ifname, int ifs, int argc, char **argv)
+int_interface(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	char *new_ifname;
 	int set = 1;
+	va_list ap;
+	char *old_ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	old_ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 	
 	if (NO_ARG(argv[0])) {
 		argv++;
@@ -1690,120 +1722,119 @@ int_interface(char *old_ifname, int ifs, int argc, cha
 }
 
 static int
-int_logger(char *ifname, int ifs, int argc, char **argv)
+int_logger(int argc, char **argv, ...)
 {
         logger(argc, argv);
         return 0; /* do not leave interface context */
 }
 
-
 static int
-int_ping(char *ifname, int ifs, int argc, char **argv)
+int_ping(int argc, char **argv, ...)
 {
 	ping(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_ping6(char *ifname, int ifs, int argc, char **argv)
+int_ping6(int argc, char **argv, ...)
 {
 	ping6(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_traceroute(char *ifname, int ifs, int argc, char **argv)
+int_traceroute(int argc, char **argv, ...)
 {
 	traceroute(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_traceroute6(char *ifname, int ifs, int argc, char **argv)
+int_traceroute6(int argc, char **argv, ...)
 {
 	traceroute6(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_ssh(char *ifname, int ifs, int argc, char **argv)
+int_ssh(int argc, char **argv, ...)
 {
 	ssh(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_telnet(char *ifname, int ifs, int argc, char **argv)
+int_telnet(int argc, char **argv, ...)
 {
 	telnet(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_do(char *ifname, int ifs, int argc, char **argv)
+int_do(int argc, char **argv, ...)
 {
 	docmd(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_setenv(char *ifname, int ifs, int argc, char **argv)
+int_setenv(int argc, char **argv, ...)
 {
 	setenvcmd(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_unsetenv(char *ifname, int ifs, int argc, char **argv)
+int_unsetenv(int argc, char **argv, ...)
 {
 	unsetenvcmd(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_saveenv(char *ifname, int ifs, int argc, char **argv)
+int_saveenv(int argc, char **argv, ...)
 {
 	saveenvcmd(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_show(char *ifname, int ifs, int argc, char **argv)
+int_show(int argc, char **argv, ...)
 {
 	showcmd(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_who(char *ifname, int ifs, int argc, char **argv)
+int_who(int argc, char **argv, ...)
 {
 	who(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_doverbose(char *ifname, int ifs, int argc, char **argv)
+int_doverbose(int argc, char **argv, ...)
 {
 	doverbose(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_doediting(char *ifname, int ifs, int argc, char **argv)
+int_doediting(int argc, char **argv, ...)
 {
 	doediting(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_manual(char *ifname, int ifs, int argc, char **argv)
+int_manual(int argc, char **argv, ...)
 {
 	manual(argc, argv);
 	return 0; /* do not leave interface context */
 }
 
 static int
-int_shell(char *ifname, int ifs, int argc, char **argv)
+int_shell(int argc, char **argv, ...)
 {
 	if (argc >1) 
 	{
@@ -1815,13 +1846,13 @@ int_shell(char *ifname, int ifs, int argc, char **argv
 }
 
 static int
-int_clear(void)
+int_clear(int argc, char **argv, ...)
 {
-	clear();
+	return clear(argc, argv);
 }
 
 static int
-int_help(void)
+int_help(int argc, char **argv, ...)
 {
 	struct intlist *i; /* pointer to current command */
 	u_int z = 0;
@@ -1845,7 +1876,7 @@ int_help(void)
 }
 
 static int
-int_exit(void)
+int_exit(int argc, char **argv, ...)
 {
 	return 1; /* leave interface config mode */
 }
@@ -2088,7 +2119,7 @@ command()
 				if (feof(stdin) || ferror(stdin)) {
 					if (interactive_mode)
 						printf("\n");
-					(void) quit();
+					(void) quit(0, NULL);
 					/* NOTREACHED */
 				}
 				break;
@@ -2168,7 +2199,7 @@ manual_usage(void)
 }
 
 static int
-manual(int argc, char **argv)
+manual(int argc, char **argv, ...)
 {
 	sig_t sigint, sigquit, sigchld;
 	char term[32], *termenv = NULL;
@@ -2260,8 +2291,8 @@ manual(int argc, char **argv)
 /*
  * Hostname command.
  */
-int
-hostname(int argc, char **argv)
+static int
+hostname(int argc, char **argv, ...)
 {
 	argv++;
 	argc--;
@@ -2279,7 +2310,8 @@ hostname(int argc, char **argv)
 	return 0;
 }
 
-int show_hostname(int argc, char **argv)
+static int
+show_hostname(int argc, char **argv, ...)
 {
 	if (gethostname(hbuf, sizeof(hbuf)))
 		printf("%% gethostname: %s\n", strerror(errno));
@@ -2288,12 +2320,11 @@ int show_hostname(int argc, char **argv)
 
 	return 0;
 }
+
 /* logger command */
 
-
-
 int
-logger(int argc, char *argv[])
+logger(int argc, char *argv[], ...)
 {
         if (argc < 2) {  
                 printf("%% Invalid arguments\n");
@@ -2310,7 +2341,7 @@ logger(int argc, char *argv[])
  * This is a pseudo command table entry used for TAB-completion purposes.
  */
 static int
-nocmd(int argc, char **argv)
+nocmd(int argc, char **argv, ...)
 {
 	Command  *cmd = NULL, *c;
 
@@ -2345,7 +2376,7 @@ nocmd(int argc, char **argv)
  * switches which offer a "do" command for context switching.
  */
 static int
-docmd(int argc, char **argv)
+docmd(int argc, char **argv, ...)
 {
 	if (argc < 2) {
 		printf("%% command name not provided\n");
@@ -2391,7 +2422,7 @@ docmd(int argc, char **argv)
 			if (cli_rtable != 0 && nsh_setrtable(cli_rtable) == 0)
 				cli_rtable = 0;
 
-			((*i->handler) (ifname, ifs, argc, argv));
+			(*i->handler)(argc, argv, ifname, ifs);
 
 			if (save_cli_rtable != cli_rtable &&
 			    nsh_setrtable(cli_rtable) == 0)
@@ -2422,7 +2453,7 @@ usage_setenv(void)
 }
 
 static int
-setenvcmd(int argc, char **argv)
+setenvcmd(int argc, char **argv, ...)
 {
 	char *name, *eq, *value;
 	void *name0;
@@ -2473,7 +2504,7 @@ setenvcmd(int argc, char **argv)
 }
 
 static int
-unsetenvcmd(int argc, char **argv)
+unsetenvcmd(int argc, char **argv, ...)
 {
 	char *name;
 	void *name0;
@@ -2514,7 +2545,7 @@ savevar(void *keyptr, size_t keysize, void *value, siz
 }
 
 static int
-saveenvcmd(int argc, char **argv)
+saveenvcmd(int argc, char **argv, ...)
 {
 	char tmppath[PATH_MAX], path[PATH_MAX];
 	FILE *f;
@@ -2583,8 +2614,8 @@ saveenvcmd(int argc, char **argv)
 /*
  * Shell command.
  */
-int
-shell(int argc, char **argv)
+static int
+shell(int argc, char **argv, ...)
 {
 	sig_t sigint, sigquit, sigchld;
 
@@ -2640,7 +2671,7 @@ shell(int argc, char **argv)
  * ping command.
  */
 int
-ping(int argc, char *argv[])
+ping(int argc, char *argv[], ...)
 {
 	if (argc < 2) {
 		printf("%% Invalid arguments\n");
@@ -2652,7 +2683,7 @@ ping(int argc, char *argv[])
 }
 
 int
-ping6(int argc, char *argv[])
+ping6(int argc, char *argv[], ...)
 {
 	if (argc < 2) {
 		printf("%% Invalid arguments\n");
@@ -2667,7 +2698,7 @@ ping6(int argc, char *argv[])
  * telnet command.
  */
 int
-telnet(int argc, char *argv[])
+telnet(int argc, char *argv[], ...)
 {
 	if (argc < 2) {
 		printf("%% Invalid arguments\n");
@@ -2682,7 +2713,7 @@ telnet(int argc, char *argv[])
  * ssh command.
  */
 int
-ssh(int argc, char *argv[])
+ssh(int argc, char *argv[], ...)
 {
 	if (argc < 2) {
 		printf("%% Invalid arguments\n");
@@ -2697,7 +2728,7 @@ ssh(int argc, char *argv[])
  * traceroute command.
  */
 int
-traceroute(int argc, char *argv[])
+traceroute(int argc, char *argv[], ...)
 {
 	if (argc < 2) {
 		printf("%% Invalid arguments\n");
@@ -2709,7 +2740,7 @@ traceroute(int argc, char *argv[])
 }
 
 int
-traceroute6(int argc, char *argv[])
+traceroute6(int argc, char *argv[], ...)
 {
 	if (argc < 2) {
 		printf("%% Invalid arguments\n");
@@ -2742,8 +2773,8 @@ argvtostring(int argc, char **argv, char *string, int 
 	return i;
 }
 
-int
-rtable(int argc, char **argv)
+static int
+rtable(int argc, char **argv, ...)
 {
 	int table, set, pos, found, curtable;
 	const char *errstr;
@@ -2866,7 +2897,7 @@ rtable(int argc, char **argv)
  * Group attribute command.
  */
 int
-group(int argc, char **argv)
+group(int argc, char **argv, ...)
 {
 	int counter = 1, set, ifs;
 	const char *errstr;
@@ -2920,18 +2951,18 @@ group(int argc, char **argv)
 }
 
 //clear terminal screen
-int
-clear(void)
+static int
+clear(int argc, char **argv, ...)
 {
-	char *argv[] = {CLEAR, NULL, NULL };	
-        cmdargs(CLEAR, argv);
+	char *args[] = {CLEAR, NULL, NULL };	
+        cmdargs(CLEAR, args);
 	return 0; 
 }
 /*
  * disable privileged mode
  */
-int
-disable(void)
+static int
+disable(int argc, char **argv, ...)
 {
 	if (privexec) {
 		exit(0);
@@ -2945,8 +2976,8 @@ disable(void)
 /*
  * verbose diagnostics
  */
-int
-doverbose(int argc, char **argv)
+static int
+doverbose(int argc, char **argv, ...)
 {
 	if (argc > 1) {
 		if (NO_ARG(argv[0])) {
@@ -2964,8 +2995,8 @@ doverbose(int argc, char **argv)
 	return 0;
 }
 
-int
-doediting(int argc, char **argv)
+static int
+doediting(int argc, char **argv, ...)
 {
 	if (argc > 1) {
 		if (NO_ARG(argv[0])) {
@@ -2984,8 +3015,8 @@ doediting(int argc, char **argv)
 	return 0;
 }
 
-int
-doconfig(int argc, char **argv)
+static int
+doconfig(int argc, char **argv, ...)
 {
 	if (argc > 1) {
 		if (NO_ARG(argv[0])) {
@@ -3003,8 +3034,8 @@ doconfig(int argc, char **argv)
 	return 0;
 }
 
-int
-exitconfig(int argc, char **argv)
+static int
+exitconfig(int argc, char **argv, ...)
 {
 	if (!config_mode) {
 		printf ("%% Configuration mode is already disabled\n");
@@ -3016,7 +3047,7 @@ exitconfig(int argc, char **argv)
 }
 
 int
-flush_history(void)
+flush_history(int argc, char **argv, ...)
 {
 	if (!editing) {
 		printf("%% Command line editing not enabled\n");
@@ -3038,11 +3069,17 @@ flush_history(void)
 /*
  * pf toilet flusher
  */
-int
-flush_pf(char *arg)
+static int
+flush_pf(int argc, char **argv, ...)
 {
 	struct fpf *x;
+	va_list ap;
+	char *arg;
 
+	va_start(ap, argv);
+	arg = va_arg(ap, char *);
+	va_end(ap);
+
 	if (!arg || arg[0] == '?') {
 		gen_help((char **)fpfs, "flush pf", "flush",
 		    sizeof(struct fpf));
@@ -3203,9 +3240,9 @@ p_argv(int argc, char **argv)
 }
 
 int
-wr_startup(void)
+wr_startup(int argc, char **argv, ...)
 {
-	char *argv[] = { SAVESCRIPT, NSHRC_TEMP, NULL };
+	char *args[] = { SAVESCRIPT, NSHRC_TEMP, NULL };
 
 	if (wr_conf(NSHRC_TEMP))
 		printf("%% Saving configuration\n");
@@ -3213,7 +3250,7 @@ wr_startup(void)
 		printf("%% Unable to save configuration: %s\n",
 		    strerror(errno));
 
-	cmdargs(SAVESCRIPT, argv);
+	cmdargs(SAVESCRIPT, args);
 
 	return(1);
 }
@@ -3396,43 +3433,44 @@ done:
  * Reboot
  */
 int
-nreboot(void)
+nreboot(int argc, char **argv, ...)
 {
 	return do_reboot(RB_AUTOBOOT);
 }
 
 int
-halt(void)
+halt(int argc, char **argv, ...)
 {
 	return do_reboot(RB_HALT);
 }
 
 int
-powerdown(void)
+powerdown(int argc, char **argv, ...)
 {
 	return do_reboot(RB_POWERDOWN);
 }
+
 /*
  * Flush wrappers
  */
-int
-flush_ip_routes(void)
+static int
+flush_ip_routes(int argc, char **argv, ...)
 {
 	flushroutes(AF_INET, AF_INET);
 
 	return(0);
 }
 
-int
-flush_arp_cache(void)
+static int
+flush_arp_cache(int argc, char **argv, ...)
 {
 	flushroutes(AF_INET, AF_LINK);
 
 	return(0);
 }
 
-int
-flush_ndp_cache(void)
+static int
+flush_ndp_cache(int argc, char **argv, ...)
 {
 	ndpdump(NULL, 1);
 	return(0);
@@ -3441,8 +3479,8 @@ flush_ndp_cache(void)
 /*
  * Show wrappers
  */
-int
-pr_conf(int argc, char **argv)
+static int
+pr_conf(int argc, char **argv, ...)
 {
 	if (priv != 1) {
 		printf ("%% Privilege required\n");
@@ -3462,8 +3500,8 @@ pr_conf(int argc, char **argv)
 /*
  * Show startup config
  */
-int
-pr_s_conf(int argc, char **argv)
+static int
+pr_s_conf(int argc, char **argv, ...)
 {
 	int ret;
 
@@ -3481,8 +3519,8 @@ pr_s_conf(int argc, char **argv)
  * Show running-config for the active context.
  * Currently only supports the interface/bridge context.
  */
-int
-pr_a_conf(int argc, char **argv)
+static int
+pr_a_conf(int argc, char **argv, ...)
 {
 	if (priv != 1) {
 		printf ("%% Privilege required\n");
@@ -3501,8 +3539,8 @@ pr_a_conf(int argc, char **argv)
 /*
  * Show differences between startup and running config.
  */
-int
-pr_conf_diff(int argc, char **argv)
+static int
+pr_conf_diff(int argc, char **argv, ...)
 {
 	int conf_fd = -1, diff_fd = -1;
 	char confpath[PATH_MAX];
@@ -3574,10 +3612,16 @@ done:
 }
 
 static int
-pr_crontab(int argc, char **argv, FILE *outfile)
+pr_crontab(int argc, char **argv, ...)
 {
 	char *crontab_argv[] = { CRONTAB, "-l", "-u", "root", NULL };
+	va_list ap;
+	FILE *outfile;
 
+	va_start(ap, argv);
+	outfile = va_arg(ap, FILE *);
+	va_end(ap);
+
 	if (priv != 1) {
 		printf("%% Privilege required\n");
 		return 0 ;
@@ -3593,8 +3637,8 @@ pr_crontab(int argc, char **argv, FILE *outfile)
 	return 0;
 }
 
-int
-pr_routes(int argc, char **argv)
+static int
+pr_routes(int argc, char **argv, ...)
 {
 	switch(argc) {
 	case 2:
@@ -3610,8 +3654,8 @@ pr_routes(int argc, char **argv)
 	return 0;
 }
 
-int
-pr_routes6(int argc, char **argv)
+static int
+pr_routes6(int argc, char **argv, ...)
 {
 	switch(argc) {
 	case 2:
@@ -3628,7 +3672,7 @@ pr_routes6(int argc, char **argv)
 }
 
 int
-pr_arp(int argc, char **argv)
+pr_arp(int argc, char **argv, ...)
 {
 	switch(argc) {
 	case 2:
@@ -3643,8 +3687,8 @@ pr_arp(int argc, char **argv)
 	return 0;
 }
 
-int
-pr_ndp(int argc, char **argv)
+static int
+pr_ndp(int argc, char **argv, ...)
 {
 	switch(argc) {
 	case 2:
@@ -3659,16 +3703,16 @@ pr_ndp(int argc, char **argv)
 	return 0;
 }
 
-int
-pr_sadb(int argc, char **argv)
+static int
+pr_sadb(int argc, char **argv, ...)
 {
 	p_rttables(PF_KEY, 0, 0);
 
 	return 0;
 }
 
-int
-pr_kernel(int argc, char **argv)
+static int
+pr_kernel(int argc, char **argv, ...)
 {
 	struct stt *x;
 
@@ -3702,8 +3746,8 @@ pf_stats(void)
 	return;
 }
 
-int
-pr_dhcp(int argc, char **argv)
+static int
+pr_dhcp(int argc, char **argv, ...)
 {
 	if (argc == 3 && argv[2][0] != '?') {
 		if (isprefix(argv[2], "leases")) {
@@ -3727,7 +3771,7 @@ envcmp(const void *item1, const void *item2)
 }
 
 static int
-pr_environment(int argc, char **argv)
+pr_environment(int argc, char **argv, ...)
 {
 	extern char **environ;
 	char **ep;
blob - 538228794818b95a085bd5e3aa46337a017832b2
blob + e3eb2326a9df857f929d08aa1b33f7ae983b6dde
--- commands.h
+++ commands.h
@@ -29,7 +29,7 @@ struct prot {
 extern char bgpd_socket_path[PATH_MAX];
 void init_bgpd_socket_path(int);
 extern struct prot prots[];
-int show_help(int, char **);
+int show_help(int, char **, ...);
 Command *getcmd(char *);
 extern Menu showlist[];
 void makeargv(void);
@@ -38,4 +38,4 @@ extern int	nsh_setrtable(int);
 extern void	sigalarm(int);
 extern char hbuf[MAXHOSTNAMELEN];
 extern char ifname[IFNAMSIZ];
-int	help(int, char**);
+int	help(int, char **, ...);
blob - 45e48e3aac7ea6216f5f45d3920d8d040bceafee
blob + 9270b99463cb1ad4a9e4150d2f673a0608250db5
--- ctl.c
+++ ctl.c
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <libgen.h>
 #include <histedit.h>
+#include <stdarg.h>
 #include <sys/signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -35,17 +36,18 @@
 /* table variable (for pkill usage) */
 static char table[16];
 
-/* service routines */
-void edit_crontab(char *);
-void install_crontab(char *);
-void edit_motd(char *);
-void call_editor(char *, char **, char *);
-void start_dhcpd(char *, char *, char *, char *, char *);
-void restart_dhcpd(char *, char *, char *, char *, char *);
+/* service routines, used as handlers in struct ctl */
+void edit_crontab(int, char **, ...);
+void install_crontab(int, char **, ...);
+void edit_motd(int, char **, ...);
+void call_editor(int, char **, ...);
+void start_dhcpd(int, char **, ...);
+void restart_dhcpd(int, char **, ...);
+
+/* subroutines */
+int fill_tmpfile(char **, char *, char **);
 int edit_file(char *, mode_t, char *, char **);
-void ctl_symlink(char *, char *, char *);
 int rule_writeline(char *, mode_t, char *);
-int fill_tmpfile(char **, char *, char **);
 int acq_lock(char *);
 void rls_lock(int);
 
@@ -111,7 +113,7 @@ struct ctl ctl_pf[] = {
 	    { PFCTL, "-d", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
 	{ "edit",	"edit, test and stage firewall rules",
 	    { "pf",  NULL },
-	    { PFCTL, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_FILL1 },
+	    { PFCTL, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",     "test and display staged firewall rules",
             { PFCTL, "-nvvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",	"test and apply staged firewall rules",
@@ -129,7 +131,7 @@ struct ctl ctl_ospf[] = {
 	    T_EXEC },
 	{ "edit",          "edit, test and stage OSPFd config",
 	    { "ospf", NULL },
-	    { OSPFD, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_FILL1 },
+	    { OSPFD, "-nf", REQTEMP, NULL }, call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",  "test staged OSPFd config",
             { OSPFD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",        "test and appy staged OSPFd config",
@@ -153,7 +155,7 @@ struct ctl ctl_ospf6[] = {
 	    T_EXEC },
 	{ "edit",           "edit, test and stage OSPF6d config",
 	    { "ospf6", NULL }, { OSPF6D, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",   "test staged OSPF6d config",   
             { OSPF6D, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",         "test and apply staged OSPF6d config",
@@ -175,7 +177,7 @@ struct ctl ctl_eigrp[] = {
 	    T_EXEC },
 	{ "edit",           "edit, test and stage EIGRPd config",
 	    { "eigrp", NULL }, { EIGRPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
         { "check-config",   "test staged EIGRPd config",
             { EIGRPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",         "test and apply stagged EIGRPd config",
@@ -198,7 +200,7 @@ struct ctl ctl_bgp[] = {
 	    { PKILL, "bgpd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
 	{ "edit",            "edit, test and stage OpenBGPD config",
 	    { "bgp", NULL }, { BGPD, "-nf", REQTEMP, NULL, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",    "test staged OpenBGPD config",
             { BGPD, "-nvf",REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",          "test and apply staged OpenBGPD config",
@@ -221,7 +223,7 @@ struct ctl ctl_rip[] = {
 	    { PKILL, table, "ripd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
 	{ "edit",            "edit, test and stage RIPd config",
 	    { "rip", NULL }, { RIPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",    "test staged RIPd config",
             { RIPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",	     "test and apply staged ripd config",
@@ -241,7 +243,7 @@ struct ctl ctl_ldp[] = {
 	   { PKILL, "ldpd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
 	{ "edit",          "edit, test and stage LDPd config",
 	   { "ldp", NULL }, { LDPD, "-nf", REQTEMP, NULL },
-	   call_editor, 0, T_HANDLER_FILL1 },
+	   call_editor, 0, T_HANDLER_TEST },
         { "check-config",  "test staged LDPd config",
             { LDPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",        "test and apply staged LDPd config",
@@ -264,7 +266,7 @@ struct ctl ctl_ipsec[] = {
 	    T_EXEC },
 	{ "edit",           "edit, test and stage isakmpd config",   
 	    { "ipsec", NULL }, { IPSECCTL, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",   "test staged isakmpd config",
             { IPSECCTL, "-nvvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",         "test and apply staged isakmpd config",
@@ -292,7 +294,7 @@ struct ctl ctl_ike[] = {
 	    { IKECTL, "decouple", NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "edit",           "edit, test and stage IKEd config",
 	    { "ike", NULL }, { IKED, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",   "test IKEd config",
             { IKED, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "reload",         "test and apply IKEd config",
@@ -314,7 +316,7 @@ struct ctl ctl_dvmrp[] = {
 	    T_EXEC },
 	{ "edit",          "edit,test and stage DVMRPd config",
 	    { "dvmrp",  NULL }, { DVMRPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "config-test",   "test staged DVMRPd config",
             { DVMRPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "log",           "configure DVMRPd logging, brief/verbose",
@@ -332,7 +334,7 @@ struct ctl ctl_rad[] = {
 	    { PKILL, "rad", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
 	{ "edit",           "edit,test and stage RAD config",
 	    { "rad", NULL}, { RAD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",   "test staged RAD config",                                   
             { RAD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -348,7 +350,7 @@ struct ctl ctl_ifstate[] = {
 	    T_EXEC },
 	{ "edit",           "edit, test and stage ifstated config",
 	    { "ifstate", NULL }, { IFSTATED, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "config-test",    "test staged ifstated config ",
             { IFSTATED, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -364,7 +366,7 @@ struct ctl ctl_sasync[] = {
 	    T_EXEC },
 	{ "edit",         "edit, test and stage SAsyncd config",
 	    { "sasync", NULL }, { SASYNCD, "-nvvc", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config", "test staged SAsyncd config",
             { SASYNCD, "-nvvc", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -389,7 +391,7 @@ struct ctl ctl_nppp[] = {
 	    T_EXEC },
 	{ "edit",	    "edit ,test and stage nPPPd config",
 	    { "nppp", NULL }, { NPPPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",   "test staged nPPPd config",
             { NPPPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -405,7 +407,7 @@ struct ctl ctl_dhcp[] = {
 	    DB_X_DISABLE, T_EXEC },
 	{ "edit",          "edit,test and stage DHCPd config",
 	    { "dhcp", NULL }, { DHCPD, "-nc", REQTEMP, NULL }, call_editor, 0,
-	    T_HANDLER_FILL1 },
+	    T_HANDLER_TEST },
 	{ "config-test",   "test staged DHCPd config",
             { DHCPD, "-nc", REQTEMP, "-l", DHCPLEASES, NULL }, { NULL },
 	    NULL, 0, T_EXEC },
@@ -425,7 +427,7 @@ struct ctl ctl_snmp[] = {
 	    T_EXEC },
 	{ "edit",          "edit,test and stage OpenSNMPD config",
 	    { "snmp", NULL }, { SNMPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "config-test",   "test staged OpenSNMPD config",
             { SNMPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -441,7 +443,7 @@ struct ctl ctl_sshd[] = {
 	    DB_X_DISABLE, T_EXEC },
 	{ "edit",            "edit, test and stage OpenSSHD config",
 	    { "sshd", NULL }, { SSHD, "-tf", REQTEMP, NULL }, call_editor, 0,
-	    T_HANDLER_FILL1 },
+	    T_HANDLER_TEST },
 	{ "config-test",     "test staged OpenSSHD config",
             { SSHD, "-tf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -456,7 +458,7 @@ struct ctl ctl_ntp[] = {
 	    { PKILL, "ntpd", NULL }, { NULL }, NULL, DB_X_DISABLE, T_EXEC },
 	{ "edit",             "edit, test and stage OpenNTPD config",
 	    { "ntp", NULL }, { NTPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",     "test staged OpenNTPD config",
             { NTPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
@@ -472,7 +474,7 @@ struct ctl ctl_relay[] = {
 	    T_EXEC },
         { "edit",             "edit, test and stage relayd config",
 	    { "relay", NULL }, { RELAYD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "check-config",     "test staged relayd config",
             { RELAYD, "-nvf", REQTEMP, NULL }, { NULL}, NULL, 0, T_EXEC },
         { "reload",           "test and apply staged relayd config",
@@ -503,7 +505,7 @@ struct ctl ctl_smtp[] = {
 	    T_EXEC },
 	{ "edit",          "edit,test and stage OpenSMTPD config",
 	    { "smtp", NULL }, { SMTPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "config-test",   "test OpenSMTPD config",
             { SMTPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "log",           "set OpenSMTPD logging brief/verbose config",
@@ -570,7 +572,7 @@ struct ctl ctl_inet[] = {
 	    { PKILL, table, "inetd", NULL }, { NULL }, NULL, DB_X_DISABLE,
 	    T_EXEC },
 	{ "edit",       "edit inetd superserver config",
-	    { "inet", NULL, NULL }, { NULL }, call_editor, 0, T_HANDLER_FILL1 },
+	    { "inet", NULL, NULL }, { NULL }, call_editor, 0, T_HANDLER_TEST },
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
 };
 
@@ -583,7 +585,7 @@ struct ctl ctl_ldap[] = {
 	    T_EXEC },
 	{ "edit",           "edit, test and stage LDAPd config",
 	    { "ldap", NULL }, { LDAPD, "-nf", REQTEMP, NULL },
-	    call_editor, 0, T_HANDLER_FILL1 },
+	    call_editor, 0, T_HANDLER_TEST },
 	{ "config-test",    "test staged LDAPd config",
             { LDAPD, "-nvf", REQTEMP, NULL }, { NULL }, NULL, 0, T_EXEC },
 	{ "log",            "config LDAPd logging, brief/verbose",
@@ -595,13 +597,6 @@ struct ctl ctl_ldap[] = {
 	{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
 };
 
-void
-ctl_symlink(char *temp, char *real, char *z)
-{
-	rmtemp(temp);
-	symlink(real, temp);
-}
-
 /* flag to other nsh sessions or nsh conf() that actions have been taken */
 void
 flag_x(char *name, char *daemon, int dbflag, char *data)
@@ -619,7 +614,7 @@ flag_x(char *name, char *daemon, int dbflag, char *dat
 
 /* the main entry point into ctl.c from CLI */
 int
-ctlhandler(int argc, char **argv, char *modhvar)
+ctlhandler(int argc, char **argv, ...)
 {
 	struct daemons *daemons;
 	struct ctl *x;
@@ -629,7 +624,13 @@ ctlhandler(int argc, char **argv, char *modhvar)
 	char **fillargs;
 	int rv = 0;
 	int nargs;
+	va_list ap;
+	char *modhvar;
 
+	va_start(ap, argv);
+	modhvar = va_arg(ap, char *);
+	va_end(ap);
+
 	/* loop daemon list to find table pointer */
 	daemons = (struct daemons *) genget(hname, (char **)ctl_daemons,
 	    sizeof(struct daemons));
@@ -689,44 +690,21 @@ ctlhandler(int argc, char **argv, char *modhvar)
 	case T_HANDLER:
 		/* pointer to handler routine, fill main args */
 		nargs = fill_tmpfile(fillargs, tmpfile, tmp_args);
-		switch (nargs) {
-		case 0:
-			(*x->handler)();
-			break;
-		case 1:
-			(*x->handler)(tmp_args[0]);
-			break;
-		case 2:
-			(*x->handler)(tmp_args[0], tmp_args[1]);
-			break;
-		case 3:
-			(*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2]);
-			break;
-		case 4:
-			(*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2],
-			    tmp_args[3]);
-			break;
-		case 5:
-			(*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2],
-			    tmp_args[3], tmp_args[4]);
-			break;
-		case 6:
-			(*x->handler)(tmp_args[0], tmp_args[1], tmp_args[2],
-			    tmp_args[3], tmp_args[4], tmp_args[5]);
-			break;
-		case NOPTFILL: /* bump this when adding more cases */
-		default:
+		/* bump NOPTFILL when adding more arguments */
+		if (nargs < NOPTFILL) {
+			(*x->handler)(nargs, tmp_args);
+		} else {
 			printf("%% handler %s %s requires too many "
 			    "arguments: %d\n", hname, argv[1], nargs);
 			break;
 		}
 	break;
-	case T_HANDLER_FILL1:
-		/* pointer to handler routine, fill args @ args[1] pointer */
+	case T_HANDLER_TEST:
+		/* pointer to handler with a test command, fill test args */
 		if (fill_tmpfile(x->test_args, tmpfile, tmp_args))
-			(*x->handler)(fillargs[0], tmp_args, fillargs[2]);
+			(*x->handler)(1, &fillargs[0], tmp_args);
 		else
-			(*x->handler)(fillargs[0], x->test_args, fillargs[2]);
+			(*x->handler)(1, &fillargs[0], x->test_args);
 	break;
 	case T_EXEC:
 		/* command to execute via execv syscall, fill main args */
@@ -746,13 +724,13 @@ done:
 }
 
 void
-restart_dhcpd(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4)
+restart_dhcpd(int argc, char **argv, ...)
 {
 	char *argv_pkill[] = { PKILL, table, "dhcpd", NULL };
 
 	cmdargs(argv_pkill[0], argv_pkill);
 	sleep(1);
-	start_dhcpd(arg0, arg1, arg2, arg3, arg4);
+	start_dhcpd(argc, argv);
 }
 
 /*
@@ -784,8 +762,9 @@ fill_tmpfile(char **fillargs, char *tmpfile, char **tm
 }
 
 void
-edit_crontab(char *name)
+edit_crontab(int argc, char **argv, ...)
 {
+	char *name = argv[0];
 	char *crontab_argv[] = { CRONTAB, "-u", "root", "-l", NULL };
 	char tmpfile[PATH_MAX];
 	int found = 0;
@@ -835,8 +814,9 @@ done:
 }
 
 void
-install_crontab(char *name)
+install_crontab(int argc, char **argv, ...)
 {
+	char *name = argv[0];
 	char *crontab_argv[] = { CRONTAB, "-u", "root", NULL, NULL };
 	char tmpfile[PATH_MAX];
 	int fd, found = 0;
@@ -865,18 +845,25 @@ install_crontab(char *name)
 }
 
 void
-edit_motd(char *name)
+edit_motd(int argc, char **argv, ...)
 {
-	call_editor(name, NULL, NULL);
+	call_editor(argc, argv);
 }
 
 void
-call_editor(char *name, char **args, char *z)
+call_editor(int argc, char **argv, ...)
 {
+	char *name = argv[0];
 	int found = 0;
 	char tmpfile[64];
 	struct daemons *daemons;
+	va_list ap;
+	char **args;
 
+	va_start(ap, argv);
+	args = va_arg(ap, char **);
+	va_end(ap);
+
 	for (daemons = ctl_daemons; daemons->name != 0; daemons++) {
 		if (strncmp(daemons->name, name, strlen(name)) == 0) {
 			found = 1;
@@ -1120,7 +1107,7 @@ rmtemp(char *file)
 }
 
 void
-start_dhcpd(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4)
+start_dhcpd(int argc, char **argv, ...)
 {
 	struct if_nameindex *ifn_list, *ifnp;
 	char **dhcpd_args = NULL;
@@ -1169,16 +1156,16 @@ start_dhcpd(char *arg0, char *arg1, char *arg2, char *
 	}
 
 	i = 0;
-	dhcpd_args[i++] = arg0; /* dhcpd */
-	dhcpd_args[i++] = arg1; /* -c */
-	dhcpd_args[i++] = arg2; /* dhcpd.conf */
-	dhcpd_args[i++] = arg3; /* -l */
+	dhcpd_args[i++] = argv[0]; /* dhcpd */
+	dhcpd_args[i++] = argv[1]; /* -c */
+	dhcpd_args[i++] = argv[2]; /* dhcpd.conf */
+	dhcpd_args[i++] = argv[3]; /* -l */
 	if (cli_rtable != 0) {
 		snprintf(leasedb, sizeof(leasedb), "%s.%d",
-		    arg4, cli_rtable);
+		    argv[4], cli_rtable);
 		dhcpd_args[i++] = leasedb; /* rdomain's leasedb */
 	} else 
-		dhcpd_args[i++] = arg4; /* default leasedb */
+		dhcpd_args[i++] = argv[4]; /* default leasedb */
 
 	for (ifnp = ifn_list; ifnp->if_name != NULL; ifnp++) {
 		int flags, rdomain;
@@ -1195,7 +1182,7 @@ start_dhcpd(char *arg0, char *arg1, char *arg2, char *
 	}
 	dhcpd_args[i] = NULL;
 
-	cmdargs(arg0, dhcpd_args);
+	cmdargs(argv[0], dhcpd_args);
 done:
 	if_freenameindex(ifn_list);
 	free(dhcpd_args);
blob - 1d5f9ba1bb4679f08e868a87794e6443df805da9
blob + 5695aa1cc3e00102dab7f6f7b6dbe5228b52120f
--- ctl.h
+++ ctl.h
@@ -69,20 +69,20 @@
 #define IFNAME  (void *)3
 #define REQTEMP (void *)4                                                       
 #define SIZE_CONF_TEMP 64
-int ctlhandler(int, char **, char *);
+int ctlhandler(int, char **, ...);
 void rmtemp(char *);
 struct ctl {
         char *name;
         char *help;
         char *args[32];
         char *test_args[32];
-        void (*handler)();
+        void (*handler)(int, char **, ...);
         int flag_x;
         int type;
 };
 
 #define T_HANDLER       1
-#define T_HANDLER_FILL1 2
+#define T_HANDLER_TEST  2
 #define T_EXEC          3
 struct daemons {
         char *name;
blob - 5f7bb39e4b9ecc29ba5dbcf43c0c431a81a07d5d
blob + d92806d81b6ea75c0e5fe742f5e7d194db8aadc0
--- ctlargs.c
+++ ctlargs.c
@@ -26,7 +26,7 @@
 #include "ctl.h"
 
 int
-pr_prot1(int argc, char **argv)
+pr_prot1(int argc, char **argv, ...)
 {
 	struct prot1 *x;
 	struct prot *prot;
blob - 3eed39cfe7a6df63939115a4588ca1b1a515f480
blob + c5a8966d0b3506a015dd105fb55b3044ddbe1d10
--- externs.h
+++ externs.h
@@ -74,9 +74,9 @@ extern char *nopterr;
 int nopt(int, char **, struct nopts *);
 
 /* ppp.c */
-int intsppp(char *, int, int, char **);
+int intsppp(int, char **, ...);
 void pppoe_ipcp(char *, int, int);
-int intpppoe(char *, int, int, char **);
+int intpppoe(int, char **, ...);
 int is_pppoe(char *, int);
 #define NSH_PPPOE_IPADDR_IPCP 1
 #define NSH_PPPOE_IPADDR_STATIC 2
@@ -144,7 +144,7 @@ extern u_long rtm_inits;
 #define FLUSH 0
 struct rtdump *getrtdump(int, int, int);
 void freertdump(struct rtdump *);
-int monitor(int, char **);
+int monitor(int, char **, ...);
 int rtmsg(int, int, int, int, int);
 void flushroutes(int, int);
 void bprintf(FILE *, int, u_char *);
@@ -191,7 +191,7 @@ extern pid_t child;
 #ifndef DHCPLEASES
 #define DHCPLEASES	"/var/db/dhcpd.leases"
 #endif
-int quit(void);
+int quit(int, char **, ...);
 void sigalarm(int);
 void command(void);
 int argvtostring(int, char **, char *, int);
@@ -206,7 +206,7 @@ void restoreprompt(void);
 extern char prompt[128];
 extern char saved_prompt[sizeof(prompt)];
 
-int group (int, char **);
+int group (int, char **, ...);
 void gen_help(char **, char *, char *, int);
 void makeargv(void);
 extern size_t cursor_argc;
@@ -218,7 +218,7 @@ typedef struct cmd {
 	char *complete;		/* context sensitive completion list */
 	char **table;		/* next table for context completion */
 	int stlen;		/* struct length (for rows in next table) */
-	int (*handler) ();	/* routine which executes command */
+	int (*handler) (int, char **, ...); /* routine which executes command */
 	int needpriv;		/* Do we need privilege to execute? */
 	int needconfig;		/* Do we need config mode to execute? */
 	int nocmd;		/* Can we specify 'no ...command...'? */
@@ -233,7 +233,7 @@ typedef struct menu {
 	int stlen;		/* struct length (for rows in next table) */
 	int minarg;		/* Minimum number of arguments */
 	int maxarg;		/* Maximum number of arguments */
-	int (*handler)();	/* Routine to perform (for special ops) */
+	int (*handler)(int, char **, ...);	/* Routine to perform */
 } Menu;
 
 struct intlist {
@@ -242,7 +242,7 @@ struct intlist {
 	char *complete;		/* context sensitive completion list */
 	char **table;		/* next table for context completion */
 	int stlen;		/* struct length (for rows in next table) */
-	int (*handler)();       /* Routine to perform (for special ops) */
+	int (*handler)(int, char **, ...);       /* Routine to perform */
 	int nocmd;		/* Can we specify 'no ...command...'? */
 };
 
@@ -274,9 +274,9 @@ const char *get_string(const char *, const char *, u_i
 void make_string(char *str, int, const u_int8_t *buf, int);
 int get_nwinfo(char *, char *, int, int);
 int get_nwpowersave(int, char *);
-int intnwkey(char *, int, int, char **);
-int inttxpower(char *, int, int, char **);
-int intbssid(char *, int, int, char **);
+int intnwkey(int, char **, ...);
+int inttxpower(int, char **, ...);
+int intbssid(int, char **, ...);
 
 /* stats.c */
 void rt_stats(void);
@@ -306,13 +306,13 @@ int Ambiguous(void *);
 
 /* sysctl.c */
 int sysctl_int(int[], int, int);
-int ipsysctl(int, char *, char *, int);
+int ipsysctl(int, char **, ...);
 void conf_sysctls(FILE *);
 
 /* route.c */
 #define NO_NETMASK 0
 #define ASSUME_NETMASK 1
-int route(int, char**);
+int route(int, char**, ...);
 void show_route(char *, int);
 int is_ip_addr(char *);
 #ifdef _IP_T_
@@ -339,10 +339,10 @@ int parse_ipv6(char *, struct in6_addr *);
 #define DEFAULT_LLPRIORITY 3
 void imr_init(char *);
 int is_valid_ifname(char *);
-int show_int(int, char **, FILE *);
-int show_vlans(int, char **);
-int show_ip(int, char **);
-int show_autoconf(int, char **);
+int show_int(int, char **, ...);
+int show_vlans(int, char **, ...);
+int show_ip(int, char **, ...);
+int show_autoconf(int, char **, ...);
 int get_rdomain(int, char *);
 int get_ifdata(char *, int);
 int get_ifflags(char *, int);
@@ -353,30 +353,30 @@ u_int32_t in4_netaddr(u_int32_t, u_int32_t);
 u_int32_t in4_brdaddr(u_int32_t, u_int32_t);
 extern struct ghs intiphelp[];
 extern struct ghs intip6help[];
-int intip(char *, int, int, char **);
+int intip(int, char **, ...);
 int intipcp(char *, int, int, char **);
-int intmtu(char *, int, int, char **);
-int intkeepalive(char *, int, int, char **);
-int intrdomain(char *, int, int, char **);
-int intdhcrelay(char *, int, int, char **);
-int intmetric(char *, int, int, char **);
-int intllprio(char *, int, int, char **);
-int intflags(char *, int, int, char **);
-int intxflags(char *, int, int, char **);
+int intmtu(int, char **, ...);
+int intkeepalive(int, char **, ...);
+int intrdomain(int, char **, ...);
+int intdhcrelay(int, char **, ...);
+int intmetric(int, char **, ...);
+int intllprio(int, char **, ...);
+int intflags(int, char **, ...);
+int intxflags(int, char **, ...);
 int intaf(char *, int, int, char **);
-int intlink(char *, int, int, char **);
-int intnwid(char *, int, int, char **);
-int intpowersave(char *, int, int, char **);
-int intdesc(char *, int, int, char **);
-int intpflow(char *, int, int, char **);
-int intlladdr(char *, int, int, char **);
-int intgroup(char *, int, int, char **);
-int intrtlabel(char *, int, int, char **);
-int intparent(char *, int, int, char **);
-int intpatch(char *, int, int, char **);
-int intmpls(char *, int, int, char **);
-int intpwe3(char *, int, int, char **);
-int intvnetflowid(char *, int, int, char **);
+int intlink(int, char **, ...);
+int intnwid(int, char **, ...);
+int intpowersave(int, char **, ...);
+int intdesc(int, char **, ...);
+int intpflow(int, char **, ...);
+int intlladdr(int, char **, ...);
+int intgroup(int, char **, ...);
+int intrtlabel(int, char **, ...);
+int intparent(int, char **, ...);
+int intpatch(int, char **, ...);
+int intmpls(int, char **, ...);
+int intpwe3(int, char **, ...);
+int intvnetflowid(int, char **, ...);
 int addaf(char *, int, int);
 int removeaf(char *, int, int);
 int check_daemon_control_socket(const char *);
@@ -388,7 +388,7 @@ char *get_hwdaddr(char *);
 void intr(void);
 
 /* version.c */
-int version(int, char **);
+int version(int, char **, ...);
 
 /* compile.c */
 extern char compiled[], compiledby[], compiledon[], compilehost[];
@@ -403,20 +403,20 @@ int bridge_addrs(int, char *, char *, char *, FILE *);
 int set_ifflag(int, char *, short);
 int clr_ifflag(int, char *, short);
 int is_bridge(int, char *);
-int brport(char *, int, int, char **);
-int brval(char *, int, int, char **);
-int brrule(char *, int, int, char **);
-int brstatic(char *, int, int, char **);
-int brpri(char *, int, int, char **);
-int flush_bridgedyn(char *);
-int flush_bridgeall(char *);
-int flush_bridgerule(char *, char*);
-int brprotect(char *, int, int, char **);
-int show_bridges(int, char **);
+int brport(int, char **, ...);
+int brval(int, char **, ...);
+int brrule(int, char **, ...);
+int brstatic(int, char **, ...);
+int brpri(int, char **, ...);
+int flush_bridgedyn(int , char **, ...);
+int flush_bridgeall(int, char **, ...);
+int flush_bridgerule(int, char **, ...);
+int brprotect(int, char **, ...);
+int show_bridges(int, char **, ...);
 
 /* tunnel.c */
-int inttunnel(char *, int, int, char **);
-int intvnetid(char *, int, int, char **);
+int inttunnel(int, char **, ...);
+int intvnetid(int, char **, ...);
 int get_physrtable(int, char *);
 int get_physttl(int, char *);
 int get_physecn(int, char *);
@@ -428,8 +428,8 @@ int64_t get_vnetid(int, char *);
 int media_status(int, char *, char *, FILE *);
 void media_supported(int, char *, char *, char *, FILE *);
 int phys_status(int, char *, char *, char *, int, int);
-int intmedia(char *, int, int, char **);
-int intmediaopt(char *, int, int, char **);
+int intmedia(int, char **, ...);
+int intmediaopt(int, char **, ...);
 int conf_media_status(FILE *, int, char *);
 struct ifmediareq;
 const char *get_ifm_linkstate_str(struct ifmediareq *);
@@ -441,13 +441,13 @@ const char *get_ifm_subtype_str(uint64_t);
 #define NSHPASSWD_TEMP "/var/run/nshpasswd"
 int read_pass(char *, size_t);
 int gen_salt(char *, size_t);
-int enable(int, char **);
+int enable(int, char **, ...);
 
 /* pfsync.c */
 #define PFSYNC_MAXUPDATES 128
-int intsyncdev(char *, int, int, char **);
-int intsyncpeer(char *, int, int, char  **);
-int intmaxupd(char *, int, int, char **);
+int intsyncdev(int, char **, ...);
+int intsyncpeer(int, char **, ...);
+int intmaxupd(int, char **, ...);
 int conf_pfsync(FILE *, int, char *);
 
 /* carp.c */
@@ -456,26 +456,26 @@ int conf_pfsync(FILE *, int, char *);
 #define CARP_VHID 2
 #define CARP_PEER 3
 #define CARP_BALANCING 4
-int intcarp(char *, int, int, char **);
-int intcpass(char *, int, int, char **);
-int intcnode(char *, int, int, char **);
+int intcarp(int, char **, ...);
+int intcpass(int, char **, ...);
+int intcnode(int, char **, ...);
 int conf_carp(FILE *, int, char *);
 int carp_state(int, char *, FILE *);
-int intcdev(char *, int, int, char **);
+int intcdev(int, char **, ...);
 int carplock(int);
 
 /* trunk.c */
-int inttrunkport(char *, int, int, char **);
-int inttrunkproto(char *, int, int, char **);
+int inttrunkport(int, char **, ...);
+int inttrunkproto(int, char **, ...);
 int conf_trunk(FILE *output, int ifs, char *ifname);
 void show_trunk(int ifs, char *ifname, FILE *);
 
 /* who.c */
-int who(int, char **);
+int who(int, char **, ...);
 
 /* arp.c */
 int arpget(const char *);
-int arpset(int, char **);
+int arpset(int, char **, ...);
 void arpdump(void);
 void conf_arp(FILE *, char *);
 char *sec2str(time_t);
@@ -483,7 +483,7 @@ struct sockaddr_dl;
 char *ether_str(struct sockaddr_dl *);
 
 /* ndp.c */
-int ndpset(int, char **);
+int ndpset(int, char **, ...);
 void ndpget(const char *);
 int ndpdelete(const char *);
 struct sockaddr_in6;
@@ -491,7 +491,7 @@ void ndpdump(struct sockaddr_in6 *, int);
 void conf_ndp(FILE *output, char *delim);
 
 /* nameserver.c */
-int nameserverset(int, char **);
+int nameserverset(int, char **, ...);
 void conf_nameserver(FILE *);
 
 /* more.c */
@@ -558,13 +558,13 @@ int pflow_addr(const char *, struct sockaddr_storage *
 int pflow_status(int, int, char *, char *);
 
 /* wg.c */
-int intwg(char *, int, int, char **);
-int intwgpeer(char *, int, int, char **);
+int intwg(int, char **, ...);
+int intwgpeer(int, char **, ...);
 void conf_wg(FILE *, int, char *);
 void show_wg(int, char *, FILE *);
 
 /* umb.c */
-int intumb(char *, int, int, char **);
+int intumb(int, char **, ...);
 void conf_umb(FILE *, int, char *);
 void show_umb(int, char *, FILE *);
 
@@ -575,7 +575,7 @@ int mbs2ws(wchar_t **, size_t *, const char *);
 int mbsavis(char**, int *, const char *);
 
 /* ctlargs.c */
-int pr_prot1(int, char **);
+int pr_prot1(int, char **, ...);
 char **step_optreq(char **, char **, int, char **, int);
 
 /* hashtable.c */
blob - 9564ad11cfdf44c8f81f31ff2f0d694bd6248954
blob + 34c3d146142d071df0804f3dd71f4585db909e98
--- helpcommands.c
+++ helpcommands.c
@@ -27,7 +27,7 @@
 #include "commands.h"
 
 int
-show_help(int argc, char **argv)
+show_help(int argc, char **argv, ...)
 {
 	Menu *s; /* pointer to current command */
 	u_int z = 0;
@@ -77,7 +77,7 @@ gen_help(char **x, char *cmdprefix, char *descrsuffix,
  * Help command.
  */
 int
-help(int argc, char **argv)
+help(int argc, char **argv, ...)
 {
 	Command *c;
 
blob - 702bb2ba0c42a7061b2a8d5e5ccf4f1eea9dbeb7
blob + b530a2fd7bcb9c19d00c32d3fcb131ad6f5df55c
--- ieee80211.c
+++ ieee80211.c
@@ -64,6 +64,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
+#include <stdarg.h>
 #include <sys/limits.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
@@ -166,12 +167,20 @@ make_string(char *str, int str_len, const u_int8_t *bu
 
 /* was setifnwkey() */
 int
-intnwkey(char *ifname, int ifs, int argc, char **argv)
+intnwkey(int argc, char **argv, ...)
 {
 	int i, len, set;
 	char *cp = NULL, *val = NULL;
 	struct ieee80211_nwkey nwkey;
 	u_int8_t keybuf[IEEE80211_WEP_NKID][16];
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	if (NO_ARG(argv[0])) {
 		set = 0;
@@ -426,12 +435,20 @@ get_nwinfo(char *ifname, char *str, int str_len, int t
 }
 
 int
-inttxpower(char *ifname, int ifs, int argc, char **argv)
+inttxpower(int argc, char **argv, ...)
 {
 	const char *errmsg = NULL;
 	struct ieee80211_txpower txpower;
 	short dbm, set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -472,12 +489,20 @@ inttxpower(char *ifname, int ifs, int argc, char **arg
 }
 
 int
-intbssid(char *ifname, int ifs, int argc, char **argv)
+intbssid(int argc, char **argv, ...)
 {
 	struct ieee80211_bssid bssid;
 	struct ether_addr *ea;
 	short set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
blob - ab83616edf04a266cb51b2ab7adb8f168bdef2e7
blob + e0d9b2290cd49156e41c518c76e2e3e882a1a6f9
--- if.c
+++ if.c
@@ -16,6 +16,7 @@
 
 #include <sys/tree.h>
 
+#include <stdarg.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <fcntl.h>
@@ -229,7 +230,7 @@ show_int_status(char *ifname, int ifs, FILE *outfile)
 }
 
 int
-show_int(int argc, char **argv, FILE *outfile)
+show_int(int argc, char **argv, ...)
 {
 	struct ifaddrs *ifap, *ifa;
 	struct if_nameindex *ifn_list, *ifnp;
@@ -238,7 +239,8 @@ show_int(int argc, char **argv, FILE *outfile)
 	struct sockaddr_in *sin = NULL, *sinmask = NULL, *sindest;
 	struct sockaddr_in6 *sin6 = NULL, *sin6mask = NULL, *sin6dest;
 	struct timeval tv;
-
+	FILE *outfile;
+	va_list ap;
 	short tmp;
 	int ifs, br, flags, days, hours, mins, pntd;
 	int ippntd = 0;
@@ -251,6 +253,10 @@ show_int(int argc, char **argv, FILE *outfile)
 
 	memset(ifname, 0, sizeof(ifname));
 
+	va_start(ap, argv);
+	outfile = va_arg(ap, FILE *);
+	va_end(ap);
+
 	if (argc == 4) {
 		/*
 		 * Allow "interface-name interface-number" as some
@@ -595,7 +601,7 @@ show_int(int argc, char **argv, FILE *outfile)
 }
 
 int
-show_autoconf(int argc, char **argv)
+show_autoconf(int argc, char **argv, ...)
 {
 	struct if_nameindex *ifn_list, *ifnp;
 	char *ifname = NULL;
@@ -719,7 +725,7 @@ RB_PROTOTYPE(ip_tree, ip_tree_entry, entry, ip_tree_cm
 RB_GENERATE(ip_tree, ip_tree_entry, entry, ip_tree_cmp);
 
 int
-show_ip(int argc, char **argv)
+show_ip(int argc, char **argv, ...)
 {
 	struct ifaddrs *ifap, *ifa;
 	struct sockaddr_in *sin = NULL, *sinmask = NULL;
@@ -1220,7 +1226,7 @@ intipusage(const char *cmdname, const char *msg)
 }
 
 int
-intip(char *ifname, int ifs, int argc, char **argv)
+intip(int argc, char **argv, ...)
 {
 	int s, set, flags, argcmax;
 	int argc0 = argc;
@@ -1233,6 +1239,14 @@ intip(char *ifname, int ifs, int argc, char **argv)
 	/* ipv6 structures */
 	struct in6_addr in6dest;
 	struct in6_aliasreq ip6req;
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	if (NO_ARG(argv[0])) {
 		set = 0;
@@ -1333,7 +1347,7 @@ intip(char *ifname, int ifs, int argc, char **argv)
 				argv_dhcp = args;
 				argc_dhcp = nitems(args) - 1;
 			}
-			return intxflags(ifname, ifs, argc_dhcp, argv_dhcp);
+			return intxflags(argc_dhcp, argv_dhcp, ifname, ifs);
 		} else {
 			printf("%% cannot get DHCP leases because dhcpleased "
 			    "is not running\n");
@@ -1354,7 +1368,7 @@ intip(char *ifname, int ifs, int argc, char **argv)
 			argv_xflags = args;
 			argc_xflags = nitems(args) - 1;
 		}
-		return intxflags(ifname, ifs, argc_xflags, argv_xflags);
+		return intxflags(argc_xflags, argv_xflags, ifname, ifs);
 	}
 
 	memset(&ip, 0, sizeof(ip));
@@ -1586,13 +1600,21 @@ ipv6ll_db_store(struct sockaddr_in6 *sin6, struct sock
  * addr/port parsing lifted from sbin/ifconfig/ifconfig.c
  */
 int
-intpflow(char *ifname, int ifs, int argc, char **argv)
+intpflow(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct pflowreq preq;
 	int set;
 	const char *errmsg = NULL;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -1654,11 +1676,19 @@ intpflow(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intpatch(char *ifname, int ifs, int argc, char **argv)
+intpatch(int argc, char **argv, ...)
 {
 	int set;
 	struct ifreq ifr;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -1693,12 +1723,20 @@ intpatch(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intmtu(char *ifname, int ifs, int argc, char **argv)
+intmtu(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	int set;
 	const char *errmsg = NULL;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -1732,12 +1770,20 @@ intmtu(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intkeepalive(char *ifname, int ifs, int argc, char **argv)
+intkeepalive(int argc, char **argv, ...)
 {
 	struct ifkalivereq ikar;
 	int set;
 	const char *errmsg = NULL;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -1800,7 +1846,7 @@ static struct mplsc {
 
 /* from ifconfig.c */
 int
-intmpls(char *ifname, int ifs, int argc, char **argv)
+intmpls(int argc, char **argv, ...)
 {
 	int set;
 	unsigned long cmd;
@@ -1808,7 +1854,15 @@ intmpls(char *ifname, int ifs, int argc, char **argv)
 	struct shim_hdr shim;
 	struct mplsc *x;
 	const char *errstr;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	bzero(&ifr, sizeof(ifr));
 
 	strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
@@ -1941,7 +1995,7 @@ pwe3usage(void)
 }
 
 int
-intpwe3(char *ifname, int ifs, int argc, char **argv)
+intpwe3(int argc, char **argv, ...)
 {
 	int set, ch, error;
 	unsigned long cmd;
@@ -1953,6 +2007,14 @@ intpwe3(char *ifname, int ifs, int argc, char **argv)
 	struct if_laddrreq req;
 	struct addrinfo hints, *res;
 	struct sockaddr_mpls *smpls = (struct sockaddr_mpls *)&req.dstaddr;
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	bzero(&ifr, sizeof(ifr));
 	bzero(&req, sizeof(req));
@@ -2066,12 +2128,18 @@ intpwe3(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intdhcrelay(char *ifname, int ifs, int argc, char **argv)
+intdhcrelay(int argc, char **argv, ...)
 {
-	char *cmd[] = { DHCRELAY, "-i", ifname, NULL, NULL };
+	char *cmd[] = { DHCRELAY, "-i", NULL, NULL, NULL };
 	int set, alen;
 	struct in_addr notused;
+	va_list ap;
+	char *ifname;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -2135,14 +2203,22 @@ intdhcrelay(char *ifname, int ifs, int argc, char **ar
 }
 
 int
-intmetric(char *ifname, int ifs, int argc, char **argv)
+intmetric(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	int set, max;
 	unsigned long theioctl;
 	char *type;
 	const char *errmsg = NULL;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -2200,12 +2276,20 @@ intmetric(char *ifname, int ifs, int argc, char **argv
 }
 
 int
-intllprio(char *ifname, int ifs, int argc, char **argv)
+intllprio(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	int set;
 	const char *errmsg = NULL;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -2246,11 +2330,19 @@ intllprio(char *ifname, int ifs, int argc, char **argv
 }
 
 int
-intgroup(char *ifname, int ifs, int argc, char **argv)
+intgroup(int argc, char **argv, ...)
 {
 	int set, i;
 	struct ifgroupreq ifgr;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -2301,11 +2393,19 @@ intgroup(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intrtlabel(char *ifname, int ifs, int argc, char **argv)
+intrtlabel(int argc, char **argv, ...)
 {
 	int set;
 	struct ifreq ifr;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -2343,12 +2443,20 @@ intrtlabel(char *ifname, int ifs, int argc, char **arg
 }
 
 int
-intparent(char *ifname, int ifs, int argc, char **argv)
+intparent(int argc, char **argv, ...)
 {
 	int set, ret;
 	unsigned long cmd;
 	struct if_parent ifp;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -2399,10 +2507,18 @@ intparent(char *ifname, int ifs, int argc, char **argv
 }
 
 int
-intflags(char *ifname, int ifs, int argc, char **argv)
+intflags(int argc, char **argv, ...)
 {
 	int set, value, flags, iftype;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2510,10 +2626,18 @@ intaf(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intxflags(char *ifname, int ifs, int argc, char **argv)
+intxflags(int argc, char **argv, ...)
 {
 	int set, value, flags;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2566,11 +2690,19 @@ intxflags(char *ifname, int ifs, int argc, char **argv
 }
 
 int
-intlink(char *ifname, int ifs, int argc, char **argv)
+intlink(int argc, char **argv, ...)
 {
 	const char *errmsg = NULL;
 	int set, i, flags, value = 0;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2628,12 +2760,20 @@ intlink(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intnwid(char *ifname, int ifs, int argc, char **argv)
+intnwid(int argc, char **argv, ...)
 {
 	struct ieee80211_nwid nwid;
 	struct ifreq ifr;
 	int set, len;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2671,12 +2811,20 @@ intnwid(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intpowersave(char *ifname, int ifs, int argc, char **argv)
+intpowersave(int argc, char **argv, ...)
 {
 	const char *errmsg = NULL;
 	struct ieee80211_power power;
 	int  set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2722,14 +2870,23 @@ intpowersave(char *ifname, int ifs, int argc, char **a
 }
 
 int
-intlladdr(char *ifname, int ifs, int argc, char **argv)
+intlladdr(int argc, char **argv, ...)
 {
 	StringList *hwdaddr;
 	char *lladdr, llorig[sizeof("00:00:00:00:00:00") + 1];
 	struct ether_addr *addr;
 	struct ifreq ifr;
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
+
 	if (NO_ARG(argv[0])) {
 		argv++;
 		argc--;
@@ -2822,12 +2979,20 @@ intlladdr(char *ifname, int ifs, int argc, char **argv
 }
 
 int
-intrdomain(char *ifname, int ifs, int argc, char **argv)
+intrdomain(int argc, char **argv, ...)
 {
 	int set, rdomain;
 	const char *errmsg = NULL;
 	struct ifreq ifr;
+	va_list ap;
+	char *ifname;
+	int ifs; 
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2862,12 +3027,20 @@ intrdomain(char *ifname, int ifs, int argc, char **arg
 }
 
 int
-intdesc(char *ifname, int ifs, int argc, char **argv)
+intdesc(int argc, char **argv, ...)
 {
 	int set;
 	char desc[IFDESCRSIZE];
 	struct ifreq ifr;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -2898,11 +3071,19 @@ intdesc(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intvnetflowid(char *ifname, int ifs, int argc, char **argv)
+intvnetflowid(int argc, char **argv, ...)
 {
 	int set;
 	struct ifreq ifr;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argv++;
@@ -3057,7 +3238,7 @@ show_vlan(int start_vnetid, int end_vnetid)
 }
 
 int
-show_vlans(int argc, char **argv)
+show_vlans(int argc, char **argv, ...)
 {
 	long long start_vnetid = -1, end_vnetid = -1;
 	const char *errstr;
blob - b0998f7a401a66c8e179f8731398ea7bc21832c4
blob + a899258cb7f4da6759becc236358b0b715f46fc0
--- kroute.c
+++ kroute.c
@@ -280,7 +280,7 @@ _monitor_sig(int signo)
 }
 
 int
-monitor(int argc, char **argv)
+monitor(int argc, char **argv, ...)
 {
 	int s, m, n, saveverbose;
 	fd_set fds; 
blob - bf86ca8dabe0a781147f326896a21743a594b1e5
blob + 8f17b0cddf04cf5733c0c39535a23a9be92ec90d
--- media.c
+++ media.c
@@ -33,6 +33,7 @@
  */
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -73,11 +74,19 @@ const struct ifmedia_description ifm_option_descriptio
     IFM_OPTION_DESCRIPTIONS;
 
 int
-intmedia(char *ifname, int ifs, int argc, char **argv)
+intmedia(int argc, char **argv, ...)
 {
 	const char *errmsg = NULL;
 	uint64_t set, media_current, type, subtype, inst;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -137,9 +146,17 @@ intmedia(char *ifname, int ifs, int argc, char **argv)
 }
 
 int
-intmediaopt(char *ifname, int ifs, int argc, char **argv)
+intmediaopt(int argc, char **argv, ...)
 {
 	int set, media_current, mediaopt;
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	if (NO_ARG(argv[0])) {
 		set = 0;
blob - 917e6bfb84da3ced26912f497b3d97ed04be002e
blob + bdf7b2652df8577e557a90f07ce6fdc0d8bb1469
--- nameserver.c
+++ nameserver.c
@@ -74,7 +74,7 @@ resolvd_is_disabled(void)
 }
 
 int
-nameserverset(int argc, char *argv[])
+nameserverset(int argc, char *argv[], ...)
 {
 	int i, set = 1;
 
blob - fb50b6294674355067d69e1886d059c6cfa3e2a1
blob + 90e0c8505715583ce7d0d867d044903b377380bf
--- ndp.c
+++ ndp.c
@@ -117,7 +117,7 @@ char ifix_buf[IFNAMSIZ];		/* if_indextoname() */
 
 static int getsocket(void);
 int parse_host(const char *, struct sockaddr_in6 *);
-int ndpset(int, char **);
+int ndpset(int, char **, ...);
 void ndpget(const char *);
 int ndpdelete(const char *);
 void ndpdump(struct sockaddr_in6 *, int);
@@ -182,7 +182,7 @@ static int	flags, found_entry;
  * Set an individual neighbor cache entry
  */
 int
-ndpset(int argc, char *argv[])
+ndpset(int argc, char *argv[], ...)
 {
 	struct sockaddr_in6 *sin = &sin_m;
 	struct sockaddr_dl *sdl;
blob - 6eb375fbb75af8281fcd5619915fb64f2123f566
blob + eb3264d77e21a24a773e0964e5b2851cbd15accf
--- passwd.c
+++ passwd.c
@@ -298,7 +298,7 @@ write_line(const char *line, size_t len, int fd)
 }
 
 int
-enable(int argc, char **argv)
+enable(int argc, char **argv, ...)
 {
 	char *doas_argv[] = {
 		NSHDOAS_PATH_STR, NULL, NULL, NULL
@@ -362,7 +362,7 @@ enable(int argc, char **argv)
 		return 0;
 	else if (exit_code == NSH_REXEC_EXIT_CODE_QUIT) {
 		/* The child exited due to a 'quit' command. */
-		quit();
+		quit(0, NULL);
 	} else  {
 		printf("%% Privileged mode child process exited "
 		    "with error code %d\n", exit_code);
blob - 78caaff6a1e2178bd9294072c088bbfb0ed83794
blob + 701590813efe3b6b89242e334d5e3835205cdcc0
--- pfsync.c
+++ pfsync.c
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <sys/limits.h>
 #include <sys/types.h>
@@ -34,12 +35,20 @@
 #define PFSYNC_MAXUPDATES 128
 
 int
-intsyncdev(char *ifname, int ifs, int argc, char **argv)
+intsyncdev(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct pfsyncreq preq;
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -96,13 +105,21 @@ intsyncdev(char *ifname, int ifs, int argc, char **arg
 }
 
 int
-intsyncpeer(char *ifname, int ifs, int argc, char **argv)
+intsyncpeer(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct pfsyncreq preq;
 	struct addrinfo hints, *peerres;
 	int set, ecode;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -169,14 +186,22 @@ intsyncpeer(char *ifname, int ifs, int argc, char **ar
 }
 
 int
-intmaxupd(char *ifname, int ifs, int argc, char **argv)
+intmaxupd(int argc, char **argv, ...)
 {
 	struct ifreq ifr;
 	struct pfsyncreq preq;
 	u_int32_t val;
 	int set;
 	const char *errmsg = NULL;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
blob - 8ad52dbef656a881995d75842c2fbdd9477289e6
blob + b82bb9d0657687e27334efed268df533ffe44af2
--- ppp.c
+++ ppp.c
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <sys/socket.h>
 #include <sys/param.h>
@@ -68,12 +69,20 @@ peerusage(void)	
 
 /* auth proto, auth name, auth key, peer proto, peer name, peer key, peer flag */
 int
-intsppp(char *ifname, int ifs, int argc, char **argv)
+intsppp(int argc, char **argv, ...)
 {
 	struct sauthreq spa;
 	struct ifreq ifr;
 	int set, ch, i, cmd = 0;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	/* command options for 'auth' */
 	static struct nopts authopts[] = {
 		{ "proto",	req_arg,	'p' },
@@ -313,10 +322,18 @@ pppoe_ipcp(char *ifname, int ifs, int set)
 
 /* pppoe dev, pppoe svc, pppoe ac */
 int
-intpppoe(char *ifname, int ifs, int argc, char **argv)
+intpppoe(int argc, char **argv, ...)
 {
 	struct pppoediscparms parms;
 	int set, ch;
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	/* command options for 'auth' */
 	static struct nopts authopts[] = {
blob - a558cf19abc8bd22c365719553f577e6a42ebe5b
blob + 25a10ba699b50d385b2291b3bbdcb6506995eaa7
--- route.c
+++ route.c
@@ -44,7 +44,7 @@ routeusage(void)
 }
 
 int
-route(int argc, char **argv)
+route(int argc, char **argv, ...)
 {
 	u_short cmd = 0;
 	u_int32_t net;
blob - b987820def6eb3b7bc042da908ed72a34ef6a2fb
blob + 9d45212bcf2f3dfa4682063566612d2fc49d0f2b
--- sysctl.c
+++ sysctl.c
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <sys/socket.h>
@@ -196,13 +197,21 @@ struct ipsysctl pipexsysctls[] = {
 };
 
 int
-ipsysctl(int set, char *cmd, char *arg, int type)
+ipsysctl(int set, char **cmd, ...)
 {
 	int32_t larg;
 	const char *errmsg = NULL;
 	struct ipsysctl *x;
 	struct sysctltab *stab;
+	va_list ap;
+	char *arg;
+	int type;
 
+	va_start(ap, cmd);
+	arg = va_arg(ap, char *);
+	type = va_arg(ap, int);
+	va_end(ap);
+
 	for (stab = sysctls; stab-> name != NULL; stab++)
 		if(stab->pf == type)
 			break;
@@ -211,13 +220,13 @@ ipsysctl(int set, char *cmd, char *arg, int type)
 		return 0;
 	}
 
-	x = (struct ipsysctl *) genget(cmd, (char **)stab->sysctl,
+	x = (struct ipsysctl *) genget(*cmd, (char **)stab->sysctl,
 	    sizeof(struct ipsysctl));
 	if (x == 0) {
-		printf("%% Invalid argument %s\n", cmd);
+		printf("%% Invalid argument %s\n", *cmd);
 		return 0;
 	} else if (Ambiguous(x)) {
-		printf("%% Ambiguous argument %s\n", cmd);
+		printf("%% Ambiguous argument %s\n", *cmd);
 		return 0;
 	}
 
blob - 4be1b9877ac4ebf68133ff2f069e13c859483fce
blob + cbd7d80d0d901cb6bd60ef617b0101ebbb4d1b2b
--- trunk.c
+++ trunk.c
@@ -26,6 +26,7 @@
  */
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -41,11 +42,19 @@
 struct trunk_protos tpr[] = TRUNK_PROTOS;
 
 int
-inttrunkport(char *ifname, int ifs, int argc, char **argv)
+inttrunkport(int argc, char **argv, ...)
 {
 	struct trunk_reqport rp;
 	int set, i;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -114,11 +123,19 @@ inttrunkport(char *ifname, int ifs, int argc, char **a
 }
 
 int
-inttrunkproto(char *ifname, int ifs, int argc, char **argv)
+inttrunkproto(int argc, char **argv, ...)
 {
 	int i, set;
 	struct trunk_reqall ra;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
blob - 28eb4eaf23744f51e0161fc8e15780d5399e18a7
blob + 92c3754a7128122d5910b0e9e7c4ecc09fede438
--- tunnel.c
+++ tunnel.c
@@ -4,6 +4,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include <errno.h>
 #include <stdint.h>
@@ -36,10 +37,18 @@ static struct nopts tunnelopts[] = {
 };
 
 int
-intvnetid(char *ifname, int ifs, int argc, char **argv)
+intvnetid(int argc, char **argv, ...)
 {
 	int set;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
@@ -70,12 +79,20 @@ tunnelusage(void)
 }
 
 int
-inttunnel(char *ifname, int ifs, int argc, char **argv)
+inttunnel(int argc, char **argv, ...)
 {
 	int set, ch, df = 0, ecn = 0;
 	char *src = NULL, *dst = NULL, *rdomain = NULL, *ttl = NULL;
 	char *dstip = NULL, *dstport = NULL;
 	char buf[MAXHOSTNAMELEN+sizeof (":65535")];
+	va_list ap;
+	char *ifname;
+	int ifs;
+
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
 
 	if (NO_ARG(argv[0])) {
 		set = 0;
blob - cc62569dfd91f9445faca4d1c7972115be691eb7
blob + b3b15a1e6d7b72d5b5b8d9122d176ecf8c337626
--- umb.c
+++ umb.c
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include <unistd.h>
 #include <util.h>
@@ -510,11 +511,19 @@ static struct umbc {
 };
 
 int
-intumb(char *ifname, int ifs, int argc, char **argv)
+intumb(int argc, char **argv, ...)
 {
 	int set;
 	struct umbc *x;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	if (NO_ARG(argv[0])) {
 		set = 0;
 		argc--;
blob - 775ab1144d79be492896a8ba89e5d1001a7eeffc
blob + f1c8de09bf9cb77daed9fe24ad90f6b1a1fe3de1
--- version.c
+++ version.c
@@ -27,7 +27,7 @@
 #include "externs.h"
 
 int
-version(int argc, char **argv)
+version(int argc, char **argv, ...)
 {
 	char cpubuf[1024];
 	char kernver[1024];
blob - aa7eec25d1c7260b8c8851d7fd692918333b0e50
blob + e4a63e09d48fb5d27208253fa13f52076ba07538
--- wg.c
+++ wg.c
@@ -4,6 +4,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <time.h>
 #include <sys/sockio.h>
 #include <sys/ioctl.h>
@@ -454,11 +455,19 @@ static struct wgc {
 };
 
 int
-intwg(char *ifname, int ifs, int argc, char **argv)
+intwg(int argc, char **argv, ...)
 {
 	int set;
 	struct wgc *x;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	/* freshen up at the NULL basin */
         wgdata.wgd_size = 0;
         wgdata.wgd_interface = wg_interface = NULL;
@@ -557,10 +566,18 @@ wgpeerusage(void)
 }
 
 int
-intwgpeer(char *ifname, int ifs, int argc, char **argv)
+intwgpeer(int argc, char **argv, ...)
 {
 	int set, ch;
+	va_list ap;
+	char *ifname;
+	int ifs;
 
+	va_start(ap, argv);
+	ifname = va_arg(ap, char *);
+	ifs = va_arg(ap, int);
+	va_end(ap);
+
 	/* command options for 'wgpeer' */
 	static struct nopts wgpeeropts[] = {
 		{ "endpoint",	req_arg,	'e' },
blob - d74d306eee9958bca13ea4f91638fa7061ba62bd
blob + 7300133a8d8e3171818a686e2f5fd664c406e1b1
--- who.c
+++ who.c
@@ -46,7 +46,7 @@ void  output(struct utmp *);
 void  output_labels(void);
 
 int
-who(int argc, char **argv)
+who(int argc, char **argv, ...)
 {
 	FILE *utmp;
 	struct utmp who;