--- ray/src/px/ttyimage.c 1989/10/20 20:36:08 1.4 +++ ray/src/px/ttyimage.c 2003/06/05 19:29:34 2.4 @@ -1,9 +1,6 @@ -/* Copyright (c) 1986 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ttyimage.c,v 2.4 2003/06/05 19:29:34 schorsch Exp $"; #endif - /* * ttyimage.c - program to dump pixel file to dumb terminal. * @@ -11,11 +8,14 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#include +#include "platform.h" #include "color.h" +#include "resolu.h" -#define NCOLS 133 +#define NCOLS 133 main(argc, argv) @@ -25,7 +25,6 @@ char **argv; FILE *input; int xres, yres; COLR scanline[NCOLS]; - char sbuf[256]; register int i, j; if (argc < 2) @@ -34,13 +33,11 @@ char **argv; fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], argv[1]); exit(1); } - - /* discard header */ - while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n') - ; + SET_FILE_BINARY(input); /* get picture dimensions */ - if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { - fprintf(stderr, "%s: bad picture size\n", argv[0]); + if (checkheader(input, COLRFMT, NULL) < 0 || + fgetresolu(&xres, &yres, input) < 0) { + fprintf(stderr, "%s: bad picture format\n", argv[0]); exit(1); } if (xres > NCOLS) { @@ -53,7 +50,7 @@ char **argv; fprintf(stderr, "%s: read error\n", argv[0]); exit(1); } - normcolrs(scanline, xres); + normcolrs(scanline, xres, 0); for (j = 0; j < xres; j++) putchar(shade(scanline[j])); putchar('\n'); @@ -67,7 +64,7 @@ int shade(clr) /* return character for color */ COLR clr; { -#define NSHADES 13 +#define NSHADES 13 static char shadech[NSHADES+1] = " .,:;+?%&*$@#";