zlibWrapper/README.md: updated info about gzip file access functions
This commit is contained in:
parent
23a1e11360
commit
95f34e056a
@ -42,10 +42,10 @@ test: example fitblk example_zstd fitblk_zstd zwrapbench minigzip minigzip_zstd
|
|||||||
./fitblk_zstd 40960 <$(TEST_FILE)
|
./fitblk_zstd 40960 <$(TEST_FILE)
|
||||||
@echo ---- minigzip start ----
|
@echo ---- minigzip start ----
|
||||||
./minigzip_zstd example$(EXT)
|
./minigzip_zstd example$(EXT)
|
||||||
cp example$(EXT).gz example$(EXT)_zstd.gz
|
#cp example$(EXT).gz example$(EXT)_zstd.gz
|
||||||
./minigzip_zstd -d example$(EXT).gz
|
./minigzip_zstd -d example$(EXT).gz
|
||||||
./minigzip example$(EXT)
|
./minigzip example$(EXT)
|
||||||
cp example$(EXT).gz example$(EXT)_gz.gz
|
#cp example$(EXT).gz example$(EXT)_gz.gz
|
||||||
./minigzip_zstd -d example$(EXT).gz
|
./minigzip_zstd -d example$(EXT).gz
|
||||||
@echo ---- minigzip end ----
|
@echo ---- minigzip end ----
|
||||||
./zwrapbench -qb3B1K $(TEST_FILE)
|
./zwrapbench -qb3B1K $(TEST_FILE)
|
||||||
|
@ -10,6 +10,8 @@ To build the zstd wrapper for zlib the following files are required:
|
|||||||
- a static or dynamic zlib library
|
- a static or dynamic zlib library
|
||||||
- zlibWrapper/zstd_zlibwrapper.h
|
- zlibWrapper/zstd_zlibwrapper.h
|
||||||
- zlibWrapper/zstd_zlibwrapper.c
|
- zlibWrapper/zstd_zlibwrapper.c
|
||||||
|
- zlibWrapper/gz*.c files (gzclose.c, gzlib.c, gzread.c, gzwrite.c)
|
||||||
|
- zlibWrapper/gz*.h files (gzcompatibility.h, gzguts.h)
|
||||||
- a static or dynamic zstd library
|
- a static or dynamic zstd library
|
||||||
|
|
||||||
The first two files are required by all projects using zlib and they are not included with the zstd distribution.
|
The first two files are required by all projects using zlib and they are not included with the zstd distribution.
|
||||||
@ -22,26 +24,26 @@ Let's assume that your project that uses zlib is compiled with:
|
|||||||
```gcc project.o -lz```
|
```gcc project.o -lz```
|
||||||
|
|
||||||
To compile the zstd wrapper with your project you have to do the following:
|
To compile the zstd wrapper with your project you have to do the following:
|
||||||
- change all references with ```#include "zlib.h"``` to ```#include "zstd_zlibwrapper.h"```
|
- change all references with `#include "zlib.h"` to `#include "zstd_zlibwrapper.h"`
|
||||||
- compile your project with `zstd_zlibwrapper.c` and a static or dynamic zstd library
|
- compile your project with `zstd_zlibwrapper.c`, `gz*.c` and a static or dynamic zstd library
|
||||||
|
|
||||||
The linking should be changed to:
|
The linking should be changed to:
|
||||||
```gcc project.o zstd_zlibwrapper.o -lz -lzstd```
|
```gcc project.o zstd_zlibwrapper.o gz*.c -lz -lzstd```
|
||||||
|
|
||||||
|
|
||||||
#### Enabling zstd compression within your project
|
#### Enabling zstd compression within your project
|
||||||
|
|
||||||
After embedding the zstd wrapper within your project the zstd library is turned off by default.
|
After embedding the zstd wrapper within your project the zstd library is turned off by default.
|
||||||
Your project should work as before with zlib. There are two options to enable zstd compression:
|
Your project should work as before with zlib. There are two options to enable zstd compression:
|
||||||
- compilation with ```-DZWRAP_USE_ZSTD=1``` (or using ```#define ZWRAP_USE_ZSTD 1``` before ```#include "zstd_zlibwrapper.h"```)
|
- compilation with `-DZWRAP_USE_ZSTD=1` (or using `#define ZWRAP_USE_ZSTD 1` before `#include "zstd_zlibwrapper.h"`)
|
||||||
- using the ```void ZWRAP_useZSTDcompression(int turn_on)``` function (declared in ```#include "zstd_zlibwrapper.h"```)
|
- using the `void ZWRAP_useZSTDcompression(int turn_on)` function (declared in `#include "zstd_zlibwrapper.h"`)
|
||||||
|
|
||||||
During decompression zlib and zstd streams are automatically detected and decompressed using a proper library.
|
During decompression zlib and zstd streams are automatically detected and decompressed using a proper library.
|
||||||
This behavior can be changed using `ZWRAP_setDecompressionType(ZWRAP_FORCE_ZLIB)` what will make zlib decompression slightly faster.
|
This behavior can be changed using `ZWRAP_setDecompressionType(ZWRAP_FORCE_ZLIB)` what will make zlib decompression slightly faster.
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
We have take the file ```test/example.c``` from [the zlib library distribution](http://zlib.net/) and copied it to [zlibWrapper/examples/example.c](examples/example.c).
|
We have take the file `test/example.c` from [the zlib library distribution](http://zlib.net/) and copied it to [zlibWrapper/examples/example.c](examples/example.c).
|
||||||
After compilation and execution it shows the following results:
|
After compilation and execution it shows the following results:
|
||||||
```
|
```
|
||||||
zlib version 1.2.8 = 0x1280, compile flags = 0x65
|
zlib version 1.2.8 = 0x1280, compile flags = 0x65
|
||||||
@ -53,13 +55,15 @@ large_inflate(): OK
|
|||||||
after inflateSync(): hello, hello!
|
after inflateSync(): hello, hello!
|
||||||
inflate with dictionary: hello, hello!
|
inflate with dictionary: hello, hello!
|
||||||
```
|
```
|
||||||
Then we have changed ```#include "zlib.h"``` to ```#include "zstd_zlibwrapper.h"```, compiled the [example.c](examples/example.c) file
|
Then we have changed `#include "zlib.h"` to `#include "zstd_zlibwrapper.h"`, compiled the [example.c](examples/example.c) file
|
||||||
with ```-DZWRAP_USE_ZSTD=1``` and linked with additional ```zstd_zlibwrapper.o -lzstd```.
|
with `-DZWRAP_USE_ZSTD=1` and linked with additional `zstd_zlibwrapper.o gz*.c -lzstd`.
|
||||||
We were forced to turn off the following functions: ```test_gzio```, ```test_flush```, ```test_sync``` which use currently unsupported features.
|
We were forced to turn off the following functions: `test_flush`, `test_sync` which use currently unsupported features.
|
||||||
After running it shows the following results:
|
After running it shows the following results:
|
||||||
```
|
```
|
||||||
zlib version 1.2.8 = 0x1280, compile flags = 0x65
|
zlib version 1.2.8 = 0x1280, compile flags = 0x65
|
||||||
uncompress(): hello, hello!
|
uncompress(): hello, hello!
|
||||||
|
gzread(): hello, hello!
|
||||||
|
gzgets() after gzseek: hello!
|
||||||
inflate(): hello, hello!
|
inflate(): hello, hello!
|
||||||
large_inflate(): OK
|
large_inflate(): OK
|
||||||
inflate with dictionary: hello, hello!
|
inflate with dictionary: hello, hello!
|
||||||
|
Loading…
Reference in New Issue
Block a user