put the usage() function inline, it was only 1 line and used once;
slightly reformat the help() text; slightly correct the text for the 'extraneous filename' error message;
This commit is contained in:
parent
db7c522411
commit
0e22daad2d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=187765
@ -245,8 +245,6 @@ static struct _s_x ether_types[] = {
|
|||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void show_usage(void);
|
|
||||||
|
|
||||||
enum tokens {
|
enum tokens {
|
||||||
TOK_NULL=0,
|
TOK_NULL=0,
|
||||||
|
|
||||||
@ -2725,21 +2723,13 @@ list(int ac, char *av[], int show_counters)
|
|||||||
#undef NEXT
|
#undef NEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
show_usage(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: ipfw [options]\n"
|
|
||||||
"do \"ipfw -h\" or see ipfw manpage for details\n"
|
|
||||||
);
|
|
||||||
exit(EX_USAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help(void)
|
help(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ipfw syntax summary (but please do read the ipfw(8) manpage):\n"
|
"ipfw syntax summary (but please do read the ipfw(8) manpage):\n\n"
|
||||||
"ipfw [-abcdefhnNqStTv] <command> where <command> is one of:\n"
|
"\tipfw [-abcdefhnNqStTv] <command>\n\n"
|
||||||
|
"where <command> is one of the following:\n\n"
|
||||||
"add [num] [set N] [prob x] RULE-BODY\n"
|
"add [num] [set N] [prob x] RULE-BODY\n"
|
||||||
"{pipe|queue} N config PIPE-BODY\n"
|
"{pipe|queue} N config PIPE-BODY\n"
|
||||||
"[pipe|queue] {zero|delete|show} [N{,N}]\n"
|
"[pipe|queue] {zero|delete|show} [N{,N}]\n"
|
||||||
@ -6471,10 +6461,8 @@ ipfw_readfile(int ac, char *av[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == NULL && ac != optind + 1) {
|
if (cmd == NULL && ac != optind + 1)
|
||||||
fprintf(stderr, "ac %d, optind %d\n", ac, optind);
|
errx(EX_USAGE, "extraneous filename arguments %s", av[ac-1]);
|
||||||
errx(EX_USAGE, "extraneous filename arguments");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((f = fopen(filename, "r")) == NULL)
|
if ((f = fopen(filename, "r")) == NULL)
|
||||||
err(EX_UNAVAILABLE, "fopen: %s", filename);
|
err(EX_UNAVAILABLE, "fopen: %s", filename);
|
||||||
@ -6554,8 +6542,11 @@ main(int ac, char *av[])
|
|||||||
if (ac > 1 && av[ac - 1][0] == '/' && access(av[ac - 1], R_OK) == 0)
|
if (ac > 1 && av[ac - 1][0] == '/' && access(av[ac - 1], R_OK) == 0)
|
||||||
ipfw_readfile(ac, av);
|
ipfw_readfile(ac, av);
|
||||||
else {
|
else {
|
||||||
if (ipfw_main(ac, av))
|
if (ipfw_main(ac, av)) {
|
||||||
show_usage();
|
errx(EX_USAGE,
|
||||||
|
"usage: ipfw [options]\n"
|
||||||
|
"do \"ipfw -h\" or \"man ipfw\" for details");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return EX_OK;
|
return EX_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user