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

Comparing ray/src/util/rtcontrib.c (file contents):
Revision 1.31 by greg, Thu Oct 6 05:49:44 2005 UTC vs.
Revision 1.32 by greg, Thu Oct 6 16:28:59 2005 UTC

# Line 75 | Line 75 | LUTAB  ofiletab = LU_SINIT(free,closestream);  /* output
75   #define OF_MODIFIER     01
76   #define OF_BIN          02
77  
78 < STREAMOUT *getostream(const char *ospec, const char *mname, int bn, int bincnt);
78 > STREAMOUT *getostream(const char *ospec, const char *mname, int bn, int noopen);
79   int ofname(char *oname, const char *ospec, const char *mname, int bn);
80   void printheader(FILE *fout, const char *info);
81   void printresolu(FILE *fout);
# Line 505 | Line 505 | addmodifier(char *modn, char *outf, char *binv, int bi
505   {
506          LUENT   *lep = lu_find(&modconttab, modn);
507          MODCONT *mp;
508 +        int     i;
509          
510          if (lep->data != NULL) {
511                  sprintf(errmsg, "duplicate modifier '%s'", modn);
# Line 517 | Line 518 | addmodifier(char *modn, char *outf, char *binv, int bi
518          mp = (MODCONT *)malloc(sizeof(MODCONT));
519          if (mp == NULL)
520                  error(SYSTEM, "out of memory in addmodifier");
520        lep->data = (char *)mp;
521          mp->outspec = outf;             /* XXX assumes static string */
522          mp->modname = modn;             /* XXX assumes static string */
523          if (binv != NULL)
# Line 530 | Line 530 | addmodifier(char *modn, char *outf, char *binv, int bi
530                  bincnt = 1;
531          else if (bincnt > 1)
532                  mp = growmodifier(mp, bincnt);
533 <        if (bincnt > 0)                 /* allocate output stream */
534 <                getostream(mp->outspec, mp->modname, 0, bincnt);
533 >        lep->data = (char *)mp;
534 >                                        /* allocate output streams */
535 >        for (i = outf==NULL || outf[0]=='!' ? 0 : bincnt; i--; )
536 >                getostream(mp->outspec, mp->modname, i, 1);
537          return mp;
538   }
539  
# Line 660 | Line 662 | printresolu(FILE *fout)
662          }
663   }
664  
665 < /* Get output stream pointer (open and write header if new and bincnt==0) */
665 > /* Get output stream pointer (open and write header if new and noopen==0) */
666   STREAMOUT *
667 < getostream(const char *ospec, const char *mname, int bn, int bincnt)
667 > getostream(const char *ospec, const char *mname, int bn, int noopen)
668   {
669          static STREAMOUT        stdos;
670          int                     ofl;
# Line 671 | Line 673 | getostream(const char *ospec, const char *mname, int b
673          STREAMOUT               *sop;
674          
675          if (ospec == NULL) {                    /* use stdout? */
676 <                if (!bincnt && !using_stdout) {
676 >                if (!noopen && !using_stdout) {
677                          stdos.reclen = 0;
678                          if (outfmt != 'a')
679                                  SET_FILE_BINARY(stdout);
# Line 681 | Line 683 | getostream(const char *ospec, const char *mname, int b
683                          using_stdout = 1;
684                  }
685                  stdos.ofp = stdout;
686 <                stdos.reclen += bincnt;
686 >                stdos.reclen += noopen;
687                  return &stdos;
688          }
689          ofl = ofname(oname, ospec, mname, bn);  /* get output name */
# Line 694 | Line 696 | getostream(const char *ospec, const char *mname, int b
696                  lep->key = strcpy((char *)malloc(strlen(oname)+1), oname);
697          sop = (STREAMOUT *)lep->data;
698          if (sop == NULL) {                      /* allocate stream */
697                if (ofl & OF_BIN && bincnt > 1) /* don't overcount bins */
698                        bincnt = 1;
699                  sop = (STREAMOUT *)malloc(sizeof(STREAMOUT));
700                  if (sop == NULL)
701                          error(SYSTEM, "out of memory in getostream");
702                  sop->reclen = oname[0] == '!' ? CNT_PIPE : 0;
703 <                sop->ofp = NULL;                /* open iff bincnt==0 */
703 >                sop->ofp = NULL;                /* open iff noopen==0 */
704                  lep->data = (char *)sop;
705          }
706 <        if (!bincnt && sop->ofp == NULL) {      /* open output stream */
706 >        if (!noopen && sop->ofp == NULL) {      /* open output stream */
707                  int             i;
708                  if (oname[0] == '!')            /* output to command */
709                          sop->ofp = popen(oname+1, "w");
# Line 718 | Line 718 | getostream(const char *ospec, const char *mname, int b
718                  if (header) {
719                          char    info[512];
720                          char    *cp = info;
721 <                        if (ofl & OF_MODIFIER) {
721 >                        if (ofl & OF_MODIFIER || sop->reclen == 1) {
722                                  sprintf(cp, "MODIFIER=%s\n", mname);
723                                  while (*cp) ++cp;
724                          }
# Line 740 | Line 740 | getostream(const char *ospec, const char *mname, int b
740                  if (xres > 0)
741                          fflush(sop->ofp);
742          }
743 <        if (sop->reclen != CNT_PIPE)            /* add bincnt to count */
744 <                sop->reclen += bincnt;
743 >        if (sop->reclen != CNT_PIPE)            /* add to length if noopen */
744 >                sop->reclen += noopen;
745          return sop;                             /* return open stream */
746   }
747  
# Line 1148 | Line 1148 | recover_output(FILE *fin)
1148                                  fclose(sout.ofp);
1149                                  break;
1150                          }
1151 <                        if (!sout.reclen) {     /* unspecified record length */
1151 >                        if (sout.reclen == CNT_UNKNOWN) {
1152                                  if (!(ofl & OF_BIN)) {
1153                                          sprintf(errmsg,
1154 <                                                "guessing 1 value per record in '%s'",
1154 >                                                "need -bn to recover file '%s'",
1155                                                          oname);
1156 <                                        error(WARNING, errmsg);
1156 >                                        error(USER, errmsg);
1157                                  }
1158                                  recsiz = outvsiz;
1159                          } else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines