roentgen b75cab
/* $Id: fax2ps.c,v 1.27 2011-04-02 19:30:20 bfriesen Exp $" */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Copyright (c) 1991-1997 Sam Leffler
roentgen b75cab
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
roentgen b75cab
 *
roentgen b75cab
 * Permission to use, copy, modify, distribute, and sell this software and 
roentgen b75cab
 * its documentation for any purpose is hereby granted without fee, provided
roentgen b75cab
 * that (i) the above copyright notices and this permission notice appear in
roentgen b75cab
 * all copies of the software and related documentation, and (ii) the names of
roentgen b75cab
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
roentgen b75cab
 * publicity relating to the software without the specific, prior written
roentgen b75cab
 * permission of Sam Leffler and Silicon Graphics.
roentgen b75cab
 * 
roentgen b75cab
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
roentgen b75cab
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
roentgen b75cab
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
roentgen b75cab
 * 
roentgen b75cab
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
roentgen b75cab
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
roentgen b75cab
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
roentgen b75cab
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
roentgen b75cab
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
roentgen b75cab
 * OF THIS SOFTWARE.
roentgen b75cab
 */
roentgen b75cab
#include "tif_config.h"
roentgen b75cab
roentgen b75cab
#include <stdlib.h></stdlib.h>
roentgen b75cab
#include <stdio.h></stdio.h>
roentgen b75cab
#include <string.h></string.h>
roentgen b75cab
#include <math.h></math.h>
roentgen b75cab
#include <time.h></time.h>
roentgen b75cab
roentgen b75cab
#ifdef HAVE_UNISTD_H
roentgen b75cab
# include <unistd.h></unistd.h>
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#ifdef HAVE_FCNTL_H
roentgen b75cab
# include <fcntl.h></fcntl.h>
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#ifdef HAVE_IO_H
roentgen b75cab
# include <io.h></io.h>
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#ifdef NEED_LIBPORT
roentgen b75cab
# include "libport.h"
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#include "tiffio.h"
roentgen b75cab
roentgen b75cab
float	defxres = 204.;		/* default x resolution (pixels/inch) */
roentgen b75cab
float	defyres = 98.;		/* default y resolution (lines/inch) */
roentgen b75cab
const float half = 0.5;
roentgen b75cab
const float points = 72.0;
roentgen b75cab
float	pageWidth = 0;		/* image page width (inches) */
roentgen b75cab
float	pageHeight = 0;		/* image page length (inches) */
roentgen b75cab
int	scaleToPage = 0;	/* if true, scale raster to page dimensions */
roentgen b75cab
int	totalPages = 0;		/* total # pages printed */
roentgen b75cab
int	row;			/* current output row */
roentgen b75cab
int	maxline = 512;		/* max output line of PostScript */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Turn a bit-mapped scanline into the appropriate sequence
roentgen b75cab
 * of PostScript characters to be rendered.
roentgen b75cab
 *  
roentgen b75cab
 * Original version written by Bret D. Whissel,
roentgen b75cab
 * Florida State University Meteorology Department
roentgen b75cab
 * March 13-15, 1995.
roentgen b75cab
 */
roentgen b75cab
static void
roentgen b75cab
printruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx)
roentgen b75cab
{
roentgen b75cab
    static struct {
roentgen b75cab
	char white, black;
roentgen b75cab
	unsigned short width;
roentgen b75cab
    } WBarr[] = {
roentgen b75cab
	{ 'd', 'n', 512 }, { 'e', 'o', 256 }, { 'f', 'p', 128 },
roentgen b75cab
	{ 'g', 'q',  64 }, { 'h', 'r',  32 }, { 'i', 's',  16 },
roentgen b75cab
	{ 'j', 't',   8 }, { 'k', 'u',   4 }, { 'l', 'v',   2 },
roentgen b75cab
	{ 'm', 'w',   1 }
roentgen b75cab
    };
roentgen b75cab
    static char* svalue =
roentgen b75cab
	" !\"#$&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abc";
roentgen b75cab
    int colormode = 1;		/* 0 for white, 1 for black */
roentgen b75cab
    uint32 runlength = 0;
roentgen b75cab
    int n = maxline;
roentgen b75cab
    uint32 x = 0;
roentgen b75cab
    int l;
roentgen b75cab
roentgen b75cab
    (void) buf;
roentgen b75cab
    printf("%d m(", row++);
roentgen b75cab
    while (runs < erun) {
roentgen b75cab
	if (runlength <= 0) {
roentgen b75cab
	    colormode ^= 1;
roentgen b75cab
	    runlength = *runs++;
roentgen b75cab
	    if (x+runlength > lastx)
roentgen b75cab
		runlength = runs[-1] = lastx-x;
roentgen b75cab
	    x += runlength;
roentgen b75cab
	    if (!colormode && runs == erun)	
roentgen b75cab
		break;		/* don't bother printing the final white run */
roentgen b75cab
	}
roentgen b75cab
	/*
roentgen b75cab
	 * If a runlength is greater than 6 pixels, then spit out
roentgen b75cab
	 * black or white characters until the runlength drops to
roentgen b75cab
	 * 6 or less.  Once a runlength is <= 6, then combine black
roentgen b75cab
	 * and white runlengths until a 6-pixel pattern is obtained.
roentgen b75cab
	 * Then write out the special character.  Six-pixel patterns
roentgen b75cab
	 * were selected since 64 patterns is the largest power of
roentgen b75cab
	 * two less than the 92 "easily printable" PostScript
roentgen b75cab
	 * characters (i.e., no escape codes or octal chars).
roentgen b75cab
	 */
roentgen b75cab
	l = 0;
roentgen b75cab
	while (runlength > 6) {	/* Run is greater than six... */
roentgen b75cab
	    if (runlength >= WBarr[l].width) {
roentgen b75cab
		if (n == 0) {
roentgen b75cab
		    putchar('\n');
roentgen b75cab
		    n = maxline;
roentgen b75cab
		}
roentgen b75cab
		putchar(colormode ? WBarr[l].black : WBarr[l].white), n--;
roentgen b75cab
		runlength -= WBarr[l].width;
roentgen b75cab
	    } else
roentgen b75cab
		l++;
roentgen b75cab
	}
roentgen b75cab
	while (runlength > 0 && runlength <= 6) {
roentgen b75cab
	    uint32 bitsleft = 6;
roentgen b75cab
	    int t = 0;
roentgen b75cab
	    while (bitsleft) {
roentgen b75cab
		if (runlength <= bitsleft) {
roentgen b75cab
		    if (colormode)
roentgen b75cab
			t |= ((1 << runlength)-1) << (bitsleft-runlength);
roentgen b75cab
		    bitsleft -= runlength;
roentgen b75cab
		    runlength = 0;
roentgen b75cab
		    if (bitsleft) {
roentgen b75cab
			if (runs >= erun)
roentgen b75cab
			    break;
roentgen b75cab
			colormode ^= 1;
roentgen b75cab
			runlength = *runs++;
roentgen b75cab
			if (x+runlength > lastx)
roentgen b75cab
			    runlength = runs[-1] = lastx-x;
roentgen b75cab
			x += runlength;
roentgen b75cab
		    }
roentgen b75cab
		} else {		/* runlength exceeds bits left */
roentgen b75cab
		    if (colormode)
roentgen b75cab
			t |= ((1 << bitsleft)-1);
roentgen b75cab
		    runlength -= bitsleft;
roentgen b75cab
		    bitsleft = 0;
roentgen b75cab
		}
roentgen b75cab
	    }
roentgen b75cab
	    if (n == 0) {
roentgen b75cab
		putchar('\n');
roentgen b75cab
		n = maxline;
roentgen b75cab
	    }
roentgen b75cab
	    putchar(svalue[t]), n--;
roentgen b75cab
	}
roentgen b75cab
    }
roentgen b75cab
    printf(")s\n");
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
/* 
roentgen b75cab
 * Create a special PostScript font for printing FAX documents.  By taking
roentgen b75cab
 * advantage of the font-cacheing mechanism, a substantial speed-up in 
roentgen b75cab
 * rendering time is realized. 
roentgen b75cab
 */
roentgen b75cab
static void
roentgen b75cab
emitFont(FILE* fd)
roentgen b75cab
{
roentgen b75cab
    static const char* fontPrologue[] = {
roentgen b75cab
	"/newfont 10 dict def newfont begin /FontType 3 def /FontMatrix [1",
roentgen b75cab
	"0 0 1 0 0] def /FontBBox [0 0 512 1] def /Encoding 256 array def",
roentgen b75cab
	"0 1 31{Encoding exch /255 put}for 120 1 255{Encoding exch /255",
roentgen b75cab
	"put}for Encoding 37 /255 put Encoding 40 /255 put Encoding 41 /255",
roentgen b75cab
	"put Encoding 92 /255 put /count 0 def /ls{Encoding exch count 3",
roentgen b75cab
	"string cvs cvn put /count count 1 add def}def 32 1 36{ls}for",
roentgen b75cab
	"38 1 39{ls}for 42 1 91{ls}for 93 1 99{ls}for /count 100",
roentgen b75cab
	"def 100 1 119{ls}for /CharDict 5 dict def CharDict begin /white",
roentgen b75cab
	"{dup 255 eq{pop}{1 dict begin 100 sub neg 512 exch bitshift",
roentgen b75cab
	"/cw exch def cw 0 0 0 cw 1 setcachedevice end}ifelse}def /black",
roentgen b75cab
	"{dup 255 eq{pop}{1 dict begin 110 sub neg 512 exch bitshift",
roentgen b75cab
	"/cw exch def cw 0 0 0 cw 1 setcachedevice 0 0 moveto cw 0 rlineto",
roentgen b75cab
	"0 1 rlineto cw neg 0 rlineto closepath fill end}ifelse}def /numbuild",
roentgen b75cab
	"{dup 255 eq{pop}{6 0 0 0 6 1 setcachedevice 0 1 5{0 moveto",
roentgen b75cab
	"dup 32 and 32 eq{1 0 rlineto 0 1 rlineto -1 0 rlineto closepath",
roentgen b75cab
	"fill newpath}if 1 bitshift}for pop}ifelse}def /.notdef {}",
roentgen b75cab
	"def /255 {}def end /BuildChar{exch begin dup 110 ge{Encoding",
roentgen b75cab
	"exch get 3 string cvs cvi CharDict /black get}{dup 100 ge {Encoding",
roentgen b75cab
	"exch get 3 string cvs cvi CharDict /white get}{Encoding exch get",
roentgen b75cab
	"3 string cvs cvi CharDict /numbuild get}ifelse}ifelse exec end",
roentgen b75cab
	"}def end /Bitfont newfont definefont 1 scalefont setfont",
roentgen b75cab
	NULL
roentgen b75cab
    };
roentgen b75cab
    int i;
roentgen b75cab
    for (i = 0; fontPrologue[i] != NULL; i++)
roentgen b75cab
	fprintf(fd, "%s\n", fontPrologue[i]);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
printTIF(TIFF* tif, uint16 pageNumber)
roentgen b75cab
{
roentgen b75cab
    uint32 w, h;
roentgen b75cab
    uint16 unit, compression;
roentgen b75cab
    float xres, yres, scale = 1.0;
roentgen b75cab
    tstrip_t s, ns;
roentgen b75cab
    time_t creation_time;
roentgen b75cab
roentgen b75cab
    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
roentgen b75cab
    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
roentgen b75cab
    if (!TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression)
roentgen b75cab
	|| compression < COMPRESSION_CCITTRLE
roentgen b75cab
	|| compression > COMPRESSION_CCITT_T6)
roentgen b75cab
	return;
roentgen b75cab
    if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) || !xres) {
roentgen b75cab
	TIFFWarning(TIFFFileName(tif),
roentgen b75cab
	    "No x-resolution, assuming %g dpi", defxres);
roentgen b75cab
	xres = defxres;
roentgen b75cab
    }
roentgen b75cab
    if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) || !yres) {
roentgen b75cab
	TIFFWarning(TIFFFileName(tif),
roentgen b75cab
	    "No y-resolution, assuming %g lpi", defyres);
roentgen b75cab
	yres = defyres;					/* XXX */
roentgen b75cab
    }
roentgen b75cab
    if (TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &unit) &&
roentgen b75cab
      unit == RESUNIT_CENTIMETER) {
roentgen b75cab
	xres *= 2.54F;
roentgen b75cab
	yres *= 2.54F;
roentgen b75cab
    }
roentgen b75cab
    if (pageWidth == 0)
roentgen b75cab
	pageWidth = w / xres;
roentgen b75cab
    if (pageHeight == 0)
roentgen b75cab
	pageHeight = h / yres;
roentgen b75cab
roentgen b75cab
    printf("%%!PS-Adobe-3.0\n");
roentgen b75cab
    printf("%%%%Creator: fax2ps\n");
roentgen b75cab
#ifdef notdef
roentgen b75cab
    printf("%%%%Title: %s\n", file);
roentgen b75cab
#endif
roentgen b75cab
    creation_time = time(0);
roentgen b75cab
    printf("%%%%CreationDate: %s", ctime(&creation_time));
roentgen b75cab
    printf("%%%%Origin: 0 0\n");
roentgen b75cab
    printf("%%%%BoundingBox: 0 0 %u %u\n",
roentgen b75cab
	(int)(pageWidth * points), (int)(pageHeight * points));	/* XXX */
roentgen b75cab
    printf("%%%%Pages: (atend)\n");
roentgen b75cab
    printf("%%%%EndComments\n");
roentgen b75cab
    printf("%%%%BeginProlog\n");
roentgen b75cab
    emitFont(stdout);
roentgen b75cab
    printf("/d{bind def}def\n"); /* bind and def proc */
roentgen b75cab
    printf("/m{0 exch moveto}d\n");
roentgen b75cab
    printf("/s{show}d\n");
roentgen b75cab
    printf("/p{showpage}d \n");	/* end page */
roentgen b75cab
    printf("%%%%EndProlog\n");
roentgen b75cab
    printf("%%%%Page: \"%u\" %u\n", pageNumber, pageNumber);
roentgen b75cab
    printf("/$pageTop save def gsave\n");
roentgen b75cab
    if (scaleToPage)
roentgen b75cab
        scale = pageHeight / (h/yres) < pageWidth / (w/xres) ?
roentgen b75cab
            pageHeight / (h/yres) : pageWidth / (w/xres);
roentgen b75cab
    printf("%g %g translate\n",
roentgen b75cab
           points * (pageWidth - scale*w/xres) * half,
roentgen b75cab
           points * (scale*h/yres + (pageHeight - scale*h/yres) * half));
roentgen b75cab
    printf("%g %g scale\n", points/xres*scale, -points/yres*scale);
roentgen b75cab
    printf("0 setgray\n");
roentgen b75cab
    TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, printruns);
roentgen b75cab
    ns = TIFFNumberOfStrips(tif);
roentgen b75cab
    row = 0;
roentgen b75cab
    for (s = 0; s < ns; s++)
roentgen b75cab
	(void) TIFFReadEncodedStrip(tif, s, (tdata_t) NULL, (tsize_t) -1);
roentgen b75cab
    printf("p\n");
roentgen b75cab
    printf("grestore $pageTop restore\n");
roentgen b75cab
    totalPages++;
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
#define	GetPageNumber(tif) \
roentgen b75cab
TIFFGetField(tif, TIFFTAG_PAGENUMBER, &pn, &ptotal)
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
findPage(TIFF* tif, uint16 pageNumber)
roentgen b75cab
{
roentgen b75cab
    uint16 pn = (uint16) -1;
roentgen b75cab
    uint16 ptotal = (uint16) -1;
roentgen b75cab
    if (GetPageNumber(tif)) {
roentgen b75cab
	while (pn != (pageNumber-1) && TIFFReadDirectory(tif) && GetPageNumber(tif))
roentgen b75cab
	    ;
roentgen b75cab
	return (pn == (pageNumber-1));
roentgen b75cab
    } else
roentgen b75cab
	return (TIFFSetDirectory(tif, (tdir_t)(pageNumber-1)));
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
fax2ps(TIFF* tif, uint16 npages, uint16* pages, char* filename)
roentgen b75cab
{
roentgen b75cab
    if (npages > 0) {
roentgen b75cab
	uint16 pn, ptotal;
roentgen b75cab
	int i;
roentgen b75cab
roentgen b75cab
	if (!GetPageNumber(tif))
roentgen b75cab
	    fprintf(stderr, "%s: No page numbers, counting directories.\n",
roentgen b75cab
		filename);
roentgen b75cab
	for (i = 0; i < npages; i++) {
roentgen b75cab
	    if (findPage(tif, pages[i]))
roentgen b75cab
		printTIF(tif, pages[i]);
roentgen b75cab
	    else
roentgen b75cab
		fprintf(stderr, "%s: No page number %d\n", filename, pages[i]);
roentgen b75cab
	}
roentgen b75cab
    } else {
roentgen b75cab
	uint16 pageNumber = 0;
roentgen b75cab
	do
roentgen b75cab
	    printTIF(tif, pageNumber++);
roentgen b75cab
	while (TIFFReadDirectory(tif));
roentgen b75cab
    }
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
#undef GetPageNumber
roentgen b75cab
roentgen b75cab
static int
roentgen b75cab
pcompar(const void* va, const void* vb)
roentgen b75cab
{
roentgen b75cab
    const int* pa = (const int*) va;
roentgen b75cab
    const int* pb = (const int*) vb;
roentgen b75cab
    return (*pa - *pb);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static	void usage(int code);
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
main(int argc, char** argv)
roentgen b75cab
{
roentgen b75cab
    extern int optind;
roentgen b75cab
    extern char* optarg;
roentgen b75cab
    uint16 *pages = NULL, npages = 0, pageNumber;
roentgen b75cab
    int c, dowarnings = 0;		/* if 1, enable library warnings */
roentgen b75cab
    TIFF* tif;
roentgen b75cab
roentgen b75cab
    while ((c = getopt(argc, argv, "l:p:x:y:W:H:wS")) != -1)
roentgen b75cab
	switch (c) {
roentgen b75cab
	case 'H':		/* page height */
roentgen b75cab
	    pageHeight = (float)atof(optarg);
roentgen b75cab
	    break;
roentgen b75cab
	case 'S':		/* scale to page */
roentgen b75cab
	    scaleToPage = 1;
roentgen b75cab
	    break;
roentgen b75cab
	case 'W':		/* page width */
roentgen b75cab
	    pageWidth = (float)atof(optarg);
roentgen b75cab
	    break;
roentgen b75cab
	case 'p':		/* print specific page */
roentgen b75cab
	    pageNumber = (uint16)atoi(optarg);
roentgen b75cab
	    if (pages)
roentgen b75cab
		pages = (uint16*) realloc(pages, (npages+1)*sizeof(uint16));
roentgen b75cab
	    else
roentgen b75cab
		pages = (uint16*) malloc(sizeof(uint16));
roentgen b75cab
	    pages[npages++] = pageNumber;
roentgen b75cab
	    break;
roentgen b75cab
	case 'w':
roentgen b75cab
	    dowarnings = 1;
roentgen b75cab
	    break;
roentgen b75cab
	case 'x':
roentgen b75cab
	    defxres = (float)atof(optarg);
roentgen b75cab
	    break;
roentgen b75cab
	case 'y':
roentgen b75cab
	    defyres = (float)atof(optarg);
roentgen b75cab
	    break;
roentgen b75cab
	case 'l':
roentgen b75cab
	    maxline = atoi(optarg);
roentgen b75cab
	    break;
roentgen b75cab
	case '?':
roentgen b75cab
	    usage(-1);
roentgen b75cab
	}
roentgen b75cab
    if (npages > 0)
roentgen b75cab
	qsort(pages, npages, sizeof(uint16), pcompar);
roentgen b75cab
    if (!dowarnings)
roentgen b75cab
	TIFFSetWarningHandler(0);
roentgen b75cab
    if (optind < argc) {
roentgen b75cab
	do {
roentgen b75cab
	    tif = TIFFOpen(argv[optind], "r");
roentgen b75cab
	    if (tif) {
roentgen b75cab
		fax2ps(tif, npages, pages, argv[optind]);
roentgen b75cab
		TIFFClose(tif);
roentgen b75cab
	    } else
roentgen b75cab
		fprintf(stderr, "%s: Can not open, or not a TIFF file.\n",
roentgen b75cab
		    argv[optind]);
roentgen b75cab
	} while (++optind < argc);
roentgen b75cab
    } else {
roentgen b75cab
	int n;
roentgen b75cab
	FILE* fd;
roentgen b75cab
	char buf[16*1024];
roentgen b75cab
roentgen b75cab
	fd = tmpfile();
roentgen b75cab
	if (fd == NULL) {
roentgen b75cab
	    fprintf(stderr, "Could not obtain temporary file.\n");
roentgen b75cab
	    exit(-2);
roentgen b75cab
	}
roentgen b75cab
#if defined(HAVE_SETMODE) && defined(O_BINARY)
roentgen b75cab
	setmode(fileno(stdin), O_BINARY);
roentgen b75cab
#endif
roentgen b75cab
	while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0)
roentgen b75cab
	    write(fileno(fd), buf, n);
roentgen b75cab
	lseek(fileno(fd), 0, SEEK_SET);
roentgen b75cab
#if defined(_WIN32) && defined(USE_WIN32_FILEIO)
roentgen b75cab
	tif = TIFFFdOpen(_get_osfhandle(fileno(fd)), "temp", "r");
roentgen b75cab
#else
roentgen b75cab
	tif = TIFFFdOpen(fileno(fd), "temp", "r");
roentgen b75cab
#endif
roentgen b75cab
	if (tif) {
roentgen b75cab
	    fax2ps(tif, npages, pages, "<stdin>");</stdin>
roentgen b75cab
	    TIFFClose(tif);
roentgen b75cab
	} else
roentgen b75cab
	    fprintf(stderr, "Can not open, or not a TIFF file.\n");
roentgen b75cab
	fclose(fd);
roentgen b75cab
    }
roentgen b75cab
    printf("%%%%Trailer\n");
roentgen b75cab
    printf("%%%%Pages: %u\n", totalPages);
roentgen b75cab
    printf("%%%%EOF\n");
roentgen b75cab
roentgen b75cab
    return (0);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
char* stuff[] = {
roentgen b75cab
"usage: fax2ps [options] [input.tif ...]",
roentgen b75cab
"where options are:",
roentgen b75cab
" -w            suppress warning messages",
roentgen b75cab
" -l chars      set maximum output line length for generated PostScript",
roentgen b75cab
" -p page#      select page to print (can use multiple times)",
roentgen b75cab
" -x xres       set default horizontal resolution of input data (dpi)",
roentgen b75cab
" -y yres       set default vertical resolution of input data (lpi)",
roentgen b75cab
" -S            scale output to page size",
roentgen b75cab
" -W width      set output page width (inches), default is 8.5",
roentgen b75cab
" -H height     set output page height (inches), default is 11",
roentgen b75cab
NULL
roentgen b75cab
};
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
usage(int code)
roentgen b75cab
{
roentgen b75cab
	char buf[BUFSIZ];
roentgen b75cab
	int i;
roentgen b75cab
roentgen b75cab
	setbuf(stderr, buf);
roentgen b75cab
        fprintf(stderr, "%s\n\n", TIFFGetVersion());
roentgen b75cab
	for (i = 0; stuff[i] != NULL; i++)
roentgen b75cab
		fprintf(stderr, "%s\n", stuff[i]);
roentgen b75cab
	exit(code);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
/* vim: set ts=8 sts=8 sw=8 noet: */
roentgen b75cab
/*
roentgen b75cab
 * Local Variables:
roentgen b75cab
 * mode: c
roentgen b75cab
 * c-basic-offset: 8
roentgen b75cab
 * fill-column: 78
roentgen b75cab
 * End:
roentgen b75cab
 */