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

Comparing ray/src/rt/lookamb.c (file contents):
Revision 2.2 by greg, Mon Jul 13 16:17:42 1992 UTC vs.
Revision 2.6 by greg, Sun Feb 27 10:17:33 1994 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  <stdio.h>
14  
15 + #ifdef MSDOS
16 + #include  <fcntl.h>
17 + #endif
18 +
19   #include  "color.h"
20  
21   #include  "ambient.h"
22  
23  
24   int  dataonly = 0;
25 <
25 > int  header = 1;
26   int  reverse = 0;
27  
28   AMBVAL  av;
29  
30  
31   main(argc, argv)                /* load ambient values from a file */
32 + int  argc;
33   char  *argv[];
34   {
35          FILE  *fp;
# Line 39 | Line 44 | char  *argv[];
44                          case 'r':
45                                  reverse = 1;
46                                  break;
47 +                        case 'h':
48 +                                header = 0;
49 +                                break;
50                          default:
51                                  fprintf(stderr, "%s: unknown option '%s'\n",
52                                                  argv[0], argv[i]);
# Line 53 | Line 61 | char  *argv[];
61                  fprintf(stderr, "%s: file not found\n", argv[i]);
62                  return(1);
63          }
64 <        if (reverse)
64 >        if (reverse) {
65 >                if (header) {
66 >                        if (checkheader(fp, "ascii", stdout) < 0)
67 >                                goto formaterr;
68 >                } else {
69 >                        newheader("RADIANCE", stdout);
70 >                        printargs(argc, argv, stdout);
71 >                }
72 >                fputformat(AMBFMT, stdout);
73 >                putchar('\n');
74 > #ifdef MSDOS
75 >                setmode(fileno(stdout), O_BINARY);
76 > #endif
77 >                putambmagic(stdout);
78                  writamb(fp);
79 <        else
79 >        } else {
80 > #ifdef MSDOS
81 >                setmode(fileno(fp), O_BINARY);
82 > #endif
83 >                if (checkheader(fp, AMBFMT, header ? stdout : (FILE *)NULL) < 0)
84 >                        goto formaterr;
85 >                if (!hasambmagic(fp))
86 >                        goto formaterr;
87 >                if (header) {
88 >                        fputformat("ascii", stdout);
89 >                        putchar('\n');
90 >                }
91                  lookamb(fp);
92 +        }
93          fclose(fp);
94          return(0);
95 + formaterr:
96 +        fprintf(stderr, "%s: format error on input\n", argv[0]);
97 +        exit(1);
98   }
99  
100  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines