fax2ps: output usage to stdout when using -h option
also use EXIT_SUCCESS, EXIT_FAILURE from C standard
This commit is contained in:
parent
b683c37524
commit
0aed3363cf
@ -48,6 +48,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
|
||||||
|
|
||||||
float defxres = 204.; /* default x resolution (pixels/inch) */
|
float defxres = 204.; /* default x resolution (pixels/inch) */
|
||||||
float defyres = 98.; /* default y resolution (lines/inch) */
|
float defyres = 98.; /* default y resolution (lines/inch) */
|
||||||
const float half = 0.5;
|
const float half = 0.5;
|
||||||
@ -330,7 +337,7 @@ main(int argc, char** argv)
|
|||||||
int c, dowarnings = 0; /* if 1, enable library warnings */
|
int c, dowarnings = 0; /* if 1, enable library warnings */
|
||||||
TIFF* tif;
|
TIFF* tif;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "l:p:x:y:W:H:wS")) != -1)
|
while ((c = getopt(argc, argv, "l:p:x:y:W:H:wSh")) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'H': /* page height */
|
case 'H': /* page height */
|
||||||
pageHeight = (float)atof(optarg);
|
pageHeight = (float)atof(optarg);
|
||||||
@ -350,7 +357,7 @@ main(int argc, char** argv)
|
|||||||
if( pages == NULL )
|
if( pages == NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Out of memory\n");
|
fprintf(stderr, "Out of memory\n");
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
pages[npages++] = pageNumber;
|
pages[npages++] = pageNumber;
|
||||||
break;
|
break;
|
||||||
@ -366,8 +373,10 @@ main(int argc, char** argv)
|
|||||||
case 'l':
|
case 'l':
|
||||||
maxline = atoi(optarg);
|
maxline = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage(EXIT_SUCCESS);
|
||||||
case '?':
|
case '?':
|
||||||
usage(-1);
|
usage(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (npages > 0)
|
if (npages > 0)
|
||||||
qsort(pages, npages, sizeof(uint16), pcompar);
|
qsort(pages, npages, sizeof(uint16), pcompar);
|
||||||
@ -391,7 +400,7 @@ main(int argc, char** argv)
|
|||||||
fd = tmpfile();
|
fd = tmpfile();
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
fprintf(stderr, "Could not obtain temporary file.\n");
|
fprintf(stderr, "Could not obtain temporary file.\n");
|
||||||
exit(-2);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#if defined(HAVE_SETMODE) && defined(O_BINARY)
|
#if defined(HAVE_SETMODE) && defined(O_BINARY)
|
||||||
setmode(fileno(stdin), O_BINARY);
|
setmode(fileno(stdin), O_BINARY);
|
||||||
@ -401,7 +410,7 @@ main(int argc, char** argv)
|
|||||||
fclose(fd);
|
fclose(fd);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Could not copy stdin to temporary file.\n");
|
"Could not copy stdin to temporary file.\n");
|
||||||
exit(-2);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_TIFF_lseek_f(fileno(fd), 0, SEEK_SET);
|
_TIFF_lseek_f(fileno(fd), 0, SEEK_SET);
|
||||||
@ -421,10 +430,10 @@ main(int argc, char** argv)
|
|||||||
printf("%%%%Pages: %u\n", totalPages);
|
printf("%%%%Pages: %u\n", totalPages);
|
||||||
printf("%%%%EOF\n");
|
printf("%%%%EOF\n");
|
||||||
|
|
||||||
return (0);
|
return (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* stuff[] = {
|
const char* stuff[] = {
|
||||||
"usage: fax2ps [options] [input.tif ...]",
|
"usage: fax2ps [options] [input.tif ...]",
|
||||||
"where options are:",
|
"where options are:",
|
||||||
" -w suppress warning messages",
|
" -w suppress warning messages",
|
||||||
@ -441,13 +450,12 @@ NULL
|
|||||||
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