params.cmdname = *argv;
- while ((opt = getopt(argc, argv, "lo:T:p:V")) != -1) {
+ while ((opt = getopt(argc, argv, "hlo:T:p:V")) != -1) {
switch (opt) {
case 'l':
params.lflag = 1;
if (params.type < 0) {
fprintf(stderr, "%s: Invalid type\n",
params.cmdname);
- usage();
+ exit(EXIT_FAILURE);
}
break;
case 'p':
case 'V':
printf("dumpimage version %s\n", PLAIN_VERSION);
exit(EXIT_SUCCESS);
+ case 'h':
+ usage();
default:
usage();
break;
}
}
+ if (argc < 2)
+ usage();
+
if (optind >= argc) {
fprintf(stderr, "%s: image file missing\n", params.cmdname);
- usage();
+ exit(EXIT_FAILURE);
}
params.imagefile = argv[optind];
if (tparams->check_params(¶ms)) {
fprintf(stderr, "%s: Parameter check failed\n",
params.cmdname);
- usage();
+ exit(EXIT_FAILURE);
}
}
" -T ==> set image type to 'type'\n"
" -p ==> 'position' (starting at 0) of the component to extract from image\n",
params.cmdname);
+ fprintf(stderr,
+ " %s -h ==> print usage information and exit\n",
+ params.cmdname);
fprintf(stderr,
" %s -V ==> print version information and exit\n",
params.cmdname);
- exit(EXIT_FAILURE);
+ exit(EXIT_SUCCESS);
}