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

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

Data Structures | Macros | Functions
gzappend.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include "zlib.h"`

Go to the source code of this file.

## Data Structures
struct | file

## Macros
#define | local static
#define | LGCHUNK 14
#define | CHUNK (1U << LGCHUNK)
#define | DSIZE 32768U
#define | read1(in)

## Functions
void | bye (char *msg1, char *msg2)
unsigned | gcd (unsigned a, unsigned b)
void | rotate (unsigned char *list, unsigned len, unsigned rot)
int | readin (file *in)
int | readmore (file *in)
void | skip (file *in, unsigned n)
unsigned long | read4 (file *in)
void | gzheader (file *in)
int | gzscan (char *name, z_stream *strm, int level)
void | gztack (char *name, int gd, z_stream *strm, int last)
int | main (int argc, char **argv)

## Macro Definition Documentation

## ◆ CHUNK

#define CHUNK (1U << LGCHUNK)

Definition at line 89 of file gzappend.c.

## ◆ DSIZE

#define DSIZE 32768U

Definition at line 90 of file gzappend.c.

## ◆ LGCHUNK

#define LGCHUNK 14

Definition at line 88 of file gzappend.c.

## ◆ local

#define local static

Definition at line 87 of file gzappend.c.

## ◆ read1

#define read1 | ( |  | in | ) |

Value:
(in->left == 0 ? readmore(in) : 0, \
in->left--, *(in->next)++)
in
unsigned in(void *in_desc, z_const unsigned char **buf)
Definition: gun.c:89
readmore
int readmore(file *in)
Definition: gzappend.c:192

Definition at line 198 of file gzappend.c.

## Function Documentation

## ◆ bye()

void bye | ( | char * | msg1,
|  | char * | msg2
| ) |  |

Definition at line 93 of file gzappend.c.

Referenced by gzheader(), gzscan(), gztack(), main(), readin(), readmore(), and skip().

## ◆ gcd()

unsigned gcd | ( | unsigned | a,
|  | unsigned | b
| ) |  |

Definition at line 102 of file gzappend.c.

Referenced by rb_int_fdiv_double(), and rotate().

## ◆ gzheader()

void gzheader | ( | file * | in | ) |

Definition at line 235 of file gzappend.c.

References bye(), in(), read1, and skip().

Referenced by gzscan().

## ◆ gzscan()

int gzscan | ( | char * | name,
|  | z_stream * | strm,
|  | int | level
| ) |  |

Definition at line 259 of file gzappend.c.

References z_stream_s::adler, z_stream_s::avail_in, z_stream_s::avail_out, file::buf, bye(), CHUNK, crc32(), z_stream_s::data_type, deflateInit2, deflatePrime(), deflateSetDictionary(), DSIZE, file::fd, free, gzheader(), inflate(), inflateEnd(), inflateInit2, L, file::left, LGCHUNK, malloc, name, file::name, file::next, z_stream_s::next_in, z_stream_s::next_out, NULL, off_t, z_stream_s::opaque, read(), read4(), readin(), readmore(), rotate(), SEEK_CUR, SEEK_SET, file::size, tot, z_stream_s::total_in, z_stream_s::total_out, write(), Z_BLOCK, Z_DATA_ERROR, Z_DEFAULT_STRATEGY, Z_DEFLATED, Z_MEM_ERROR, Z_NULL, Z_OK, Z_STREAM_END, Z_STREAM_ERROR, z_stream_s::zalloc, and z_stream_s::zfree.

Referenced by main().

## ◆ gztack()

void gztack | ( | char * | name,
|  | int | gd,
|  | z_stream * | strm,
|  | int | last
| ) |  |

Definition at line 388 of file gzappend.c.

References z_stream_s::adler, z_stream_s::avail_in, z_stream_s::avail_out, bye(), CHUNK, crc32(), deflate(), deflateEnd(), free, in(), last, len, malloc, name, z_stream_s::next_in, z_stream_s::next_out, NULL, out, read(), z_stream_s::total_in, write(), Z_FINISH, Z_NO_FLUSH, and Z_STREAM_END.

Referenced by main().

## ◆ main()

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

Definition at line 466 of file gzappend.c.

References argc, argv, bye(), gzscan(), gztack(), NULL, and Z_DEFAULT_COMPRESSION.

## ◆ read4()

unsigned long read4 | ( | file * | in | ) |

Definition at line 223 of file gzappend.c.

References in(), long(), and read1.

Referenced by gzscan().

## ◆ readin()

int readin | ( | file * | in | ) |

Definition at line 180 of file gzappend.c.

References bye(), in(), len, and read().

Referenced by gzscan(), and readmore().

## ◆ readmore()

int readmore | ( | file * | in | ) |

Definition at line 192 of file gzappend.c.

References bye(), in(), and readin().

Referenced by gzscan(), and skip().

## ◆ rotate()

void rotate | ( | unsigned char * | list,
|  | unsigned | len,
|  | unsigned | rot
| ) |  |

Definition at line 123 of file gzappend.c.

References gcd(), last, len, and memmove().

Referenced by gzscan().

## ◆ skip()

void skip | ( | file * | in,
|  | unsigned | n
| ) |  |

Definition at line 202 of file gzappend.c.

References bye(), in(), off_t, readmore(), and SEEK_CUR.

Referenced by bskip(), deflate_index_extract(), gzheader(), and main().