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

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

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

Go to the source code of this file.

## Data Structures
struct | bin

## Macros
#define | local static
#define | CHUNK 32768 /* must be a power of two and fit in unsigned */
#define | bget(in)

## Functions
int | bail (char *why1, char *why2)
void | bclose (bin *in)
bin * | bopen (char *name)
int | bload (bin *in)
unsigned long | bget4 (bin *in)
void | bskip (bin *in, unsigned skip)
void | gzhead (bin *in)
void | put4 (unsigned long val, FILE *out)
void | zpull (z_streamp strm, bin *in)
void | gzinit (unsigned long *crc, unsigned long *tot, FILE *out)
void | gzcopy (char *name, int clr, unsigned long *crc, unsigned long *tot, FILE *out)
int | main (int argc, char **argv)

## Macro Definition Documentation

## ◆ bget

#define bget | ( |  | in | ) |

Value:
(in->left ? 0 : bload(in), \
in->left ? (in->left--, *(in->next)++) : \
bail("unexpected end of file on ", in->name))
in
unsigned in(void *in_desc, z_const unsigned char **buf)
Definition: gun.c:89
bload
int bload(bin *in)
Definition: gzjoin.c:121

Definition at line 140 of file gzjoin.c.

## ◆ CHUNK

#define CHUNK 32768 /* must be a power of two and fit in unsigned */

Definition at line 75 of file gzjoin.c.

## ◆ local

#define local static

Definition at line 63 of file gzjoin.c.

## Function Documentation

## ◆ bail()

int bail | ( | char * | why1,
|  | char * | why2
| ) |  |

Definition at line 66 of file gzjoin.c.

Referenced by bskip(), gzcopy(), gzhead(), and zpull().

## ◆ bclose()

void bclose | ( | bin * | in | ) |

Definition at line 87 of file gzjoin.c.

References free, in(), and NULL.

Referenced by bopen(), and gzcopy().

## ◆ bget4()

unsigned long bget4 | ( | bin * | in | ) |

Definition at line 145 of file gzjoin.c.

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

Referenced by gzcopy().

## ◆ bload()

int bload | ( | bin * | in | ) |

Definition at line 121 of file gzjoin.c.

References CHUNK, in(), len, long(), NULL, and read().

Referenced by bskip(), and zpull().

## ◆ bopen()

bin * bopen | ( | char * | name | ) |

Definition at line 100 of file gzjoin.c.

References bclose(), CHUNK, in(), malloc, name, and NULL.

Referenced by gzcopy().

## ◆ bskip()

void bskip | ( | bin * | in,
|  | unsigned | skip
| ) |  |

Definition at line 157 of file gzjoin.c.

References bail(), bload(), CHUNK, in(), NULL, read(), SEEK_CUR, and skip().

Referenced by gzhead().

## ◆ gzcopy()

void gzcopy | ( | char * | name,
|  | int | clr,
|  | unsigned long * | crc,
|  | unsigned long * | tot,
|  | FILE * | out
| ) |  |

Definition at line 279 of file gzjoin.c.

References z_stream_s::avail_in, z_stream_s::avail_out, bail(), bclose(), bget4(), bopen(), CHUNK, crc32_combine(), z_stream_s::data_type, free, gzhead(), in(), inflate(), inflateEnd(), inflateInit2, last, len, long(), malloc, name, z_stream_s::next_in, z_stream_s::next_out, NULL, z_stream_s::opaque, out, put4(), tot, Z_BLOCK, Z_DATA_ERROR, Z_MEM_ERROR, Z_NULL, z_off_t, Z_OK, z_stream_s::zalloc, z_stream_s::zfree, and zpull().

Referenced by main().

## ◆ gzhead()

void gzhead | ( | bin * | in | ) |

Definition at line 204 of file gzjoin.c.

References bail(), bget, bskip(), in(), and len.

Referenced by gzcopy().

## ◆ gzinit()

void gzinit | ( | unsigned long * | crc,
|  | unsigned long * | tot,
|  | FILE * | out
| ) |  |

Definition at line 265 of file gzjoin.c.

References crc32(), L, out, tot, and Z_NULL.

Referenced by main().

## ◆ main()

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

Definition at line 427 of file gzjoin.c.

References argc, argv, gzcopy(), gzinit(), and tot.

## ◆ put4()

void put4 | ( | unsigned long | val,
|  | FILE * | out
| ) |  |

Definition at line 245 of file gzjoin.c.

References out.

Referenced by gzcopy().

## ◆ zpull()

void zpull | ( | z_streamp | strm,
|  | bin * | in
| ) |  |

Definition at line 254 of file gzjoin.c.

References bail(), bload(), and in().

Referenced by gzcopy().