diff options
| author | Antonin Descampe <antonin@gmail.com> | 2014-04-22 21:22:49 +0000 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2014-04-22 21:22:49 +0000 |
| commit | 8d93eae64acd18fac3c856e0a311905359233b96 (patch) | |
| tree | 8af15444ee62690d89a309712002b82543450341 /src/bin/jp2/opj_decompress.c | |
| parent | 9a3d660d1b3ac71f00369baf183a154a00f9f222 (diff) | |
[trunk] fixed some warning and errors formatting and add a '-version'
option to opj_compress and opj_decompress binaries
Diffstat (limited to 'src/bin/jp2/opj_decompress.c')
| -rw-r--r-- | src/bin/jp2/opj_decompress.c | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index 59edb4a4..1164f061 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -332,6 +332,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i opj_option_t long_option[]={ {"ImgDir",REQ_ARG, NULL ,'y'}, {"OutFor",REQ_ARG, NULL ,'O'}, + {"version",NO_ARG, NULL ,'v'} }; const char optlist[] = "i:o:r:l:x:d:t:" @@ -341,7 +342,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i "W:" #endif /* USE_JPWL */ /* <<UniPG */ - "h" ; + "hv" ; totlen=sizeof(long_option); img_fol->set_out_format = 0; do { @@ -367,7 +368,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i return 1; default: fprintf(stderr, - "!! Unrecognized format for infile: %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n", + "[ERROR] Unknown input file format: %s \n" + " Known file formats are *.j2k, *.jp2, *.jpc or *.jpt\n", infile); return 1; } @@ -472,10 +474,17 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i decode_help_display(); return 1; - /* ------------------------------------------------------ */ + /* ------------------------------------------------------ */ + + case 'v': /* display the openjpeg library version in use */ + fprintf(stdout,"This is the opj_decompress utility from the OpenJPEG project.\n" + "It has been compiled against openjp2 library v%s.\n",opj_version()); + return 1; + + /* ----------------------------------------------------- */ case 'y': /* Image Directory path */ - { + { img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1); strcpy(img_fol->imgdirpath,opj_optarg); img_fol->set_imgdir=1; @@ -589,31 +598,32 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i /* ----------------------------------------------------- */ - default: - fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg); - break; + default: + fprintf(stderr, "[WARNING] An invalid option has been ignored\n"); + break; } }while(c != -1); /* check for possible errors */ if(img_fol->set_imgdir==1){ if(!(parameters->infile[0]==0)){ - fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n"); + fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together !!\n"); return 1; } if(img_fol->set_out_format == 0){ - fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n"); + fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used !!\n"); fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n"); return 1; } if(!((parameters->outfile[0] == 0))){ - fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n"); + fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together !!\n"); return 1; } }else{ if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) { - fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]); - fprintf(stderr, " Try: %s -h\n",argv[0]); + fprintf(stderr, "[ERROR] Required parameters are missing\n" + "Example: %s -i image.j2k -o image.pgm\n",argv[0]); + fprintf(stderr, " Help: %s -h\n",argv[0]); return 1; } } @@ -877,81 +887,81 @@ int main(int argc, char **argv) switch (parameters.cod_format) { case PXM_DFMT: /* PNM PGM PPM */ if (imagetopnm(image, parameters.outfile)) { - fprintf(stderr,"Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; case PGX_DFMT: /* PGX */ if(imagetopgx(image, parameters.outfile)){ - fprintf(stderr,"Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; case BMP_DFMT: /* BMP */ if(imagetobmp(image, parameters.outfile)){ - fprintf(stderr,"Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; #ifdef OPJ_HAVE_LIBTIFF case TIF_DFMT: /* TIFF */ if(imagetotif(image, parameters.outfile)){ - fprintf(stderr,"Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; #endif /* OPJ_HAVE_LIBTIFF */ case RAW_DFMT: /* RAW */ if(imagetoraw(image, parameters.outfile)){ - fprintf(stderr,"Error generating raw file. Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Error generating raw file. Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; case RAWL_DFMT: /* RAWL */ if(imagetorawl(image, parameters.outfile)){ - fprintf(stderr,"Error generating rawl file. Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Error generating rawl file. Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; case TGA_DFMT: /* TGA */ if(imagetotga(image, parameters.outfile)){ - fprintf(stderr,"Error generating tga file. Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Error generating tga file. Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; #ifdef OPJ_HAVE_LIBPNG case PNG_DFMT: /* PNG */ if(imagetopng(image, parameters.outfile)){ - fprintf(stderr,"Error generating png file. Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Error generating png file. Outfile %s not generated\n",parameters.outfile); failed = 1; } else { - fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile); + fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile); } break; #endif /* OPJ_HAVE_LIBPNG */ @@ -959,7 +969,7 @@ int main(int argc, char **argv) * and OPJ_HAVE_LIBTIF or OPJ_HAVE_LIBPNG is undefined */ default: - fprintf(stderr,"Outfile %s not generated\n",parameters.outfile); + fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile); failed = 1; } |
