1 |
– |
/* Copyright (c) 1993 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 |
|
* pcompos.c - program to composite pictures. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
14 |
– |
|
11 |
|
#include <math.h> |
12 |
+ |
#include <time.h> |
13 |
|
|
14 |
< |
#ifdef MSDOS |
18 |
< |
#include <fcntl.h> |
19 |
< |
#endif |
14 |
> |
#include "copyright.h" |
15 |
|
|
16 |
+ |
#include "platform.h" |
17 |
|
#include "color.h" |
22 |
– |
|
18 |
|
#include "resolu.h" |
19 |
|
|
20 |
|
#define MAXFILE 64 |
53 |
|
|
54 |
|
int nfile; /* number of files */ |
55 |
|
|
56 |
+ |
char ourfmt[LPICFMT+1] = PICFMT; |
57 |
|
int wrongformat = 0; |
58 |
|
|
59 |
< |
FILE *popen(), *lblopen(); |
59 |
> |
FILE *lblopen(); |
60 |
> |
void quit(); |
61 |
|
|
65 |
– |
extern char *malloc(); |
62 |
|
|
67 |
– |
|
63 |
|
tabputs(s) /* print line preceded by a tab */ |
64 |
|
char *s; |
65 |
|
{ |
66 |
|
char fmt[32]; |
67 |
|
|
68 |
< |
if (isformat(s)) { |
69 |
< |
formatval(fmt, s); |
70 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
68 |
> |
if (isheadid(s)) |
69 |
> |
return(0); |
70 |
> |
if (formatval(fmt, s)) { |
71 |
> |
if (globmatch(ourfmt, fmt)) { |
72 |
> |
wrongformat = 0; |
73 |
> |
strcpy(ourfmt, fmt); |
74 |
> |
} else |
75 |
> |
wrongformat = 1; |
76 |
|
} else { |
77 |
|
putc('\t', stdout); |
78 |
|
fputs(s, stdout); |
79 |
|
} |
80 |
+ |
return(0); |
81 |
|
} |
82 |
|
|
83 |
|
|
91 |
|
int xsgn, ysgn; |
92 |
|
char *thislabel; |
93 |
|
int an; |
94 |
< |
#ifdef MSDOS |
95 |
< |
extern int _fmode; |
96 |
< |
_fmode = O_BINARY; |
96 |
< |
setmode(fileno(stdin), O_BINARY); |
97 |
< |
setmode(fileno(stdout), O_BINARY); |
98 |
< |
#endif |
94 |
> |
SET_DEFAULT_BINARY(); |
95 |
> |
SET_FILE_BINARY(stdin); |
96 |
> |
SET_FILE_BINARY(stdout); |
97 |
|
progname = argv[0]; |
98 |
|
|
99 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
141 |
|
goto userr; |
142 |
|
} |
143 |
|
dofiles: |
144 |
+ |
newheader("RADIANCE", stdout); |
145 |
+ |
fputnow(stdout); |
146 |
|
for (nfile = 0; an < argc; nfile++) { |
147 |
|
if (nfile >= MAXFILE) |
148 |
|
goto toomany; |
220 |
|
printf("%s:\n", input[nfile].name); |
221 |
|
getheader(input[nfile].fp, tabputs, NULL); |
222 |
|
if (wrongformat) { |
223 |
< |
fprintf(stderr, "%s: not a Radiance picture\n", |
223 |
> |
fprintf(stderr, "%s: incompatible input format\n", |
224 |
|
input[nfile].name); |
225 |
|
quit(1); |
226 |
|
} |
287 |
|
ymax = ysiz; |
288 |
|
/* add new header info. */ |
289 |
|
printargs(argc, argv, stdout); |
290 |
< |
fputformat(COLRFMT, stdout); |
290 |
> |
if (strcmp(ourfmt, PICFMT)) |
291 |
> |
fputformat(ourfmt, stdout); /* print format if known */ |
292 |
|
putchar('\n'); |
293 |
|
fprtresolu(xsiz, ysiz, stdout); |
294 |
|
|
408 |
|
} |
409 |
|
|
410 |
|
|
411 |
+ |
void |
412 |
|
quit(code) /* exit gracefully */ |
413 |
|
int code; |
414 |
|
{ |