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

Comparing ray/src/cv/pkgBSDF.c (file contents):
Revision 2.1 by greg, Thu Jun 23 18:05:18 2011 UTC vs.
Revision 2.5 by greg, Sun Apr 21 22:56:14 2013 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   * Take BSDF XML file and generate a referencing Radiance object
6   */
7  
8 + #include "rtio.h"
9   #include "paths.h"
10   #include "bsdf.h"
11  
# Line 52 | Line 53 | geomBSDF(const SDData *bsp)
53          char    command[SDnameLn+64];
54          int     fd;
55                                          /* write MGF to temp file */
56 <        fd = open(mktemp(strcpy(tmpfile,TEMPLATE)), O_WRONLY|O_CREAT|O_EXCL);
56 >        fd = open(mktemp(strcpy(tmpfile,TEMPLATE)), O_WRONLY|O_CREAT|O_EXCL, 0600);
57          if (fd < 0) {
58                  fprintf(stderr, "Cannot open temp file '%s'\n", tmpfile);
59                  return(0);
60          }
61 <        write(fd, bsp->mgf, strlen(bsp->mgf));
61 >        (void)write(fd, bsp->mgf, strlen(bsp->mgf));
62          close(fd);
63                                          /* set up command */
64          if (do_instance) {
# Line 82 | Line 83 | geomBSDF(const SDData *bsp)
83  
84   /* Load a BSDF XML file and produce a corresponding Radiance object */
85   static int
86 < cvtBSDF(const char *fname)
86 > cvtBSDF(char *fname)
87   {
88          int     retOK;
89          SDData  myBSDF;
90 <                                        /* load the XML file */
90 >        char    *pname;
91 >                                        /* find and load the XML file */
92          retOK = strlen(fname);
93          if (retOK < 5 || strcmp(fname+retOK-4, ".xml")) {
94                  fprintf(stderr, "%s: input does not end in '.xml'\n", fname);
95                  return(0);
96          }
97 +        pname = getpath(fname, getrlibpath(), R_OK);
98 +        if (pname == NULL) {
99 +                fprintf(stderr, "%s: cannot find BSDF file\n", fname);
100 +                return(0);
101 +        }
102          SDclearBSDF(&myBSDF, fname);
103 <        if (SDreportEnglish(SDloadFile(&myBSDF, fname), stderr))
103 >        if (SDreportError(SDloadFile(&myBSDF, pname), stderr))
104                  return(0);
105          retOK = (myBSDF.dim[0] > FTINY) & (myBSDF.dim[1] > FTINY);
106          if (!retOK) {
# Line 106 | Line 113 | cvtBSDF(const char *fname)
113                          retOK = (freopen(rname, "w", stdout) != NULL);
114                  }
115                  if (retOK) {
116 +                        if (myBSDF.matn[0] && myBSDF.makr[0])
117 +                                printf("# Material '%s' by '%s'\n\n",
118 +                                                myBSDF.matn, myBSDF.makr);
119                          if (myBSDF.mgf == NULL) {
120                                  faceBSDF(&myBSDF, .0);
121                          } else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines