if (strcmp(argv[0], cmd->name) == 0) {
ret = cmd->func(argc, (const char**) argv);
switch (ret) {
+ case CMD_WARNING:
+ WARN("Some command(s) went wrong");
+ break;
case CMD_ERROR:
ERR("Command error");
break;
if (opt_sessiond_path != NULL) {
ret = access(opt_sessiond_path, F_OK | X_OK);
if (ret < 0) {
- ERR("No such file: %s", opt_sessiond_path);
+ ERR("No such file or access denied: %s", opt_sessiond_path);
goto end;
}
pathname = opt_sessiond_path;
ret = spawn_sessiond(pathname);
free(alloc_pathname);
if (ret < 0) {
- ERR("Problem occurs when starting %s", pathname);
+ ERR("Problem occurred when starting %s", pathname);
goto end;
}
}
for (i = 0; i < argc; i++) {
if ((strncmp(argv[i], "-h", sizeof("-h")) == 0) ||
strncmp(argv[i], "--h", sizeof("--h")) == 0 ||
- strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0) {
+ strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0 ||
+ strncmp(argv[i], "--list-commands", sizeof("--list-commands")) == 0) {
return 1;
}
}
}
/*
- * parse_args
+ * Parse command line arguments.
*
- * Parse command line arguments.
- * Return 0 if OK, else -1
+ * Return 0 if OK, else -1
*/
static int parse_args(int argc, char **argv)
{
while ((opt = getopt_long(argc, argv, "+hnvqg:", long_options, NULL)) != -1) {
switch (opt) {
case 'h':
- usage(stderr);
- goto error;
+ usage(stdout);
+ goto end;
case 'v':
opt_verbose += 1;
break;
case OPT_DUMP_OPTIONS:
list_options(stdout);
ret = 0;
- goto error;
+ goto end;
case OPT_DUMP_COMMANDS:
list_commands(stdout);
ret = 0;
- goto error;
+ goto end;
default:
usage(stderr);
goto error;
goto error;
}
+end:
return 0;
error: