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

Comparing ray/src/common/portio.c (file contents):
Revision 2.15 by greg, Fri Oct 19 01:40:33 2012 UTC vs.
Revision 2.16 by greg, Thu Mar 3 22:06:18 2016 UTC

# Line 67 | Line 67 | putflt(                                /* put out floating point number */
67   }
68  
69  
70 + int
71 + putbinary(                      /* fwrite() replacement for small objects */
72 +        char *s,
73 +        int elsiz,
74 +        int nel,
75 +        FILE *fp)
76 + {
77 +        int     nbytes = elsiz*nel;
78 +
79 +        if (nbytes > 512)
80 +                return(fwrite(s, elsiz, nel, fp));
81 +        
82 +        while (nbytes-- > 0)
83 +                putc(*s++, fp);
84 +
85 +        return(nel);
86 + }
87 +
88 +
89   char *
90   getstr(                         /* get null-terminated string */
91          char  *s,
# Line 124 | Line 143 | getflt(                                /* get a floating point number */
143          }
144          d = (l + (l > 0 ? .5 : -.5)) * (1./0x7fffffff);
145          return(ldexp(d, (int)getint(1, fp)));
146 + }
147 +
148 +
149 + int
150 + getbinary(                      /* fread() replacement for small objects */
151 +        char *s,
152 +        int elsiz,
153 +        int nel,
154 +        FILE *fp)
155 + {
156 +        int     nbytes = elsiz*nel;
157 +        int     c;
158 +
159 +        if (nbytes > 512)
160 +                return(fread(s, elsiz, nel, fp));
161 +        
162 +        while (nbytes-- > 0) {
163 +                if ((c = getc(fp)) == EOF)
164 +                        return((elsiz*nel - nbytes)/elsiz);
165 +                *s++ = c;
166 +        }
167 +        return(nel);
168   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines