1#![allow(bad_style)]
2#![doc(html_root_url = "https://docs.rs/brotli-sys/0.2")]
3
4extern crate libc;
5
6use libc::{c_void, size_t, c_int, c_char};
7
8#[cfg(target_env = "msvc")]
9#[doc(hidden)]
10pub type __enum_ty = libc::c_int;
11#[cfg(not(target_env = "msvc"))]
12#[doc(hidden)]
13pub type __enum_ty = libc::c_uint;
14
15pub type __enum_ty_s = libc::c_int;
16
17pub type brotli_alloc_func = Option<extern "C" fn(*mut c_void, size_t) -> *mut c_void>;
18pub type brotli_free_func = Option<extern "C" fn(*mut c_void, *mut c_void)>;
19
20pub type BrotliDecoderResult = __enum_ty;
23pub type BrotliDecoderErrorCode = __enum_ty_s;
24
25pub enum BrotliDecoderState {}
26
27pub const BROTLI_DECODER_RESULT_ERROR: BrotliDecoderResult = 0;
28pub const BROTLI_DECODER_RESULT_SUCCESS: BrotliDecoderResult = 1;
29pub const BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: BrotliDecoderResult = 2;
30pub const BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: BrotliDecoderResult = 3;
31
32pub const BROTLI_DECODER_NO_ERROR: BrotliDecoderErrorCode = 0;
33pub const BROTLI_DECODER_SUCCESS: BrotliDecoderErrorCode = 1;
34pub const BROTLI_DECODER_NEEDS_MORE_INPUT: BrotliDecoderErrorCode = 2;
35pub const BROTLI_DECODER_NEEDS_MORE_OUTPUT: BrotliDecoderErrorCode = 3;
36pub const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: BrotliDecoderErrorCode = -1;
37pub const BROTLI_DECODER_ERROR_FORMAT_RESERVED: BrotliDecoderErrorCode = -2;
38pub const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: BrotliDecoderErrorCode = -3;
39pub const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: BrotliDecoderErrorCode = -4;
40pub const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: BrotliDecoderErrorCode = -5;
41pub const BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: BrotliDecoderErrorCode = -6;
42pub const BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: BrotliDecoderErrorCode = -7;
43pub const BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: BrotliDecoderErrorCode = -8;
44pub const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: BrotliDecoderErrorCode = -9;
45pub const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: BrotliDecoderErrorCode = -10;
46pub const BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: BrotliDecoderErrorCode = -11;
47pub const BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: BrotliDecoderErrorCode = -12;
48pub const BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: BrotliDecoderErrorCode = -13;
49pub const BROTLI_DECODER_ERROR_FORMAT_PADDING_1: BrotliDecoderErrorCode = -14;
50pub const BROTLI_DECODER_ERROR_FORMAT_PADDING_2: BrotliDecoderErrorCode = -15;
51pub const BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: BrotliDecoderErrorCode = -20;
52pub const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: BrotliDecoderErrorCode = -21;
53pub const BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: BrotliDecoderErrorCode = -22;
54pub const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: BrotliDecoderErrorCode = -25;
55pub const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: BrotliDecoderErrorCode = -26;
56pub const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: BrotliDecoderErrorCode = -27;
57pub const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: BrotliDecoderErrorCode = -30;
58pub const BROTLI_DECODER_ERROR_UNREACHABLE: BrotliDecoderErrorCode = -31;
59
60extern "C" {
61 pub fn BrotliDecoderCreateInstance(alloc_func: brotli_alloc_func,
62 free_func: brotli_free_func,
63 opaque: *mut c_void)
64 -> *mut BrotliDecoderState;
65 pub fn BrotliDecoderDestroyInstance(state: *mut BrotliDecoderState);
66 pub fn BrotliDecoderDecompress(encoded_size: size_t,
67 encoded_buffer: *const u8,
68 decoded_size: *mut size_t,
69 decoded_buffer: *mut u8) ->
70 BrotliDecoderResult;
71 pub fn BrotliDecoderDecompressStream(state: *mut BrotliDecoderState,
72 available_in: *mut size_t,
73 next_in: *mut *const u8,
74 available_out: *mut size_t,
75 next_out: *mut *mut u8,
76 total_out: *mut size_t)
77 -> BrotliDecoderResult;
78 pub fn BrotliDecoderSetCustomDictionary(state: *mut BrotliDecoderState,
79 size: size_t,
80 dict: *const u8);
81 pub fn BrotliDecoderHasMoreOutput(state: *const BrotliDecoderState) -> c_int;
82 pub fn BrotliDecoderTakeOutput(state: *mut BrotliDecoderState,
83 size: *mut size_t)
84 -> *const u8;
85 pub fn BrotliDecoderIsUsed(state: *const BrotliDecoderState) -> c_int;
86 pub fn BrotliDecoderIsFinished(state: *const BrotliDecoderState) -> c_int;
87 pub fn BrotliDecoderGetErrorCode(state: *const BrotliDecoderState) -> BrotliDecoderErrorCode;
88 pub fn BrotliDecoderErrorString(c: BrotliDecoderErrorCode) -> *const c_char;
89 pub fn BrotliDecoderVersion() -> u32;
90}
91
92
93
94pub type BrotliEncoderMode = __enum_ty;
97pub type BrotliEncoderParameter = __enum_ty;
98pub type BrotliEncoderOperation = __enum_ty;
99
100pub const BROTLI_MODE_GENERIC: BrotliEncoderMode = 0;
101pub const BROTLI_MODE_TEXT: BrotliEncoderMode = 1;
102pub const BROTLI_MODE_FONT: BrotliEncoderMode = 2;
103
104pub const BROTLI_PARAM_MODE: BrotliEncoderParameter = 0;
105pub const BROTLI_PARAM_QUALITY: BrotliEncoderParameter = 1;
106pub const BROTLI_PARAM_LGWIN: BrotliEncoderParameter = 2;
107pub const BROTLI_PARAM_LGBLOCK: BrotliEncoderParameter = 3;
108pub const BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: BrotliEncoderParameter = 4;
109pub const BROTLI_PARAM_SIZE_HINT: BrotliEncoderParameter = 5;
110
111pub const BROTLI_OPERATION_PROCESS: BrotliEncoderOperation = 0;
112pub const BROTLI_OPERATION_FLUSH: BrotliEncoderOperation = 1;
113pub const BROTLI_OPERATION_FINISH: BrotliEncoderOperation = 2;
114pub const BROTLI_OPERATION_EMIT_METADATA: BrotliEncoderOperation = 3;
115
116pub const BROTLI_DEFAULT_QUALITY: u32 = 11;
117pub const BROTLI_DEFAULT_WINDOW: u32 = 22;
118pub const BROTLI_DEFAULT_MODE: u32 = 0;
119
120pub enum BrotliEncoderState {}
121
122extern "C" {
123 pub fn BrotliEncoderSetParameter(state: *mut BrotliEncoderState,
124 param: BrotliEncoderParameter,
125 value: u32)
126 -> c_int;
127 pub fn BrotliEncoderCreateInstance(alloc_func: brotli_alloc_func,
128 free_func: brotli_free_func,
129 opaque: *mut c_void)
130 -> *mut BrotliEncoderState;
131 pub fn BrotliEncoderDestroyInstance(state: *mut BrotliEncoderState);
132 pub fn BrotliEncoderSetCustomDictionary(state: *mut BrotliEncoderState,
144 size: size_t,
145 dict: *const u8);
146 pub fn BrotliEncoderMaxCompressedSize(input_size: size_t) -> size_t;
147 pub fn BrotliEncoderCompress(quality: c_int,
148 lgwin: c_int,
149 mode: BrotliEncoderMode,
150 input_size: size_t,
151 input_buffer: *const u8,
152 encoded_size: *mut size_t,
153 encoded_buffer: *mut u8)
154 -> c_int;
155 pub fn BrotliEncoderCompressStream(state: *mut BrotliEncoderState,
156 op: BrotliEncoderOperation,
157 available_in: *mut size_t,
158 next_in: *mut *const u8,
159 available_out: *mut size_t,
160 next_out: *mut *mut u8,
161 total_out: *mut size_t)
162 -> c_int;
163 pub fn BrotliEncoderIsFinished(state: *mut BrotliEncoderState) -> c_int;
164 pub fn BrotliEncoderHasMoreOutput(state: *mut BrotliEncoderState) -> c_int;
165 pub fn BrotliEncoderTakeOutput(state: *mut BrotliEncoderState,
166 size: *mut usize)
167 -> *const u8;
168 pub fn BrotliEncoderVersion() -> u32;
169}