Commit deed4db5 authored by 's avatar
Browse files

fixes in command line arguments handling

git-svn-id: file:///home/svn/mapi/trunk@829 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent ef740130
...@@ -2543,65 +2543,48 @@ static void ...@@ -2543,65 +2543,48 @@ static void
parse_arguments (int argc, char **argv) parse_arguments (int argc, char **argv)
{ {
int c; int c;
const char optstring[] = "as:i:ht:r";
const struct option longopts[] = {
#ifdef WITH_ADMISSION_CONTROL
{"admctrl", no_argument, NULL, 'a'},
{"shmpath", required_argument, NULL, 's'},
{"shmid", required_argument, NULL, 'i'},
{"timeout", required_argument, NULL, 't'},
#ifdef WITH_RESOURCE_CONTROL #ifdef WITH_RESOURCE_CONTROL
{"resctrl", no_argument, NULL, 'r'}, static const char optstring[] = "vhr";
#else
static const char optstring[] = "vh";
#endif #endif
static const struct option longopts[] = {
#ifdef WITH_RESOURCE_CONTROL
{"resctrl", no_argument, NULL, 'r'},
#endif #endif
{"version", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"", 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
while ((c = getopt_long (argc, argv, optstring, longopts, NULL)) >= 0) while ((c = getopt_long (argc, argv, optstring, longopts, NULL)) != -1) {
switch (c) switch (c) {
{
#ifdef WITH_ADMISSION_CONTROL
case 'a':
admission_control_enabled = 1;
break;
case 's':
admctrl_pathname = optarg;
break;
case 'i':
admctrl_pid = *optarg;
break;
case 't':
admctrl_timeout = strtol (optarg, NULL, 10);
if (admctrl_timeout < 0)
{
printf ("Invalid timeout!\nUsing default %ld microsecs\n",
admctrl_timeout);
admctrl_timeout = DEFAULT_ADMCTRL_TIMEOUT;
}
break;
#ifdef WITH_RESOURCE_CONTROL #ifdef WITH_RESOURCE_CONTROL
case 'r': case 'r':
resource_control_enabled = 1; resource_control_enabled = 1;
break; break;
#endif
#endif #endif
case 'v':
printf("mapid: MAPI v%s\n", PACKAGE_VERSION);
exit(EXIT_SUCCESS);
break;
case 0: // long option without an equivalent short arg
case 'h': case 'h':
print_usage (argv[0]); case '?':
exit (EXIT_SUCCESS);
default: default:
print_usage (argv[0]); print_usage (argv[0]);
exit (EXIT_FAILURE); exit(EXIT_FAILURE);
} }
}
} }
static void set_debug() static void set_debug()
{ {
conf_category_entry_t *cat=NULL; conf_category_entry_t *cat=NULL;
conf_parameter_t *p=NULL; conf_parameter_t *p=NULL;
int logmask = 0; int logmask = 0;
if (pc_load (mapid_conf)) if (pc_load (mapid_conf))
...@@ -2610,15 +2593,14 @@ static void set_debug() ...@@ -2610,15 +2593,14 @@ static void set_debug()
} }
if(cat!=NULL && cat->params!=NULL) if(cat!=NULL && cat->params!=NULL)
p = cat->params; p = cat->params;
if (p != NULL) if (p != NULL)
{ {
if (strcmp (p->name, "debuglevel") == 0) if (strcmp (p->name, "debuglevel") == 0)
logmask=atoi(p->value); logmask=atoi(p->value);
pc_close (); pc_close ();
} }
if(logmask==0||logmask==2) if(logmask==0||logmask==2)
setlogmask(LOG_UPTO(LOG_WARNING)); setlogmask(LOG_UPTO(LOG_WARNING));
if(logmask==1) if(logmask==1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment