| 8 | 
  | 
#include  <stdio.h> | 
| 9 | 
  | 
#include  <math.h> | 
| 10 | 
  | 
#include  <time.h> | 
| 11 | 
+ | 
#include  <string.h> | 
| 12 | 
+ | 
 | 
| 13 | 
+ | 
#include  "platform.h" | 
| 14 | 
+ | 
#include  "rtio.h" | 
| 15 | 
+ | 
#include  "paths.h" | 
| 16 | 
  | 
#include  "color.h" | 
| 17 | 
  | 
#include  "resolu.h" | 
| 18 | 
  | 
 | 
| 19 | 
< | 
#ifdef MSDOS | 
| 15 | 
< | 
#include  <fcntl.h> | 
| 16 | 
< | 
#endif | 
| 19 | 
> | 
#define dumpheader(fp)  putbinary(headlines, 1, headlen, fp) | 
| 20 | 
  | 
 | 
| 18 | 
– | 
extern int      addhline(); | 
| 19 | 
– | 
 | 
| 20 | 
– | 
#define dumpheader(fp)  fwrite(headlines, 1, headlen, fp) | 
| 21 | 
– | 
 | 
| 21 | 
  | 
int  bradj = 0;                         /* brightness adjustment */ | 
| 23 | 
– | 
 | 
| 22 | 
  | 
int  doflat = 1;                        /* produce flat file */ | 
| 25 | 
– | 
 | 
| 23 | 
  | 
int  force = 0;                         /* force file overwrite? */ | 
| 27 | 
– | 
 | 
| 24 | 
  | 
int  findframe = 0;                     /* find a specific frame? */ | 
| 29 | 
– | 
 | 
| 25 | 
  | 
int  frameno = 0;                       /* current frame number */ | 
| 26 | 
  | 
int  fmterr = 0;                        /* got input format error */ | 
| 27 | 
  | 
char  *headlines;                       /* current header info. */ | 
| 29 | 
  | 
 | 
| 30 | 
  | 
char  *progname; | 
| 31 | 
  | 
 | 
| 32 | 
+ | 
static gethfunc addhline; | 
| 33 | 
+ | 
static int transfer(char *ospec); | 
| 34 | 
+ | 
static int loadheader(FILE *fp); | 
| 35 | 
  | 
 | 
| 36 | 
< | 
main(argc, argv) | 
| 37 | 
< | 
int  argc; | 
| 38 | 
< | 
char  *argv[]; | 
| 36 | 
> | 
 | 
| 37 | 
> | 
int | 
| 38 | 
> | 
main(int  argc, char  *argv[]) | 
| 39 | 
  | 
{ | 
| 40 | 
  | 
        char    *ospec; | 
| 41 | 
  | 
        int  i; | 
| 75 | 
  | 
                                progname, argv[i]); | 
| 76 | 
  | 
                exit(1); | 
| 77 | 
  | 
        } | 
| 78 | 
< | 
#ifdef MSDOS | 
| 81 | 
< | 
        setmode(fileno(stdin), O_BINARY); | 
| 82 | 
< | 
#endif | 
| 78 | 
> | 
        SET_FILE_BINARY(stdin); | 
| 79 | 
  | 
        ospec = i==argc-2 ? argv[i+1] : (char *)NULL; | 
| 80 | 
  | 
        while (transfer(ospec)) | 
| 81 | 
  | 
                ; | 
| 88 | 
  | 
} | 
| 89 | 
  | 
 | 
| 90 | 
  | 
 | 
| 91 | 
< | 
transfer(ospec)                 /* transfer a Radiance picture */ | 
| 92 | 
< | 
char    *ospec; | 
| 91 | 
> | 
static int | 
| 92 | 
> | 
transfer(                       /* transfer a Radiance picture */ | 
| 93 | 
> | 
        char    *ospec | 
| 94 | 
> | 
) | 
| 95 | 
  | 
{ | 
| 96 | 
< | 
        char    oname[128]; | 
| 96 | 
> | 
        char    oname[PATH_MAX]; | 
| 97 | 
  | 
        FILE    *fp; | 
| 98 | 
  | 
        int     order; | 
| 99 | 
  | 
        int     xmax, ymax; | 
| 152 | 
  | 
                        } | 
| 153 | 
  | 
                } | 
| 154 | 
  | 
        } | 
| 155 | 
< | 
#ifdef MSDOS | 
| 158 | 
< | 
        setmode(fileno(fp), O_BINARY); | 
| 159 | 
< | 
#endif | 
| 155 | 
> | 
        SET_FILE_BINARY(fp); | 
| 156 | 
  | 
        dumpheader(fp);                 /* put out header */ | 
| 157 | 
  | 
        fputs(progname, fp); | 
| 158 | 
  | 
        if (bradj) | 
| 174 | 
  | 
                if (bradj) | 
| 175 | 
  | 
                        shiftcolrs(scanin, xmax, bradj); | 
| 176 | 
  | 
                if (doflat) | 
| 177 | 
< | 
                        fwrite((char *)scanin, sizeof(COLR), xmax, fp); | 
| 177 | 
> | 
                        putbinary((char *)scanin, sizeof(COLR), xmax, fp); | 
| 178 | 
  | 
                else | 
| 179 | 
  | 
                        fwritecolrs(scanin, xmax, fp); | 
| 180 | 
  | 
                if (ferror(fp)) { | 
| 192 | 
  | 
} | 
| 193 | 
  | 
 | 
| 194 | 
  | 
 | 
| 195 | 
< | 
int | 
| 196 | 
< | 
addhline(s)                     /* add a line to our info. header */ | 
| 197 | 
< | 
char    *s; | 
| 195 | 
> | 
static int | 
| 196 | 
> | 
addhline(                       /* add a line to our info. header */ | 
| 197 | 
> | 
        char    *s, | 
| 198 | 
> | 
        void    *p | 
| 199 | 
> | 
) | 
| 200 | 
  | 
{ | 
| 201 | 
  | 
        char    fmt[32]; | 
| 202 | 
  | 
        int     n; | 
| 207 | 
  | 
                frameno = atoi(s+6); | 
| 208 | 
  | 
        n = strlen(s); | 
| 209 | 
  | 
        if (headlen) | 
| 210 | 
< | 
                headlines = (char *)realloc(headlines, headlen+n+1); | 
| 210 | 
> | 
                headlines = (char *)realloc((void *)headlines, headlen+n+1); | 
| 211 | 
  | 
        else | 
| 212 | 
  | 
                headlines = (char *)malloc(n+1); | 
| 213 | 
  | 
        if (headlines == NULL) { | 
| 220 | 
  | 
} | 
| 221 | 
  | 
 | 
| 222 | 
  | 
 | 
| 223 | 
< | 
loadheader(fp)                  /* load an info. header into memory */ | 
| 224 | 
< | 
FILE    *fp; | 
| 223 | 
> | 
static int | 
| 224 | 
> | 
loadheader(                     /* load an info. header into memory */ | 
| 225 | 
> | 
        FILE    *fp | 
| 226 | 
> | 
) | 
| 227 | 
  | 
{ | 
| 228 | 
  | 
        fmterr = 0; frameno = 0; | 
| 229 | 
  | 
        if (headlen) {                  /* free old header */ |