Home | History | Annotate | Download | only in examples

Lines Matching defs:in

7   warranty.  In no event will the author be held liable for any damages
16 in a product, an acknowledgment in the product documentation would be
33 * - Add L to constants in lseek() calls
34 * - Remove some debugging information in error messages
37 * - Finish off gzip file in gztack()
40 * - Use in-place rotate instead of auxiliary buffer
49 avoid copying that file, in case it's large. Note that this results in the
57 number of unusued bits in the last input byte used. gzappend will not work
62 bit and the number of unused bits in the last byte of the compressed data.
66 Then the last block bit is cleared by seeking back in the file and rewriting
122 /* rotate list[0..len-1] left by rot positions, in place */
134 /* pointer to last entry in list */
153 /* otherwise do rotate as a set of cycles in place */
159 to = from; /* next step in cycle */
172 int size; /* 1 << size is bytes in buf */
175 z_const unsigned char *next; /* next byte in buffer */
180 local int readin(file *in)
184 len = read(in->fd, in->buf, 1 << in->size);
185 if (len == -1) bye("error reading ", in->name);
186 in->left = (unsigned)len;
187 in->next = in->buf;
191 /* read from file in, exit if end-of-file */
192 local int readmore(file *in)
194 if (readin(in) == 0) bye("unexpected end of ", in->name);
198 #define read1(in) (in->left == 0 ? readmore(in) : 0, \
199 in->left--, *(in->next)++)
201 /* skip over n bytes of in */
202 local void skip(file *in, unsigned n)
206 if (n > in->left) {
207 n -= in->left;
208 bypass = n & ~((1U << in->size) - 1);
210 if (lseek(in->fd, (off_t)bypass, SEEK_CUR) == -1)
211 bye("seeking ", in->name);
214 readmore(in);
215 if (n > in->left)
216 bye("unexpected end of ", in->name);
218 in->left -= n;
219 in->next += n;
222 /* read a four-byte unsigned integer, little-endian, from in */
223 unsigned long read4(file *in)
227 val = read1(in);
228 val += (unsigned)read1(in) << 8;
229 val += (unsigned long)read1(in) << 16;
230 val += (unsigned long)read1(in) << 24;
235 local void gzheader(file *in)
240 if (read1(in) != 31 || read1(in) != 139) bye(in->name, " not a gzip file");
241 if (read1(in) != 8) bye("unknown compression method in", in->name);
242 flags = read1(in);
243 if (flags & 0xe0) bye("unknown header flags set in", in->name);
244 skip(in, 6);
246 n = read1(in);
247 n += (unsigned)(read1(in)) << 8;
248 skip(in, n);
250 if (flags & 8) while (read1(in) != 0) ;
251 if (flags & 16) while (read1(in) != 0) ;
252 if (flags & 2) skip(in, 2);
256 continue compression of the data in the gzip file, and return a file
314 bye("invalid compressed data--format violated in", name);
344 bye("invalid compressed data--crc mismatch in ", name);
347 bye("invalid compressed data--length mismatch in", name);
392 unsigned char *in, *out;
404 in = malloc(CHUNK);
406 if (in == NULL || out == NULL) bye("out of memory", "");
411 len = read(fd, in, CHUNK);
419 strm->next_in = in;
420 if (len) strm->adler = crc32(strm->adler, in, (unsigned)len);
458 free(in);