mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 16:26:59 +00:00
output: make --skip to take arguments what will be skipped
Accidental typo in usage() caused realisation making skipping to fully controllable is good idea. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
e4f7259cf6
commit
3369278fc0
9 changed files with 216 additions and 23 deletions
|
|
@ -85,6 +85,49 @@ static void prepare_memory(struct conf_t *state)
|
|||
state->shared_net_head = state->shared_net_root;
|
||||
}
|
||||
|
||||
/*! \brief The --skip option argument parser. */
|
||||
static void skip_arg_parse(struct conf_t *state, char *optarg)
|
||||
{
|
||||
enum {
|
||||
OPT_ARG_OK = 0,
|
||||
OPT_ARG_WARNING,
|
||||
OPT_ARG_CRITICAL,
|
||||
OPT_ARG_MINSIZE,
|
||||
OPT_ARG_SUPRESSED
|
||||
};
|
||||
char *const tokens[] = {
|
||||
[OPT_ARG_OK] = "ok",
|
||||
[OPT_ARG_WARNING] = "warning",
|
||||
[OPT_ARG_CRITICAL] = "critical",
|
||||
[OPT_ARG_MINSIZE] = "minsize",
|
||||
[OPT_ARG_SUPRESSED] = "suppressed",
|
||||
NULL
|
||||
};
|
||||
char *value;
|
||||
|
||||
while (*optarg != '\0') {
|
||||
switch(getsubopt(&optarg, tokens, &value)) {
|
||||
case OPT_ARG_OK:
|
||||
state->skip_ok = 1;
|
||||
break;
|
||||
case OPT_ARG_WARNING:
|
||||
state->skip_warning = 1;
|
||||
break;
|
||||
case OPT_ARG_CRITICAL:
|
||||
state->skip_critical = 1;
|
||||
break;
|
||||
case OPT_ARG_MINSIZE:
|
||||
state->skip_minsize = 1;
|
||||
break;
|
||||
case OPT_ARG_SUPRESSED:
|
||||
state->skip_suppressed = 1;
|
||||
break;
|
||||
default:
|
||||
error(EXIT_FAILURE, 0, "unknown --skip specifier: %s", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Start of execution. Parse options, and call other other
|
||||
* functions one after another. At the moment adding threading support
|
||||
* would be difficult, but there does not seem to be valid reason to
|
||||
|
|
@ -120,7 +163,7 @@ int main(int argc, char **argv)
|
|||
OPT_WARN_COUNT,
|
||||
OPT_CRIT_COUNT,
|
||||
OPT_COLOR,
|
||||
OPT_SKIP_OK,
|
||||
OPT_SKIP,
|
||||
OPT_SET_IPV,
|
||||
OPT_MUSTACH
|
||||
};
|
||||
|
|
@ -130,7 +173,7 @@ int main(int argc, char **argv)
|
|||
{"config", required_argument, NULL, 'c'},
|
||||
{"leases", required_argument, NULL, 'l'},
|
||||
{"color", required_argument, NULL, OPT_COLOR},
|
||||
{"skip-ok", no_argument, NULL, OPT_SKIP_OK},
|
||||
{"skip", required_argument, NULL, OPT_SKIP},
|
||||
{"format", required_argument, NULL, 'f'},
|
||||
{"sort", required_argument, NULL, 's'},
|
||||
{"reverse", no_argument, NULL, 'r'},
|
||||
|
|
@ -223,8 +266,8 @@ int main(int argc, char **argv)
|
|||
if (state.color_mode == color_unknown)
|
||||
error(EXIT_FAILURE, errno, "unknown color mode: %s", quote(optarg));
|
||||
break;
|
||||
case OPT_SKIP_OK:
|
||||
state.skip_ok = 1;
|
||||
case OPT_SKIP:
|
||||
skip_arg_parse(&state, optarg);
|
||||
break;
|
||||
case OPT_SNET_ALARMS:
|
||||
state.snet_alarms = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue