Ruby: ext/zlib/zlib-1.2.13/examples/gun.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Functions | Variables
gun.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <utime.h>`
`#include "zlib.h"`

Go to the source code of this file.

## Data Structures
struct | ind
struct | outd

## Macros
#define | local static
#define | SIZE 32768U /* input and output buffer sizes */
#define | PIECE 16384 /* limits i/o chunks for 16-bit int case */
#define | NEXT()
#define | FLUSHCODE()

## Functions
unsigned | in (void *in_desc, z_const unsigned char **buf)
int | out (void *out_desc, unsigned char *buf, unsigned len)
int | lunpipe (unsigned have, z_const unsigned char *next, struct ind *indp, int outfile, z_stream *strm)
int | gunpipe (z_stream *strm, int infile, int outfile)
void | copymeta (char *from, char *to)
int | gunzip (z_stream *strm, char *inname, char *outname, int test)
int | main (int argc, char **argv)

## Variables
unsigned char | inbuf [SIZE]
unsigned char | outbuf [SIZE]
unsigned short | prefix [65536]
unsigned char | suffix [65536]
unsigned char | match [65280+2]

## Macro Definition Documentation

## ◆ FLUSHCODE

#define FLUSHCODE | ( |  | ) |

Value:
do { \
left = 0; \
rem = 0; \
if (chunk > have) { \
chunk -= have; \
have = 0; \
if (NEXT() == -1) \
break; \
chunk--; \
if (chunk > have) { \
chunk = have = 0; \
break; \
} \
} \
have -= chunk; \
next += chunk; \
chunk = 0; \
} while (0)
NEXT
#define NEXT()
Definition: gun.c:155

Definition at line 171 of file gun.c.

## ◆ local

#define local static

Definition at line 73 of file gun.c.

## ◆ NEXT

#define NEXT | ( |  | ) |

Value:
(have ? 0 : (have = in(indp, &next)), \
last = have ? (have--, (int)(*next++)) : -1)
in
unsigned in(void *in_desc, z_const unsigned char **buf)
Definition: gun.c:89
last
unsigned int last
Definition: nkf.c:4324

Definition at line 155 of file gun.c.

## ◆ PIECE

#define PIECE 16384 /* limits i/o chunks for 16-bit int case */

Definition at line 77 of file gun.c.

## ◆ SIZE

#define SIZE 32768U /* input and output buffer sizes */

Definition at line 76 of file gun.c.

## Function Documentation

## ◆ copymeta()

void copymeta | ( | char * | from,
|  | char * | to
| ) |  |

Definition at line 517 of file gun.c.

References utimbuf::actime, chown(), utimbuf::modtime, and stat.

Referenced by gunzip().

## ◆ gunpipe()

int gunpipe | ( | z_stream * | strm,
|  | int | infile,
|  | int | outfile
| ) |  |

Definition at line 383 of file gun.c.

References z_stream_s::avail_in, outd::check, outd::crc, crc32(), in(), ind::inbuf, inbuf, ind::infile, inflateBack(), int(), L, last, len, lunpipe(), z_stream_s::msg, NEXT, z_stream_s::next_in, NULL, out, outd::outfile, outd::total, Z_BUF_ERROR, z_const, Z_DATA_ERROR, Z_ERRNO, Z_NULL, Z_OK, and Z_STREAM_END.

Referenced by gunzip().

## ◆ gunzip()

int gunzip | ( | z_stream * | strm,
|  | char * | inname,
|  | char * | outname,
|  | int | test
| ) |  |

Definition at line 548 of file gun.c.

References copymeta(), gunpipe(), z_stream_s::msg, z_stream_s::next_in, NULL, strerror(), Z_BUF_ERROR, Z_DATA_ERROR, Z_ERRNO, Z_MEM_ERROR, Z_NULL, and Z_OK.

Referenced by main().

## ◆ in()

unsigned in | ( | void * | in_desc,
|  | z_const unsigned char ** | buf
| ) |  |

Definition at line 89 of file gun.c.

References ind::inbuf, ind::infile, int(), len, PIECE, read(), and SIZE.

Referenced by bclose(), bget4(), blast(), bload(), bopen(), bskip(), def(), deflate_index_build(), deflate_index_extract(), gunpipe(), gzcopy(), gzhead(), gzheader(), gzip_normalize(), gztack(), inet_ntop(), inf(), inflate(), inflate_fast(), inflateSync(), load(), ossl_bin2hex(), partcompress(), rb_ractor_stdin_set(), rb_w32_inet_ntop(), read4(), readin(), readmore(), skip(), tar(), yyparse(), and zpull().

## ◆ lunpipe()

int lunpipe | ( | unsigned | have,
|  | z_const unsigned char * | next,
|  | struct ind * | indp,
|  | int | outfile,
|  | z_stream * | strm
| ) |  |

Definition at line 200 of file gun.c.

References bits(), outd::check, FLUSHCODE, last, mask, match, max, z_stream_s::msg, NEXT, z_stream_s::next_in, out, outbuf, outd::outfile, prefix, SIZE, suffix, Z_BUF_ERROR, Z_DATA_ERROR, and Z_OK.

Referenced by gunpipe().

## ◆ main()

int main | ( | int argc | ,
|  | char ** | argv
| ) |  |

Definition at line 631 of file gun.c.

References argc, argv, free, gunzip(), inflateBackEnd(), inflateBackInit, int(), len, malloc, match, memcpy, NULL, z_stream_s::opaque, strlen(), Z_NULL, Z_OK, z_stream_s::zalloc, and z_stream_s::zfree.

## ◆ out()

int out | ( | void * | out_desc,
|  | unsigned char * | buf,
|  | unsigned | len
| ) |  |

Definition at line 131 of file gun.c.

References outd::check, outd::crc, crc32(), int(), len, outd::outfile, PIECE, outd::total, and write().

## Variable Documentation

## ◆ inbuf

unsigned char inbuf[SIZE]

Definition at line 161 of file gun.c.

Referenced by gunpipe().

## ◆ match

unsigned char match[65280+2]

Definition at line 165 of file gun.c.

Referenced by inflate_table(), longest_match(), lunpipe(), main(), onig_search_gpos(), rb_backref_set_string(), rb_match_busy(), rb_match_count(), rb_match_nth_defined(), rb_match_unbusy(), rb_reg_backref_number(), rb_reg_last_match(), rb_reg_match_last(), rb_reg_match_post(), rb_reg_match_pre(), rb_reg_nth_defined(), rb_reg_nth_match(), rb_reg_start_with_p(), and strtod().

## ◆ outbuf

unsigned char outbuf[SIZE]

Definition at line 162 of file gun.c.

Referenced by lunpipe().

## ◆ prefix

unsigned short prefix[65536]

Definition at line 163 of file gun.c.

Referenced by lunpipe(), rb_str_format(), and rb_w32_pipe().

## ◆ suffix

unsigned char suffix[65536]

Definition at line 164 of file gun.c.

Referenced by lunpipe(), and ruby_set_inplace_mode().