--- ray/src/px/oki20.c 1992/07/03 10:30:07 2.4 +++ ray/src/px/oki20.c 2004/03/28 20:33:14 2.13 @@ -1,49 +1,49 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: oki20.c,v 2.13 2004/03/28 20:33:14 schorsch Exp $"; #endif - /* - * oki20c.c - program to dump pixel file to OkiMate 20 color printer. + * oki20.c - program to dump pixel file to OkiMate 20 printer. */ #include +#include +#include "platform.h" +#include "rtprocess.h" #include "color.h" #include "resolu.h" -#define NROWS 1440 /* 10" at 144 dpi */ -#define NCOLS 960 /* 8" at 120 dpi */ +#define NROWS 1440 /* 10" at 144 dpi */ +#define NCOLS 960 /* 8" at 120 dpi */ -#define ASPECT (120./144.) /* pixel aspect ratio */ +#define ASPECT (120./144.) /* pixel aspect ratio */ -#define FILTER "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT +#define FILTER "pfilt -1 -x %d -y %d -p %f",NCOLS,NROWS,ASPECT +#define FILTER_F "pfilt -1 -x %d -y %d -p %f \"%s\"",NCOLS,NROWS,ASPECT -#ifdef BSD -#define clearlbuf() bzero((char *)lpat, sizeof(lpat)) -#else -#define clearlbuf() (void)memset((char *)lpat, 0, sizeof(lpat)) -#endif - long lpat[NCOLS]; int dofilter = 0; /* filter through pfilt first? */ +static int printp(char *fname); +static void plotscan(COLR scan[], int len, int y); +static int bit(COLR col, int x); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { int i, status = 0; - + SET_DEFAULT_BINARY(); + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); if (argc > 1 && !strcmp(argv[1], "-p")) { dofilter++; argv++; argc--; } -#ifdef _IOLBF - stdout->_flag &= ~_IOLBF; -#endif if (argc < 2) status = printp(NULL) == -1; else @@ -53,10 +53,12 @@ char *argv[]; } -printp(fname) /* print a picture */ -char *fname; +static int +printp( /* print a picture */ + char *fname +) { - char buf[64]; + char buf[PATH_MAX]; FILE *input; int xres, yres; COLR scanline[NCOLS]; @@ -64,10 +66,10 @@ char *fname; if (dofilter) { if (fname == NULL) { - sprintf(buf, FILTER, ""); + sprintf(buf, FILTER); fname = ""; } else - sprintf(buf, FILTER, fname); + sprintf(buf, FILTER_F, fname); if ((input = popen(buf, "r")) == NULL) { fprintf(stderr, "Cannot execute: %s\n", buf); return(-1); @@ -95,8 +97,6 @@ char *fname; } /* set line spacing (overlap for knitting) */ fputs("\0333\042\022", stdout); - /* clear line buffer */ - clearlbuf(); /* put out scanlines */ for (i = yres-1; i >= 0; i--) { if (freadcolrs(scanline, xres, input) < 0) { @@ -118,10 +118,12 @@ char *fname; } -plotscan(scan, len, y) /* plot a scanline */ -COLR scan[]; -int len; -int y; +static void +plotscan( /* plot a scanline */ + COLR scan[], + int len, + int y +) { int bpos, start, end; register long c; @@ -154,11 +156,13 @@ int y; putchar(i >> 8); for (i = start; i <= end; i++) { c = lpat[i]; - putchar(c>>16); - putchar(c>>8 & 255); - putchar(c & 255); - /* repeat this row next time */ - lpat[i] = (c & 1) << 23; + putchar((int)(c>>16)); + putchar((int)(c>>8 & 255)); + putchar((int)(c & 255)); + if (y) /* repeat this row next time */ + lpat[i] = (c & 1) << 23; + else /* or clear for next image */ + lpat[i] = 0L; } putchar('\r'); putchar('\n'); @@ -166,9 +170,11 @@ int y; } -bit(col, x) /* determine bit value for pixel at x */ -COLR col; -register int x; +static int +bit( /* determine bit value for pixel at x */ + COLR col, + register int x +) { static int cerr[NCOLS]; static int err;