aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c32
1 files changed, 19 insertions, 13 deletions
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 <pwd.h>
#include <sys/types.h>
+#include <netlink/version.h>
/* 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 <ifname> 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);
+ }
}