Debian Codegraph @

src/c/compression_zstd/_zstdmodule.h

raw
1 /* Low level interface to the Zstandard algorithm & the zstd library. */
2
3 /* Declarations shared between different parts of the _zstd module*/
4
5 #ifndef ZSTD_MODULE_H
6 #define ZSTD_MODULE_H
7
8 #include "backports_zstd_compat.h"
9 #include "zstddict.h"
10
11 /* Type specs */
12 extern PyType_Spec zstd_dict_type_spec;
13 extern PyType_Spec zstd_compressor_type_spec;
14 extern PyType_Spec zstd_decompressor_type_spec;
15
16 typedef struct {
17 /* Module heap types. */
18 PyTypeObject *ZstdDict_type;
19 PyTypeObject *ZstdCompressor_type;
20 PyTypeObject *ZstdDecompressor_type;
21 PyObject *ZstdError;
22
23 /* enum types set by set_parameter_types. */
24 PyTypeObject *CParameter_type;
25 PyTypeObject *DParameter_type;
26 } _zstd_state;
27
28 typedef enum {
29 ERR_DECOMPRESS,
30 ERR_COMPRESS,
31 ERR_SET_PLEDGED_INPUT_SIZE,
32
33 ERR_LOAD_D_DICT,
34 ERR_LOAD_C_DICT,
35
36 ERR_GET_C_BOUNDS,
37 ERR_GET_D_BOUNDS,
38 ERR_SET_C_LEVEL,
39
40 ERR_TRAIN_DICT,
41 ERR_FINALIZE_DICT,
42 } error_type;
43
44 typedef enum {
45 DICT_TYPE_DIGESTED = 0,
46 DICT_TYPE_UNDIGESTED = 1,
47 DICT_TYPE_PREFIX = 2
48 } dictionary_type;
49
50 extern ZstdDict *
51 _Py_parse_zstd_dict(const _zstd_state *state,
52 PyObject *dict, int *type);
53
54 /* Format error message and set ZstdError. */
55 extern void
56 set_zstd_error(const _zstd_state *state,
57 error_type type, size_t zstd_ret);
58
59 extern void
60 set_parameter_error(int is_compress, int key_v, int value_v);
61
62 #endif // !ZSTD_MODULE_H