• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/minidlna/zlib-1.2.3/examples/

Lines Matching refs:in

16      in a product, an acknowledgment in the product documentation would be
38 decompress all of the input data in order to find the bits in the compressed
47 compressed data in order to connect the streams. The output gzip file
64 /* exit with an error (return a value to allow use in an expression) */
74 #define CHUNK 32768 /* must be a power of two and fit in unsigned */
86 local void bclose(bin *in)
88 if (in != NULL) {
89 if (in->fd != -1)
90 close(in->fd);
91 if (in->buf != NULL)
92 free(in->buf);
93 free(in);
101 bin *in;
103 in = malloc(sizeof(bin));
104 if (in == NULL)
106 in->buf = malloc(CHUNK);
107 in->fd = open(name, O_RDONLY, 0);
108 if (in->buf == NULL || in->fd == -1) {
109 bclose(in);
112 in->left = 0;
113 in->next = in->buf;
114 in->name = name;
115 return in;
120 local int bload(bin *in)
124 if (in == NULL)
126 if (in->left != 0)
128 in->next = in->buf;
130 len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left);
133 in->left += (unsigned)len;
134 } while (len != 0 && in->left < CHUNK);
139 #define bget(in) (in->left ? 0 : bload(in), \
140 in->left ? (in->left--, *(in->next)++) : \
141 bail("unexpected end of file on ", in->name))
144 local unsigned long bget4(bin *in)
148 val = bget(in);
149 val += (unsigned long)(bget(in)) << 8;
150 val += (unsigned long)(bget(in)) << 16;
151 val += (unsigned long)(bget(in)) << 24;
155 /* skip bytes in file */
156 local void bskip(bin *in, unsigned skip)
159 if (in == NULL)
162 /* easy case -- skip bytes in buffer */
163 if (skip <= in->left) {
164 in->left -= skip;
165 in->next += skip;
169 /* skip what's in buffer, discard buffer contents */
170 skip -= in->left;
171 in->left = 0;
181 lseek(in->fd, skip - 1, SEEK_CUR);
182 if (read(in->fd, in->buf, 1) != 1)
183 bail("unexpected end of file on ", in->name);
188 lseek(in->fd, skip - left, SEEK_CUR);
193 bload(in);
194 if (skip > in->left)
195 bail("unexpected end of file on ", in->name);
196 in->left -= skip;
197 in->next += skip;
202 /* skip the gzip header from file in */
203 local void gzhead(bin *in)
208 if (bget(in) != 0x1f || bget(in) != 0x8b || bget(in) != 8)
209 bail(in->name, " is not a valid gzip file");
212 flags = bget(in);
214 bail("unknown reserved bits set in ", in->name);
217 bskip(in, 6);
223 len = bget(in);
224 len += (unsigned)(bget(in)) << 8;
225 bskip(in, len);
230 while (bget(in) != 0)
235 while (bget(in) != 0)
240 bskip(in, 2);
253 local void zpull(z_streamp strm, bin *in)
255 if (in->left == 0)
256 bload(in);
257 if (in->left == 0)
258 bail("unexpected end of file on ", in->name);
259 strm->avail_in = in->left;
260 strm->next_in = in->next;
282 int pos; /* where the "last block" bit is in byte */
284 bin *in; /* buffered input file */
285 unsigned char *start; /* start of compressed data in buffer */
291 in = bopen(name);
292 if (in == NULL)
294 gzhead(in);
310 zpull(&strm, in);
320 start = in->buf;
321 in->left = 0;
322 zpull(&strm, in);
333 bail("invalid compressed data in ", in->name);
345 /* number of unused bits in last byte */
350 /* next last-block bit is in last used byte */
357 /* next last-block bit is in next unused byte */
361 start = in->buf;
362 in->left = 0;
363 zpull(&strm, in);
373 in->left = strm.avail_in;
374 in->next = strm.next_in;
378 fwrite(start, 1, in->next - start - 1, out);
379 last = in->next[-1];
390 putc(0, out); /* two more bits in block header */
410 *crc = crc32_combine(*crc, bget4(in), len);
416 bclose(in);