mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 08:16:59 +00:00
main: move output_format to state, and rename color_format
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
e8e9d49ebb
commit
3f85360c64
3 changed files with 21 additions and 23 deletions
|
|
@ -133,7 +133,7 @@ static void skip_arg_parse(struct conf_t *state, char *optarg)
|
|||
}
|
||||
|
||||
/*! \brief Command line options parser. */
|
||||
static char parse_command_line_opts(struct conf_t *state, int argc, char **argv)
|
||||
static void parse_command_line_opts(struct conf_t *state, int argc, char **argv)
|
||||
{
|
||||
enum {
|
||||
OPT_SNET_ALARMS = CHAR_MAX + 1,
|
||||
|
|
@ -172,7 +172,6 @@ static char parse_command_line_opts(struct conf_t *state, int argc, char **argv)
|
|||
{"ip-version", required_argument, NULL, OPT_SET_IPV},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
char output_format = '\0';
|
||||
int alarming = 0;
|
||||
|
||||
while (1) {
|
||||
|
|
@ -192,7 +191,7 @@ static char parse_command_line_opts(struct conf_t *state, int argc, char **argv)
|
|||
break;
|
||||
case 'f':
|
||||
/* Output format */
|
||||
output_format = optarg[0];
|
||||
state->output_format = optarg[0];
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
|
|
@ -231,7 +230,7 @@ static char parse_command_line_opts(struct conf_t *state, int argc, char **argv)
|
|||
case OPT_MUSTACH:
|
||||
#ifdef BUILD_MUSTACH
|
||||
state->mustach_template = optarg;
|
||||
output_format = 'm';
|
||||
state->output_format = 'm';
|
||||
#else
|
||||
error(EXIT_FAILURE, 0, "compiled without mustach support");
|
||||
#endif
|
||||
|
|
@ -312,19 +311,18 @@ static char parse_command_line_opts(struct conf_t *state, int argc, char **argv)
|
|||
}
|
||||
/* Output format is not defined, if alarm thresholds are then it's alarming, else use the
|
||||
* default. */
|
||||
if (output_format == '\0') {
|
||||
if (state->output_format == '\0') {
|
||||
if (alarming == 1)
|
||||
output_format = 'a';
|
||||
state->output_format = 'a';
|
||||
else {
|
||||
const char *const default_format = OUTPUT_FORMAT;
|
||||
|
||||
output_format = default_format[0];
|
||||
state->output_format = default_format[0];
|
||||
}
|
||||
}
|
||||
if (output_format == 'X' || output_format == 'J') {
|
||||
if (state->output_format == 'X' || state->output_format == 'J') {
|
||||
state->print_mac_addreses = 1;
|
||||
}
|
||||
return output_format;
|
||||
}
|
||||
|
||||
/*!\brief Start of execution. This will mostly call other functions one
|
||||
|
|
@ -347,14 +345,13 @@ int main(int argc, char **argv)
|
|||
.ip_version = IPvUNKNOWN,
|
||||
0
|
||||
};
|
||||
char output_format;
|
||||
int ret_val;
|
||||
|
||||
atexit(close_stdout);
|
||||
set_program_name(argv[0]);
|
||||
prepare_memory(&state);
|
||||
set_ipv_functions(&state, IPvUNKNOWN);
|
||||
output_format = parse_command_line_opts(&state, argc, argv);
|
||||
parse_command_line_opts(&state, argc, argv);
|
||||
|
||||
/* Do the job */
|
||||
parse_config(&state, 1, state.dhcpdconf_file, state.shared_net_root);
|
||||
|
|
@ -365,7 +362,7 @@ int main(int argc, char **argv)
|
|||
mergesort_ranges(&state, state.ranges, state.num_ranges, NULL, 1);
|
||||
if (state.reverse_order == 1)
|
||||
flip_ranges(&state);
|
||||
ret_val = output_analysis(&state, output_format);
|
||||
ret_val = output_analysis(&state);
|
||||
clean_up(&state);
|
||||
return (ret_val);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue