rgb2ycbcr: use EXIT_FAILURE / EXIT_SUCCESS
the -h option was already used so it cannot be used for help/usage see #17
This commit is contained in:
parent
113a07e9f3
commit
aa4409eda5
@ -39,6 +39,13 @@
|
||||
#include "tiffiop.h"
|
||||
#include "tiffio.h"
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
#define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#define streq(a,b) (strcmp(a,b) == 0)
|
||||
#define CopyField(tag, v) \
|
||||
if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
|
||||
@ -89,17 +96,17 @@ main(int argc, char* argv[])
|
||||
else if (streq(optarg, "zip"))
|
||||
compression = COMPRESSION_ADOBE_DEFLATE;
|
||||
else
|
||||
usage(-1);
|
||||
usage(EXIT_FAILURE);
|
||||
break;
|
||||
case 'h':
|
||||
horizSubSampling = atoi(optarg);
|
||||
if( horizSubSampling != 1 && horizSubSampling != 2 && horizSubSampling != 4 )
|
||||
usage(-1);
|
||||
usage(EXIT_FAILURE);
|
||||
break;
|
||||
case 'v':
|
||||
vertSubSampling = atoi(optarg);
|
||||
if( vertSubSampling != 1 && vertSubSampling != 2 && vertSubSampling != 4 )
|
||||
usage(-1);
|
||||
usage(EXIT_FAILURE);
|
||||
break;
|
||||
case 'r':
|
||||
rowsperstrip = atoi(optarg);
|
||||
@ -113,14 +120,14 @@ main(int argc, char* argv[])
|
||||
refBlackWhite[5] = 240.;
|
||||
break;
|
||||
case '?':
|
||||
usage(0);
|
||||
usage(EXIT_FAILURE);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (argc - optind < 2)
|
||||
usage(-1);
|
||||
usage(EXIT_FAILURE);
|
||||
out = TIFFOpen(argv[argc-1], "w");
|
||||
if (out == NULL)
|
||||
return (-2);
|
||||
return (EXIT_FAILURE);
|
||||
setupLumaTables();
|
||||
for (; optind < argc-1; optind++) {
|
||||
in = TIFFOpen(argv[optind], "r");
|
||||
@ -137,7 +144,7 @@ main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
(void) TIFFClose(out);
|
||||
return (0);
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
float *lumaRed;
|
||||
@ -357,7 +364,7 @@ tiffcvt(TIFF* in, TIFF* out)
|
||||
return result;
|
||||
}
|
||||
|
||||
char* stuff[] = {
|
||||
const char* stuff[] = {
|
||||
"usage: rgb2ycbcr [-c comp] [-r rows] [-h N] [-v N] input... output\n",
|
||||
"where comp is one of the following compression algorithms:\n",
|
||||
" jpeg\t\tJPEG encoding\n",
|
||||
@ -375,14 +382,12 @@ char* stuff[] = {
|
||||
static void
|
||||
usage(int code)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int i;
|
||||
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
|
||||
|
||||
setbuf(stderr, buf);
|
||||
|
||||
fprintf(stderr, "%s\n\n", TIFFGetVersion());
|
||||
fprintf(out, "%s\n\n", TIFFGetVersion());
|
||||
for (i = 0; stuff[i] != NULL; i++)
|
||||
fprintf(stderr, "%s\n", stuff[i]);
|
||||
fprintf(out, "%s\n", stuff[i]);
|
||||
exit(code);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user