ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pcompos.c
(Generate patch)

Comparing ray/src/px/pcompos.c (file contents):
Revision 2.20 by gwlarson, Tue Oct 27 09:08:25 1998 UTC vs.
Revision 2.29 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 1 | Line 1
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   *
# Line 11 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   */
9  
10   #include  <stdio.h>
14
11   #include  <math.h>
12 + #include  <time.h>
13 + #include  <string.h>
14  
15 < #ifdef MSDOS
18 < #include  <fcntl.h>
19 < #endif
15 > #include "copyright.h"
16  
17 + #include  "platform.h"
18 + #include  "rtprocess.h"
19 + #include  "rterror.h"
20   #include  "color.h"
22
21   #include  "resolu.h"
22  
23   #define  MAXFILE        64
# Line 42 | Line 40 | int  labelht = 24;                     /* label height */
40  
41   int  checkthresh = 0;                   /* check threshold value */
42  
43 + char  StandardInput[] = "<stdin>";
44   char  Command[] = "<Command>";
45   char  Label[] = "<Label>";
46  
# Line 61 | Line 60 | int  nfile;                    /* number of files */
60   char  ourfmt[LPICFMT+1] = PICFMT;
61   int  wrongformat = 0;
62  
64 FILE  *popen(), *lblopen();
63  
64 < extern char  *malloc();
64 > static gethfunc tabputs;
65 > static void compos(void);
66 > static int cmpcolr(COLR  c1, COLR  c2);
67 > static FILE * lblopen(char  *s, int  *xp, int  *yp);
68  
69  
70 < tabputs(s)                      /* print line preceded by a tab */
71 < char  *s;
70 >
71 > static int
72 > tabputs(                        /* print line preceded by a tab */
73 >        char    *s,
74 >        void    *p
75 > )
76   {
77          char  fmt[32];
78  
# Line 87 | Line 92 | char  *s;
92   }
93  
94  
95 < main(argc, argv)
96 < int  argc;
97 < char  *argv[];
95 > int
96 > main(
97 >        int  argc,
98 >        char  *argv[]
99 > )
100   {
101          int  ncolumns = 0;
102          int  autolabel = 0;
# Line 97 | Line 104 | char  *argv[];
104          int  xsgn, ysgn;
105          char  *thislabel;
106          int  an;
107 < #ifdef MSDOS
108 <        extern int  _fmode;
109 <        _fmode = O_BINARY;
103 <        setmode(fileno(stdin), O_BINARY);
104 <        setmode(fileno(stdout), O_BINARY);
105 < #endif
107 >        SET_DEFAULT_BINARY();
108 >        SET_FILE_BINARY(stdin);
109 >        SET_FILE_BINARY(stdout);
110          progname = argv[0];
111  
112          for (an = 1; an < argc && argv[an][0] == '-'; an++)
# Line 151 | Line 155 | char  *argv[];
155                  }
156   dofiles:
157          newheader("RADIANCE", stdout);
158 +        fputnow(stdout);
159          for (nfile = 0; an < argc; nfile++) {
160                  if (nfile >= MAXFILE)
161                          goto toomany;
# Line 208 | Line 213 | getfile:
213                  if (autolabel && thislabel == NULL)
214                          thislabel = argv[an];
215                  if (!strcmp(argv[an], "-")) {
216 <                        input[nfile].name = "<stdin>";
216 >                        input[nfile].name = StandardInput;
217                          input[nfile].fp = stdin;
218                  } else {
219                          if (argv[an][0] == '!') {
# Line 228 | Line 233 | getfile:
233                  printf("%s:\n", input[nfile].name);
234                  getheader(input[nfile].fp, tabputs, NULL);
235                  if (wrongformat) {
236 <                        fprintf(stderr, "%s: bad Radiance input file\n",
236 >                        fprintf(stderr, "%s: incompatible input format\n",
237                                          input[nfile].name);
238                          quit(1);
239                  }
# Line 316 | Line 321 | toomany:
321   labelerr:
322          fprintf(stderr, "%s: error opening label\n", progname);
323          quit(1);
324 +        return 1; /* pro forma return */
325   }
326  
327  
328 < compos()                                /* composite pictures */
328 > static void
329 > compos(void)                            /* composite pictures */
330   {
331          COLR  *scanin, *scanout;
332          int  y;
# Line 373 | Line 380 | compos()                               /* composite pictures */
380                          quit(1);
381                  }
382          }
383 +                                        /* read remainders from streams */
384 +        for (i = 0; i < nfile; i++)
385 +                if (input[i].name[0] == '<')
386 +                        while (getc(input[i].fp) != EOF)
387 +                                ;
388          return;
389   memerr:
390          perror(progname);
# Line 380 | Line 392 | memerr:
392   }
393  
394  
395 < int
396 < cmpcolr(c1, c2)                 /* compare two colr's (improvisation) */
397 < register COLR  c1, c2;
395 > static int
396 > cmpcolr(                        /* compare two colr's (improvisation) */
397 >        register COLR  c1,
398 >        register COLR  c2
399 > )
400   {
401          register int  i, j;
402  
403          j = 4;                          /* check exponents first! */
404          while (j--)
405 <                if (i = c1[j] - c2[j])
405 >                if ( (i = c1[j] - c2[j]) )
406                          return(i);
407          return(0);
408   }
409  
410  
411 < FILE *
412 < lblopen(s, xp, yp)              /* open pipe to label generator */
413 < char  *s;
414 < int  *xp, *yp;
411 > static FILE *
412 > lblopen(                /* open pipe to label generator */
413 >        char  *s,
414 >        int  *xp,
415 >        int  *yp
416 > )
417   {
418 <        char  com[128];
418 >        char  com[PATH_MAX];
419          FILE  *fp;
420  
421          sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s);
# Line 416 | Line 432 | err:
432   }
433  
434  
435 + void
436   quit(code)              /* exit gracefully */
437   int  code;
438   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines