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