--- ray/src/px/ttyimage.c 1990/01/26 08:17:41 1.6 +++ ray/src/px/ttyimage.c 2004/03/28 20:33:14 2.5 @@ -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.5 2004/03/28 20:33:14 schorsch Exp $"; #endif - /* * ttyimage.c - program to dump pixel file to dumb terminal. * @@ -11,16 +8,20 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#include +#include "platform.h" #include "color.h" +#include "resolu.h" -#define NCOLS 133 +#define NCOLS 133 +static int shade(COLR clr); -main(argc, argv) -int argc; -char **argv; + +int +main(int argc, char **argv) { FILE *input; int xres, yres; @@ -33,12 +34,11 @@ char **argv; fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], argv[1]); exit(1); } - - /* discard header */ - getheader(input, NULL); + 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) { @@ -61,11 +61,12 @@ char **argv; } -int -shade(clr) /* return character for color */ -COLR clr; +static int +shade( /* return character for color */ + COLR clr +) { -#define NSHADES 13 +#define NSHADES 13 static char shadech[NSHADES+1] = " .,:;+?%&*$@#";