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