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.2 by greg, Thu Aug 25 04:32:29 2011 UTC vs.
Revision 2.7 by greg, Tue Aug 18 15:23:38 2015 UTC

# Line 53 | 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 87 | Line 87 | cvtBSDF(char *fname)
87   {
88          int     retOK;
89          SDData  myBSDF;
90 <        char    *pname;
90 >        char    *pname, *fnbeg;
91                                          /* find and load the XML file */
92          retOK = strlen(fname);
93 <        if (retOK < 5 || strcmp(fname+retOK-4, ".xml")) {
93 >        if (retOK < 5 || strcasecmp(fname+retOK-4, ".xml")) {
94                  fprintf(stderr, "%s: input does not end in '.xml'\n", fname);
95                  return(0);
96          }
# Line 99 | Line 99 | cvtBSDF(char *fname)
99                  fprintf(stderr, "%s: cannot find BSDF file\n", fname);
100                  return(0);
101          }
102 +        fnbeg = strrchr(fname, DIRSEP);
103 +        if (fnbeg != NULL)              /* eliminate directory */
104 +                fname = fnbeg+1;
105          SDclearBSDF(&myBSDF, fname);
106 <        if (SDreportEnglish(SDloadFile(&myBSDF, pname), stderr))
106 >        if (SDreportError(SDloadFile(&myBSDF, pname), stderr))
107                  return(0);
108          retOK = (myBSDF.dim[0] > FTINY) & (myBSDF.dim[1] > FTINY);
109          if (!retOK) {
# Line 113 | Line 116 | cvtBSDF(char *fname)
116                          retOK = (freopen(rname, "w", stdout) != NULL);
117                  }
118                  if (retOK) {
119 +                        if (myBSDF.matn[0] && myBSDF.makr[0])
120 +                                printf("# Material '%s' by '%s'\n\n",
121 +                                                myBSDF.matn, myBSDF.makr);
122                          if (myBSDF.mgf == NULL) {
123                                  faceBSDF(&myBSDF, .0);
124                          } else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines