• 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=ac91bcd40e1439ee1e742cc47989530b112c99bd$
37 //
38 
39 #ifndef CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_
40 #define CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_
41 #pragma once
42 
43 #include "include/capi/cef_base_capi.h"
44 #include "include/capi/cef_stream_capi.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 ///
51 // Structure that supports the reading of zip archives via the zlib unzip API.
52 // The functions of this structure should only be called on the thread that
53 // creates the object.
54 ///
55 typedef struct _cef_zip_reader_t {
56   ///
57   // Base structure.
58   ///
59   cef_base_ref_counted_t base;
60 
61   ///
62   // Moves the cursor to the first file in the archive. Returns true (1) if the
63   // cursor position was set successfully.
64   ///
65   int(CEF_CALLBACK* move_to_first_file)(struct _cef_zip_reader_t* self);
66 
67   ///
68   // Moves the cursor to the next file in the archive. Returns true (1) if the
69   // cursor position was set successfully.
70   ///
71   int(CEF_CALLBACK* move_to_next_file)(struct _cef_zip_reader_t* self);
72 
73   ///
74   // Moves the cursor to the specified file in the archive. If |caseSensitive|
75   // is true (1) then the search will be case sensitive. Returns true (1) if the
76   // cursor position was set successfully.
77   ///
78   int(CEF_CALLBACK* move_to_file)(struct _cef_zip_reader_t* self,
79                                   const cef_string_t* fileName,
80                                   int caseSensitive);
81 
82   ///
83   // Closes the archive. This should be called directly to ensure that cleanup
84   // occurs on the correct thread.
85   ///
86   int(CEF_CALLBACK* close)(struct _cef_zip_reader_t* self);
87 
88   // The below functions act on the file at the current cursor position.
89 
90   ///
91   // Returns the name of the file.
92   ///
93   // The resulting string must be freed by calling cef_string_userfree_free().
94   cef_string_userfree_t(CEF_CALLBACK* get_file_name)(
95       struct _cef_zip_reader_t* self);
96 
97   ///
98   // Returns the uncompressed size of the file.
99   ///
100   int64(CEF_CALLBACK* get_file_size)(struct _cef_zip_reader_t* self);
101 
102   ///
103   // Returns the last modified timestamp for the file.
104   ///
105   cef_time_t(CEF_CALLBACK* get_file_last_modified)(
106       struct _cef_zip_reader_t* self);
107 
108   ///
109   // Opens the file for reading of uncompressed data. A read password may
110   // optionally be specified.
111   ///
112   int(CEF_CALLBACK* open_file)(struct _cef_zip_reader_t* self,
113                                const cef_string_t* password);
114 
115   ///
116   // Closes the file.
117   ///
118   int(CEF_CALLBACK* close_file)(struct _cef_zip_reader_t* self);
119 
120   ///
121   // Read uncompressed file contents into the specified buffer. Returns < 0 if
122   // an error occurred, 0 if at the end of file, or the number of bytes read.
123   ///
124   int(CEF_CALLBACK* read_file)(struct _cef_zip_reader_t* self,
125                                void* buffer,
126                                size_t bufferSize);
127 
128   ///
129   // Returns the current offset in the uncompressed file contents.
130   ///
131   int64(CEF_CALLBACK* tell)(struct _cef_zip_reader_t* self);
132 
133   ///
134   // Returns true (1) if at end of the file contents.
135   ///
136   int(CEF_CALLBACK* eof)(struct _cef_zip_reader_t* self);
137 } cef_zip_reader_t;
138 
139 ///
140 // Create a new cef_zip_reader_t object. The returned object's functions can
141 // only be called from the thread that created the object.
142 ///
143 CEF_EXPORT cef_zip_reader_t* cef_zip_reader_create(
144     struct _cef_stream_reader_t* stream);
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif  // CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_
151