00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <unistd.h>
00030 #include <string.h>
00031
00032 #include "safe.h"
00033 #include "conf.h"
00034
00035 #include "../config.h"
00036
00037 static void usage(void);
00038
00044 static void
00045 usage(void)
00046 {
00047 printf("Usage: wifidog [options]\n");
00048 printf("\n");
00049 printf(" -c [filename] Use this config file\n");
00050 printf(" -f Run in foreground\n");
00051 printf(" -d <level> Debug level\n");
00052 printf(" -s Log to syslog\n");
00053 printf(" -w <path> Wdctl socket path\n");
00054 printf(" -h Print usage\n");
00055 printf(" -v Print version information\n");
00056 printf("\n");
00057 }
00058
00061 void
00062 parse_commandline(int argc, char **argv)
00063 {
00064 int c;
00065 s_config *config = config_get_config();
00066
00067 while (-1 != (c = getopt(argc, argv, "c:hfd:sw:v"))) {
00068 switch(c) {
00069 case 'h':
00070 usage();
00071 exit(1);
00072 break;
00073
00074 case 'c':
00075 if (optarg) {
00076 strncpy(config->configfile, optarg, sizeof(config->configfile));
00077 }
00078 break;
00079
00080 case 'w':
00081 if (optarg) {
00082 free(config->wdctl_sock);
00083 config->wdctl_sock = safe_strdup(optarg);
00084 }
00085 break;
00086
00087 case 'f':
00088 config->daemon = 0;
00089 break;
00090
00091 case 'd':
00092 if (optarg) {
00093 config->debuglevel = atoi(optarg);
00094 }
00095 break;
00096
00097 case 's':
00098 config->log_syslog = 1;
00099 break;
00100
00101 case 'v':
00102 printf("This is WiFiDog version " VERSION "\n");
00103 exit(1);
00104 break;
00105
00106 default:
00107 usage();
00108 exit(1);
00109 break;
00110 }
00111 }
00112 }
00113