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, |
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 |
|
} |