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,55 +2543,38 @@ static void
parse_arguments (int argc, char **argv)
{
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
{"resctrl", no_argument, NULL, 'r'},
static const char optstring[] = "vhr";
#else
static const char optstring[] = "vh";
#endif
static const struct option longopts[] = {
#ifdef WITH_RESOURCE_CONTROL
{"resctrl", no_argument, NULL, 'r'},
#endif
{"version", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"", 0, NULL, 0}
{NULL, 0, NULL, 0}
};
while ((c = getopt_long (argc, argv, optstring, longopts, NULL)) >= 0)
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;
while ((c = getopt_long (argc, argv, optstring, longopts, NULL)) != -1) {
switch (c) {
#ifdef WITH_RESOURCE_CONTROL
case 'r':
resource_control_enabled = 1;
break;
#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':
print_usage (argv[0]);
exit (EXIT_SUCCESS);
case '?':
default:
print_usage (argv[0]);
exit (EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}
}
......@@ -2616,7 +2599,6 @@ static void set_debug()
if (strcmp (p->name, "debuglevel") == 0)
logmask=atoi(p->value);
pc_close ();
}
if(logmask==0||logmask==2)
......
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