+ verbosity option
This commit is contained in:
parent
bdcbf8c067
commit
568811eb90
@ -16,33 +16,42 @@
|
|||||||
|
|
||||||
int verbosity = 0;
|
int verbosity = 0;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
void help(int k)
|
||||||
|
{
|
||||||
|
if (verbosity) fimg_print_version(k);
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FloatImg fimg;
|
FloatImg fimg;
|
||||||
int foo;
|
int foo, opt;
|
||||||
|
|
||||||
/*
|
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
||||||
* pas de traitement des options ?
|
switch(opt) {
|
||||||
*/
|
case 'v': verbosity++; break;
|
||||||
|
case 'h': help(1); exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (3 != argc) {
|
if (2 != argc-optind) {
|
||||||
fimg_print_version(1);
|
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
|
||||||
fprintf(stderr, "usage:\n\t%s foo.png bar.fimg\n", argv[0]);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&fimg, 0, sizeof(FloatImg));
|
memset(&fimg, 0, sizeof(FloatImg));
|
||||||
|
|
||||||
foo = fimg_create_from_png(argv[1], &fimg);
|
foo = fimg_create_from_png(argv[optind], &fimg);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s : err %d, abort.\n", argv[0], foo);
|
fprintf(stderr, "%s : err %d, abort.\n", argv[0], foo);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity) fimg_describe(&fimg, argv[2]);
|
if (verbosity) fimg_describe(&fimg, argv[optind+1]);
|
||||||
|
|
||||||
foo = fimg_dump_to_file(&fimg, argv[2], 0);
|
foo = fimg_dump_to_file(&fimg, argv[optind+1], 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "save as '%s' -> err %d\n", argv[2], foo);
|
fprintf(stderr, "save as '%s' -> err %d\n", argv[2], foo);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user