--- ray/src/px/ra_rgbe.c 2003/02/22 02:07:28 2.10 +++ ray/src/px/ra_rgbe.c 2019/12/28 18:05:14 2.21 @@ -1,32 +1,24 @@ #ifndef lint -static const char RCSid[] = "$Id: ra_rgbe.c,v 2.10 2003/02/22 02:07:28 greg Exp $"; +static const char RCSid[] = "$Id: ra_rgbe.c,v 2.21 2019/12/28 18:05:14 greg Exp $"; #endif /* * program to convert from RADIANCE RLE to flat format */ -#include #include -#include + +#include "platform.h" +#include "rtio.h" +#include "paths.h" #include "color.h" #include "resolu.h" -#ifdef MSDOS -#include -#endif +#define dumpheader(fp) putbinary(headlines, 1, headlen, fp) -extern int addhline(); - -#define dumpheader(fp) fwrite(headlines, 1, headlen, fp) - int bradj = 0; /* brightness adjustment */ - int doflat = 1; /* produce flat file */ - int force = 0; /* force file overwrite? */ - int findframe = 0; /* find a specific frame? */ - int frameno = 0; /* current frame number */ int fmterr = 0; /* got input format error */ char *headlines; /* current header info. */ @@ -34,10 +26,13 @@ int headlen; /* current header length */ char *progname; +static gethfunc addhline; +static int transfer(char *ospec); +static int loadheader(FILE *fp); -main(argc, argv) -int argc; -char *argv[]; + +int +main(int argc, char *argv[]) { char *ospec; int i; @@ -77,9 +72,7 @@ gotfile: progname, argv[i]); exit(1); } -#ifdef MSDOS - setmode(fileno(stdin), O_BINARY); -#endif + SET_FILE_BINARY(stdin); ospec = i==argc-2 ? argv[i+1] : (char *)NULL; while (transfer(ospec)) ; @@ -92,10 +85,12 @@ userr: } -transfer(ospec) /* transfer a Radiance picture */ -char *ospec; +static int +transfer( /* transfer a Radiance picture */ + char *ospec +) { - char oname[128]; + char oname[PATH_MAX]; FILE *fp; int order; int xmax, ymax; @@ -154,9 +149,7 @@ char *ospec; } } } -#ifdef MSDOS - setmode(fileno(fp), O_BINARY); -#endif + SET_FILE_BINARY(fp); dumpheader(fp); /* put out header */ fputs(progname, fp); if (bradj) @@ -178,7 +171,7 @@ char *ospec; if (bradj) shiftcolrs(scanin, xmax, bradj); if (doflat) - fwrite((char *)scanin, sizeof(COLR), xmax, fp); + putbinary((char *)scanin, sizeof(COLR), xmax, fp); else fwritecolrs(scanin, xmax, fp); if (ferror(fp)) { @@ -196,11 +189,13 @@ char *ospec; } -int -addhline(s) /* add a line to our info. header */ -char *s; +static int +addhline( /* add a line to our info. header */ + char *s, + void *p +) { - char fmt[32]; + char fmt[MAXFMTLEN]; int n; if (formatval(fmt, s)) @@ -209,7 +204,7 @@ char *s; frameno = atoi(s+6); n = strlen(s); if (headlen) - headlines = (char *)realloc(headlines, headlen+n+1); + headlines = (char *)realloc((void *)headlines, headlen+n+1); else headlines = (char *)malloc(n+1); if (headlines == NULL) { @@ -222,8 +217,10 @@ char *s; } -loadheader(fp) /* load an info. header into memory */ -FILE *fp; +static int +loadheader( /* load an info. header into memory */ + FILE *fp +) { fmterr = 0; frameno = 0; if (headlen) { /* free old header */