[Telemetry] Reenable unused-import lint check for telemetry.
[chromium-blink-merge.git] / third_party / brotli / dec / streams.h
blob71301a930a8e2d6f211f9d43d0713a18d1e81126
1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
16 /* Functions for streaming input and output. */
18 #ifndef BROTLI_DEC_STREAMS_H_
19 #define BROTLI_DEC_STREAMS_H_
21 #include <stdio.h>
22 #include "./types.h"
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
28 /* Function pointer type used to read len bytes into buf. Returns the */
29 /* number of bytes read or -1 on error. */
30 typedef int (*BrotliInputFunction)(void* data, uint8_t* buf, size_t len);
32 /* Input callback function with associated data. */
33 typedef struct {
34 BrotliInputFunction cb_;
35 void* data_;
36 } BrotliInput;
38 /* Reads len bytes into buf, using the in callback. */
39 static BROTLI_INLINE int BrotliRead(BrotliInput in, uint8_t* buf, size_t len) {
40 return in.cb_(in.data_, buf, len);
43 /* Function pointer type used to write len bytes into buf. Returns the */
44 /* number of bytes written or -1 on error. */
45 typedef int (*BrotliOutputFunction)(void* data, const uint8_t* buf, size_t len);
47 /* Output callback function with associated data. */
48 typedef struct {
49 BrotliOutputFunction cb_;
50 void* data_;
51 } BrotliOutput;
53 /* Writes len bytes into buf, using the out callback. */
54 static BROTLI_INLINE int BrotliWrite(BrotliOutput out,
55 const uint8_t* buf, size_t len) {
56 return out.cb_(out.data_, buf, len);
59 /* Memory region with position. */
60 typedef struct {
61 const uint8_t* buffer;
62 size_t length;
63 size_t pos;
64 } BrotliMemInput;
66 /* Input callback where *data is a BrotliMemInput struct. */
67 int BrotliMemInputFunction(void* data, uint8_t* buf, size_t count);
69 /* Returns an input callback that wraps the given memory region. */
70 BrotliInput BrotliInitMemInput(const uint8_t* buffer, size_t length,
71 BrotliMemInput* mem_input);
73 /* Output buffer with position. */
74 typedef struct {
75 uint8_t* buffer;
76 size_t length;
77 size_t pos;
78 } BrotliMemOutput;
80 /* Output callback where *data is a BrotliMemOutput struct. */
81 int BrotliMemOutputFunction(void* data, const uint8_t* buf, size_t count);
83 /* Returns an output callback that wraps the given memory region. */
84 BrotliOutput BrotliInitMemOutput(uint8_t* buffer, size_t length,
85 BrotliMemOutput* mem_output);
87 /* Input callback that reads from standard input. */
88 int BrotliStdinInputFunction(void* data, uint8_t* buf, size_t count);
89 BrotliInput BrotliStdinInput();
91 /* Output callback that writes to standard output. */
92 int BrotliStdoutOutputFunction(void* data, const uint8_t* buf, size_t count);
93 BrotliOutput BrotliStdoutOutput();
95 /* Input callback that reads from a file. */
96 int BrotliFileInputFunction(void* data, uint8_t* buf, size_t count);
97 BrotliInput BrotliFileInput(FILE* f);
99 /* Output callback that writes to a file. */
100 int BrotliFileOutputFunction(void* data, const uint8_t* buf, size_t count);
101 BrotliOutput BrotliFileOutput(FILE* f);
103 #if defined(__cplusplus) || defined(c_plusplus)
104 } /* extern "C" */
105 #endif
107 #endif /* BROTLI_DEC_STREAMS_H_ */