From 5744c3a0214950433c3a4375798c1c8eba1b398c Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Mon, 2 Jan 2017 22:42:43 +0000 Subject: New upstream version 0.8.1 --- conf.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 27c11dc..294564b 100644 --- a/conf.c +++ b/conf.c @@ -20,6 +20,7 @@ #include "wavemon.h" #include #include +#include /* GLOBALS */ #define MAX_IFLIST_ENTRIES 64 @@ -94,7 +95,7 @@ void conf_get_interface_list(void) } iw_get_interface_list(if_list, MAX_IFLIST_ENTRIES); if (!if_list[0]) - err_quit("no supported wireless interfaces found!"); + err_quit("no supported wireless interfaces found! Check manpage for help."); conf.if_idx = 0; if (old_if) { @@ -529,10 +530,7 @@ static void init_conf_items(void) void getconf(int argc, char *argv[]) { int arg, help = 0, version = 0; - - conf_get_interface_list(); - init_conf_items(); - read_cf(); + const char *iface = NULL; while ((arg = getopt(argc, argv, "ghi:v")) >= 0) { switch (arg) { @@ -543,10 +541,7 @@ void getconf(int argc, char *argv[]) help++; break; case 'i': - conf.if_idx = argv_find(if_list, optarg); - if (conf.if_idx < 0) - err_quit("no wireless extensions found on '%s'", - optarg); + iface = optarg; break; case 'v': version++; @@ -557,8 +552,7 @@ void getconf(int argc, char *argv[]) } if (version) { - printf("wavemon %s", PACKAGE_VERSION); - printf(" with %s.\n", curses_version()); + printf("wavemon %s\n", PACKAGE_VERSION); printf("Distributed under the terms of the GPLv3.\n%s", help ? "\n" : ""); } if (help) { @@ -566,9 +560,21 @@ void getconf(int argc, char *argv[]) printf(" -g Ensure screen is sufficiently dimensioned\n"); printf(" -h This help screen\n"); printf(" -i Use specified network interface (default: auto)\n"); - printf(" -v Print version number\n"); + printf(" -v Print version details\n"); } - if (version || help) + if (version || help) { exit(EXIT_SUCCESS); + } + + /* Actual initialization. */ + conf_get_interface_list(); + init_conf_items(); + read_cf(); + + if (iface) { + conf.if_idx = argv_find(if_list, iface); + if (conf.if_idx < 0) + err_quit("%s is not a usable wireless interface", iface); + } } -- cgit v1.2.3