1 #ifndef _HAD_ZIPINT_H 2 #define _HAD_ZIPINT_H 3 4 /* 5 zipint.h -- internal declarations. 6 Copyright (c) 1999-2017 Dieter Baron and Thomas Klausner 7 8 This file is part of libzip, a library to manipulate ZIP archives. 9 The authors can be contacted at <libzip@nih.at> 10 11 Redistribution and use in source and binary forms, with or without 12 modification, are permitted provided that the following conditions 13 are met: 14 1. Redistributions of source code must retain the above copyright 15 notice, this list of conditions and the following disclaimer. 16 2. Redistributions in binary form must reproduce the above copyright 17 notice, this list of conditions and the following disclaimer in 18 the documentation and/or other materials provided with the 19 distribution. 20 3. The names of the authors may not be used to endorse or promote 21 products derived from this software without specific prior 22 written permission. 23 24 THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS 25 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 30 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 32 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 34 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37 #ifdef PHP_WIN32 38 # include "php_zip_config.w32.h" 39 #else 40 # include "config.h" 41 #endif 42 43 /* to have *_MAX definitions for all types when compiling with g++ */ 44 #define __STDC_LIMIT_MACROS 45 46 #include <zlib.h> 47 48 #ifdef PHP_WIN32 49 /* for dup(), close(), etc. */ 50 #include <io.h> 51 #include "config.w32.h" 52 #endif 53 54 #ifndef _ZIP_COMPILING_DEPRECATED 55 #define ZIP_DISABLE_DEPRECATED 56 #endif 57 58 #include "zip.h" 59 60 #ifdef HAVE_STDBOOL_H 61 #include <stdbool.h> 62 #else 63 typedef char bool; 64 #define true 1 65 #define false 0 66 #endif 67 68 #include <errno.h> 69 70 /* at least MinGW does not provide EOPNOTSUPP, see 71 * http://sourceforge.net/p/mingw/bugs/263/ 72 */ 73 #ifndef EOPNOTSUPP 74 #define EOPNOTSUPP EINVAL 75 #endif 76 77 /* at least MinGW does not provide EOVERFLOW, see 78 * http://sourceforge.net/p/mingw/bugs/242/ 79 */ 80 #ifndef EOVERFLOW 81 #define EOVERFLOW EFBIG 82 #endif 83 84 #ifdef _WIN32 85 #if defined(HAVE__CLOSE) 86 #define close _close 87 #endif 88 #if defined(HAVE__DUP) 89 #define dup _dup 90 #endif 91 /* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */ 92 #if defined(HAVE__FDOPEN) 93 #define fdopen _fdopen 94 #endif 95 #if !defined(HAVE_FILENO) && defined(HAVE__FILENO) 96 #define fileno _fileno 97 #endif 98 /* Windows' open() doesn't understand Unix permissions */ 99 #if defined(HAVE__OPEN) 100 #define open(a, b, c) _open((a), (b)) 101 #endif 102 #if defined(HAVE__SNPRINTF) 103 #define snprintf _snprintf 104 #endif 105 #if defined(HAVE__STRDUP) 106 #if !defined(HAVE_STRDUP) || defined(_WIN32) 107 #undef strdup 108 #define strdup _strdup 109 #endif 110 #endif 111 #if !defined(HAVE__SETMODE) && defined(HAVE_SETMODE) 112 #define _setmode setmode 113 #endif 114 #endif 115 116 #ifndef HAVE_FSEEKO 117 #define fseeko(s, o, w) (fseek((s), (long int)(o), (w))) 118 #endif 119 120 #ifndef HAVE_FTELLO 121 #define ftello(s) ((long)ftell((s))) 122 #endif 123 124 #ifndef HAVE_MKSTEMP 125 int _zip_mkstemp(char *); 126 #define mkstemp _zip_mkstemp 127 #endif 128 129 #if !defined(HAVE_STRCASECMP) 130 #if defined(HAVE__STRICMP) 131 #define strcasecmp _stricmp 132 #elif defined(HAVE_STRICMP) 133 #define strcasecmp stricmp 134 #endif 135 #endif 136 137 #if SIZEOF_OFF_T == 8 138 #define ZIP_OFF_MAX ZIP_INT64_MAX 139 #define ZIP_OFF_MIN ZIP_INT64_MIN 140 #elif SIZEOF_OFF_T == 4 141 #define ZIP_OFF_MAX ZIP_INT32_MAX 142 #define ZIP_OFF_MIN ZIP_INT32_MIN 143 #elif SIZEOF_OFF_T == 2 144 #define ZIP_OFF_MAX ZIP_INT16_MAX 145 #define ZIP_OFF_MIN ZIP_INT16_MIN 146 #else 147 #error unsupported size of off_t 148 #endif 149 150 #if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO) 151 #define ZIP_FSEEK_MAX ZIP_OFF_MAX 152 #define ZIP_FSEEK_MIN ZIP_OFF_MIN 153 #else 154 #include <limits.h> 155 #define ZIP_FSEEK_MAX LONG_MAX 156 #define ZIP_FSEEK_MIN LONG_MIN 157 #endif 158 159 #ifndef SIZE_MAX 160 #if SIZEOF_SIZE_T == 8 161 #define SIZE_MAX ZIP_INT64_MAX 162 #elif SIZEOF_SIZE_T == 4 163 #define SIZE_MAX ZIP_INT32_MAX 164 #elif SIZEOF_SIZE_T == 2 165 #define SIZE_MAX ZIP_INT16_MAX 166 #else 167 #error unsupported size of size_t 168 #endif 169 #endif 170 171 #define CENTRAL_MAGIC "PK\1\2" 172 #define LOCAL_MAGIC "PK\3\4" 173 #define EOCD_MAGIC "PK\5\6" 174 #define DATADES_MAGIC "PK\7\8" 175 #define EOCD64LOC_MAGIC "PK\6\7" 176 #define EOCD64_MAGIC "PK\6\6" 177 #define CDENTRYSIZE 46u 178 #define LENTRYSIZE 30 179 #define MAXCOMLEN 65536 180 #define MAXEXTLEN 65536 181 #define EOCDLEN 22 182 #define EOCD64LOCLEN 20 183 #define EOCD64LEN 56 184 #define CDBUFSIZE (MAXCOMLEN+EOCDLEN+EOCD64LOCLEN) 185 #define BUFSIZE 8192 186 #define EFZIP64SIZE 28 187 188 #define ZIP_CM_REPLACED_DEFAULT (-2) 189 190 #define ZIP_CM_IS_DEFAULT(x) ((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT) 191 192 #define ZIP_EF_UTF_8_COMMENT 0x6375 193 #define ZIP_EF_UTF_8_NAME 0x7075 194 #define ZIP_EF_ZIP64 0x0001 195 196 #define ZIP_EF_IS_INTERNAL(id) ((id) == ZIP_EF_UTF_8_COMMENT || (id) == ZIP_EF_UTF_8_NAME || (id) == ZIP_EF_ZIP64) 197 198 /* according to unzip-6.0's zipinfo.c, this corresponds to a regular file with rw permissions for everyone */ 199 #define ZIP_EXT_ATTRIB_DEFAULT (0100666u<<16) 200 /* according to unzip-6.0's zipinfo.c, this corresponds to a directory with rwx permissions for everyone */ 201 #define ZIP_EXT_ATTRIB_DEFAULT_DIR (0040777u<<16) 202 203 204 #define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b)) 205 #define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) 206 207 /* This section contains API that won't materialize like this. It's 208 placed in the internal section, pending cleanup. */ 209 210 /* flags for compression and encryption sources */ 211 212 #define ZIP_CODEC_DECODE 0 /* decompress/decrypt (encode flag not set) */ 213 #define ZIP_CODEC_ENCODE 1 /* compress/encrypt */ 214 215 216 typedef zip_source_t *(*zip_compression_implementation)(zip_t *, zip_source_t *, zip_int32_t, int); 217 typedef zip_source_t *(*zip_encryption_implementation)(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); 218 219 zip_compression_implementation _zip_get_compression_implementation(zip_int32_t); 220 zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t); 221 222 223 224 /* This API is not final yet, but we need it internally, so it's private for now. */ 225 226 const zip_uint8_t *zip_get_extra_field_by_id(zip_t *, int, int, zip_uint16_t, int, zip_uint16_t *); 227 228 /* This section contains API that is of limited use until support for 229 user-supplied compression/encryption implementation is finished. 230 Thus we will keep it private for now. */ 231 232 typedef zip_int64_t (*zip_source_layered_callback)(zip_source_t *, void *, void *, zip_uint64_t, enum zip_source_cmd); 233 zip_source_t *zip_source_crc(zip_t *, zip_source_t *, int); 234 zip_source_t *zip_source_deflate(zip_t *, zip_source_t *, zip_int32_t, int); 235 zip_source_t *zip_source_layered(zip_t *, zip_source_t *, zip_source_layered_callback, void *); 236 zip_source_t *zip_source_layered_create(zip_source_t *src, zip_source_layered_callback cb, void *ud, zip_error_t *error); 237 zip_source_t *zip_source_pkware(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); 238 int zip_source_remove(zip_source_t *); 239 zip_int64_t zip_source_supports(zip_source_t *src); 240 zip_source_t *zip_source_window(zip_t *, zip_source_t *, zip_uint64_t, zip_uint64_t); 241 242 243 /* error source for layered sources */ 244 245 enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL }; 246 247 /* directory entry: general purpose bit flags */ 248 249 #define ZIP_GPBF_ENCRYPTED 0x0001 /* is encrypted */ 250 #define ZIP_GPBF_DATA_DESCRIPTOR 0x0008 /* crc/size after file data */ 251 #define ZIP_GPBF_STRONG_ENCRYPTION 0x0040 /* uses strong encryption */ 252 #define ZIP_GPBF_ENCODING_UTF_8 0x0800 /* file name encoding is UTF-8 */ 253 254 255 /* extra fields */ 256 #define ZIP_EF_LOCAL ZIP_FL_LOCAL /* include in local header */ 257 #define ZIP_EF_CENTRAL ZIP_FL_CENTRAL /* include in central directory */ 258 #define ZIP_EF_BOTH (ZIP_EF_LOCAL|ZIP_EF_CENTRAL) /* include in both */ 259 260 #define ZIP_FL_FORCE_ZIP64 1024 /* force zip64 extra field (_zip_dirent_write) */ 261 262 #define ZIP_FL_ENCODING_ALL (ZIP_FL_ENC_GUESS|ZIP_FL_ENC_CP437|ZIP_FL_ENC_UTF_8) 263 264 265 /* encoding type */ 266 enum zip_encoding_type { 267 ZIP_ENCODING_UNKNOWN, /* not yet analyzed */ 268 ZIP_ENCODING_ASCII, /* plain ASCII */ 269 ZIP_ENCODING_UTF8_KNOWN, /* is UTF-8 */ 270 ZIP_ENCODING_UTF8_GUESSED, /* possibly UTF-8 */ 271 ZIP_ENCODING_CP437, /* Code Page 437 */ 272 ZIP_ENCODING_ERROR /* should be UTF-8 but isn't */ 273 }; 274 275 typedef enum zip_encoding_type zip_encoding_type_t; 276 277 #ifndef ZIP_HASH_TABLE_SIZE 278 #define ZIP_HASH_TABLE_SIZE 8192 279 #endif 280 281 struct zip_hash; 282 283 typedef struct zip_cdir zip_cdir_t; 284 typedef struct zip_dirent zip_dirent_t; 285 typedef struct zip_entry zip_entry_t; 286 typedef struct zip_extra_field zip_extra_field_t; 287 typedef struct zip_string zip_string_t; 288 typedef struct zip_buffer zip_buffer_t; 289 typedef struct zip_hash zip_hash_t; 290 291 /* zip archive, part of API */ 292 293 struct zip { 294 zip_source_t *src; /* data source for archive */ 295 unsigned int open_flags; /* flags passed to zip_open */ 296 zip_error_t error; /* error information */ 297 298 unsigned int flags; /* archive global flags */ 299 unsigned int ch_flags; /* changed archive global flags */ 300 301 char *default_password; /* password used when no other supplied */ 302 303 zip_string_t *comment_orig; /* archive comment */ 304 zip_string_t *comment_changes; /* changed archive comment */ 305 bool comment_changed; /* whether archive comment was changed */ 306 307 zip_uint64_t nentry; /* number of entries */ 308 zip_uint64_t nentry_alloc; /* number of entries allocated */ 309 zip_entry_t *entry; /* entries */ 310 311 unsigned int nopen_source; /* number of open sources using archive */ 312 unsigned int nopen_source_alloc; /* number of sources allocated */ 313 zip_source_t **open_source; /* open sources using archive */ 314 315 zip_hash_t *names; /* hash table for name lookup */ 316 317 char *tempdir; /* custom temp dir (needed e.g. for OS X sandboxing) */ 318 }; 319 320 /* file in zip archive, part of API */ 321 322 struct zip_file { 323 zip_t *za; /* zip archive containing this file */ 324 zip_error_t error; /* error information */ 325 bool eof; 326 zip_source_t *src; /* data source */ 327 }; 328 329 /* zip archive directory entry (central or local) */ 330 331 #define ZIP_DIRENT_COMP_METHOD 0x0001u 332 #define ZIP_DIRENT_FILENAME 0x0002u 333 #define ZIP_DIRENT_COMMENT 0x0004u 334 #define ZIP_DIRENT_EXTRA_FIELD 0x0008u 335 #define ZIP_DIRENT_ATTRIBUTES 0x0010u 336 #define ZIP_DIRENT_LAST_MOD 0x0020u 337 #define ZIP_DIRENT_ALL 0xffffu 338 339 struct zip_dirent { 340 zip_uint32_t changed; 341 bool local_extra_fields_read; /* whether we already read in local header extra fields */ 342 bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */ 343 344 zip_uint16_t version_madeby; /* (c) version of creator */ 345 zip_uint16_t version_needed; /* (cl) version needed to extract */ 346 zip_uint16_t bitflags; /* (cl) general purpose bit flag */ 347 zip_int32_t comp_method; /* (cl) compression method used (uint16 and ZIP_CM_DEFAULT (-1)) */ 348 time_t last_mod; /* (cl) time of last modification */ 349 zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */ 350 zip_uint64_t comp_size; /* (cl) size of compressed data */ 351 zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */ 352 zip_string_t *filename; /* (cl) file name (NUL-terminated) */ 353 zip_extra_field_t *extra_fields; /* (cl) extra fields, parsed */ 354 zip_string_t *comment; /* (c) file comment */ 355 zip_uint32_t disk_number; /* (c) disk number start */ 356 zip_uint16_t int_attrib; /* (c) internal file attributes */ 357 zip_uint32_t ext_attrib; /* (c) external file attributes */ 358 zip_uint64_t offset; /* (c) offset of local header */ 359 }; 360 361 /* zip archive central directory */ 362 363 struct zip_cdir { 364 zip_entry_t *entry; /* directory entries */ 365 zip_uint64_t nentry; /* number of entries */ 366 zip_uint64_t nentry_alloc; /* number of entries allocated */ 367 368 zip_uint64_t size; /* size of central directory */ 369 zip_uint64_t offset; /* offset of central directory in file */ 370 zip_string_t *comment; /* zip archive comment */ 371 }; 372 373 struct zip_extra_field { 374 zip_extra_field_t *next; 375 zip_flags_t flags; /* in local/central header */ 376 zip_uint16_t id; /* header id */ 377 zip_uint16_t size; /* data size */ 378 zip_uint8_t *data; 379 }; 380 381 enum zip_source_write_state { 382 ZIP_SOURCE_WRITE_CLOSED, /* write is not in progress */ 383 ZIP_SOURCE_WRITE_OPEN, /* write is in progress */ 384 ZIP_SOURCE_WRITE_FAILED, /* commit failed, only rollback allowed */ 385 ZIP_SOURCE_WRITE_REMOVED /* file was removed */ 386 }; 387 typedef enum zip_source_write_state zip_source_write_state_t; 388 389 struct zip_source { 390 zip_source_t *src; 391 union { 392 zip_source_callback f; 393 zip_source_layered_callback l; 394 } cb; 395 void *ud; 396 zip_error_t error; 397 zip_int64_t supports; /* supported commands */ 398 unsigned int open_count; /* number of times source was opened (directly or as lower layer) */ 399 zip_source_write_state_t write_state; /* whether source is open for writing */ 400 bool source_closed; /* set if source archive is closed */ 401 zip_t *source_archive; /* zip archive we're reading from, NULL if not from archive */ 402 unsigned int refcount; 403 }; 404 405 #define ZIP_SOURCE_IS_OPEN_READING(src) ((src)->open_count > 0) 406 #define ZIP_SOURCE_IS_OPEN_WRITING(src) ((src)->write_state == ZIP_SOURCE_WRITE_OPEN) 407 #define ZIP_SOURCE_IS_LAYERED(src) ((src)->src != NULL) 408 409 /* entry in zip archive directory */ 410 411 struct zip_entry { 412 zip_dirent_t *orig; 413 zip_dirent_t *changes; 414 zip_source_t *source; 415 bool deleted; 416 }; 417 418 419 /* file or archive comment, or filename */ 420 421 struct zip_string { 422 zip_uint8_t *raw; /* raw string */ 423 zip_uint16_t length; /* length of raw string */ 424 enum zip_encoding_type encoding; /* autorecognized encoding */ 425 zip_uint8_t *converted; /* autoconverted string */ 426 zip_uint32_t converted_length; /* length of converted */ 427 }; 428 429 430 /* bounds checked access to memory buffer */ 431 432 struct zip_buffer { 433 bool ok; 434 bool free_data; 435 436 zip_uint8_t *data; 437 zip_uint64_t size; 438 zip_uint64_t offset; 439 }; 440 441 /* which files to write in which order */ 442 443 struct zip_filelist { 444 zip_uint64_t idx; 445 /* TODO const char *name; */ 446 }; 447 448 typedef struct zip_filelist zip_filelist_t; 449 450 451 extern const char * const _zip_err_str[]; 452 extern const int _zip_nerr_str; 453 extern const int _zip_err_type[]; 454 455 456 #define ZIP_ENTRY_CHANGED(e, f) ((e)->changes && ((e)->changes->changed & (f))) 457 458 #define ZIP_ENTRY_DATA_CHANGED(x) ((x)->source != NULL) 459 460 #define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY) 461 462 463 zip_int64_t _zip_add_entry(zip_t *); 464 465 zip_uint8_t *_zip_buffer_data(zip_buffer_t *buffer); 466 bool _zip_buffer_eof(zip_buffer_t *buffer); 467 void _zip_buffer_free(zip_buffer_t *buffer); 468 zip_uint8_t *_zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length); 469 zip_uint16_t _zip_buffer_get_16(zip_buffer_t *buffer); 470 zip_uint32_t _zip_buffer_get_32(zip_buffer_t *buffer); 471 zip_uint64_t _zip_buffer_get_64(zip_buffer_t *buffer); 472 zip_uint8_t _zip_buffer_get_8(zip_buffer_t *buffer); 473 zip_uint64_t _zip_buffer_left(zip_buffer_t *buffer); 474 zip_buffer_t *_zip_buffer_new(zip_uint8_t *data, zip_uint64_t size); 475 zip_buffer_t *_zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error); 476 zip_uint64_t _zip_buffer_offset(zip_buffer_t *buffer); 477 bool _zip_buffer_ok(zip_buffer_t *buffer); 478 int _zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length); 479 int _zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i); 480 int _zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i); 481 int _zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i); 482 int _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i); 483 int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length); 484 int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset); 485 zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer); 486 487 int _zip_cdir_compute_crc(zip_t *, uLong *); 488 void _zip_cdir_free(zip_cdir_t *); 489 zip_cdir_t *_zip_cdir_new(zip_uint64_t, zip_error_t *); 490 zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors); 491 void _zip_deregister_source(zip_t *za, zip_source_t *src); 492 493 zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *); 494 void _zip_dirent_free(zip_dirent_t *); 495 void _zip_dirent_finalize(zip_dirent_t *); 496 void _zip_dirent_init(zip_dirent_t *); 497 bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t); 498 zip_dirent_t *_zip_dirent_new(void); 499 zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error); 500 zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t, zip_error_t *); 501 int _zip_dirent_write(zip_t *za, zip_dirent_t *dirent, zip_flags_t flags); 502 503 zip_extra_field_t *_zip_ef_clone(const zip_extra_field_t *, zip_error_t *); 504 zip_extra_field_t *_zip_ef_delete_by_id(zip_extra_field_t *, zip_uint16_t, zip_uint16_t, zip_flags_t); 505 void _zip_ef_free(zip_extra_field_t *); 506 const zip_uint8_t *_zip_ef_get_by_id(const zip_extra_field_t *, zip_uint16_t *, zip_uint16_t, zip_uint16_t, zip_flags_t, zip_error_t *); 507 zip_extra_field_t *_zip_ef_merge(zip_extra_field_t *, zip_extra_field_t *); 508 zip_extra_field_t *_zip_ef_new(zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_flags_t); 509 bool _zip_ef_parse(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_extra_field_t **, zip_error_t *); 510 zip_extra_field_t *_zip_ef_remove_internal(zip_extra_field_t *); 511 zip_uint16_t _zip_ef_size(const zip_extra_field_t *, zip_flags_t); 512 int _zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags); 513 514 void _zip_entry_finalize(zip_entry_t *); 515 void _zip_entry_init(zip_entry_t *); 516 517 void _zip_error_clear(zip_error_t *); 518 void _zip_error_get(const zip_error_t *, int *, int *); 519 520 void _zip_error_copy(zip_error_t *dst, const zip_error_t *src); 521 void _zip_error_set_from_source(zip_error_t *, zip_source_t *); 522 523 const zip_uint8_t *_zip_extract_extra_field_by_id(zip_error_t *, zip_uint16_t, int, const zip_uint8_t *, zip_uint16_t, zip_uint16_t *); 524 525 int _zip_file_extra_field_prepare_for_change(zip_t *, zip_uint64_t); 526 int _zip_file_fillbuf(void *, size_t, zip_file_t *); 527 zip_uint64_t _zip_file_get_offset(const zip_t *, zip_uint64_t, zip_error_t *); 528 529 int _zip_filerange_crc(zip_source_t *src, zip_uint64_t offset, zip_uint64_t length, uLong *crcp, zip_error_t *error); 530 531 zip_dirent_t *_zip_get_dirent(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *); 532 533 enum zip_encoding_type _zip_guess_encoding(zip_string_t *, enum zip_encoding_type); 534 zip_uint8_t *_zip_cp437_to_utf8(const zip_uint8_t * const, zip_uint32_t, zip_uint32_t *, zip_error_t *); 535 536 bool _zip_hash_add(zip_hash_t *hash, const zip_uint8_t *name, zip_uint64_t index, zip_flags_t flags, zip_error_t *error); 537 bool _zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *key, zip_error_t *error); 538 void _zip_hash_free(zip_hash_t *hash); 539 zip_int64_t _zip_hash_lookup(zip_hash_t *hash, const zip_uint8_t *name, zip_flags_t flags, zip_error_t *error); 540 zip_hash_t *_zip_hash_new(zip_uint16_t hash_size, zip_error_t *error); 541 void _zip_hash_revert(zip_hash_t *hash); 542 543 zip_t *_zip_open(zip_source_t *, unsigned int, zip_error_t *); 544 545 int _zip_read(zip_source_t *src, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error); 546 int _zip_read_at_offset(zip_source_t *src, zip_uint64_t offset, unsigned char *b, size_t length, zip_error_t *error); 547 zip_uint8_t *_zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error); 548 int _zip_read_local_ef(zip_t *, zip_uint64_t); 549 zip_string_t *_zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t lenght, bool nulp, zip_error_t *error); 550 int _zip_register_source(zip_t *za, zip_source_t *src); 551 552 void _zip_set_open_error(int *zep, const zip_error_t *err, int ze); 553 554 zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command); 555 zip_source_t *_zip_source_file_or_p(const char *, FILE *, zip_uint64_t, zip_int64_t, const zip_stat_t *, zip_error_t *error); 556 void _zip_source_invalidate(zip_source_t *src); 557 zip_source_t *_zip_source_new(zip_error_t *error); 558 int _zip_source_set_source_archive(zip_source_t *, zip_t *); 559 zip_source_t *_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_uint64_t length, zip_stat_t *st, zip_error_t *error); 560 zip_source_t *_zip_source_zip_new(zip_t *, zip_t *, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_uint64_t, const char *); 561 562 int _zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error); 563 int _zip_string_equal(const zip_string_t *, const zip_string_t *); 564 void _zip_string_free(zip_string_t *); 565 zip_uint32_t _zip_string_crc32(const zip_string_t *); 566 const zip_uint8_t *_zip_string_get(zip_string_t *, zip_uint32_t *, zip_flags_t, zip_error_t *); 567 zip_uint16_t _zip_string_length(const zip_string_t *); 568 zip_string_t *_zip_string_new(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_error_t *); 569 int _zip_string_write(zip_t *za, const zip_string_t *string); 570 571 int _zip_changed(const zip_t *, zip_uint64_t *); 572 const char *_zip_get_name(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *); 573 int _zip_local_header_read(zip_t *, int); 574 void *_zip_memdup(const void *, size_t, zip_error_t *); 575 zip_int64_t _zip_name_locate(zip_t *, const char *, zip_flags_t, zip_error_t *); 576 zip_t *_zip_new(zip_error_t *); 577 578 zip_int64_t _zip_file_replace(zip_t *, zip_uint64_t, const char *, zip_source_t *, zip_flags_t); 579 int _zip_set_name(zip_t *, zip_uint64_t, const char *, zip_flags_t); 580 void _zip_u2d_time(time_t, zip_uint16_t *, zip_uint16_t *); 581 int _zip_unchange(zip_t *, zip_uint64_t, int); 582 void _zip_unchange_data(zip_entry_t *); 583 int _zip_write(zip_t *za, const void *data, zip_uint64_t length); 584 585 #endif /* zipint.h */ 586