]>
iEval git - io-compress-brotli.git/blob - dec/streams.h
a849432749b63cae90b790bc71e0e0975489c896
1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
7 /* Functions for streaming input and output. */
9 #ifndef BROTLI_DEC_STREAMS_H_
10 #define BROTLI_DEC_STREAMS_H_
16 #if defined(__cplusplus) || defined(c_plusplus)
20 /* Function pointer type used to read len bytes into buf. Returns the */
21 /* number of bytes read or -1 on error. */
22 typedef int (*BrotliInputFunction
)(void* data
, uint8_t* buf
, size_t len
);
24 /* Input callback function with associated data. */
26 BrotliInputFunction cb_
;
30 /* Reads len bytes into buf, using the in callback. */
31 static BROTLI_INLINE
int BrotliRead(BrotliInput in
, uint8_t* buf
, size_t len
) {
32 return in
.cb_(in
.data_
, buf
, len
);
35 /* Function pointer type used to write len bytes into buf. Returns the */
36 /* number of bytes written or -1 on error. */
37 typedef int (*BrotliOutputFunction
)(void* data
, const uint8_t* buf
, size_t len
);
39 /* Output callback function with associated data. */
41 BrotliOutputFunction cb_
;
45 /* Writes len bytes into buf, using the out callback. */
46 static BROTLI_INLINE
int BrotliWrite(BrotliOutput out
,
47 const uint8_t* buf
, size_t len
) {
48 return out
.cb_(out
.data_
, buf
, len
);
51 /* Memory region with position. */
53 const uint8_t* buffer
;
58 /* Input callback where *data is a BrotliMemInput struct. */
59 int BrotliMemInputFunction(void* data
, uint8_t* buf
, size_t count
);
61 /* Returns an input callback that wraps the given memory region. */
62 BrotliInput
BrotliInitMemInput(const uint8_t* buffer
, size_t length
,
63 BrotliMemInput
* mem_input
);
65 /* Output buffer with position. */
72 /* Output callback where *data is a BrotliMemOutput struct. */
73 int BrotliMemOutputFunction(void* data
, const uint8_t* buf
, size_t count
);
75 /* Returns an output callback that wraps the given memory region. */
76 BrotliOutput
BrotliInitMemOutput(uint8_t* buffer
, size_t length
,
77 BrotliMemOutput
* mem_output
);
79 /* Input callback that reads from a file. */
80 int BrotliFileInputFunction(void* data
, uint8_t* buf
, size_t count
);
81 BrotliInput
BrotliFileInput(FILE* f
);
83 /* Output callback that writes to a file. */
84 int BrotliFileOutputFunction(void* data
, const uint8_t* buf
, size_t count
);
85 BrotliOutput
BrotliFileOutput(FILE* f
);
87 /* Output callback that does nothing, always consumes the whole input. */
88 int BrotliNullOutputFunction(void* data
, const uint8_t* buf
, size_t count
);
89 BrotliOutput
BrotliNullOutput(void);
91 #if defined(__cplusplus) || defined(c_plusplus)
95 #endif /* BROTLI_DEC_STREAMS_H_ */
This page took 0.05064 seconds and 3 git commands to generate.