Fossil SCM

fossil-scm / compat / zlib / contrib / blast / blast.h
Blame History Raw 85 lines
1
/* blast.h -- interface for blast.c
2
Copyright (C) 2003, 2012, 2013 Mark Adler
3
version 1.3, 24 Aug 2013
4
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the author be held liable for any damages
7
arising from the use of this software.
8
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
12
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
20
21
Mark Adler [email protected]
22
*/
23
24
#define local static /* for local function definitions */
25
26
/*
27
* blast() decompresses the PKWare Data Compression Library (DCL) compressed
28
* format. It provides the same functionality as the explode() function in
29
* that library. (Note: PKWare overused the "implode" verb, and the format
30
* used by their library implode() function is completely different and
31
* incompatible with the implode compression method supported by PKZIP.)
32
*
33
* The binary mode for stdio functions should be used to assure that the
34
* compressed data is not corrupted when read or written. For example:
35
* fopen(..., "rb") and fopen(..., "wb").
36
*/
37
38
39
typedef unsigned (*blast_in)(void *how, unsigned char **buf);
40
typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
41
/* Definitions for input/output functions passed to blast(). See below for
42
* what the provided functions need to do.
43
*/
44
45
46
int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
47
unsigned *left, unsigned char **in);
48
/* Decompress input to output using the provided infun() and outfun() calls.
49
* On success, the return value of blast() is zero. If there is an error in
50
* the source data, i.e. it is not in the proper format, then a negative value
51
* is returned. If there is not enough input available or there is not enough
52
* output space, then a positive error is returned.
53
*
54
* The input function is invoked: len = infun(how, &buf), where buf is set by
55
* infun() to point to the input buffer, and infun() returns the number of
56
* available bytes there. If infun() returns zero, then blast() returns with
57
* an input error. (blast() only asks for input if it needs it.) inhow is for
58
* use by the application to pass an input descriptor to infun(), if desired.
59
*
60
* If left and in are not NULL and *left is not zero when blast() is called,
61
* then the *left bytes at *in are consumed for input before infun() is used.
62
*
63
* The output function is invoked: err = outfun(how, buf, len), where the bytes
64
* to be written are buf[0..len-1]. If err is not zero, then blast() returns
65
* with an output error. outfun() is always called with len <= 4096. outhow
66
* is for use by the application to pass an output descriptor to outfun(), if
67
* desired.
68
*
69
* If there is any unused input, *left is set to the number of bytes that were
70
* read and *in points to them. Otherwise *left is set to zero and *in is set
71
* to NULL. If left or in are NULL, then they are not set.
72
*
73
* The return codes are:
74
*
75
* 2: ran out of input before completing decompression
76
* 1: output error before completing decompression
77
* 0: successful decompression
78
* -1: literal flag not zero or one
79
* -2: dictionary size not in 4..6
80
* -3: distance is too far back
81
*
82
* At the bottom of blast.c is an example program that uses blast() that can be
83
* compiled to produce a command-line decompression filter by defining TEST.
84
*/
85

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button