1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* program to convert from RADIANCE RLE to flat format |
6 |
|
*/ |
7 |
|
|
11 |
– |
#include <stdio.h> |
8 |
|
#include <math.h> |
9 |
+ |
|
10 |
+ |
#include "platform.h" |
11 |
+ |
#include "rtio.h" |
12 |
+ |
#include "paths.h" |
13 |
|
#include "color.h" |
14 |
|
#include "resolu.h" |
15 |
|
|
16 |
< |
#ifdef MSDOS |
17 |
< |
#include <fcntl.h> |
18 |
< |
#endif |
16 |
> |
#define dumpheader(fp) putbinary(headlines, 1, headlen, fp) |
17 |
|
|
20 |
– |
extern char *malloc(), *realloc(), *tempbuffer(); |
21 |
– |
extern int addhline(); |
22 |
– |
|
23 |
– |
#define dumpheader(fp) fwrite(headlines, 1, headlen, fp) |
24 |
– |
|
18 |
|
int bradj = 0; /* brightness adjustment */ |
26 |
– |
|
19 |
|
int doflat = 1; /* produce flat file */ |
28 |
– |
|
20 |
|
int force = 0; /* force file overwrite? */ |
30 |
– |
|
21 |
|
int findframe = 0; /* find a specific frame? */ |
32 |
– |
|
22 |
|
int frameno = 0; /* current frame number */ |
23 |
|
int fmterr = 0; /* got input format error */ |
24 |
|
char *headlines; /* current header info. */ |
26 |
|
|
27 |
|
char *progname; |
28 |
|
|
29 |
+ |
static gethfunc addhline; |
30 |
+ |
static int transfer(char *ospec); |
31 |
+ |
static int loadheader(FILE *fp); |
32 |
|
|
33 |
< |
main(argc, argv) |
34 |
< |
int argc; |
35 |
< |
char *argv[]; |
33 |
> |
|
34 |
> |
int |
35 |
> |
main(int argc, char *argv[]) |
36 |
|
{ |
37 |
|
char *ospec; |
38 |
|
int i; |
72 |
|
progname, argv[i]); |
73 |
|
exit(1); |
74 |
|
} |
75 |
< |
#ifdef MSDOS |
84 |
< |
setmode(fileno(stdin), O_BINARY); |
85 |
< |
#endif |
75 |
> |
SET_FILE_BINARY(stdin); |
76 |
|
ospec = i==argc-2 ? argv[i+1] : (char *)NULL; |
77 |
|
while (transfer(ospec)) |
78 |
|
; |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
< |
transfer(ospec) /* transfer a Radiance picture */ |
89 |
< |
char *ospec; |
88 |
> |
static int |
89 |
> |
transfer( /* transfer a Radiance picture */ |
90 |
> |
char *ospec |
91 |
> |
) |
92 |
|
{ |
93 |
< |
char oname[128]; |
93 |
> |
char oname[PATH_MAX]; |
94 |
|
FILE *fp; |
95 |
|
int order; |
96 |
|
int xmax, ymax; |
149 |
|
} |
150 |
|
} |
151 |
|
} |
152 |
< |
#ifdef MSDOS |
161 |
< |
setmode(fileno(fp), O_BINARY); |
162 |
< |
#endif |
152 |
> |
SET_FILE_BINARY(fp); |
153 |
|
dumpheader(fp); /* put out header */ |
154 |
|
fputs(progname, fp); |
155 |
|
if (bradj) |
171 |
|
if (bradj) |
172 |
|
shiftcolrs(scanin, xmax, bradj); |
173 |
|
if (doflat) |
174 |
< |
fwrite((char *)scanin, sizeof(COLR), xmax, fp); |
174 |
> |
putbinary((char *)scanin, sizeof(COLR), xmax, fp); |
175 |
|
else |
176 |
|
fwritecolrs(scanin, xmax, fp); |
177 |
|
if (ferror(fp)) { |
189 |
|
} |
190 |
|
|
191 |
|
|
192 |
< |
addhline(s) /* add a line to our info. header */ |
193 |
< |
char *s; |
192 |
> |
static int |
193 |
> |
addhline( /* add a line to our info. header */ |
194 |
> |
char *s, |
195 |
> |
void *p |
196 |
> |
) |
197 |
|
{ |
198 |
< |
char fmt[32]; |
198 |
> |
char fmt[MAXFMTLEN]; |
199 |
|
int n; |
200 |
|
|
201 |
|
if (formatval(fmt, s)) |
204 |
|
frameno = atoi(s+6); |
205 |
|
n = strlen(s); |
206 |
|
if (headlen) |
207 |
< |
headlines = (char *)realloc(headlines, headlen+n+1); |
207 |
> |
headlines = (char *)realloc((void *)headlines, headlen+n+1); |
208 |
|
else |
209 |
|
headlines = (char *)malloc(n+1); |
210 |
|
if (headlines == NULL) { |
213 |
|
} |
214 |
|
strcpy(headlines+headlen, s); |
215 |
|
headlen += n; |
216 |
+ |
return(0); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
< |
loadheader(fp) /* load an info. header into memory */ |
221 |
< |
FILE *fp; |
220 |
> |
static int |
221 |
> |
loadheader( /* load an info. header into memory */ |
222 |
> |
FILE *fp |
223 |
> |
) |
224 |
|
{ |
225 |
|
fmterr = 0; frameno = 0; |
226 |
|
if (headlen) { /* free old header */ |