Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions tools/nut-scanner/nut-scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,22 @@ int main(int argc, char *argv[])
xml_sec.usec_timeout = -1; /* Override with the "timeout" common setting later */
xml_sec.peername = NULL;

/* Parse command line options -- First loop: only get debug level */
/* Suppress error messages, for now -- leave them to the second loop. */
opterr = 0;
while((opt_ret = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
if (opt_ret == 'D')
nut_debug_level++;

nutscan_init();

display_func = nutscan_display_ups_conf;

/* Parse command line options -- Second loop: everything else */
/* Restore error messages... */
opterr = 1;
/* ...and index of the item to be processed by getopt(). */
optind = 1;
/* Note: the getopts print an error message about unknown arguments
* or arguments which need a second token and that is missing now */
while((opt_ret = getopt_long(argc, argv, optstring, longopts, NULL))!=-1) {
Expand Down Expand Up @@ -278,7 +292,7 @@ int main(int argc, char *argv[])
cidr = strdup(optarg);
break;
case 'D':
nut_debug_level++;
/* nothing to do, here */
break;
case 'c':
if(!nutscan_avail_snmp) {
Expand Down Expand Up @@ -466,12 +480,6 @@ int main(int argc, char *argv[])
/* BEWARE: allow_all does not include allow_eaton_serial! */
}

/* TODO: nutscan_init() should consider (via args? shared global vars?)
* which scan types we desire at this run, and not try to load irrelevant
* libraries.
*/
nutscan_init();

/* TODO/discuss : Should the #else...#endif code below for lack of pthreads
* during build also serve as a fallback for pthread failure at runtime?
*/
Expand Down