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