Main Page | Data Structures | Directories | File List | Data Fields

src/commandline.c

00001 /********************************************************************\
00002  * This program is free software; you can redistribute it and/or    *
00003  * modify it under the terms of the GNU General Public License as   *
00004  * published by the Free Software Foundation; either version 2 of   *
00005  * the License, or (at your option) any later version.              *
00006  *                                                                  *
00007  * This program is distributed in the hope that it will be useful,  *
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00010  * GNU General Public License for more details.                     *
00011  *                                                                  *
00012  * You should have received a copy of the GNU General Public License*
00013  * along with this program; if not, contact:                        *
00014  *                                                                  *
00015  * Free Software Foundation           Voice:  +1-617-542-5942       *
00016  * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
00017  * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
00018  *                                                                  *
00019 \********************************************************************/
00020 
00021 /* $Header: /cvsroot/wifidog/wifidog/src/commandline.c,v 1.13 2005/02/20 21:29:14 minaguib Exp $ */
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 

Generated on Sun Apr 3 20:04:45 2005 for WifiDog by  doxygen 1.4.1