Lines Matching refs:in

87 local void bclose(bin *in)  in bclose()  argument
89 if (in != NULL) { in bclose()
90 if (in->fd != -1) in bclose()
91 close(in->fd); in bclose()
92 if (in->buf != NULL) in bclose()
93 free(in->buf); in bclose()
94 free(in); in bclose()
102 bin *in; in bopen() local
104 in = malloc(sizeof(bin)); in bopen()
105 if (in == NULL) in bopen()
107 in->buf = malloc(CHUNK); in bopen()
108 in->fd = open(name, O_RDONLY, 0); in bopen()
109 if (in->buf == NULL || in->fd == -1) { in bopen()
110 bclose(in); in bopen()
113 in->left = 0; in bopen()
114 in->next = in->buf; in bopen()
115 in->name = name; in bopen()
116 return in; in bopen()
121 local int bload(bin *in) in bload() argument
125 if (in == NULL) in bload()
127 if (in->left != 0) in bload()
129 in->next = in->buf; in bload()
131 len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left); in bload()
134 in->left += (unsigned)len; in bload()
135 } while (len != 0 && in->left < CHUNK); in bload()
140 #define bget(in) (in->left ? 0 : bload(in), \ argument
141 in->left ? (in->left--, *(in->next)++) : \
142 bail("unexpected end of file on ", in->name))
145 local unsigned long bget4(bin *in) in bget4() argument
149 val = bget(in); in bget4()
150 val += (unsigned long)(bget(in)) << 8; in bget4()
151 val += (unsigned long)(bget(in)) << 16; in bget4()
152 val += (unsigned long)(bget(in)) << 24; in bget4()
157 local void bskip(bin *in, unsigned skip) in bskip() argument
160 if (in == NULL) in bskip()
164 if (skip <= in->left) { in bskip()
165 in->left -= skip; in bskip()
166 in->next += skip; in bskip()
171 skip -= in->left; in bskip()
172 in->left = 0; in bskip()
182 lseek(in->fd, skip - 1, SEEK_CUR); in bskip()
183 if (read(in->fd, in->buf, 1) != 1) in bskip()
184 bail("unexpected end of file on ", in->name); in bskip()
189 lseek(in->fd, skip - left, SEEK_CUR); in bskip()
194 bload(in); in bskip()
195 if (skip > in->left) in bskip()
196 bail("unexpected end of file on ", in->name); in bskip()
197 in->left -= skip; in bskip()
198 in->next += skip; in bskip()
204 local void gzhead(bin *in) in gzhead() argument
209 if (bget(in) != 0x1f || bget(in) != 0x8b || bget(in) != 8) in gzhead()
210 bail(in->name, " is not a valid gzip file"); in gzhead()
213 flags = bget(in); in gzhead()
215 bail("unknown reserved bits set in ", in->name); in gzhead()
218 bskip(in, 6); in gzhead()
224 len = bget(in); in gzhead()
225 len += (unsigned)(bget(in)) << 8; in gzhead()
226 bskip(in, len); in gzhead()
231 while (bget(in) != 0) in gzhead()
236 while (bget(in) != 0) in gzhead()
241 bskip(in, 2); in gzhead()
254 local void zpull(z_streamp strm, bin *in) in zpull() argument
256 if (in->left == 0) in zpull()
257 bload(in); in zpull()
258 if (in->left == 0) in zpull()
259 bail("unexpected end of file on ", in->name); in zpull()
260 strm->avail_in = in->left; in zpull()
261 strm->next_in = in->next; in zpull()
285 bin *in; /* buffered input file */ in gzcopy() local
292 in = bopen(name); in gzcopy()
293 if (in == NULL) in gzcopy()
295 gzhead(in); in gzcopy()
311 zpull(&strm, in); in gzcopy()
312 start = in->next; in gzcopy()
321 start = in->buf; in gzcopy()
322 in->left = 0; in gzcopy()
323 zpull(&strm, in); in gzcopy()
334 bail("invalid compressed data in ", in->name); in gzcopy()
355 in->buf[strm.next_in - in->buf - 1] &= ~pos; in gzcopy()
362 start = in->buf; in gzcopy()
363 in->left = 0; in gzcopy()
364 zpull(&strm, in); in gzcopy()
368 in->buf[strm.next_in - in->buf] &= ~1; in gzcopy()
374 in->left = strm.avail_in; in gzcopy()
375 in->next = in->buf + (strm.next_in - in->buf); in gzcopy()
379 fwrite(start, 1, in->next - start - 1, out); in gzcopy()
380 last = in->next[-1]; in gzcopy()
411 *crc = crc32_combine(*crc, bget4(in), len); in gzcopy()
417 bclose(in); in gzcopy()