Debian Codegraph @

unzip/unzip.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/Lib/unzip.h $
21 * $Revision: 3 $
22 * $Date: 8/15/99 8:07p $
23 * $Author: Jeff $
24 *
25 * Unzip class
26 *
27 * $Log: /DescentIII/Main/Lib/unzip.h $
28 *
29 * 3 8/15/99 8:07p Jeff
30 * handle disk write errors when extracting
31 *
32 * 2 8/13/99 8:01p Jeff
33 * initial creation of zip class
34 *
35 * $NoKeywords: $
36 */
37
38 #ifndef UNZIP_H
39 #define UNZIP_Hcxx . . $ `unzip/unzip.h:39:9`!
40
41 #include <cstdint>
42 #include <cstdio>
43
44 struct zipentrycxx . . $ zipentry# {
45 uint32_tcxx . . $ uint32_t# cent_file_header_sigcxx . . $ zipentry#cent_file_header_sig.;
46 uint8_tcxx . . $ uint8_t# version_made_bycxx . . $ zipentry#version_made_by.;
47 uint8_tcxx . . $ uint8_t# host_oscxx . . $ zipentry#host_os.;
48 uint8_tcxx . . $ uint8_t# version_needed_to_extractcxx . . $ zipentry#version_needed_to_extract.;
49 uint8_tcxx . . $ uint8_t# os_needed_to_extractcxx . . $ zipentry#os_needed_to_extract.;
50 uint16_tcxx . . $ uint16_t# general_purpose_bit_flagcxx . . $ zipentry#general_purpose_bit_flag.;
51 uint16_tcxx . . $ uint16_t# compression_methodcxx . . $ zipentry#compression_method.;
52 uint16_tcxx . . $ uint16_t# last_mod_file_timecxx . . $ zipentry#last_mod_file_time.;
53 uint16_tcxx . . $ uint16_t# last_mod_file_datecxx . . $ zipentry#last_mod_file_date.;
54 uint32_tcxx . . $ uint32_t# crc32cxx . . $ zipentry#crc32.;
55 uint32_tcxx . . $ uint32_t# compressed_sizecxx . . $ zipentry#compressed_size.;
56 uint32_tcxx . . $ uint32_t# uncompressed_sizecxx . . $ zipentry#uncompressed_size.;
57 uint16_tcxx . . $ uint16_t# filename_lengthcxx . . $ zipentry#filename_length.;
58 uint16_tcxx . . $ uint16_t# extra_field_lengthcxx . . $ zipentry#extra_field_length.;
59 uint16_tcxx . . $ uint16_t# file_comment_lengthcxx . . $ zipentry#file_comment_length.;
60 uint16_tcxx . . $ uint16_t# disk_number_startcxx . . $ zipentry#disk_number_start.;
61 uint16_tcxx . . $ uint16_t# internal_file_attribcxx . . $ zipentry#internal_file_attrib.;
62 uint32_tcxx . . $ uint32_t# external_file_attribcxx . . $ zipentry#external_file_attrib.;
63 uint32_tcxx . . $ uint32_t# offset_lcl_hdr_frm_frst_diskcxx . . $ zipentry#offset_lcl_hdr_frm_frst_disk.;
64 char *namecxx . . $ zipentry#name.;
65 };
66
67 class ZIPcxx . . $ ZIP# {
68 public:
69 // constructor/destructor
70 ZIPcxx . . $ ZIP#ZIP(49f6e7a06ebc5aa8).();
71 ~cxx . . $ ZIP#`~ZIP`(ced63f7c635d850d).ZIPcxx . . $ ZIP#();
72
73 public:
74 // opens a zip file for reading
75 // returns true on success
76 bool OpenZipcxx . . $ ZIP#OpenZip(c5f7da30cbc0f4e9).(const char *path);
77
78 // closes an open zip file
79 void CloseZipcxx . . $ ZIP#CloseZip(49f6e7a06ebc5aa8).();
80
81 // Reads the current zip entry from the zip file (and moves
82 // to the next entry). Returns NULL if there are no more entries
83 zipentrycxx . . $ zipentry# *ReadNextZipEntrycxx . . $ ZIP#ReadNextZipEntry(49bfa059dac8e27d).();
84
85 // Resets a ZIP file to the first entry
86 void Rewindcxx . . $ ZIP#Rewind(49f6e7a06ebc5aa8).();
87
88 // Reads a file from the given zip entry into a buffer in memory
89 // -1 : no ZIP file open
90 // -2 : corrupt file
91 // -3 : Version too new
92 // -4 : OS not supported
93 // -5 : No Disk Spanning
94 // -6 : Error inflating
95 // -7 : Compression Type Not Supported
96 int ReadFilecxx . . $ ZIP#ReadFile(c690ba302e3ff01d).(zipentrycxx . . $ zipentry# *ent, char *data);
97
98 // Extracts a file from the given zip entry into another file
99 // -1 : no ZIP file open
100 // -2 : corrupt file
101 // -3 : Version too new
102 // -4 : OS not supported
103 // -5 : No Disk Spanning
104 // -6 : Error inflating
105 // -7 : Compression Type Not Supported
106 // -8 : Unable to open output
107 // -9 : Error writing to file
108 int ExtractFilecxx . . $ ZIP#ExtractFile(6368df9ccc80b6b3).(zipentrycxx . . $ zipentry# *ent, const char *filename);
109
110 private:
111 bool FindECDSignaturecxx . . $ ZIP#FindECDSignature(e7ab2d42594eba7).(char *buffer, int buflen, int *offset);
112 int ReadECDcxx . . $ ZIP#ReadECD(b126dc7c1de90089).();
113 int ReadZipDatacxx . . $ ZIP#ReadZipData(c690ba302e3ff01d).(zipentrycxx . . $ zipentry# *ent, char *data);
114 int ReadZipDataToFilecxx . . $ ZIP#ReadZipDataToFile(d92add29cb964409).(zipentrycxx . . $ zipentry# *ent, FILE *file);
115 int SeekToCompressedDatacxx . . $ ZIP#SeekToCompressedData(71e99d3a41c7d32b).(zipentrycxx . . $ zipentry# *ent);
116 int InflateFilecxx . . $ ZIP#InflateFile(20bf2652f263df83).(FILE *in_file, unsigned in_size, uint8_tcxx . . $ uint8_t# *out_data, unsigned out_size);
117 int InflateFileToFilecxx . . $ ZIP#InflateFileToFile(a602d8568e72276a).(FILE *in_file, unsigned in_size, FILE *file, unsigned out_size);
118
119 private:
120 bool m_opencxx . . $ ZIP#m_open.;
121 char *m_zipcxx . . $ ZIP#m_zip.; // zip name
122 FILE *m_fpcxx . . $ ZIP#m_fp.; // zip handler
123 int32_t m_lengthcxx . . $ ZIP#m_length.; // length of zip file
124
125 char *m_ecdcxx . . $ ZIP#m_ecd.; // end_of_cent_dir data
126 unsigned m_ecd_lengthcxx . . $ ZIP#m_ecd_length.; // end_of_cent_dir length
127
128 char *m_cdcxx . . $ ZIP#m_cd.; // cent_dir data
129
130 unsigned m_cd_poscxx . . $ ZIP#m_cd_pos.; // position in cent_dir
131
132 zipentrycxx . . $ zipentry# m_entcxx . . $ ZIP#m_ent.; // buffer for readzip
133
134 // end_of_cent_dir
135 uint32_tcxx . . $ uint32_t# m_end_of_cent_dir_sigcxx . . $ ZIP#m_end_of_cent_dir_sig.;
136 uint16_tcxx . . $ uint16_t# m_number_of_this_diskcxx . . $ ZIP#m_number_of_this_disk.;
137 uint16_tcxx . . $ uint16_t# m_number_of_disk_start_cent_dircxx . . $ ZIP#m_number_of_disk_start_cent_dir.;
138 uint16_tcxx . . $ uint16_t# m_total_entries_cent_dir_this_diskcxx . . $ ZIP#m_total_entries_cent_dir_this_disk.;
139 uint16_tcxx . . $ uint16_t# m_total_entries_cent_dircxx . . $ ZIP#m_total_entries_cent_dir.;
140 uint32_tcxx . . $ uint32_t# m_size_of_cent_dircxx . . $ ZIP#m_size_of_cent_dir.;
141 uint32_tcxx . . $ uint32_t# m_offset_to_start_of_cent_dircxx . . $ ZIP#m_offset_to_start_of_cent_dir.;
142 uint16_tcxx . . $ uint16_t# m_zipfile_comment_lengthcxx . . $ ZIP#m_zipfile_comment_length.;
143 char *m_zipfile_commentcxx . . $ ZIP#m_zipfile_comment.; // pointer in ecd
144 };
145
146 // Compare two filename without using directory
147 int CompareZipFileNamecxx . . $ CompareZipFileName(5ae29d726ae57f88).(const char *zipfile, const char *file);
148
149 #endif