diff options
author | Michael Stapelberg <michael+x200@stapelberg.de> | 2008-10-07 15:33:54 +0200 |
---|---|---|
committer | Michael Stapelberg <michael+x200@stapelberg.de> | 2008-10-07 15:33:54 +0200 |
commit | 8f5d77d5e4d979acf21507c0e764a11709de8db5 (patch) | |
tree | cacc4410975c0ffb906bb600fbeffac404ef5680 /wmiistatus.c | |
parent | b9948793a5f02a649f1baf700baefab40e044567 (diff) |
Add option parsing via getopt, cleanup Makefile
Diffstat (limited to 'wmiistatus.c')
-rw-r--r-- | wmiistatus.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/wmiistatus.c b/wmiistatus.c index 714da1a..1dd551e 100644 --- a/wmiistatus.c +++ b/wmiistatus.c @@ -49,6 +49,7 @@ #include <arpa/inet.h> #include <glob.h> #include <dirent.h> +#include <getopt.h> #define _IS_WMIISTATUS_C #include "wmiistatus.h" @@ -323,13 +324,24 @@ static bool process_runs(const char *path) { return (stat(procbuf, &statbuf) >= 0); } -int main(void) { +int main(int argc, char *argv[]) { char part[512], pathbuf[512], *end; unsigned int i; - load_configuration("/etc/wmiistatus.conf"); + char *configfile = PREFIX "/etc/wmiistatus.conf"; + int o, option_index = 0; + struct option long_options[] = { + {"config", required_argument, 0, 'c'}, + {0, 0, 0, 0} + }; + + while ((o = getopt_long(argc, argv, "c:", long_options, &option_index)) != -1) + if ((char)o == 'c') + configfile = optarg; + + load_configuration(configfile); cleanup_rbar_dir(); if (wlan_interface) create_file(concat(order[ORDER_WLAN],"wlan")); |