00001 #include <unistd.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <stdio.h>
00005
00006 #include "../include/appConfig.h"
00007
00008
00009 int
00010 handleCmdLine(tAppConfig * config, int argc, char *argv[])
00011 {
00012 int opt;
00013
00014 while ((opt = getopt(argc, argv, "Dvp:l:n:b:")) != -1) {
00015 switch (opt) {
00016 case 'p':
00017
00018 config->port = atoi(optarg);
00019 break;
00020
00021 case 'l':
00022
00023 strncpy(config->logPath, optarg, sizeof(config->logPath)-1);
00024 break;
00025
00026 case 'n':
00027
00028 strncpy(config->namePat, optarg, sizeof(config->namePat)-1);
00029 break;
00030
00031 case 'b':
00032
00033 config->maxPending = atoi(optarg);
00034 break;
00035
00036 case 'v':
00037
00038 config->verbose = 1;
00039 break;
00040
00041 case 'D':
00042
00043 config->doDaemon = 1;
00044 break;
00045
00046 default:
00047
00048 fprintf(
00049 stderr,
00050 "Usage: %s [-p port] [-l logPath] [-n logNamePattern] [-c maxClient] [-b backlog] [-v] [-D]\n"
00051 "Defaults:\n"
00052 "\t%-20s: port this service will use [%d]\n"
00053 "\t%-20s: path where the logfiles will be stored [%s/]\n"
00054 "\t%-20s: patten used by strftime to create the log filename [%s]\n"
00055 "\t%-20s: maximum connection backlog [%d]\n"
00056 "\t%-20s: be more verbose in syslog [off]\n"
00057 "\t%-20s: deamonize me\n",
00058 argv[0],
00059 "-p port", DEFAULTPORT,
00060 "-l logPath", DEFAULTPATH,
00061 "-n logNamePattern", LOGNAMEPATTERN,
00062 "-b backlog", MAXPENDING,
00063 "-v",
00064 "-D");
00065 exit(EXIT_FAILURE);
00066 }
00067 }
00068
00069 return 0;
00070 }