123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #ifndef TINF_H_INCLUDED
- #define TINF_H_INCLUDED
- #include <stdlib.h>
- #include <stdint.h>
- #include <stdbool.h>
- #ifndef TINFCC
- #ifdef __WATCOMC__
- #define TINFCC __cdecl
- #else
- #define TINFCC
- #endif
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define TINF_OK 0
- #define TINF_DONE 1
- #define TINF_DATA_ERROR (-3)
- #define TINF_CHKSUM_ERROR (-4)
- #define TINF_DICT_ERROR (-5)
- #define TINF_CHKSUM_NONE 0
- #define TINF_CHKSUM_ADLER 1
- #define TINF_CHKSUM_CRC 2
- #define TINF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
- typedef struct {
- unsigned short table[16];
- unsigned short trans[288];
- } TINF_TREE;
- struct TINF_DATA;
- typedef struct TINF_DATA {
-
- const unsigned char *source;
-
- const unsigned char *source_limit;
-
- int (*readSource)(struct TINF_DATA *data);
- unsigned int tag;
- unsigned int bitcount;
-
- unsigned char *destStart;
-
- unsigned int destSize;
-
- unsigned char *dest;
-
- unsigned int destRemaining;
-
- unsigned int checksum;
- char checksum_type;
- bool eof;
- int btype;
- int bfinal;
- unsigned int curlen;
- int lzOff;
- unsigned char *dict_ring;
- unsigned int dict_size;
- unsigned int dict_idx;
- TINF_TREE ltree;
- TINF_TREE dtree;
- } TINF_DATA;
- #define TINF_PUT(d, c) \
- { \
- *d->dest++ = c; \
- if (d->dict_ring) { d->dict_ring[d->dict_idx++] = c; if (d->dict_idx == d->dict_size) d->dict_idx = 0; } \
- }
- unsigned char TINFCC uzlib_get_byte(TINF_DATA *d);
- void TINFCC uzlib_init(void);
- void TINFCC uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen);
- int TINFCC uzlib_uncompress(TINF_DATA *d);
- int TINFCC uzlib_uncompress_chksum(TINF_DATA *d);
- int TINFCC uzlib_zlib_parse_header(TINF_DATA *d);
- int TINFCC uzlib_gzip_parse_header(TINF_DATA *d);
- void TINFCC uzlib_compress(void *data, const uint8_t *src, unsigned slen);
- uint32_t TINFCC uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum);
- uint32_t TINFCC uzlib_crc32(const void *data, unsigned int length, uint32_t crc);
- #ifdef __cplusplus
- }
- #endif
- #endif
|