--- ray/src/px/pflip.c 1995/10/16 11:40:11 2.4 +++ ray/src/px/pflip.c 2006/08/08 18:04:41 2.9 @@ -1,21 +1,16 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: pflip.c,v 2.9 2006/08/08 18:04:41 greg Exp $"; #endif - /* * flip picture file horizontally and/or vertically */ #include +#include +#include -#ifdef MSDOS -#include -#endif - +#include "platform.h" #include "color.h" - #include "resolu.h" int order; /* input orientation */ @@ -31,11 +26,14 @@ FILE *fin; /* input file */ char *progname; -extern char *malloc(); +static void memerr(void); +static void scanfile(void); +static void flip(void); -int -neworder() /* figure out new order from old */ + +static int +neworder(void) /* figure out new order from old */ { register int no; @@ -51,18 +49,16 @@ neworder() /* figure out new order from old */ return(no); } - -main(argc, argv) -int argc; -char *argv[]; +int +main( + int argc, + char *argv[] +) { static char picfmt[LPICFMT+1] = PICFMT; int i, rval; -#ifdef MSDOS - extern int _fmode; - _fmode = O_BINARY; - setmode(fileno(stdout), O_BINARY); -#endif + SET_DEFAULT_BINARY(); + SET_FILE_BINARY(stdout); progname = argv[0]; for (i = 1; i < argc; i++) @@ -80,7 +76,7 @@ char *argv[]; exit(1); } if ((fin = fopen(argv[i], "r")) == NULL) { - fprintf(stderr, "%s: cannot open\n", argv[1]); + fprintf(stderr, "%s: cannot open\n", argv[i]); exit(1); } if (i < argc-1 && freopen(argv[i+1], "w", stdout) == NULL) { @@ -113,14 +109,16 @@ char *argv[]; } -memerr() +static void +memerr(void) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } -scanfile() /* scan to the end of file */ +static void +scanfile(void) /* scan to the end of file */ { extern long ftell(); COLR *scanin; @@ -138,11 +136,12 @@ scanfile() /* scan to the end of file */ } } scanpos[0] = ftell(fin); - free((char *)scanin); + free((void *)scanin); } -flip() /* flip the picture */ +static void +flip(void) /* flip the picture */ { COLR *scanin, *scanout; int y; @@ -172,7 +171,7 @@ flip() /* flip the picture */ exit(1); } } - free((char *)scanin); + free((void *)scanin); if (fhoriz) - free((char *)scanout); + free((void *)scanout); }