• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // This file was generated by the CEF translator tool and should not edited
33 // by hand. See the translator.README.txt file in the tools directory for
34 // more information.
35 //
36 // $hash=87f6cad177614ece33d9574f0f2964e5bb97d613$
37 //
38 
39 #ifndef CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_
40 #define CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_
41 #pragma once
42 
43 #include "include/capi/cef_base_capi.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 ///
50 // Structure the client can implement to provide a custom stream reader. The
51 // functions of this structure may be called on any thread.
52 ///
53 typedef struct _cef_read_handler_t {
54   ///
55   // Base structure.
56   ///
57   cef_base_ref_counted_t base;
58 
59   ///
60   // Read raw binary data.
61   ///
62   size_t(CEF_CALLBACK* read)(struct _cef_read_handler_t* self,
63                              void* ptr,
64                              size_t size,
65                              size_t n);
66 
67   ///
68   // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
69   // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure.
70   ///
71   int(CEF_CALLBACK* seek)(struct _cef_read_handler_t* self,
72                           int64 offset,
73                           int whence);
74 
75   ///
76   // Return the current offset position.
77   ///
78   int64(CEF_CALLBACK* tell)(struct _cef_read_handler_t* self);
79 
80   ///
81   // Return non-zero if at end of file.
82   ///
83   int(CEF_CALLBACK* eof)(struct _cef_read_handler_t* self);
84 
85   ///
86   // Return true (1) if this handler performs work like accessing the file
87   // system which may block. Used as a hint for determining the thread to access
88   // the handler from.
89   ///
90   int(CEF_CALLBACK* may_block)(struct _cef_read_handler_t* self);
91 } cef_read_handler_t;
92 
93 ///
94 // Structure used to read data from a stream. The functions of this structure
95 // may be called on any thread.
96 ///
97 typedef struct _cef_stream_reader_t {
98   ///
99   // Base structure.
100   ///
101   cef_base_ref_counted_t base;
102 
103   ///
104   // Read raw binary data.
105   ///
106   size_t(CEF_CALLBACK* read)(struct _cef_stream_reader_t* self,
107                              void* ptr,
108                              size_t size,
109                              size_t n);
110 
111   ///
112   // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
113   // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure.
114   ///
115   int(CEF_CALLBACK* seek)(struct _cef_stream_reader_t* self,
116                           int64 offset,
117                           int whence);
118 
119   ///
120   // Return the current offset position.
121   ///
122   int64(CEF_CALLBACK* tell)(struct _cef_stream_reader_t* self);
123 
124   ///
125   // Return non-zero if at end of file.
126   ///
127   int(CEF_CALLBACK* eof)(struct _cef_stream_reader_t* self);
128 
129   ///
130   // Returns true (1) if this reader performs work like accessing the file
131   // system which may block. Used as a hint for determining the thread to access
132   // the reader from.
133   ///
134   int(CEF_CALLBACK* may_block)(struct _cef_stream_reader_t* self);
135 } cef_stream_reader_t;
136 
137 ///
138 // Create a new cef_stream_reader_t object from a file.
139 ///
140 CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
141     const cef_string_t* fileName);
142 
143 ///
144 // Create a new cef_stream_reader_t object from data.
145 ///
146 CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data,
147                                                                   size_t size);
148 
149 ///
150 // Create a new cef_stream_reader_t object from a custom handler.
151 ///
152 CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler(
153     cef_read_handler_t* handler);
154 
155 ///
156 // Structure the client can implement to provide a custom stream writer. The
157 // functions of this structure may be called on any thread.
158 ///
159 typedef struct _cef_write_handler_t {
160   ///
161   // Base structure.
162   ///
163   cef_base_ref_counted_t base;
164 
165   ///
166   // Write raw binary data.
167   ///
168   size_t(CEF_CALLBACK* write)(struct _cef_write_handler_t* self,
169                               const void* ptr,
170                               size_t size,
171                               size_t n);
172 
173   ///
174   // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
175   // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure.
176   ///
177   int(CEF_CALLBACK* seek)(struct _cef_write_handler_t* self,
178                           int64 offset,
179                           int whence);
180 
181   ///
182   // Return the current offset position.
183   ///
184   int64(CEF_CALLBACK* tell)(struct _cef_write_handler_t* self);
185 
186   ///
187   // Flush the stream.
188   ///
189   int(CEF_CALLBACK* flush)(struct _cef_write_handler_t* self);
190 
191   ///
192   // Return true (1) if this handler performs work like accessing the file
193   // system which may block. Used as a hint for determining the thread to access
194   // the handler from.
195   ///
196   int(CEF_CALLBACK* may_block)(struct _cef_write_handler_t* self);
197 } cef_write_handler_t;
198 
199 ///
200 // Structure used to write data to a stream. The functions of this structure may
201 // be called on any thread.
202 ///
203 typedef struct _cef_stream_writer_t {
204   ///
205   // Base structure.
206   ///
207   cef_base_ref_counted_t base;
208 
209   ///
210   // Write raw binary data.
211   ///
212   size_t(CEF_CALLBACK* write)(struct _cef_stream_writer_t* self,
213                               const void* ptr,
214                               size_t size,
215                               size_t n);
216 
217   ///
218   // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
219   // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure.
220   ///
221   int(CEF_CALLBACK* seek)(struct _cef_stream_writer_t* self,
222                           int64 offset,
223                           int whence);
224 
225   ///
226   // Return the current offset position.
227   ///
228   int64(CEF_CALLBACK* tell)(struct _cef_stream_writer_t* self);
229 
230   ///
231   // Flush the stream.
232   ///
233   int(CEF_CALLBACK* flush)(struct _cef_stream_writer_t* self);
234 
235   ///
236   // Returns true (1) if this writer performs work like accessing the file
237   // system which may block. Used as a hint for determining the thread to access
238   // the writer from.
239   ///
240   int(CEF_CALLBACK* may_block)(struct _cef_stream_writer_t* self);
241 } cef_stream_writer_t;
242 
243 ///
244 // Create a new cef_stream_writer_t object for a file.
245 ///
246 CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file(
247     const cef_string_t* fileName);
248 
249 ///
250 // Create a new cef_stream_writer_t object for a custom handler.
251 ///
252 CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
253     cef_write_handler_t* handler);
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif  // CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_
260