Lines Matching defs:in

16      in a product, an acknowledgment in the product documentation would be
39 decompress all of the input data in order to find the bits in the compressed
48 compressed data in order to connect the streams. The output gzip file
65 /* exit with an error (return a value to allow use in an expression) */
75 #define CHUNK 32768 /* must be a power of two and fit in unsigned */
87 local void bclose(bin *in)
89 if (in != NULL) {
90 if (in->fd != -1)
91 close(in->fd);
92 if (in->buf != NULL)
93 free(in->buf);
94 free(in);
102 bin *in;
104 in = malloc(sizeof(bin));
105 if (in == NULL)
107 in->buf = malloc(CHUNK);
108 in->fd = open(name, O_RDONLY, 0);
109 if (in->buf == NULL || in->fd == -1) {
110 bclose(in);
113 in->left = 0;
114 in->next = in->buf;
115 in->name = name;
116 return in;
121 local int bload(bin *in)
125 if (in == NULL)
127 if (in->left != 0)
129 in->next = in->buf;
131 len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left);
134 in->left += (unsigned)len;
135 } while (len != 0 && in->left < CHUNK);
140 #define bget(in) (in->left ? 0 : bload(in), \
141 in->left ? (in->left--, *(in->next)++) : \
142 bail("unexpected end of file on ", in->name))
145 local unsigned long bget4(bin *in)
149 val = bget(in);
150 val += (unsigned long)(bget(in)) << 8;
151 val += (unsigned long)(bget(in)) << 16;
152 val += (unsigned long)(bget(in)) << 24;
156 /* skip bytes in file */
157 local void bskip(bin *in, unsigned skip)
160 if (in == NULL)
163 /* easy case -- skip bytes in buffer */
164 if (skip <= in->left) {
165 in->left -= skip;
166 in->next += skip;
170 /* skip what's in buffer, discard buffer contents */
171 skip -= in->left;
172 in->left = 0;
182 lseek(in->fd, skip - 1, SEEK_CUR);
183 if (read(in->fd, in->buf, 1) != 1)
184 bail("unexpected end of file on ", in->name);
189 lseek(in->fd, skip - left, SEEK_CUR);
194 bload(in);
195 if (skip > in->left)
196 bail("unexpected end of file on ", in->name);
197 in->left -= skip;
198 in->next += skip;
203 /* skip the gzip header from file in */
204 local void gzhead(bin *in)
209 if (bget(in) != 0x1f || bget(in) != 0x8b || bget(in) != 8)
210 bail(in->name, " is not a valid gzip file");
213 flags = bget(in);
215 bail("unknown reserved bits set in ", in->name);
218 bskip(in, 6);
224 len = bget(in);
225 len += (unsigned)(bget(in)) << 8;
226 bskip(in, len);
231 while (bget(in) != 0)
236 while (bget(in) != 0)
241 bskip(in, 2);
254 local void zpull(z_streamp strm, bin *in)
256 if (in->left == 0)
257 bload(in);
258 if (in->left == 0)
259 bail("unexpected end of file on ", in->name);
260 strm->avail_in = in->left;
261 strm->next_in = in->next;
283 int pos; /* where the "last block" bit is in byte */
285 bin *in; /* buffered input file */
286 unsigned char *start; /* start of compressed data in buffer */
292 in = bopen(name);
293 if (in == NULL)
295 gzhead(in);
311 zpull(&strm, in);
312 start = in->next;
321 start = in->buf;
322 in->left = 0;
323 zpull(&strm, in);
334 bail("invalid compressed data in ", in->name);
346 /* number of unused bits in last byte */
351 /* next last-block bit is in last used byte */
355 in->buf[strm.next_in - in->buf - 1] &= ~pos;
358 /* next last-block bit is in next unused byte */
362 start = in->buf;
363 in->left = 0;
364 zpull(&strm, in);
368 in->buf[strm.next_in - in->buf] &= ~1;
374 in->left = strm.avail_in;
375 in->next = in->buf + (strm.next_in - in->buf);
379 fwrite(start, 1, in->next - start - 1, out);
380 last = in->next[-1];
391 putc(0, out); /* two more bits in block header */
411 *crc = crc32_combine(*crc, bget4(in), len);
417 bclose(in);