--- ray/src/px/pcompos.c 1994/02/27 10:17:04 2.18 +++ ray/src/px/pcompos.c 2003/11/10 12:28:56 2.26 @@ -1,9 +1,6 @@ -/* Copyright (c) 1993 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: pcompos.c,v 2.26 2003/11/10 12:28:56 schorsch Exp $"; #endif - /* * pcompos.c - program to composite pictures. * @@ -11,15 +8,15 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include - #include +#include +#include -#ifdef MSDOS -#include -#endif +#include "copyright.h" +#include "platform.h" +#include "rtprocess.h" #include "color.h" - #include "resolu.h" #define MAXFILE 64 @@ -58,26 +55,31 @@ struct { int nfile; /* number of files */ +char ourfmt[LPICFMT+1] = PICFMT; int wrongformat = 0; -FILE *popen(), *lblopen(); +FILE *lblopen(); +void quit(); -extern char *malloc(); - tabputs(s) /* print line preceded by a tab */ char *s; { char fmt[32]; if (isheadid(s)) - return; - if (formatval(fmt, s)) - wrongformat = strcmp(fmt, COLRFMT); - else { + return(0); + if (formatval(fmt, s)) { + if (globmatch(ourfmt, fmt)) { + wrongformat = 0; + strcpy(ourfmt, fmt); + } else + wrongformat = 1; + } else { putc('\t', stdout); fputs(s, stdout); } + return(0); } @@ -91,12 +93,9 @@ char *argv[]; int xsgn, ysgn; char *thislabel; int an; -#ifdef MSDOS - extern int _fmode; - _fmode = O_BINARY; - setmode(fileno(stdin), O_BINARY); - setmode(fileno(stdout), O_BINARY); -#endif + SET_DEFAULT_BINARY(); + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); progname = argv[0]; for (an = 1; an < argc && argv[an][0] == '-'; an++) @@ -145,6 +144,7 @@ char *argv[]; } dofiles: newheader("RADIANCE", stdout); + fputnow(stdout); for (nfile = 0; an < argc; nfile++) { if (nfile >= MAXFILE) goto toomany; @@ -222,7 +222,7 @@ getfile: printf("%s:\n", input[nfile].name); getheader(input[nfile].fp, tabputs, NULL); if (wrongformat) { - fprintf(stderr, "%s: not a Radiance picture\n", + fprintf(stderr, "%s: incompatible input format\n", input[nfile].name); quit(1); } @@ -289,7 +289,8 @@ getfile: ymax = ysiz; /* add new header info. */ printargs(argc, argv, stdout); - fputformat(COLRFMT, stdout); + if (strcmp(ourfmt, PICFMT)) + fputformat(ourfmt, stdout); /* print format if known */ putchar('\n'); fprtresolu(xsiz, ysiz, stdout); @@ -381,7 +382,7 @@ register COLR c1, c2; j = 4; /* check exponents first! */ while (j--) - if (i = c1[j] - c2[j]) + if ( (i = c1[j] - c2[j]) ) return(i); return(0); } @@ -392,7 +393,7 @@ lblopen(s, xp, yp) /* open pipe to label generator */ char *s; int *xp, *yp; { - char com[128]; + char com[PATH_MAX]; FILE *fp; sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s); @@ -409,6 +410,7 @@ err: } +void quit(code) /* exit gracefully */ int code; {