Rizin
unix-like reverse engineering framework and cli tools
zip.h File Reference
#include <zipconf.h>
#include <stdio.h>
#include <sys/types.h>
#include <time.h>

Go to the source code of this file.

Classes

struct  zip_source_args_seek
 
struct  zip_error
 
struct  zip_stat
 
struct  zip_buffer_fragment
 
struct  zip_file_attributes
 

Macros

#define ZIP_EXTERN
 
#define ZIP_CREATE   1
 
#define ZIP_EXCL   2
 
#define ZIP_CHECKCONS   4
 
#define ZIP_TRUNCATE   8
 
#define ZIP_RDONLY   16
 
#define ZIP_FL_NOCASE   1u /* ignore case on name lookup */
 
#define ZIP_FL_NODIR   2u /* ignore directory component */
 
#define ZIP_FL_COMPRESSED   4u /* read compressed data */
 
#define ZIP_FL_UNCHANGED   8u /* use original data, ignoring changes */
 
#define ZIP_FL_RECOMPRESS   16u /* force recompression of data */
 
#define ZIP_FL_ENCRYPTED   32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */
 
#define ZIP_FL_ENC_GUESS   0u /* guess string encoding (is default) */
 
#define ZIP_FL_ENC_RAW   64u /* get unmodified string */
 
#define ZIP_FL_ENC_STRICT   128u /* follow specification strictly */
 
#define ZIP_FL_LOCAL   256u /* in local header */
 
#define ZIP_FL_CENTRAL   512u /* in central directory */
 
#define ZIP_FL_ENC_UTF_8   2048u /* string is UTF-8 encoded */
 
#define ZIP_FL_ENC_CP437   4096u /* string is CP437 encoded */
 
#define ZIP_FL_OVERWRITE   8192u /* zip_file_add: if file with name exists, overwrite (replace) it */
 
#define ZIP_AFL_RDONLY   2u /* read only -- cannot be cleared */
 
#define ZIP_EXTRA_FIELD_ALL   ZIP_UINT16_MAX
 
#define ZIP_EXTRA_FIELD_NEW   ZIP_UINT16_MAX
 
#define ZIP_ER_OK   0 /* N No error */
 
#define ZIP_ER_MULTIDISK   1 /* N Multi-disk zip archives not supported */
 
#define ZIP_ER_RENAME   2 /* S Renaming temporary file failed */
 
#define ZIP_ER_CLOSE   3 /* S Closing zip archive failed */
 
#define ZIP_ER_SEEK   4 /* S Seek error */
 
#define ZIP_ER_READ   5 /* S Read error */
 
#define ZIP_ER_WRITE   6 /* S Write error */
 
#define ZIP_ER_CRC   7 /* N CRC error */
 
#define ZIP_ER_ZIPCLOSED   8 /* N Containing zip archive was closed */
 
#define ZIP_ER_NOENT   9 /* N No such file */
 
#define ZIP_ER_EXISTS   10 /* N File already exists */
 
#define ZIP_ER_OPEN   11 /* S Can't open file */
 
#define ZIP_ER_TMPOPEN   12 /* S Failure to create temporary file */
 
#define ZIP_ER_ZLIB   13 /* Z Zlib error */
 
#define ZIP_ER_MEMORY   14 /* N Malloc failure */
 
#define ZIP_ER_CHANGED   15 /* N Entry has been changed */
 
#define ZIP_ER_COMPNOTSUPP   16 /* N Compression method not supported */
 
#define ZIP_ER_EOF   17 /* N Premature end of file */
 
#define ZIP_ER_INVAL   18 /* N Invalid argument */
 
#define ZIP_ER_NOZIP   19 /* N Not a zip archive */
 
#define ZIP_ER_INTERNAL   20 /* N Internal error */
 
#define ZIP_ER_INCONS   21 /* L Zip archive inconsistent */
 
#define ZIP_ER_REMOVE   22 /* S Can't remove file */
 
#define ZIP_ER_DELETED   23 /* N Entry has been deleted */
 
#define ZIP_ER_ENCRNOTSUPP   24 /* N Encryption method not supported */
 
#define ZIP_ER_RDONLY   25 /* N Read-only archive */
 
#define ZIP_ER_NOPASSWD   26 /* N No password provided */
 
#define ZIP_ER_WRONGPASSWD   27 /* N Wrong password provided */
 
#define ZIP_ER_OPNOTSUPP   28 /* N Operation not supported */
 
#define ZIP_ER_INUSE   29 /* N Resource still in use */
 
#define ZIP_ER_TELL   30 /* S Tell error */
 
#define ZIP_ER_COMPRESSED_DATA   31 /* N Compressed data invalid */
 
#define ZIP_ER_CANCELLED   32 /* N Operation cancelled */
 
#define ZIP_ET_NONE   0 /* sys_err unused */
 
#define ZIP_ET_SYS   1 /* sys_err is errno */
 
#define ZIP_ET_ZLIB   2 /* sys_err is zlib error code */
 
#define ZIP_ET_LIBZIP   3 /* sys_err is libzip error code */
 
#define ZIP_CM_DEFAULT   -1 /* better of deflate or store */
 
#define ZIP_CM_STORE   0 /* stored (uncompressed) */
 
#define ZIP_CM_SHRINK   1 /* shrunk */
 
#define ZIP_CM_REDUCE_1   2 /* reduced with factor 1 */
 
#define ZIP_CM_REDUCE_2   3 /* reduced with factor 2 */
 
#define ZIP_CM_REDUCE_3   4 /* reduced with factor 3 */
 
#define ZIP_CM_REDUCE_4   5 /* reduced with factor 4 */
 
#define ZIP_CM_IMPLODE   6 /* imploded */
 
#define ZIP_CM_DEFLATE   8 /* deflated */
 
#define ZIP_CM_DEFLATE64   9 /* deflate64 */
 
#define ZIP_CM_PKWARE_IMPLODE   10 /* PKWARE imploding */
 
#define ZIP_CM_BZIP2   12 /* compressed using BZIP2 algorithm */
 
#define ZIP_CM_LZMA   14 /* LZMA (EFS) */
 
#define ZIP_CM_TERSE   18 /* compressed using IBM TERSE (new) */
 
#define ZIP_CM_LZ77   19 /* IBM LZ77 z Architecture (PFS) */
 
#define ZIP_CM_LZMA2   33
 
#define ZIP_CM_ZSTD   93 /* Zstandard compressed data */
 
#define ZIP_CM_XZ   95 /* XZ compressed data */
 
#define ZIP_CM_JPEG   96 /* Compressed Jpeg data */
 
#define ZIP_CM_WAVPACK   97 /* WavPack compressed data */
 
#define ZIP_CM_PPMD   98 /* PPMd version I, Rev 1 */
 
#define ZIP_EM_NONE   0 /* not encrypted */
 
#define ZIP_EM_TRAD_PKWARE   1 /* traditional PKWARE encryption */
 
#define ZIP_EM_AES_128   0x0101 /* Winzip AES encryption */
 
#define ZIP_EM_AES_192   0x0102
 
#define ZIP_EM_AES_256   0x0103
 
#define ZIP_EM_UNKNOWN   0xffff /* unknown algorithm */
 
#define ZIP_OPSYS_DOS   0x00u
 
#define ZIP_OPSYS_AMIGA   0x01u
 
#define ZIP_OPSYS_OPENVMS   0x02u
 
#define ZIP_OPSYS_UNIX   0x03u
 
#define ZIP_OPSYS_VM_CMS   0x04u
 
#define ZIP_OPSYS_ATARI_ST   0x05u
 
#define ZIP_OPSYS_OS_2   0x06u
 
#define ZIP_OPSYS_MACINTOSH   0x07u
 
#define ZIP_OPSYS_Z_SYSTEM   0x08u
 
#define ZIP_OPSYS_CPM   0x09u
 
#define ZIP_OPSYS_WINDOWS_NTFS   0x0au
 
#define ZIP_OPSYS_MVS   0x0bu
 
#define ZIP_OPSYS_VSE   0x0cu
 
#define ZIP_OPSYS_ACORN_RISC   0x0du
 
#define ZIP_OPSYS_VFAT   0x0eu
 
#define ZIP_OPSYS_ALTERNATE_MVS   0x0fu
 
#define ZIP_OPSYS_BEOS   0x10u
 
#define ZIP_OPSYS_TANDEM   0x11u
 
#define ZIP_OPSYS_OS_400   0x12u
 
#define ZIP_OPSYS_OS_X   0x13u
 
#define ZIP_OPSYS_DEFAULT   ZIP_OPSYS_UNIX
 
#define ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd)   (((zip_int64_t)1) << (cmd))
 
#define ZIP_SOURCE_CHECK_SUPPORTED(supported, cmd)   (((supported) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd)) != 0)
 
#define ZIP_SOURCE_SUPPORTS_READABLE
 
#define ZIP_SOURCE_SUPPORTS_SEEKABLE
 
#define ZIP_SOURCE_SUPPORTS_WRITABLE
 
#define ZIP_SOURCE_GET_ARGS(type, data, len, error)   ((len) < sizeof(type) ? zip_error_set((error), ZIP_ER_INVAL, 0), (type *)NULL : (type *)(data))
 
#define ZIP_STAT_NAME   0x0001u
 
#define ZIP_STAT_INDEX   0x0002u
 
#define ZIP_STAT_SIZE   0x0004u
 
#define ZIP_STAT_COMP_SIZE   0x0008u
 
#define ZIP_STAT_MTIME   0x0010u
 
#define ZIP_STAT_CRC   0x0020u
 
#define ZIP_STAT_COMP_METHOD   0x0040u
 
#define ZIP_STAT_ENCRYPTION_METHOD   0x0080u
 
#define ZIP_STAT_FLAGS   0x0100u
 
#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM   0x0001u
 
#define ZIP_FILE_ATTRIBUTES_ASCII   0x0002u
 
#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED   0x0004u
 
#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES   0x0008u
 
#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS   0x0010u
 

Typedefs

typedef enum zip_source_cmd zip_source_cmd_t
 
typedef struct zip_source_args_seek zip_source_args_seek_t
 
typedef struct zip zip_t
 
typedef struct zip_error zip_error_t
 
typedef struct zip_file zip_file_t
 
typedef struct zip_file_attributes zip_file_attributes_t
 
typedef struct zip_source zip_source_t
 
typedef struct zip_stat zip_stat_t
 
typedef struct zip_buffer_fragment zip_buffer_fragment_t
 
typedef zip_uint32_t zip_flags_t
 
typedef zip_int64_t(* zip_source_callback) (void *_Nullable, void *_Nullable, zip_uint64_t, zip_source_cmd_t)
 
typedef void(* zip_progress_callback) (zip_t *_Nonnull, double, void *_Nullable)
 
typedef int(* zip_cancel_callback) (zip_t *_Nonnull, void *_Nullable)
 
typedef void(* zip_progress_callback_t) (double)
 

Enumerations

enum  zip_source_cmd {
  ZIP_SOURCE_OPEN , ZIP_SOURCE_READ , ZIP_SOURCE_CLOSE , ZIP_SOURCE_STAT ,
  ZIP_SOURCE_ERROR , ZIP_SOURCE_FREE , ZIP_SOURCE_SEEK , ZIP_SOURCE_TELL ,
  ZIP_SOURCE_BEGIN_WRITE , ZIP_SOURCE_COMMIT_WRITE , ZIP_SOURCE_ROLLBACK_WRITE , ZIP_SOURCE_WRITE ,
  ZIP_SOURCE_SEEK_WRITE , ZIP_SOURCE_TELL_WRITE , ZIP_SOURCE_SUPPORTS , ZIP_SOURCE_REMOVE ,
  ZIP_SOURCE_RESERVED_1 , ZIP_SOURCE_BEGIN_WRITE_CLONING , ZIP_SOURCE_ACCEPT_EMPTY , ZIP_SOURCE_GET_FILE_ATTRIBUTES
}
 

Functions

ZIP_EXTERN void zip_register_progress_callback (zip_t *_Nonnull, zip_progress_callback_t _Nullable)
 
ZIP_EXTERN zip_int64_t zip_add (zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_int64_t zip_add_dir (zip_t *_Nonnull, const char *_Nonnull)
 
ZIP_EXTERN const char *_Nullable zip_get_file_comment (zip_t *_Nonnull, zip_uint64_t, int *_Nullable, int)
 
ZIP_EXTERN int zip_get_num_files (zip_t *_Nonnull)
 
ZIP_EXTERN int zip_rename (zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull)
 
ZIP_EXTERN int zip_replace (zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull)
 
ZIP_EXTERN int zip_set_file_comment (zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, int)
 
ZIP_EXTERN int zip_error_get_sys_type (int)
 
ZIP_EXTERN void zip_error_get (zip_t *_Nonnull, int *_Nullable, int *_Nullable)
 
ZIP_EXTERN int zip_error_to_str (char *_Nonnull, zip_uint64_t, int, int)
 
ZIP_EXTERN void zip_file_error_get (zip_file_t *_Nonnull, int *_Nullable, int *_Nullable)
 
ZIP_EXTERN int zip_close (zip_t *_Nonnull)
 
ZIP_EXTERN int zip_delete (zip_t *_Nonnull, zip_uint64_t)
 
ZIP_EXTERN zip_int64_t zip_dir_add (zip_t *_Nonnull, const char *_Nonnull, zip_flags_t)
 
ZIP_EXTERN void zip_discard (zip_t *_Nonnull)
 
ZIP_EXTERN zip_error_t *_Nonnull zip_get_error (zip_t *_Nonnull)
 
ZIP_EXTERN void zip_error_clear (zip_t *_Nonnull)
 
ZIP_EXTERN int zip_error_code_zip (const zip_error_t *_Nonnull)
 
ZIP_EXTERN int zip_error_code_system (const zip_error_t *_Nonnull)
 
ZIP_EXTERN void zip_error_fini (zip_error_t *_Nonnull)
 
ZIP_EXTERN void zip_error_init (zip_error_t *_Nonnull)
 
ZIP_EXTERN void zip_error_init_with_code (zip_error_t *_Nonnull, int)
 
ZIP_EXTERN void zip_error_set (zip_error_t *_Nullable, int, int)
 
ZIP_EXTERN const char *_Nonnull zip_error_strerror (zip_error_t *_Nonnull)
 
ZIP_EXTERN int zip_error_system_type (const zip_error_t *_Nonnull)
 
ZIP_EXTERN zip_int64_t zip_error_to_data (const zip_error_t *_Nonnull, void *_Nonnull, zip_uint64_t)
 
ZIP_EXTERN int zip_fclose (zip_file_t *_Nonnull)
 
ZIP_EXTERN zip_t *_Nullable zip_fdopen (int, int, int *_Nullable)
 
ZIP_EXTERN zip_int64_t zip_file_add (zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull, zip_flags_t)
 
ZIP_EXTERN void zip_file_attributes_init (zip_file_attributes_t *_Nonnull)
 
ZIP_EXTERN void zip_file_error_clear (zip_file_t *_Nonnull)
 
ZIP_EXTERN int zip_file_extra_field_delete (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t)
 
ZIP_EXTERN int zip_file_extra_field_delete_by_id (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t)
 
ZIP_EXTERN int zip_file_extra_field_set (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *_Nullable, zip_uint16_t, zip_flags_t)
 
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count (zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
 
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t)
 
ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_uint16_t *_Nullable, zip_flags_t)
 
ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get_by_id (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_flags_t)
 
ZIP_EXTERN const char *_Nullable zip_file_get_comment (zip_t *_Nonnull, zip_uint64_t, zip_uint32_t *_Nullable, zip_flags_t)
 
ZIP_EXTERN zip_error_t *_Nonnull zip_file_get_error (zip_file_t *_Nonnull)
 
ZIP_EXTERN int zip_file_get_external_attributes (zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t *_Nullable, zip_uint32_t *_Nullable)
 
ZIP_EXTERN int zip_file_is_seekable (zip_file_t *_Nonnull)
 
ZIP_EXTERN int zip_file_rename (zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull, zip_flags_t)
 
ZIP_EXTERN int zip_file_replace (zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull, zip_flags_t)
 
ZIP_EXTERN int zip_file_set_comment (zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, zip_uint16_t, zip_flags_t)
 
ZIP_EXTERN int zip_file_set_dostime (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t)
 
ZIP_EXTERN int zip_file_set_encryption (zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, const char *_Nullable)
 
ZIP_EXTERN int zip_file_set_external_attributes (zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t)
 
ZIP_EXTERN int zip_file_set_mtime (zip_t *_Nonnull, zip_uint64_t, time_t, zip_flags_t)
 
ZIP_EXTERN const char *_Nonnull zip_file_strerror (zip_file_t *_Nonnull)
 
ZIP_EXTERN zip_file_t *_Nullable zip_fopen (zip_t *_Nonnull, const char *_Nonnull, zip_flags_t)
 
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_encrypted (zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, const char *_Nullable)
 
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index (zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
 
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index_encrypted (zip_t *_Nonnull, zip_uint64_t, zip_flags_t, const char *_Nullable)
 
ZIP_EXTERN zip_int64_t zip_fread (zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t)
 
ZIP_EXTERN zip_int8_t zip_fseek (zip_file_t *_Nonnull, zip_int64_t, int)
 
ZIP_EXTERN zip_int64_t zip_ftell (zip_file_t *_Nonnull)
 
ZIP_EXTERN const char *_Nullable zip_get_archive_comment (zip_t *_Nonnull, int *_Nullable, zip_flags_t)
 
ZIP_EXTERN int zip_get_archive_flag (zip_t *_Nonnull, zip_flags_t, zip_flags_t)
 
ZIP_EXTERN const char *_Nullable zip_get_name (zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
 
ZIP_EXTERN zip_int64_t zip_get_num_entries (zip_t *_Nonnull, zip_flags_t)
 
ZIP_EXTERN const char *_Nonnull zip_libzip_version (void)
 
ZIP_EXTERN zip_int64_t zip_name_locate (zip_t *_Nonnull, const char *_Nonnull, zip_flags_t)
 
ZIP_EXTERN zip_t *_Nullable zip_open (const char *_Nonnull, int, int *_Nullable)
 
ZIP_EXTERN zip_t *_Nullable zip_open_from_source (zip_source_t *_Nonnull, int, zip_error_t *_Nullable)
 
ZIP_EXTERN int zip_register_progress_callback_with_state (zip_t *_Nonnull, double, zip_progress_callback _Nullable, void(*_Nullable)(void *_Nullable), void *_Nullable)
 
ZIP_EXTERN int zip_register_cancel_callback_with_state (zip_t *_Nonnull, zip_cancel_callback _Nullable, void(*_Nullable)(void *_Nullable), void *_Nullable)
 
ZIP_EXTERN int zip_set_archive_comment (zip_t *_Nonnull, const char *_Nullable, zip_uint16_t)
 
ZIP_EXTERN int zip_set_archive_flag (zip_t *_Nonnull, zip_flags_t, int)
 
ZIP_EXTERN int zip_set_default_password (zip_t *_Nonnull, const char *_Nullable)
 
ZIP_EXTERN int zip_set_file_compression (zip_t *_Nonnull, zip_uint64_t, zip_int32_t, zip_uint32_t)
 
ZIP_EXTERN int zip_source_begin_write (zip_source_t *_Nonnull)
 
ZIP_EXTERN int zip_source_begin_write_cloning (zip_source_t *_Nonnull, zip_uint64_t)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer (zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_create (const void *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment (zip_t *_Nonnull, const zip_buffer_fragment_t *_Nonnull, zip_uint64_t, int)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment_create (const zip_buffer_fragment_t *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable)
 
ZIP_EXTERN int zip_source_close (zip_source_t *_Nonnull)
 
ZIP_EXTERN int zip_source_commit_write (zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_error_t *_Nonnull zip_source_error (zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_file (zip_t *_Nonnull, const char *_Nonnull, zip_uint64_t, zip_int64_t)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_file_create (const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_filep (zip_t *_Nonnull, FILE *_Nonnull, zip_uint64_t, zip_int64_t)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_filep_create (FILE *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable)
 
ZIP_EXTERN void zip_source_free (zip_source_t *_Nullable)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_function (zip_t *_Nonnull, zip_source_callback _Nonnull, void *_Nullable)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_function_create (zip_source_callback _Nonnull, void *_Nullable, zip_error_t *_Nullable)
 
ZIP_EXTERN int zip_source_get_file_attributes (zip_source_t *_Nonnull, zip_file_attributes_t *_Nonnull)
 
ZIP_EXTERN int zip_source_is_deleted (zip_source_t *_Nonnull)
 
ZIP_EXTERN void zip_source_keep (zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap (zip_source_cmd_t,...)
 
ZIP_EXTERN int zip_source_open (zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_int64_t zip_source_read (zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t)
 
ZIP_EXTERN void zip_source_rollback_write (zip_source_t *_Nonnull)
 
ZIP_EXTERN int zip_source_seek (zip_source_t *_Nonnull, zip_int64_t, int)
 
ZIP_EXTERN zip_int64_t zip_source_seek_compute_offset (zip_uint64_t, zip_uint64_t, void *_Nonnull, zip_uint64_t, zip_error_t *_Nullable)
 
ZIP_EXTERN int zip_source_seek_write (zip_source_t *_Nonnull, zip_int64_t, int)
 
ZIP_EXTERN int zip_source_stat (zip_source_t *_Nonnull, zip_stat_t *_Nonnull)
 
ZIP_EXTERN zip_int64_t zip_source_tell (zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_int64_t zip_source_tell_write (zip_source_t *_Nonnull)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_window_create (zip_source_t *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable)
 
ZIP_EXTERN zip_int64_t zip_source_write (zip_source_t *_Nonnull, const void *_Nullable, zip_uint64_t)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_zip (zip_t *_Nonnull, zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t)
 
ZIP_EXTERN zip_source_t *_Nullable zip_source_zip_create (zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable)
 
ZIP_EXTERN int zip_stat (zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, zip_stat_t *_Nonnull)
 
ZIP_EXTERN int zip_stat_index (zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull)
 
ZIP_EXTERN void zip_stat_init (zip_stat_t *_Nonnull)
 
ZIP_EXTERN const char *_Nonnull zip_strerror (zip_t *_Nonnull)
 
ZIP_EXTERN int zip_unchange (zip_t *_Nonnull, zip_uint64_t)
 
ZIP_EXTERN int zip_unchange_all (zip_t *_Nonnull)
 
ZIP_EXTERN int zip_unchange_archive (zip_t *_Nonnull)
 
ZIP_EXTERN int zip_compression_method_supported (zip_int32_t method, int compress)
 
ZIP_EXTERN int zip_encryption_method_supported (zip_uint16_t method, int encode)
 

Macro Definition Documentation

◆ ZIP_AFL_RDONLY

#define ZIP_AFL_RDONLY   2u /* read only -- cannot be cleared */

Definition at line 94 of file zip.h.

◆ ZIP_CHECKCONS

#define ZIP_CHECKCONS   4

Definition at line 69 of file zip.h.

◆ ZIP_CM_BZIP2

#define ZIP_CM_BZIP2   12 /* compressed using BZIP2 algorithm */

Definition at line 161 of file zip.h.

◆ ZIP_CM_DEFAULT

#define ZIP_CM_DEFAULT   -1 /* better of deflate or store */

Definition at line 148 of file zip.h.

◆ ZIP_CM_DEFLATE

#define ZIP_CM_DEFLATE   8 /* deflated */

Definition at line 157 of file zip.h.

◆ ZIP_CM_DEFLATE64

#define ZIP_CM_DEFLATE64   9 /* deflate64 */

Definition at line 158 of file zip.h.

◆ ZIP_CM_IMPLODE

#define ZIP_CM_IMPLODE   6 /* imploded */

Definition at line 155 of file zip.h.

◆ ZIP_CM_JPEG

#define ZIP_CM_JPEG   96 /* Compressed Jpeg data */

Definition at line 171 of file zip.h.

◆ ZIP_CM_LZ77

#define ZIP_CM_LZ77   19 /* IBM LZ77 z Architecture (PFS) */

Definition at line 166 of file zip.h.

◆ ZIP_CM_LZMA

#define ZIP_CM_LZMA   14 /* LZMA (EFS) */

Definition at line 163 of file zip.h.

◆ ZIP_CM_LZMA2

#define ZIP_CM_LZMA2   33

Definition at line 168 of file zip.h.

◆ ZIP_CM_PKWARE_IMPLODE

#define ZIP_CM_PKWARE_IMPLODE   10 /* PKWARE imploding */

Definition at line 159 of file zip.h.

◆ ZIP_CM_PPMD

#define ZIP_CM_PPMD   98 /* PPMd version I, Rev 1 */

Definition at line 173 of file zip.h.

◆ ZIP_CM_REDUCE_1

#define ZIP_CM_REDUCE_1   2 /* reduced with factor 1 */

Definition at line 151 of file zip.h.

◆ ZIP_CM_REDUCE_2

#define ZIP_CM_REDUCE_2   3 /* reduced with factor 2 */

Definition at line 152 of file zip.h.

◆ ZIP_CM_REDUCE_3

#define ZIP_CM_REDUCE_3   4 /* reduced with factor 3 */

Definition at line 153 of file zip.h.

◆ ZIP_CM_REDUCE_4

#define ZIP_CM_REDUCE_4   5 /* reduced with factor 4 */

Definition at line 154 of file zip.h.

◆ ZIP_CM_SHRINK

#define ZIP_CM_SHRINK   1 /* shrunk */

Definition at line 150 of file zip.h.

◆ ZIP_CM_STORE

#define ZIP_CM_STORE   0 /* stored (uncompressed) */

Definition at line 149 of file zip.h.

◆ ZIP_CM_TERSE

#define ZIP_CM_TERSE   18 /* compressed using IBM TERSE (new) */

Definition at line 165 of file zip.h.

◆ ZIP_CM_WAVPACK

#define ZIP_CM_WAVPACK   97 /* WavPack compressed data */

Definition at line 172 of file zip.h.

◆ ZIP_CM_XZ

#define ZIP_CM_XZ   95 /* XZ compressed data */

Definition at line 170 of file zip.h.

◆ ZIP_CM_ZSTD

#define ZIP_CM_ZSTD   93 /* Zstandard compressed data */

Definition at line 169 of file zip.h.

◆ ZIP_CREATE

#define ZIP_CREATE   1

Definition at line 67 of file zip.h.

◆ ZIP_EM_AES_128

#define ZIP_EM_AES_128   0x0101 /* Winzip AES encryption */

Definition at line 190 of file zip.h.

◆ ZIP_EM_AES_192

#define ZIP_EM_AES_192   0x0102

Definition at line 191 of file zip.h.

◆ ZIP_EM_AES_256

#define ZIP_EM_AES_256   0x0103

Definition at line 192 of file zip.h.

◆ ZIP_EM_NONE

#define ZIP_EM_NONE   0 /* not encrypted */

Definition at line 177 of file zip.h.

◆ ZIP_EM_TRAD_PKWARE

#define ZIP_EM_TRAD_PKWARE   1 /* traditional PKWARE encryption */

Definition at line 178 of file zip.h.

◆ ZIP_EM_UNKNOWN

#define ZIP_EM_UNKNOWN   0xffff /* unknown algorithm */

Definition at line 193 of file zip.h.

◆ ZIP_ER_CANCELLED

#define ZIP_ER_CANCELLED   32 /* N Operation cancelled */

Definition at line 137 of file zip.h.

◆ ZIP_ER_CHANGED

#define ZIP_ER_CHANGED   15 /* N Entry has been changed */

Definition at line 120 of file zip.h.

◆ ZIP_ER_CLOSE

#define ZIP_ER_CLOSE   3 /* S Closing zip archive failed */

Definition at line 108 of file zip.h.

◆ ZIP_ER_COMPNOTSUPP

#define ZIP_ER_COMPNOTSUPP   16 /* N Compression method not supported */

Definition at line 121 of file zip.h.

◆ ZIP_ER_COMPRESSED_DATA

#define ZIP_ER_COMPRESSED_DATA   31 /* N Compressed data invalid */

Definition at line 136 of file zip.h.

◆ ZIP_ER_CRC

#define ZIP_ER_CRC   7 /* N CRC error */

Definition at line 112 of file zip.h.

◆ ZIP_ER_DELETED

#define ZIP_ER_DELETED   23 /* N Entry has been deleted */

Definition at line 128 of file zip.h.

◆ ZIP_ER_ENCRNOTSUPP

#define ZIP_ER_ENCRNOTSUPP   24 /* N Encryption method not supported */

Definition at line 129 of file zip.h.

◆ ZIP_ER_EOF

#define ZIP_ER_EOF   17 /* N Premature end of file */

Definition at line 122 of file zip.h.

◆ ZIP_ER_EXISTS

#define ZIP_ER_EXISTS   10 /* N File already exists */

Definition at line 115 of file zip.h.

◆ ZIP_ER_INCONS

#define ZIP_ER_INCONS   21 /* L Zip archive inconsistent */

Definition at line 126 of file zip.h.

◆ ZIP_ER_INTERNAL

#define ZIP_ER_INTERNAL   20 /* N Internal error */

Definition at line 125 of file zip.h.

◆ ZIP_ER_INUSE

#define ZIP_ER_INUSE   29 /* N Resource still in use */

Definition at line 134 of file zip.h.

◆ ZIP_ER_INVAL

#define ZIP_ER_INVAL   18 /* N Invalid argument */

Definition at line 123 of file zip.h.

◆ ZIP_ER_MEMORY

#define ZIP_ER_MEMORY   14 /* N Malloc failure */

Definition at line 119 of file zip.h.

◆ ZIP_ER_MULTIDISK

#define ZIP_ER_MULTIDISK   1 /* N Multi-disk zip archives not supported */

Definition at line 106 of file zip.h.

◆ ZIP_ER_NOENT

#define ZIP_ER_NOENT   9 /* N No such file */

Definition at line 114 of file zip.h.

◆ ZIP_ER_NOPASSWD

#define ZIP_ER_NOPASSWD   26 /* N No password provided */

Definition at line 131 of file zip.h.

◆ ZIP_ER_NOZIP

#define ZIP_ER_NOZIP   19 /* N Not a zip archive */

Definition at line 124 of file zip.h.

◆ ZIP_ER_OK

#define ZIP_ER_OK   0 /* N No error */

Definition at line 105 of file zip.h.

◆ ZIP_ER_OPEN

#define ZIP_ER_OPEN   11 /* S Can't open file */

Definition at line 116 of file zip.h.

◆ ZIP_ER_OPNOTSUPP

#define ZIP_ER_OPNOTSUPP   28 /* N Operation not supported */

Definition at line 133 of file zip.h.

◆ ZIP_ER_RDONLY

#define ZIP_ER_RDONLY   25 /* N Read-only archive */

Definition at line 130 of file zip.h.

◆ ZIP_ER_READ

#define ZIP_ER_READ   5 /* S Read error */

Definition at line 110 of file zip.h.

◆ ZIP_ER_REMOVE

#define ZIP_ER_REMOVE   22 /* S Can't remove file */

Definition at line 127 of file zip.h.

◆ ZIP_ER_RENAME

#define ZIP_ER_RENAME   2 /* S Renaming temporary file failed */

Definition at line 107 of file zip.h.

◆ ZIP_ER_SEEK

#define ZIP_ER_SEEK   4 /* S Seek error */

Definition at line 109 of file zip.h.

◆ ZIP_ER_TELL

#define ZIP_ER_TELL   30 /* S Tell error */

Definition at line 135 of file zip.h.

◆ ZIP_ER_TMPOPEN

#define ZIP_ER_TMPOPEN   12 /* S Failure to create temporary file */

Definition at line 117 of file zip.h.

◆ ZIP_ER_WRITE

#define ZIP_ER_WRITE   6 /* S Write error */

Definition at line 111 of file zip.h.

◆ ZIP_ER_WRONGPASSWD

#define ZIP_ER_WRONGPASSWD   27 /* N Wrong password provided */

Definition at line 132 of file zip.h.

◆ ZIP_ER_ZIPCLOSED

#define ZIP_ER_ZIPCLOSED   8 /* N Containing zip archive was closed */

Definition at line 113 of file zip.h.

◆ ZIP_ER_ZLIB

#define ZIP_ER_ZLIB   13 /* Z Zlib error */

Definition at line 118 of file zip.h.

◆ ZIP_ET_LIBZIP

#define ZIP_ET_LIBZIP   3 /* sys_err is libzip error code */

Definition at line 144 of file zip.h.

◆ ZIP_ET_NONE

#define ZIP_ET_NONE   0 /* sys_err unused */

Definition at line 141 of file zip.h.

◆ ZIP_ET_SYS

#define ZIP_ET_SYS   1 /* sys_err is errno */

Definition at line 142 of file zip.h.

◆ ZIP_ET_ZLIB

#define ZIP_ET_ZLIB   2 /* sys_err is zlib error code */

Definition at line 143 of file zip.h.

◆ ZIP_EXCL

#define ZIP_EXCL   2

Definition at line 68 of file zip.h.

◆ ZIP_EXTERN

#define ZIP_EXTERN

Definition at line 54 of file zip.h.

◆ ZIP_EXTRA_FIELD_ALL

#define ZIP_EXTRA_FIELD_ALL   ZIP_UINT16_MAX

Definition at line 99 of file zip.h.

◆ ZIP_EXTRA_FIELD_NEW

#define ZIP_EXTRA_FIELD_NEW   ZIP_UINT16_MAX

Definition at line 100 of file zip.h.

◆ ZIP_FILE_ATTRIBUTES_ASCII

#define ZIP_FILE_ATTRIBUTES_ASCII   0x0002u

Definition at line 330 of file zip.h.

◆ ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES

#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES   0x0008u

Definition at line 332 of file zip.h.

◆ ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS

#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS   0x0010u

Definition at line 333 of file zip.h.

◆ ZIP_FILE_ATTRIBUTES_HOST_SYSTEM

#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM   0x0001u

Definition at line 329 of file zip.h.

◆ ZIP_FILE_ATTRIBUTES_VERSION_NEEDED

#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED   0x0004u

Definition at line 331 of file zip.h.

◆ ZIP_FL_CENTRAL

#define ZIP_FL_CENTRAL   512u /* in central directory */

Definition at line 86 of file zip.h.

◆ ZIP_FL_COMPRESSED

#define ZIP_FL_COMPRESSED   4u /* read compressed data */

Definition at line 78 of file zip.h.

◆ ZIP_FL_ENC_CP437

#define ZIP_FL_ENC_CP437   4096u /* string is CP437 encoded */

Definition at line 89 of file zip.h.

◆ ZIP_FL_ENC_GUESS

#define ZIP_FL_ENC_GUESS   0u /* guess string encoding (is default) */

Definition at line 82 of file zip.h.

◆ ZIP_FL_ENC_RAW

#define ZIP_FL_ENC_RAW   64u /* get unmodified string */

Definition at line 83 of file zip.h.

◆ ZIP_FL_ENC_STRICT

#define ZIP_FL_ENC_STRICT   128u /* follow specification strictly */

Definition at line 84 of file zip.h.

◆ ZIP_FL_ENC_UTF_8

#define ZIP_FL_ENC_UTF_8   2048u /* string is UTF-8 encoded */

Definition at line 88 of file zip.h.

◆ ZIP_FL_ENCRYPTED

#define ZIP_FL_ENCRYPTED   32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */

Definition at line 81 of file zip.h.

◆ ZIP_FL_LOCAL

#define ZIP_FL_LOCAL   256u /* in local header */

Definition at line 85 of file zip.h.

◆ ZIP_FL_NOCASE

#define ZIP_FL_NOCASE   1u /* ignore case on name lookup */

Definition at line 76 of file zip.h.

◆ ZIP_FL_NODIR

#define ZIP_FL_NODIR   2u /* ignore directory component */

Definition at line 77 of file zip.h.

◆ ZIP_FL_OVERWRITE

#define ZIP_FL_OVERWRITE   8192u /* zip_file_add: if file with name exists, overwrite (replace) it */

Definition at line 90 of file zip.h.

◆ ZIP_FL_RECOMPRESS

#define ZIP_FL_RECOMPRESS   16u /* force recompression of data */

Definition at line 80 of file zip.h.

◆ ZIP_FL_UNCHANGED

#define ZIP_FL_UNCHANGED   8u /* use original data, ignoring changes */

Definition at line 79 of file zip.h.

◆ ZIP_OPSYS_ACORN_RISC

#define ZIP_OPSYS_ACORN_RISC   0x0du

Definition at line 208 of file zip.h.

◆ ZIP_OPSYS_ALTERNATE_MVS

#define ZIP_OPSYS_ALTERNATE_MVS   0x0fu

Definition at line 210 of file zip.h.

◆ ZIP_OPSYS_AMIGA

#define ZIP_OPSYS_AMIGA   0x01u

Definition at line 196 of file zip.h.

◆ ZIP_OPSYS_ATARI_ST

#define ZIP_OPSYS_ATARI_ST   0x05u

Definition at line 200 of file zip.h.

◆ ZIP_OPSYS_BEOS

#define ZIP_OPSYS_BEOS   0x10u

Definition at line 211 of file zip.h.

◆ ZIP_OPSYS_CPM

#define ZIP_OPSYS_CPM   0x09u

Definition at line 204 of file zip.h.

◆ ZIP_OPSYS_DEFAULT

#define ZIP_OPSYS_DEFAULT   ZIP_OPSYS_UNIX

Definition at line 216 of file zip.h.

◆ ZIP_OPSYS_DOS

#define ZIP_OPSYS_DOS   0x00u

Definition at line 195 of file zip.h.

◆ ZIP_OPSYS_MACINTOSH

#define ZIP_OPSYS_MACINTOSH   0x07u

Definition at line 202 of file zip.h.

◆ ZIP_OPSYS_MVS

#define ZIP_OPSYS_MVS   0x0bu

Definition at line 206 of file zip.h.

◆ ZIP_OPSYS_OPENVMS

#define ZIP_OPSYS_OPENVMS   0x02u

Definition at line 197 of file zip.h.

◆ ZIP_OPSYS_OS_2

#define ZIP_OPSYS_OS_2   0x06u

Definition at line 201 of file zip.h.

◆ ZIP_OPSYS_OS_400

#define ZIP_OPSYS_OS_400   0x12u

Definition at line 213 of file zip.h.

◆ ZIP_OPSYS_OS_X

#define ZIP_OPSYS_OS_X   0x13u

Definition at line 214 of file zip.h.

◆ ZIP_OPSYS_TANDEM

#define ZIP_OPSYS_TANDEM   0x11u

Definition at line 212 of file zip.h.

◆ ZIP_OPSYS_UNIX

#define ZIP_OPSYS_UNIX   0x03u

Definition at line 198 of file zip.h.

◆ ZIP_OPSYS_VFAT

#define ZIP_OPSYS_VFAT   0x0eu

Definition at line 209 of file zip.h.

◆ ZIP_OPSYS_VM_CMS

#define ZIP_OPSYS_VM_CMS   0x04u

Definition at line 199 of file zip.h.

◆ ZIP_OPSYS_VSE

#define ZIP_OPSYS_VSE   0x0cu

Definition at line 207 of file zip.h.

◆ ZIP_OPSYS_WINDOWS_NTFS

#define ZIP_OPSYS_WINDOWS_NTFS   0x0au

Definition at line 205 of file zip.h.

◆ ZIP_OPSYS_Z_SYSTEM

#define ZIP_OPSYS_Z_SYSTEM   0x08u

Definition at line 203 of file zip.h.

◆ ZIP_RDONLY

#define ZIP_RDONLY   16

Definition at line 71 of file zip.h.

◆ ZIP_SOURCE_CHECK_SUPPORTED

#define ZIP_SOURCE_CHECK_SUPPORTED (   supported,
  cmd 
)    (((supported) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd)) != 0)

Definition at line 245 of file zip.h.

◆ ZIP_SOURCE_GET_ARGS

#define ZIP_SOURCE_GET_ARGS (   type,
  data,
  len,
  error 
)    ((len) < sizeof(type) ? zip_error_set((error), ZIP_ER_INVAL, 0), (type *)NULL : (type *)(data))

Definition at line 279 of file zip.h.

◆ ZIP_SOURCE_MAKE_COMMAND_BITMASK

#define ZIP_SOURCE_MAKE_COMMAND_BITMASK (   cmd)    (((zip_int64_t)1) << (cmd))

Definition at line 243 of file zip.h.

◆ ZIP_SOURCE_SUPPORTS_READABLE

#define ZIP_SOURCE_SUPPORTS_READABLE
Value:

Definition at line 249 of file zip.h.

◆ ZIP_SOURCE_SUPPORTS_SEEKABLE

#define ZIP_SOURCE_SUPPORTS_SEEKABLE
Value:

Definition at line 256 of file zip.h.

◆ ZIP_SOURCE_SUPPORTS_WRITABLE

◆ ZIP_STAT_COMP_METHOD

#define ZIP_STAT_COMP_METHOD   0x0040u

Definition at line 296 of file zip.h.

◆ ZIP_STAT_COMP_SIZE

#define ZIP_STAT_COMP_SIZE   0x0008u

Definition at line 293 of file zip.h.

◆ ZIP_STAT_CRC

#define ZIP_STAT_CRC   0x0020u

Definition at line 295 of file zip.h.

◆ ZIP_STAT_ENCRYPTION_METHOD

#define ZIP_STAT_ENCRYPTION_METHOD   0x0080u

Definition at line 297 of file zip.h.

◆ ZIP_STAT_FLAGS

#define ZIP_STAT_FLAGS   0x0100u

Definition at line 298 of file zip.h.

◆ ZIP_STAT_INDEX

#define ZIP_STAT_INDEX   0x0002u

Definition at line 291 of file zip.h.

◆ ZIP_STAT_MTIME

#define ZIP_STAT_MTIME   0x0010u

Definition at line 294 of file zip.h.

◆ ZIP_STAT_NAME

#define ZIP_STAT_NAME   0x0001u

Definition at line 290 of file zip.h.

◆ ZIP_STAT_SIZE

#define ZIP_STAT_SIZE   0x0004u

Definition at line 292 of file zip.h.

◆ ZIP_TRUNCATE

#define ZIP_TRUNCATE   8

Definition at line 70 of file zip.h.

Typedef Documentation

◆ zip_buffer_fragment_t

Definition at line 1 of file zip.h.

◆ zip_cancel_callback

typedef int(* zip_cancel_callback) (zip_t *_Nonnull, void *_Nullable)

Definition at line 351 of file zip.h.

◆ zip_error_t

typedef struct zip_error zip_error_t

Definition at line 1 of file zip.h.

◆ zip_file_attributes_t

Definition at line 1 of file zip.h.

◆ zip_file_t

typedef struct zip_file zip_file_t

Definition at line 1 of file zip.h.

◆ zip_flags_t

Definition at line 347 of file zip.h.

◆ zip_progress_callback

typedef void(* zip_progress_callback) (zip_t *_Nonnull, double, void *_Nullable)

Definition at line 350 of file zip.h.

◆ zip_progress_callback_t

typedef void(* zip_progress_callback_t) (double)

Definition at line 354 of file zip.h.

◆ zip_source_args_seek_t

Definition at line 1 of file zip.h.

◆ zip_source_callback

typedef zip_int64_t(* zip_source_callback) (void *_Nullable, void *_Nullable, zip_uint64_t, zip_source_cmd_t)

Definition at line 349 of file zip.h.

◆ zip_source_cmd_t

Definition at line 1 of file zip.h.

◆ zip_source_t

typedef struct zip_source zip_source_t

Definition at line 1 of file zip.h.

◆ zip_stat_t

typedef struct zip_stat zip_stat_t

Definition at line 1 of file zip.h.

◆ zip_t

typedef struct zip zip_t

Definition at line 1 of file zip.h.

Enumeration Type Documentation

◆ zip_source_cmd

Enumerator
ZIP_SOURCE_OPEN 
ZIP_SOURCE_READ 
ZIP_SOURCE_CLOSE 
ZIP_SOURCE_STAT 
ZIP_SOURCE_ERROR 
ZIP_SOURCE_FREE 
ZIP_SOURCE_SEEK 
ZIP_SOURCE_TELL 
ZIP_SOURCE_BEGIN_WRITE 
ZIP_SOURCE_COMMIT_WRITE 
ZIP_SOURCE_ROLLBACK_WRITE 
ZIP_SOURCE_WRITE 
ZIP_SOURCE_SEEK_WRITE 
ZIP_SOURCE_TELL_WRITE 
ZIP_SOURCE_SUPPORTS 
ZIP_SOURCE_REMOVE 
ZIP_SOURCE_RESERVED_1 
ZIP_SOURCE_BEGIN_WRITE_CLONING 
ZIP_SOURCE_ACCEPT_EMPTY 
ZIP_SOURCE_GET_FILE_ATTRIBUTES 

Definition at line 219 of file zip.h.

219  {
220  ZIP_SOURCE_OPEN, /* prepare for reading */
221  ZIP_SOURCE_READ, /* read data */
222  ZIP_SOURCE_CLOSE, /* reading is done */
223  ZIP_SOURCE_STAT, /* get meta information */
224  ZIP_SOURCE_ERROR, /* get error information */
225  ZIP_SOURCE_FREE, /* cleanup and free resources */
226  ZIP_SOURCE_SEEK, /* set position for reading */
227  ZIP_SOURCE_TELL, /* get read position */
228  ZIP_SOURCE_BEGIN_WRITE, /* prepare for writing */
229  ZIP_SOURCE_COMMIT_WRITE, /* writing is done */
230  ZIP_SOURCE_ROLLBACK_WRITE, /* discard written changes */
231  ZIP_SOURCE_WRITE, /* write data */
232  ZIP_SOURCE_SEEK_WRITE, /* set position for writing */
233  ZIP_SOURCE_TELL_WRITE, /* get write position */
234  ZIP_SOURCE_SUPPORTS, /* check whether source supports command */
235  ZIP_SOURCE_REMOVE, /* remove file */
236  ZIP_SOURCE_RESERVED_1, /* previously used internally */
237  ZIP_SOURCE_BEGIN_WRITE_CLONING, /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */
238  ZIP_SOURCE_ACCEPT_EMPTY, /* whether empty files are valid archives */
239  ZIP_SOURCE_GET_FILE_ATTRIBUTES /* get additional file attributes */
240 };
@ ZIP_SOURCE_RESERVED_1
Definition: zip.h:236
@ ZIP_SOURCE_GET_FILE_ATTRIBUTES
Definition: zip.h:239
@ ZIP_SOURCE_ACCEPT_EMPTY
Definition: zip.h:238
@ ZIP_SOURCE_BEGIN_WRITE_CLONING
Definition: zip.h:237

Function Documentation

◆ zip_add()

ZIP_EXTERN zip_int64_t zip_add ( zip_t _Nonnull,
const char *  _Nonnull,
zip_source_t _Nonnull 
)

Definition at line 47 of file zip_add.c.

47  {
48  return zip_file_add(za, name, source, 0);
49 }
ZIP_EXTERN zip_int64_t zip_file_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull, zip_flags_t)
Definition: zip_file_add.c:45
const char * source
Definition: lz4.h:699
Definition: z80asm.h:102
zip_t * za
Definition: ziptool.c:79

References source, za, and zip_file_add().

Referenced by add(), add_file(), add_from_zip(), add_nul(), main(), merge_zip(), and rz_io_zip_flush_file().

◆ zip_add_dir()

ZIP_EXTERN zip_int64_t zip_add_dir ( zip_t _Nonnull,
const char *  _Nonnull 
)

Definition at line 42 of file zip_add_dir.c.

42  {
43  return zip_dir_add(za, name, 0);
44 }
ZIP_EXTERN zip_int64_t zip_dir_add(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t)
Definition: zip_dir_add.c:44

References za, and zip_dir_add().

Referenced by add_dir().

◆ zip_close()

ZIP_EXTERN int zip_close ( zip_t _Nonnull)

Definition at line 52 of file zip_close.c.

52  {
53  zip_uint64_t i, j, survivors, unchanged_offset;
55  int error;
56  zip_filelist_t *filelist;
57  int changed;
58 
59  if (za == NULL)
60  return -1;
61 
62  changed = _zip_changed(za, &survivors);
63 
64  /* don't create zip files with no entries */
65  if (survivors == 0) {
66  if ((za->open_flags & ZIP_TRUNCATE) || changed) {
67  if (zip_source_remove(za->src) < 0) {
70  return -1;
71  }
72  }
73  }
74  zip_discard(za);
75  return 0;
76  }
77 
78  if (!changed) {
79  zip_discard(za);
80  return 0;
81  }
82 
83  if (survivors > za->nentry) {
85  return -1;
86  }
87 
88  if ((filelist = (zip_filelist_t *)malloc(sizeof(filelist[0]) * (size_t)survivors)) == NULL)
89  return -1;
90 
91  unchanged_offset = ZIP_UINT64_MAX;
92  /* create list of files with index into original archive */
93  for (i = j = 0; i < za->nentry; i++) {
94  if (za->entry[i].orig != NULL && ZIP_ENTRY_HAS_CHANGES(&za->entry[i])) {
95  unchanged_offset = ZIP_MIN(unchanged_offset, za->entry[i].orig->offset);
96  }
97  if (za->entry[i].deleted) {
98  continue;
99  }
100 
101  if (j >= survivors) {
102  free(filelist);
104  return -1;
105  }
106 
107  filelist[j].idx = i;
108  j++;
109  }
110  if (j < survivors) {
111  free(filelist);
113  return -1;
114  }
115 
117  unchanged_offset = 0;
118  }
119  else {
120  if (unchanged_offset == ZIP_UINT64_MAX) {
121  /* we're keeping all file data, find the end of the last one */
122  zip_uint64_t last_index = ZIP_UINT64_MAX;
123  unchanged_offset = 0;
124 
125  for (i = 0; i < za->nentry; i++) {
126  if (za->entry[i].orig != NULL) {
127  if (za->entry[i].orig->offset >= unchanged_offset) {
128  unchanged_offset = za->entry[i].orig->offset;
129  last_index = i;
130  }
131  }
132  }
133  if (last_index != ZIP_UINT64_MAX) {
134  if ((unchanged_offset = _zip_file_get_end(za, last_index, &za->error)) == 0) {
135  free(filelist);
136  return -1;
137  }
138  }
139  }
140  if (unchanged_offset > 0) {
141  if (zip_source_begin_write_cloning(za->src, unchanged_offset) < 0) {
142  /* cloning not supported, need to copy everything */
143  unchanged_offset = 0;
144  }
145  }
146  }
147  if (unchanged_offset == 0) {
148  if (zip_source_begin_write(za->src) < 0) {
150  free(filelist);
151  return -1;
152  }
153  }
154 
155  if (_zip_progress_start(za->progress) != 0) {
158  free(filelist);
159  return -1;
160  }
161  error = 0;
162  for (j = 0; j < survivors; j++) {
163  int new_data;
165  zip_dirent_t *de;
166 
167  if (_zip_progress_subrange(za->progress, (double)j / (double)survivors, (double)(j + 1) / (double)survivors) != 0) {
169  error = 1;
170  break;
171  }
172 
173  i = filelist[j].idx;
174  entry = za->entry + i;
175 
176  if (entry->orig != NULL && entry->orig->offset < unchanged_offset) {
177  /* already implicitly copied by cloning */
178  continue;
179  }
180 
182 
183  /* create new local directory entry */
184  if (entry->changes == NULL) {
185  if ((entry->changes = _zip_dirent_clone(entry->orig)) == NULL) {
187  error = 1;
188  break;
189  }
190  }
191  de = entry->changes;
192 
193  if (_zip_read_local_ef(za, i) < 0) {
194  error = 1;
195  break;
196  }
197 
198  if ((off = zip_source_tell_write(za->src)) < 0) {
200  error = 1;
201  break;
202  }
203  de->offset = (zip_uint64_t)off;
204 
205  if (new_data) {
206  zip_source_t *zs;
207 
208  zs = NULL;
210  if ((zs = _zip_source_zip_new(za, i, ZIP_FL_UNCHANGED, 0, 0, NULL, &za->error)) == NULL) {
211  error = 1;
212  break;
213  }
214  }
215 
216  /* add_data writes dirent */
217  if (add_data(za, zs ? zs : entry->source, de, entry->changes ? entry->changes->changed : 0) < 0) {
218  error = 1;
219  if (zs)
220  zip_source_free(zs);
221  break;
222  }
223  if (zs)
224  zip_source_free(zs);
225  }
226  else {
228 
230  /* when copying data, all sizes are known -> no data descriptor needed */
231  /* except for PKWare encryption, where removing the data descriptor breaks password validation */
233  }
234  if (_zip_dirent_write(za, de, ZIP_FL_LOCAL) < 0) {
235  error = 1;
236  break;
237  }
238  if ((offset = _zip_file_get_offset(za, i, &za->error)) == 0) {
239  error = 1;
240  break;
241  }
244  error = 1;
245  break;
246  }
247  if (copy_data(za, de->comp_size) < 0) {
248  error = 1;
249  break;
250  }
251 
253  if (write_data_descriptor(za, de, _zip_dirent_needs_zip64(de, 0)) < 0) {
254  error = 1;
255  break;
256  }
257  }
258  }
259  }
260 
261  if (!error) {
262  if (write_cdir(za, filelist, survivors) < 0)
263  error = 1;
264  }
265 
266  free(filelist);
267 
268  if (!error) {
269  if (zip_source_commit_write(za->src) != 0) {
271  error = 1;
272  }
274  }
275 
276  if (error) {
278  return -1;
279  }
280 
281  zip_discard(za);
282 
283  return 0;
284 }
lzma_index ** i
Definition: index.h:629
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf uLong offset
Definition: ioapi.h:144
#define ZIP_ER_INTERNAL
Definition: zip.h:125
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
ZIP_EXTERN void zip_source_rollback_write(zip_source_t *_Nonnull)
ZIP_EXTERN int zip_source_commit_write(zip_source_t *_Nonnull)
#define ZIP_ER_MEMORY
Definition: zip.h:119
ZIP_EXTERN int zip_error_code_system(const zip_error_t *_Nonnull)
Definition: zip_error.c:40
#define ZIP_EM_TRAD_PKWARE
Definition: zip.h:178
ZIP_EXTERN int zip_source_seek(zip_source_t *_Nonnull, zip_int64_t, int)
#define ZIP_FL_LOCAL
Definition: zip.h:85
#define ZIP_ER_REMOVE
Definition: zip.h:127
ZIP_EXTERN zip_error_t *_Nonnull zip_source_error(zip_source_t *_Nonnull)
ZIP_EXTERN void zip_discard(zip_t *_Nonnull)
Definition: zip_discard.c:45
ZIP_EXTERN zip_int64_t zip_source_tell_write(zip_source_t *_Nonnull)
ZIP_EXTERN int zip_source_begin_write(zip_source_t *_Nonnull)
#define ZIP_TRUNCATE
Definition: zip.h:70
#define ZIP_ER_CANCELLED
Definition: zip.h:137
ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull)
Definition: zip_error.c:46
ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable)
#define ZIP_FL_UNCHANGED
Definition: zip.h:79
ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t *_Nonnull, zip_uint64_t)
void * malloc(size_t size)
Definition: malloc.c:123
int off
Definition: pal.c:13
#define ENOENT
Definition: sftypes.h:112
Definition: zipcmp.c:77
zip_uint16_t bitflags
Definition: zipint.h:335
zip_uint64_t offset
Definition: zipint.h:347
zip_uint64_t comp_size
Definition: zipint.h:339
zip_uint16_t encryption_method
Definition: zipint.h:350
Definition: zipint.h:408
zip_dirent_t * orig
Definition: zipint.h:409
bool deleted
Definition: zipint.h:412
zip_uint64_t idx
Definition: zipint.h:458
zip_error_t error
Definition: zipint.h:281
zip_source_t * src
Definition: zipint.h:279
zip_entry_t * entry
Definition: zipint.h:294
zip_uint64_t nentry
Definition: zipint.h:292
unsigned int open_flags
Definition: zipint.h:280
zip_progress_t * progress
Definition: zipint.h:302
void error(const char *msg)
Definition: untgz.c:593
#define SEEK_SET
Definition: zip.c:88
int _zip_changed(const zip_t *za, zip_uint64_t *survivorsp)
Definition: zip_close.c:655
static int add_data(zip_t *, zip_source_t *, zip_dirent_t *, zip_uint32_t)
Definition: zip_close.c:288
static int write_cdir(zip_t *, const zip_filelist_t *, zip_uint64_t)
Definition: zip_close.c:637
static int copy_data(zip_t *, zip_uint64_t)
Definition: zip_close.c:556
static int write_data_descriptor(zip_t *za, const zip_dirent_t *dirent, int is_zip64)
Definition: zip_close.c:683
zip_dirent_t * _zip_dirent_clone(const zip_dirent_t *sde)
Definition: zip_dirent.c:215
int _zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags)
Definition: zip_dirent.c:765
bool _zip_dirent_needs_zip64(const zip_dirent_t *de, zip_flags_t flags)
Definition: zip_dirent.c:296
void _zip_error_set_from_source(zip_error_t *err, zip_source_t *src)
Definition: zip_error.c:135
int _zip_read_local_ef(zip_t *za, zip_uint64_t idx)
zip_uint64_t _zip_file_get_end(const zip_t *za, zip_uint64_t index, zip_error_t *error)
zip_uint64_t _zip_file_get_offset(const zip_t *za, zip_uint64_t idx, zip_error_t *error)
int _zip_progress_subrange(zip_progress_t *progress, double start, double end)
Definition: zip_progress.c:172
void _zip_progress_end(zip_progress_t *progress)
Definition: zip_progress.c:68
int _zip_progress_start(zip_progress_t *progress)
Definition: zip_progress.c:151
int zip_source_remove(zip_source_t *src)
zip_int64_t zip_source_supports(zip_source_t *src)
zip_source_t * _zip_source_zip_new(zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_uint64_t len, const char *password, zip_error_t *error)
uint64_t zip_uint64_t
Definition: zipconf.h:39
uint16_t zip_uint16_t
Definition: zipconf.h:35
#define ZIP_UINT64_MAX
Definition: zipconf.h:55
int64_t zip_int64_t
Definition: zipconf.h:38
#define ZIP_ENTRY_DATA_CHANGED(x)
Definition: zipint.h:476
#define ZIP_DIRENT_COMP_METHOD
Definition: zipint.h:316
#define ZIP_ENTRY_HAS_CHANGES(e)
Definition: zipint.h:477
#define ZIP_MIN(a, b)
Definition: zipint.h:473
#define ZIP_GPBF_DATA_DESCRIPTOR
Definition: zipint.h:237
#define ZIP_ENTRY_CHANGED(e, f)
Definition: zipint.h:475
#define ZIP_DIRENT_ENCRYPTION_METHOD
Definition: zipint.h:322

References _zip_changed(), _zip_dirent_clone(), _zip_dirent_needs_zip64(), _zip_dirent_write(), _zip_error_set_from_source(), _zip_file_get_end(), _zip_file_get_offset(), _zip_progress_end(), _zip_progress_start(), _zip_progress_subrange(), _zip_read_local_ef(), _zip_source_zip_new(), add_data(), zip_dirent::bitflags, zip_dirent::comp_size, copy_data(), zip_entry::deleted, zip_dirent::encryption_method, ENOENT, zip::entry, zip::error, error(), free(), i, zip_filelist::idx, malloc(), zip::nentry, NULL, off, zip_dirent::offset, zip::open_flags, zip_entry::orig, zip::progress, SEEK_SET, zip::src, write_cdir(), write_data_descriptor(), za, ZIP_DIRENT_COMP_METHOD, ZIP_DIRENT_ENCRYPTION_METHOD, zip_discard(), ZIP_EM_TRAD_PKWARE, ZIP_ENTRY_CHANGED, ZIP_ENTRY_DATA_CHANGED, ZIP_ENTRY_HAS_CHANGES, ZIP_ER_CANCELLED, ZIP_ER_INTERNAL, ZIP_ER_MEMORY, ZIP_ER_REMOVE, zip_error_code_system(), zip_error_code_zip(), zip_error_set(), ZIP_FL_LOCAL, ZIP_FL_UNCHANGED, ZIP_GPBF_DATA_DESCRIPTOR, ZIP_MIN, zip_source_begin_write(), ZIP_SOURCE_BEGIN_WRITE_CLONING, zip_source_begin_write_cloning(), zip_source_commit_write(), zip_source_error(), zip_source_free(), ZIP_SOURCE_MAKE_COMMAND_BITMASK, zip_source_remove(), zip_source_rollback_write(), zip_source_seek(), zip_source_supports(), zip_source_tell_write(), ZIP_TRUNCATE, and ZIP_UINT64_MAX.

Referenced by add_from_zip(), compare_zip(), LLVMFuzzerTestOneInput(), main(), merge_zip(), rz_io_zip_alloc_zipfileobj(), rz_io_zip_flush_file(), rz_io_zip_get_by_file_idx(), rz_io_zip_get_files(), rz_io_zip_slurp_file(), and zin_close().

◆ zip_compression_method_supported()

ZIP_EXTERN int zip_compression_method_supported ( zip_int32_t  method,
int  compress 
)

Definition at line 112 of file zip_source_compress.c.

112  {
113  if (method == ZIP_CM_STORE) {
114  return 1;
115  }
116  return _zip_get_compression_algorithm(method, compress) != NULL;
117 }
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: compress.c:68
#define ZIP_CM_STORE
Definition: zip.h:149
zip_compression_algorithm_t * _zip_get_compression_algorithm(zip_int32_t method, bool compress)

References _zip_get_compression_algorithm(), compress(), context::method, NULL, and ZIP_CM_STORE.

Referenced by usage(), and zip_set_file_compression().

◆ zip_delete()

ZIP_EXTERN int zip_delete ( zip_t _Nonnull,
zip_uint64_t  idx 
)

Definition at line 39 of file zip_delete.c.

39  {
40  const char *name;
41 
42  if (idx >= za->nentry) {
44  return -1;
45  }
46 
47  if (ZIP_IS_RDONLY(za)) {
49  return -1;
50  }
51 
52  if ((name = _zip_get_name(za, idx, 0, &za->error)) == NULL) {
53  return -1;
54  }
55 
56  if (!_zip_hash_delete(za->names, (const zip_uint8_t *)name, &za->error)) {
57  return -1;
58  }
59 
60  /* allow duplicate file names, because the file will
61  * be removed directly afterwards */
62  if (_zip_unchange(za, idx, 1) != 0)
63  return -1;
64 
65  za->entry[idx].deleted = 1;
66 
67  return 0;
68 }
#define ZIP_ER_RDONLY
Definition: zip.h:130
#define ZIP_ER_INVAL
Definition: zip.h:123
int idx
Definition: setup.py:197
const char * name
Definition: op.c:541
zip_hash_t * names
Definition: zipint.h:300
const char * _zip_get_name(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error)
Definition: zip_get_name.c:47
bool _zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *name, zip_error_t *error)
Definition: zip_hash.c:264
int _zip_unchange(zip_t *za, zip_uint64_t idx, int allow_duplicates)
Definition: zip_unchange.c:47
uint8_t zip_uint8_t
Definition: zipconf.h:33
#define ZIP_IS_RDONLY(za)
Definition: zipint.h:479

References _zip_get_name(), _zip_hash_delete(), _zip_unchange(), zip_entry::deleted, zip::entry, zip::error, setup::idx, name, zip::names, zip::nentry, NULL, za, ZIP_ER_INVAL, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.

Referenced by delete(), main(), and zip_dir_add().

◆ zip_dir_add()

ZIP_EXTERN zip_int64_t zip_dir_add ( zip_t _Nonnull,
const char *  _Nonnull,
zip_flags_t  flags 
)

Definition at line 44 of file zip_dir_add.c.

44  {
45  size_t len;
47  char *s;
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
55  if (name == NULL) {
57  return -1;
58  }
59 
60  s = NULL;
61  len = strlen(name);
62 
63  if (name[len - 1] != '/') {
64  if ((s = (char *)malloc(len + 2)) == NULL) {
66  return -1;
67  }
68  strcpy(s, name);
69  s[len] = '/';
70  s[len + 1] = '\0';
71  }
72 
73  if ((source = zip_source_buffer(za, NULL, 0, 0)) == NULL) {
74  free(s);
75  return -1;
76  }
77 
79 
80  free(s);
81 
82  if (idx < 0)
84  else {
87  return -1;
88  }
89  }
90 
91  return idx;
92 }
size_t len
Definition: 6502dis.c:15
ZIP_EXTERN int zip_file_set_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t)
ZIP_EXTERN int zip_delete(zip_t *_Nonnull, zip_uint64_t)
Definition: zip_delete.c:39
#define ZIP_OPSYS_DEFAULT
Definition: zip.h:216
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer(zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int)
static RzSocket * s
Definition: rtr.c:28
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
zip_int64_t _zip_file_replace(zip_t *za, zip_uint64_t idx, const char *name, zip_source_t *source, zip_flags_t flags)
#define ZIP_EXT_ATTRIB_DEFAULT_DIR
Definition: zipint.h:95

References _zip_file_replace(), zip::error, flags, free(), setup::idx, len, malloc(), NULL, s, source, za, zip_delete(), ZIP_ER_INVAL, ZIP_ER_MEMORY, ZIP_ER_RDONLY, zip_error_set(), ZIP_EXT_ATTRIB_DEFAULT_DIR, zip_file_set_external_attributes(), ZIP_IS_RDONLY, ZIP_OPSYS_DEFAULT, zip_source_buffer(), zip_source_free(), and ZIP_UINT64_MAX.

Referenced by zip_add_dir().

◆ zip_discard()

ZIP_EXTERN void zip_discard ( zip_t _Nonnull)

Definition at line 45 of file zip_discard.c.

45  {
47 
48  if (za == NULL)
49  return;
50 
51  if (za->src) {
54  }
55 
59 
61 
62  if (za->entry) {
63  for (i = 0; i < za->nentry; i++)
65  free(za->entry);
66  }
67 
68  for (i = 0; i < za->nopen_source; i++) {
70  }
72 
74 
76 
77  free(za);
78 
79  return;
80 }
ZIP_EXTERN int zip_source_close(zip_source_t *_Nonnull)
ZIP_EXTERN void zip_error_fini(zip_error_t *_Nonnull)
Definition: zip_error.c:52
zip_source_t ** open_source
Definition: zipint.h:298
zip_string_t * comment_changes
Definition: zipint.h:289
unsigned int nopen_source
Definition: zipint.h:296
zip_string_t * comment_orig
Definition: zipint.h:288
char * default_password
Definition: zipint.h:286
void _zip_entry_finalize(zip_entry_t *e)
Definition: zip_entry.c:38
void _zip_hash_free(zip_hash_t *hash)
Definition: zip_hash.c:184
void _zip_progress_free(zip_progress_t *progress)
Definition: zip_progress.c:74
void _zip_source_invalidate(zip_source_t *src)
void _zip_string_free(zip_string_t *s)
Definition: zip_string.c:69

References _zip_entry_finalize(), _zip_hash_free(), _zip_progress_free(), _zip_source_invalidate(), _zip_string_free(), zip::comment_changes, zip::comment_orig, zip::default_password, zip::entry, zip::error, free(), i, zip::names, zip::nentry, zip::nopen_source, NULL, zip::open_source, zip::progress, zip::src, za, zip_error_fini(), zip_source_close(), and zip_source_free().

Referenced by _zip_open(), main(), and zip_close().

◆ zip_encryption_method_supported()

ZIP_EXTERN int zip_encryption_method_supported ( zip_uint16_t  method,
int  encode 
)

Definition at line 57 of file zip_get_encryption_implementation.c.

57  {
58  if (method == ZIP_EM_NONE) {
59  return 1;
60  }
62 }
static void encode(size_t size, lzma_action action)
Definition: full_flush.c:25
#define ZIP_EM_NONE
Definition: zip.h:177
zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t em, int operation)
#define ZIP_CODEC_ENCODE
Definition: zipint.h:108
#define ZIP_CODEC_DECODE
Definition: zipint.h:107

References _zip_get_encryption_implementation(), encode(), NULL, ZIP_CODEC_DECODE, ZIP_CODEC_ENCODE, and ZIP_EM_NONE.

Referenced by usage().

◆ zip_error_clear()

ZIP_EXTERN void zip_error_clear ( zip_t _Nonnull)

Definition at line 39 of file zip_error_clear.c.

39  {
40  if (za == NULL)
41  return;
42 
44 }
void _zip_error_clear(zip_error_t *err)
Definition: zip_error.c:92

References _zip_error_clear(), zip::error, NULL, and za.

◆ zip_error_code_system()

ZIP_EXTERN int zip_error_code_system ( const zip_error_t _Nonnull)

Definition at line 40 of file zip_error.c.

40  {
41  return error->sys_err;
42 }

References error().

Referenced by _zip_checkcons(), _zip_file_exists(), _zip_find_central_dir(), _zip_read_cdir(), _zip_set_open_error(), do_read(), read_file(), zip_close(), and zip_error_to_data().

◆ zip_error_code_zip()

◆ zip_error_fini()

◆ zip_error_get()

ZIP_EXTERN void zip_error_get ( zip_t _Nonnull,
int _Nullable,
int _Nullable 
)

Definition at line 40 of file zip_error_get.c.

40  {
41  _zip_error_get(&za->error, zep, sep);
42 }
void _zip_error_get(const zip_error_t *err, int *zep, int *sep)
Definition: zip_error.c:113

References _zip_error_get(), zip::error, and za.

◆ zip_error_get_sys_type()

ZIP_EXTERN int zip_error_get_sys_type ( int  ze)

Definition at line 39 of file zip_error_get_sys_type.c.

39  {
40  if (ze < 0 || ze >= _zip_err_str_count) {
41  return 0;
42  }
43 
44  return _zip_err_str[ze].type;
45 }
const struct _zip_err_info _zip_err_str[]
Definition: zip_err_str.c:15
const int _zip_err_str_count
Definition: zip_err_str.c:51

References _zip_err_str, _zip_err_str_count, and _zip_err_info::type.

Referenced by main().

◆ zip_error_init()

◆ zip_error_init_with_code()

ZIP_EXTERN void zip_error_init_with_code ( zip_error_t _Nonnull,
int  ze 
)

Definition at line 66 of file zip_error.c.

66  {
68  error->zip_err = ze;
69  switch (zip_error_system_type(error)) {
70  case ZIP_ET_SYS:
71  case ZIP_ET_LIBZIP:
72  error->sys_err = errno;
73  break;
74 
75  default:
76  error->sys_err = 0;
77  break;
78  }
79 }
#define ZIP_ET_LIBZIP
Definition: zip.h:144
#define ZIP_ET_SYS
Definition: zip.h:142
ZIP_EXTERN int zip_error_system_type(const zip_error_t *error)
Definition: zip_error.c:83
ZIP_EXTERN void zip_error_init(zip_error_t *err)
Definition: zip_error.c:59

References error(), zip_error_init(), zip_error_system_type(), ZIP_ET_LIBZIP, and ZIP_ET_SYS.

Referenced by add_from_zip(), cat(), do_read(), list_zip(), main(), and merge_zip().

◆ zip_error_set()

ZIP_EXTERN void zip_error_set ( zip_error_t _Nullable,
int  ze,
int  se 
)

Definition at line 126 of file zip_error.c.

126  {
127  if (err) {
128  err->zip_err = ze;
129  err->sys_err = se;
130  }
131 }

References err.

Referenced by _zip_add_entry(), _zip_buffer_new_from_source(), _zip_cdir_grow(), _zip_cdir_new(), _zip_cdir_write(), _zip_checkcons(), _zip_cp437_to_utf8(), _zip_crypto_aes_new(), _zip_crypto_hmac_new(), _zip_dirent_process_winzip_aes(), _zip_dirent_read(), _zip_dirent_size(), _zip_dirent_write(), _zip_ef_clone(), _zip_ef_get_by_id(), _zip_ef_parse(), _zip_ef_utf8(), _zip_ef_write(), _zip_file_extra_field_prepare_for_change(), _zip_file_get_end(), _zip_file_get_offset(), _zip_file_new(), _zip_file_replace(), _zip_find_central_dir(), _zip_get_dirent(), _zip_hash_add(), _zip_hash_delete(), _zip_hash_lookup(), _zip_hash_new(), _zip_memdup(), _zip_name_locate(), _zip_new(), _zip_open(), _zip_progress_new(), _zip_read(), _zip_read_cdir(), _zip_read_data(), _zip_read_eocd(), _zip_read_eocd64(), _zip_read_local_ef(), _zip_register_source(), _zip_set_name(), _zip_source_call(), _zip_source_invalidate(), _zip_source_new(), _zip_source_window_new(), _zip_source_zip_new(), _zip_stat_win32(), _zip_stdio_op_commit_write(), _zip_stdio_op_create_temp_output(), _zip_stdio_op_open(), _zip_stdio_op_read(), _zip_stdio_op_remove(), _zip_stdio_op_seek(), _zip_stdio_op_stat(), _zip_stdio_op_tell(), _zip_stdio_op_write(), _zip_string_new(), _zip_unchange(), _zip_win32_named_op_commit_write(), _zip_win32_named_op_create_temp_output(), _zip_win32_named_op_remove(), _zip_win32_named_op_stat(), _zip_win32_named_op_write(), _zip_win32_op_read(), _zip_win32_op_seek(), _zip_win32_op_tell(), _zip_winzip_aes_new(), _zip_write(), add_data(), allocate(), buffer_clone(), buffer_from_file(), buffer_grow_fragments(), buffer_new(), buffer_read_file(), buffer_to_file(), buffer_write(), compress_callback(), compress_read(), compression_source_new(), copy_data(), copy_source(), crc_read(), create_temp_file(), decrypt_header(), do_read(), encrypt_header(), end(), hash_resize(), hole_new(), input(), pkware_decrypt(), pkware_encrypt(), process(), read_data(), read_file(), read_from_file(), read_hole(), read_to_memory(), source_hole_cb(), source_nul(), source_nul_cb(), start(), trad_pkware_new(), verify_hmac(), win32_named_open(), window_read(), winzip_aes_decrypt(), winzip_aes_encrypt(), winzip_aes_new(), write_data_descriptor(), zip_close(), zip_delete(), zip_dir_add(), zip_file_add(), zip_file_extra_field_delete(), zip_file_extra_field_delete_by_id(), zip_file_extra_field_get(), zip_file_extra_field_get_by_id(), zip_file_extra_field_set(), zip_file_extra_fields_count(), zip_file_extra_fields_count_by_id(), zip_file_rename(), zip_file_replace(), zip_file_set_comment(), zip_file_set_encryption(), zip_file_set_external_attributes(), zip_file_set_mtime(), zip_fread(), zip_get_num_files(), zip_open_from_source(), zip_set_archive_comment(), zip_set_archive_flag(), zip_set_default_password(), zip_set_file_comment(), zip_set_file_compression(), zip_source_begin_write(), zip_source_begin_write_cloning(), zip_source_buffer_fragment_with_attributes_create(), zip_source_buffer_with_attributes_create(), zip_source_close(), zip_source_commit_write(), zip_source_crc_create(), zip_source_file_common_new(), zip_source_file_create(), zip_source_filep_create(), zip_source_get_file_attributes(), zip_source_open(), zip_source_pkware_decode(), zip_source_pkware_encode(), zip_source_read(), zip_source_seek(), zip_source_seek_compute_offset(), zip_source_seek_write(), zip_source_stat(), zip_source_tell(), zip_source_tell_write(), zip_source_win32a_create(), zip_source_win32handle_create(), zip_source_win32w_create(), zip_source_winzip_aes_decode(), zip_source_winzip_aes_encode(), zip_source_write(), zip_source_zip_create(), and zip_stat_index().

◆ zip_error_strerror()

ZIP_EXTERN const char* _Nonnull zip_error_strerror ( zip_error_t _Nonnull)

Definition at line 43 of file zip_error_strerror.c.

43  {
44  const char *zip_error_string, *system_error_string;
45  char buf[128], *s;
46 
48 
49  if (err->zip_err < 0 || err->zip_err >= _zip_err_str_count) {
50  snprintf(buf, sizeof(buf), "Unknown error %d", err->zip_err);
51  buf[sizeof(buf) - 1] = '\0'; /* make sure string is NUL-terminated */
52  zip_error_string = NULL;
53  system_error_string = buf;
54  }
55  else {
56  zip_error_string = _zip_err_str[err->zip_err].description;
57 
58  switch (_zip_err_str[err->zip_err].type) {
59  case ZIP_ET_SYS:
60  system_error_string = strerror(err->sys_err);
61  break;
62 
63  case ZIP_ET_ZLIB:
64  system_error_string = zError(err->sys_err);
65  break;
66 
67  case ZIP_ET_LIBZIP: {
69  int index = GET_INDEX_FROM_DETAIL(err->sys_err);
70 
71  if (error == 0) {
72  system_error_string = NULL;
73  }
74  else if (error >= _zip_err_details_count) {
75  snprintf(buf, sizeof(buf), "invalid detail error %u", error);
76  buf[sizeof(buf) - 1] = '\0'; /* make sure string is NUL-terminated */
77  system_error_string = buf;
78  }
80  snprintf(buf, sizeof(buf), "entry %d: %s", index, _zip_err_details[error].description);
81  buf[sizeof(buf) - 1] = '\0'; /* make sure string is NUL-terminated */
82  system_error_string = buf;
83  }
84  else {
85  system_error_string = _zip_err_details[error].description;
86  }
87  break;
88  }
89 
90  default:
91  system_error_string = NULL;
92  }
93  }
94 
95  if (system_error_string == NULL) {
96  return zip_error_string;
97  }
98  else {
99  if ((s = (char *)malloc(strlen(system_error_string) + (zip_error_string ? strlen(zip_error_string) + 2 : 0) + 1)) == NULL) {
101  }
102 
103  sprintf(s, "%s%s%s", (zip_error_string ? zip_error_string : ""), (zip_error_string ? ": " : ""), system_error_string);
104  err->str = s;
105 
106  return s;
107  }
108 }
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
sprintf
Definition: kernel.h:365
#define ZIP_ET_ZLIB
Definition: zip.h:143
int type
Definition: mipsasm.c:17
description
Definition: setup.py:259
const char * description
Definition: zipint.h:197
const struct _zip_err_info _zip_err_details[]
Definition: zip_err_str.c:53
const int _zip_err_details_count
Definition: zip_err_str.c:76
#define GET_INDEX_FROM_DETAIL(error)
Definition: zipint.h:208
#define MAX_DETAIL_INDEX
Definition: zipint.h:206
#define ZIP_DETAIL_ET_ENTRY
Definition: zipint.h:193
#define GET_ERROR_FROM_DETAIL(error)
Definition: zipint.h:209
const char *ZEXPORT zError(int err)
Definition: zutil.c:133

References _zip_err_details, _zip_err_details_count, _zip_err_str, _zip_err_str_count, setup::description, _zip_err_info::description, err, error(), GET_ERROR_FROM_DETAIL, GET_INDEX_FROM_DETAIL, malloc(), MAX_DETAIL_INDEX, NULL, s, snprintf, sprintf, type, _zip_err_info::type, zError(), ZIP_DETAIL_ET_ENTRY, ZIP_ER_MEMORY, zip_error_fini(), ZIP_ET_LIBZIP, ZIP_ET_SYS, and ZIP_ET_ZLIB.

Referenced by add_from_zip(), cat(), copy_source(), do_read(), list_zip(), main(), merge_zip(), open_compressed(), open_file(), windows_open(), write_memory_src_to_file(), zip_file_strerror(), and zip_strerror().

◆ zip_error_system_type()

ZIP_EXTERN int zip_error_system_type ( const zip_error_t _Nonnull)

Definition at line 83 of file zip_error.c.

83  {
84  if (error->zip_err < 0 || error->zip_err >= _zip_err_str_count)
85  return ZIP_ET_NONE;
86 
87  return _zip_err_str[error->zip_err].type;
88 }
#define ZIP_ET_NONE
Definition: zip.h:141

References _zip_err_str, _zip_err_str_count, error(), _zip_err_info::type, and ZIP_ET_NONE.

Referenced by _zip_error_get(), _zip_set_open_error(), and zip_error_init_with_code().

◆ zip_error_to_data()

ZIP_EXTERN zip_int64_t zip_error_to_data ( const zip_error_t _Nonnull,
void *  _Nonnull,
zip_uint64_t  length 
)

Definition at line 141 of file zip_error.c.

141  {
142  int *e = (int *)data;
143 
144  if (length < sizeof(int) * 2) {
145  return -1;
146  }
147 
148  e[0] = zip_error_code_zip(error);
150  return sizeof(int) * 2;
151 }
#define e(frag)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
static int
Definition: sfsocketcall.h:114
ZIP_EXTERN int zip_error_code_zip(const zip_error_t *error)
Definition: zip_error.c:46
ZIP_EXTERN int zip_error_code_system(const zip_error_t *error)
Definition: zip_error.c:40

References e, error(), int, length, zip_error_code_system(), and zip_error_code_zip().

Referenced by compress_callback(), crc_read(), pkware_decrypt(), pkware_encrypt(), read_data(), read_file(), source_hole_cb(), source_nul_cb(), window_read(), winzip_aes_decrypt(), and winzip_aes_encrypt().

◆ zip_error_to_str()

ZIP_EXTERN int zip_error_to_str ( char *  _Nonnull,
zip_uint64_t  len,
int  ze,
int  se 
)

Definition at line 44 of file zip_error_to_str.c.

44  {
45  const char *zs, *ss;
46 
47  if (ze < 0 || ze >= _zip_err_str_count) {
48  return snprintf(buf, len, "Unknown error %d", ze);
49  }
50 
51  zs = _zip_err_str[ze].description;
52 
53  switch (_zip_err_str[ze].type) {
54  case ZIP_ET_SYS:
55  ss = strerror(se);
56  break;
57 
58  case ZIP_ET_ZLIB:
59  ss = zError(se);
60  break;
61 
62  default:
63  ss = NULL;
64  }
65 
66  return snprintf(buf, len, "%s%s%s", zs, (ss ? ": " : ""), (ss ? ss : ""));
67 }

References _zip_err_str, _zip_err_str_count, _zip_err_info::description, len, NULL, snprintf, type, zError(), ZIP_ET_SYS, and ZIP_ET_ZLIB.

◆ zip_fclose()

ZIP_EXTERN int zip_fclose ( zip_file_t _Nonnull)

Definition at line 41 of file zip_fclose.c.

41  {
42  int ret;
43 
44  if (zf->src)
45  zip_source_free(zf->src);
46 
47  ret = 0;
48  if (zf->error.zip_err)
49  ret = zf->error.zip_err;
50 
51  zip_error_fini(&zf->error);
52  free(zf);
53  return ret;
54 }

References zip_file::error, free(), zip_file::src, zip_error::zip_err, zip_error_fini(), and zip_source_free().

Referenced by cat(), do_read(), LLVMFuzzerTestOneInput(), main(), rz_io_zip_slurp_file(), and test_file().

◆ zip_fdopen()

ZIP_EXTERN zip_t* _Nullable zip_fdopen ( int  fd_orig,
int  _flags,
int _Nullable 
)

Definition at line 42 of file zip_fdopen.c.

42  {
43  int fd;
44  FILE *fp;
45  zip_t *za;
47  struct zip_error error;
48 
49  if (_flags < 0 || (_flags & ~(ZIP_CHECKCONS | ZIP_RDONLY))) {
51  return NULL;
52  }
53 
54  /* We dup() here to avoid messing with the passed in fd.
55  We could not restore it to the original state in case of error. */
56 
57  if ((fd = dup(fd_orig)) < 0) {
59  return NULL;
60  }
61 
62  if ((fp = fdopen(fd, "rb")) == NULL) {
63  close(fd);
65  return NULL;
66  }
67 
69  if ((src = zip_source_filep_create(fp, 0, -1, &error)) == NULL) {
70  fclose(fp);
71  _zip_set_open_error(zep, &error, 0);
73  return NULL;
74  }
75 
76  if ((za = zip_open_from_source(src, _flags, &error)) == NULL) {
78  _zip_set_open_error(zep, &error, 0);
80  return NULL;
81  }
82 
84  close(fd_orig);
85  return za;
86 }
lzma_index * src
Definition: index.h:567
static static fork const void static count close
Definition: sflib.h:33
#define ZIP_ER_OPEN
Definition: zip.h:116
ZIP_EXTERN zip_t *_Nullable zip_open_from_source(zip_source_t *_Nonnull, int, zip_error_t *_Nullable)
Definition: zip_open.c:79
#define ZIP_CHECKCONS
Definition: zip.h:69
#define ZIP_RDONLY
Definition: zip.h:71
ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull)
Definition: zip_error.c:59
ZIP_EXTERN zip_source_t *_Nullable zip_source_filep_create(FILE *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode dup
Definition: sflib.h:68
string FILE
Definition: benchmark.py:21
Definition: zip.h:284
Definition: zipint.h:278
static const z80_opcode fd[]
Definition: z80_tab.h:997
void _zip_set_open_error(int *zep, const zip_error_t *err, int ze)
Definition: zip_open.c:217

References _zip_set_open_error(), close, dup, error(), fd, benchmark::FILE, NULL, src, za, ZIP_CHECKCONS, ZIP_ER_INVAL, ZIP_ER_OPEN, zip_error_fini(), zip_error_init(), zip_open_from_source(), ZIP_RDONLY, zip_source_filep_create(), and zip_source_free().

Referenced by read_from_file().

◆ zip_file_add()

ZIP_EXTERN zip_int64_t zip_file_add ( zip_t _Nonnull,
const char *  _Nonnull,
zip_source_t _Nonnull,
zip_flags_t  flags 
)

Definition at line 45 of file zip_file_add.c.

45  {
46  if (name == NULL || source == NULL) {
48  return -1;
49  }
50 
52 }

References _zip_file_replace(), zip::error, flags, NULL, source, za, ZIP_ER_INVAL, zip_error_set(), and ZIP_UINT64_MAX.

Referenced by main(), and zip_add().

◆ zip_file_attributes_init()

ZIP_EXTERN void zip_file_attributes_init ( zip_file_attributes_t _Nonnull)

◆ zip_file_error_clear()

ZIP_EXTERN void zip_file_error_clear ( zip_file_t _Nonnull)

Definition at line 39 of file zip_file_error_clear.c.

39  {
40  if (zf == NULL)
41  return;
42 
43  _zip_error_clear(&zf->error);
44 }

References _zip_error_clear(), zip_file::error, and NULL.

◆ zip_file_error_get()

ZIP_EXTERN void zip_file_error_get ( zip_file_t _Nonnull,
int _Nullable,
int _Nullable 
)

Definition at line 39 of file zip_file_error_get.c.

39  {
40  _zip_error_get(&zf->error, zep, sep);
41 }

References _zip_error_get(), and zip_file::error.

◆ zip_file_extra_field_delete()

ZIP_EXTERN int zip_file_extra_field_delete ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  ef_idx,
zip_flags_t  flags 
)

Definition at line 39 of file zip_extra_field_api.c.

39  {
40  zip_dirent_t *de;
41 
42  if ((flags & ZIP_EF_BOTH) == 0) {
44  return -1;
45  }
46 
47  if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) {
49  return -1;
50  }
51 
52  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
53  return -1;
54 
55  if (ZIP_IS_RDONLY(za)) {
57  return -1;
58  }
59 
61  return -1;
62 
63  de = za->entry[idx].changes;
64 
66  return 0;
67 }
#define ZIP_EXTRA_FIELD_ALL
Definition: zip.h:99
zip_extra_field_t * extra_fields
Definition: zipint.h:342
zip_dirent_t * changes
Definition: zipint.h:410
zip_dirent_t * _zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error)
Definition: zip_dirent.c:1064
zip_extra_field_t * _zip_ef_delete_by_id(zip_extra_field_t *ef, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags)
int _zip_file_extra_field_prepare_for_change(zip_t *za, zip_uint64_t idx)
#define ZIP_EF_BOTH
Definition: zipint.h:245

References _zip_ef_delete_by_id(), _zip_file_extra_field_prepare_for_change(), _zip_get_dirent(), zip_entry::changes, zip::entry, zip::error, zip_dirent::extra_fields, flags, setup::idx, NULL, za, ZIP_EF_BOTH, ZIP_ER_INVAL, ZIP_ER_RDONLY, zip_error_set(), ZIP_EXTRA_FIELD_ALL, and ZIP_IS_RDONLY.

Referenced by delete_extra().

◆ zip_file_extra_field_delete_by_id()

ZIP_EXTERN int zip_file_extra_field_delete_by_id ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  ef_id,
zip_uint16_t  ef_idx,
zip_flags_t  flags 
)

Definition at line 71 of file zip_extra_field_api.c.

71  {
72  zip_dirent_t *de;
73 
74  if ((flags & ZIP_EF_BOTH) == 0) {
76  return -1;
77  }
78 
79  if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) {
81  return -1;
82  }
83 
84  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
85  return -1;
86 
87  if (ZIP_IS_RDONLY(za)) {
89  return -1;
90  }
91 
93  return -1;
94 
95  de = za->entry[idx].changes;
96 
97  de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ef_id, ef_idx, flags);
98  return 0;
99 }

References _zip_ef_delete_by_id(), _zip_file_extra_field_prepare_for_change(), _zip_get_dirent(), zip_entry::changes, zip::entry, zip::error, zip_dirent::extra_fields, flags, setup::idx, NULL, za, ZIP_EF_BOTH, ZIP_ER_INVAL, ZIP_ER_RDONLY, zip_error_set(), ZIP_EXTRA_FIELD_ALL, and ZIP_IS_RDONLY.

Referenced by delete_extra_by_id().

◆ zip_file_extra_field_get()

ZIP_EXTERN const zip_uint8_t* _Nullable zip_file_extra_field_get ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  ef_idx,
zip_uint16_t _Nullable,
zip_uint16_t _Nullable,
zip_flags_t  flags 
)

Definition at line 103 of file zip_extra_field_api.c.

103  {
104  static const zip_uint8_t empty[1] = {'\0'};
105 
106  zip_dirent_t *de;
108  int i;
109 
110  if ((flags & ZIP_EF_BOTH) == 0) {
112  return NULL;
113  }
114 
115  if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL)
116  return NULL;
117 
118  if (flags & ZIP_FL_LOCAL)
119  if (_zip_read_local_ef(za, idx) < 0)
120  return NULL;
121 
122  i = 0;
123  for (ef = de->extra_fields; ef; ef = ef->next) {
124  if (ef->flags & flags & ZIP_EF_BOTH) {
125  if (i < ef_idx) {
126  i++;
127  continue;
128  }
129 
130  if (idp)
131  *idp = ef->id;
132  if (lenp)
133  *lenp = ef->size;
134  if (ef->size > 0)
135  return ef->data;
136  else
137  return empty;
138  }
139  }
140 
142  return NULL;
143 }
#define ef(frag,...)
#define ZIP_ER_NOENT
Definition: zip.h:114
Definition: zipcmp.c:69
zip_uint16_t size
Definition: zipcmp.c:73
zip_uint16_t id
Definition: zipcmp.c:72
const zip_uint8_t * data
Definition: zipcmp.c:74
zip_uint16_t flags
Definition: zipcmp.c:71

References _zip_get_dirent(), _zip_read_local_ef(), ef::data, ef, zip::error, zip_dirent::extra_fields, flags, ef::flags, i, ef::id, setup::idx, NULL, ef::size, za, ZIP_EF_BOTH, ZIP_ER_INVAL, ZIP_ER_NOENT, zip_error_set(), and ZIP_FL_LOCAL.

Referenced by ef_read(), and get_extra().

◆ zip_file_extra_field_get_by_id()

ZIP_EXTERN const zip_uint8_t* _Nullable zip_file_extra_field_get_by_id ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  ef_id,
zip_uint16_t  ef_idx,
zip_uint16_t _Nullable,
zip_flags_t  flags 
)

Definition at line 147 of file zip_extra_field_api.c.

147  {
148  zip_dirent_t *de;
149 
150  if ((flags & ZIP_EF_BOTH) == 0) {
152  return NULL;
153  }
154 
155  if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL)
156  return NULL;
157 
158  if (flags & ZIP_FL_LOCAL)
159  if (_zip_read_local_ef(za, idx) < 0)
160  return NULL;
161 
162  return _zip_ef_get_by_id(de->extra_fields, lenp, ef_id, ef_idx, flags, &za->error);
163 }
const zip_uint8_t * _zip_ef_get_by_id(const zip_extra_field_t *ef, zip_uint16_t *lenp, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags, zip_error_t *error)

References _zip_ef_get_by_id(), _zip_get_dirent(), _zip_read_local_ef(), zip::error, zip_dirent::extra_fields, flags, setup::idx, NULL, za, ZIP_EF_BOTH, ZIP_ER_INVAL, zip_error_set(), and ZIP_FL_LOCAL.

Referenced by get_extra_by_id().

◆ zip_file_extra_field_set()

ZIP_EXTERN int zip_file_extra_field_set ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  ef_id,
zip_uint16_t  ef_idx,
const zip_uint8_t _Nullable,
zip_uint16_t  len,
zip_flags_t  flags 
)

Definition at line 221 of file zip_extra_field_api.c.

221  {
222  zip_dirent_t *de;
223  zip_uint16_t ls, cs;
224  zip_extra_field_t *ef, *ef_prev, *ef_new;
225  int i, found, new_len;
226 
227  if ((flags & ZIP_EF_BOTH) == 0) {
229  return -1;
230  }
231 
232  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
233  return -1;
234 
235  if (ZIP_IS_RDONLY(za)) {
237  return -1;
238  }
239 
240  if (ZIP_EF_IS_INTERNAL(ef_id)) {
242  return -1;
243  }
244 
246  return -1;
247 
248  de = za->entry[idx].changes;
249 
250  ef = de->extra_fields;
251  ef_prev = NULL;
252  i = 0;
253  found = 0;
254 
255  for (; ef; ef = ef->next) {
256  if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH)) {
257  if (i == ef_idx) {
258  found = 1;
259  break;
260  }
261  i++;
262  }
263  ef_prev = ef;
264  }
265 
266  if (i < ef_idx && ef_idx != ZIP_EXTRA_FIELD_NEW) {
268  return -1;
269  }
270 
271  if (flags & ZIP_EF_LOCAL)
273  else
274  ls = 0;
275  if (flags & ZIP_EF_CENTRAL)
277  else
278  cs = 0;
279 
280  new_len = ls > cs ? ls : cs;
281  if (found)
282  new_len -= ef->size + 4;
283  new_len += len + 4;
284 
285  if (new_len > ZIP_UINT16_MAX) {
287  return -1;
288  }
289 
290  if ((ef_new = _zip_ef_new(ef_id, len, data, flags)) == NULL) {
292  return -1;
293  }
294 
295  if (found) {
296  if ((ef->flags & ZIP_EF_BOTH) == (flags & ZIP_EF_BOTH)) {
297  ef_new->next = ef->next;
298  ef->next = NULL;
299  _zip_ef_free(ef);
300  if (ef_prev)
301  ef_prev->next = ef_new;
302  else
303  de->extra_fields = ef_new;
304  }
305  else {
306  ef->flags &= ~(flags & ZIP_EF_BOTH);
307  ef_new->next = ef->next;
308  ef->next = ef_new;
309  }
310  }
311  else if (ef_prev) {
312  ef_new->next = ef_prev->next;
313  ef_prev->next = ef_new;
314  }
315  else
316  de->extra_fields = ef_new;
317 
318  return 0;
319 }
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
#define ZIP_EXTRA_FIELD_NEW
Definition: zip.h:100
zip_extra_field_t * next
Definition: zipint.h:368
zip_uint16_t _zip_ef_size(const zip_extra_field_t *ef, zip_flags_t flags)
zip_extra_field_t * _zip_ef_new(zip_uint16_t id, zip_uint16_t size, const zip_uint8_t *data, zip_flags_t flags)
void _zip_ef_free(zip_extra_field_t *ef)
#define ZIP_UINT16_MAX
Definition: zipconf.h:47
#define ZIP_EF_CENTRAL
Definition: zipint.h:244
#define ZIP_EF_LOCAL
Definition: zipint.h:243
#define ZIP_EF_IS_INTERNAL(id)
Definition: zipint.h:90

References _zip_ef_free(), _zip_ef_new(), _zip_ef_size(), _zip_file_extra_field_prepare_for_change(), _zip_get_dirent(), zip_entry::changes, test_evm::cs, ef, zip::entry, zip::error, zip_dirent::extra_fields, flags, ef::flags, found, i, ef::id, setup::idx, len, zip_extra_field::next, NULL, ef::size, za, ZIP_EF_BOTH, ZIP_EF_CENTRAL, ZIP_EF_IS_INTERNAL, ZIP_EF_LOCAL, ZIP_ER_INVAL, ZIP_ER_MEMORY, ZIP_ER_RDONLY, zip_error_set(), ZIP_EXTRA_FIELD_NEW, ZIP_IS_RDONLY, and ZIP_UINT16_MAX.

Referenced by set_extra().

◆ zip_file_extra_fields_count()

ZIP_EXTERN zip_int16_t zip_file_extra_fields_count ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_flags_t  flags 
)

Definition at line 167 of file zip_extra_field_api.c.

167  {
168  zip_dirent_t *de;
170  zip_uint16_t n;
171 
172  if ((flags & ZIP_EF_BOTH) == 0) {
174  return -1;
175  }
176 
177  if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL)
178  return -1;
179 
180  if (flags & ZIP_FL_LOCAL)
181  if (_zip_read_local_ef(za, idx) < 0)
182  return -1;
183 
184  n = 0;
185  for (ef = de->extra_fields; ef; ef = ef->next)
186  if (ef->flags & flags & ZIP_EF_BOTH)
187  n++;
188 
189  return (zip_int16_t)n;
190 }
int n
Definition: mipsasm.c:19
int16_t zip_int16_t
Definition: zipconf.h:34

References _zip_get_dirent(), _zip_read_local_ef(), ef, zip::error, zip_dirent::extra_fields, flags, ef::flags, setup::idx, n, NULL, za, ZIP_EF_BOTH, ZIP_ER_INVAL, zip_error_set(), and ZIP_FL_LOCAL.

Referenced by count_extra(), and ef_read().

◆ zip_file_extra_fields_count_by_id()

ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  ef_id,
zip_flags_t  flags 
)

Definition at line 194 of file zip_extra_field_api.c.

194  {
195  zip_dirent_t *de;
197  zip_uint16_t n;
198 
199  if ((flags & ZIP_EF_BOTH) == 0) {
201  return -1;
202  }
203 
204  if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL)
205  return -1;
206 
207  if (flags & ZIP_FL_LOCAL)
208  if (_zip_read_local_ef(za, idx) < 0)
209  return -1;
210 
211  n = 0;
212  for (ef = de->extra_fields; ef; ef = ef->next)
213  if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH))
214  n++;
215 
216  return (zip_int16_t)n;
217 }

References _zip_get_dirent(), _zip_read_local_ef(), ef, zip::error, zip_dirent::extra_fields, flags, ef::flags, ef::id, setup::idx, n, NULL, za, ZIP_EF_BOTH, ZIP_ER_INVAL, zip_error_set(), and ZIP_FL_LOCAL.

Referenced by count_extra_by_id().

◆ zip_file_get_comment()

ZIP_EXTERN const char* _Nullable zip_file_get_comment ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint32_t _Nullable,
zip_flags_t  flags 
)

Definition at line 40 of file zip_file_get_comment.c.

40  {
41  zip_dirent_t *de;
43  const zip_uint8_t *str;
44 
45  if ((de = _zip_get_dirent(za, idx, flags, NULL)) == NULL)
46  return NULL;
47 
48  if ((str = _zip_string_get(de->comment, &len, flags, &za->error)) == NULL)
49  return NULL;
50 
51  if (lenp)
52  *lenp = len;
53 
54  return (const char *)str;
55 }
zip_string_t * comment
Definition: zipint.h:343
const zip_uint8_t * _zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip_error_t *error)
Definition: zip_string.c:80
uint32_t zip_uint32_t
Definition: zipconf.h:37

References _zip_get_dirent(), _zip_string_get(), zip_dirent::comment, zip::error, flags, setup::idx, len, NULL, cmd_descs_generate::str, and za.

Referenced by list_zip(), and zip_get_file_comment().

◆ zip_file_get_error()

ZIP_EXTERN zip_error_t* _Nonnull zip_file_get_error ( zip_file_t _Nonnull)

Definition at line 52 of file zip_error_get.c.

52  {
53  return &f->error;
54 }
#define f(i)
Definition: sha256.c:46

References f.

Referenced by do_read(), and main().

◆ zip_file_get_external_attributes()

ZIP_EXTERN int zip_file_get_external_attributes ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_flags_t  flags,
zip_uint8_t _Nullable,
zip_uint32_t _Nullable 
)

Definition at line 37 of file zip_file_get_external_attributes.c.

37  {
38  zip_dirent_t *de;
39 
40  if ((de = _zip_get_dirent(za, idx, flags, NULL)) == NULL)
41  return -1;
42 
43  if (opsys)
44  *opsys = (zip_uint8_t)((de->version_madeby >> 8) & 0xff);
45 
46  if (attributes)
47  *attributes = de->ext_attrib;
48 
49  return 0;
50 }
zip_uint32_t ext_attrib
Definition: zipint.h:346
zip_uint16_t version_madeby
Definition: zipint.h:333

References _zip_get_dirent(), zip_dirent::ext_attrib, flags, setup::idx, NULL, zip_dirent::version_madeby, and za.

◆ zip_file_is_seekable()

ZIP_EXTERN int zip_file_is_seekable ( zip_file_t _Nonnull)

Definition at line 55 of file zip_fseek.c.

55  {
56  if (!zfile) {
57  return -1;
58  }
59 
61 }
#define ZIP_SOURCE_CHECK_SUPPORTED(supported, cmd)
Definition: zip.h:245

References zip_file::src, ZIP_SOURCE_CHECK_SUPPORTED, ZIP_SOURCE_SEEK, and zip_source_supports().

Referenced by is_seekable().

◆ zip_file_rename()

ZIP_EXTERN int zip_file_rename ( zip_t _Nonnull,
zip_uint64_t  idx,
const char *  _Nonnull,
zip_flags_t  flags 
)

Definition at line 41 of file zip_file_rename.c.

41  {
42  const char *old_name;
43  int old_is_dir, new_is_dir;
44 
45  if (idx >= za->nentry || (name != NULL && strlen(name) > ZIP_UINT16_MAX)) {
47  return -1;
48  }
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
55  if ((old_name = zip_get_name(za, idx, 0)) == NULL)
56  return -1;
57 
58  new_is_dir = (name != NULL && name[strlen(name) - 1] == '/');
59  old_is_dir = (old_name[strlen(old_name) - 1] == '/');
60 
61  if (new_is_dir != old_is_dir) {
63  return -1;
64  }
65 
66  return _zip_set_name(za, idx, name, flags);
67 }
ZIP_EXTERN const char *_Nullable zip_get_name(zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
Definition: zip_get_name.c:41
int _zip_set_name(zip_t *za, zip_uint64_t idx, const char *name, zip_flags_t flags)
Definition: zip_set_name.c:42

References _zip_set_name(), zip::error, flags, setup::idx, zip::nentry, NULL, za, ZIP_ER_INVAL, ZIP_ER_RDONLY, zip_error_set(), zip_get_name(), ZIP_IS_RDONLY, and ZIP_UINT16_MAX.

Referenced by zip_rename().

◆ zip_file_replace()

ZIP_EXTERN int zip_file_replace ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_source_t _Nonnull,
zip_flags_t  flags 
)

Definition at line 39 of file zip_file_replace.c.

39  {
40  if (idx >= za->nentry || source == NULL) {
42  return -1;
43  }
44 
45  if (_zip_file_replace(za, idx, NULL, source, flags) == -1)
46  return -1;
47 
48  return 0;
49 }

References _zip_file_replace(), zip::error, flags, setup::idx, zip::nentry, NULL, source, za, ZIP_ER_INVAL, and zip_error_set().

Referenced by replace_file_contents(), and zip_replace().

◆ zip_file_set_comment()

ZIP_EXTERN int zip_file_set_comment ( zip_t _Nonnull,
zip_uint64_t  idx,
const char *  _Nullable,
zip_uint16_t  len,
zip_flags_t  flags 
)

Definition at line 41 of file zip_file_set_comment.c.

41  {
42  zip_entry_t *e;
43  zip_string_t *cstr;
44  int changed;
45 
46  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
47  return -1;
48 
49  if (ZIP_IS_RDONLY(za)) {
51  return -1;
52  }
53 
54  if (len > 0 && comment == NULL) {
56  return -1;
57  }
58 
59  if (len > 0) {
60  if ((cstr = _zip_string_new((const zip_uint8_t *)comment, len, flags, &za->error)) == NULL)
61  return -1;
64  }
65  else
66  cstr = NULL;
67 
68  e = za->entry + idx;
69 
70  if (e->changes) {
71  _zip_string_free(e->changes->comment);
72  e->changes->comment = NULL;
73  e->changes->changed &= ~ZIP_DIRENT_COMMENT;
74  }
75 
76  if (e->orig && e->orig->comment)
77  changed = !_zip_string_equal(e->orig->comment, cstr);
78  else
79  changed = (cstr != NULL);
80 
81  if (changed) {
82  if (e->changes == NULL) {
83  if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
85  _zip_string_free(cstr);
86  return -1;
87  }
88  }
89  e->changes->comment = cstr;
90  e->changes->changed |= ZIP_DIRENT_COMMENT;
91  }
92  else {
93  _zip_string_free(cstr);
94  if (e->changes && e->changes->changed == 0) {
95  _zip_dirent_free(e->changes);
96  e->changes = NULL;
97  }
98  }
99 
100  return 0;
101 }
#define ZIP_FL_ENC_GUESS
Definition: zip.h:82
enum zip_encoding_type encoding
Definition: zipint.h:421
void _zip_dirent_free(zip_dirent_t *zde)
Definition: zip_dirent.c:258
zip_string_t * _zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_error_t *error)
Definition: zip_string.c:121
int _zip_string_equal(const zip_string_t *a, const zip_string_t *b)
Definition: zip_string.c:55
zip_encoding_type_t _zip_guess_encoding(zip_string_t *str, zip_encoding_type_t expected_encoding)
Definition: zip_utf-8.c:100
#define ZIP_FL_ENCODING_ALL
Definition: zipint.h:249
#define ZIP_DIRENT_COMMENT
Definition: zipint.h:318
@ ZIP_ENCODING_UTF8_GUESSED
Definition: zipint.h:257
@ ZIP_ENCODING_UTF8_KNOWN
Definition: zipint.h:256
@ ZIP_ENCODING_UNKNOWN
Definition: zipint.h:254

References _zip_dirent_clone(), _zip_dirent_free(), _zip_get_dirent(), _zip_guess_encoding(), _zip_string_equal(), _zip_string_free(), _zip_string_new(), e, zip_string::encoding, zip::entry, zip::error, flags, setup::idx, len, NULL, za, ZIP_DIRENT_COMMENT, ZIP_ENCODING_UNKNOWN, ZIP_ENCODING_UTF8_GUESSED, ZIP_ENCODING_UTF8_KNOWN, ZIP_ER_INVAL, ZIP_ER_MEMORY, ZIP_ER_RDONLY, zip_error_set(), ZIP_FL_ENC_GUESS, ZIP_FL_ENCODING_ALL, and ZIP_IS_RDONLY.

Referenced by set_file_comment(), and zip_set_file_comment().

◆ zip_file_set_dostime()

ZIP_EXTERN int zip_file_set_dostime ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  dtime,
zip_uint16_t  ddate,
zip_flags_t  flags 
)

Definition at line 37 of file zip_file_set_mtime.c.

37  {
38  time_t mtime;
39  mtime = _zip_d2u_time(dtime, ddate);
40  return zip_file_set_mtime(za, idx, mtime, flags);
41 }
int time_t
Definition: sftypes.h:66
time_t _zip_d2u_time(zip_uint16_t dtime, zip_uint16_t ddate)
Definition: zip_dirent.c:1004
ZIP_EXTERN int zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags)

References _zip_d2u_time(), flags, setup::idx, za, and zip_file_set_mtime().

Referenced by set_file_dostime().

◆ zip_file_set_encryption()

ZIP_EXTERN int zip_file_set_encryption ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_uint16_t  method,
const char *  _Nullable 
)

Definition at line 41 of file zip_file_set_encryption.c.

41  {
42  zip_entry_t *e;
43  zip_uint16_t old_method;
44 
45  if (idx >= za->nentry) {
47  return -1;
48  }
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
57  return -1;
58  }
59 
60  e = za->entry + idx;
61 
62  old_method = (e->orig == NULL ? ZIP_EM_NONE : e->orig->encryption_method);
63 
64  if (method == old_method && password == NULL) {
65  if (e->changes) {
66  if (e->changes->changed & ZIP_DIRENT_PASSWORD) {
67  _zip_crypto_clear(e->changes->password, strlen(e->changes->password));
68  free(e->changes->password);
69  e->changes->password = (e->orig == NULL ? NULL : e->orig->password);
70  }
71  e->changes->changed &= ~(ZIP_DIRENT_ENCRYPTION_METHOD | ZIP_DIRENT_PASSWORD);
72  if (e->changes->changed == 0) {
73  _zip_dirent_free(e->changes);
74  e->changes = NULL;
75  }
76  }
77  }
78  else {
79  char *our_password = NULL;
80 
81  if (password) {
82  if ((our_password = strdup(password)) == NULL) {
84  return -1;
85  }
86  }
87 
88  if (e->changes == NULL) {
89  if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
90  if (our_password) {
91  _zip_crypto_clear(our_password, strlen(our_password));
92  }
93  free(our_password);
95  return -1;
96  }
97  }
98 
99  e->changes->encryption_method = method;
100  e->changes->changed |= ZIP_DIRENT_ENCRYPTION_METHOD;
101  if (password) {
102  e->changes->password = our_password;
103  e->changes->changed |= ZIP_DIRENT_PASSWORD;
104  }
105  else {
106  if (e->changes->changed & ZIP_DIRENT_PASSWORD) {
107  _zip_crypto_clear(e->changes->password, strlen(e->changes->password));
108  free(e->changes->password);
109  e->changes->password = e->orig ? e->orig->password : NULL;
110  e->changes->changed &= ~ZIP_DIRENT_PASSWORD;
111  }
112  }
113  }
114 
115  return 0;
116 }
#define ZIP_ER_ENCRNOTSUPP
Definition: zip.h:129
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define ZIP_DIRENT_PASSWORD
Definition: zipint.h:323
#define _zip_crypto_clear(b, l)
Definition: zipint.h:489

References _zip_crypto_clear, _zip_dirent_clone(), _zip_dirent_free(), _zip_get_encryption_implementation(), e, zip::entry, zip::error, free(), setup::idx, zip::nentry, NULL, strdup(), za, ZIP_CODEC_ENCODE, ZIP_DIRENT_ENCRYPTION_METHOD, ZIP_DIRENT_PASSWORD, ZIP_EM_NONE, ZIP_ER_ENCRNOTSUPP, ZIP_ER_INVAL, ZIP_ER_MEMORY, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.

Referenced by set_file_encryption().

◆ zip_file_set_external_attributes()

ZIP_EXTERN int zip_file_set_external_attributes ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_flags_t  flags,
zip_uint8_t  opsys,
zip_uint32_t  attributes 
)

Definition at line 37 of file zip_file_set_external_attributes.c.

37  {
38  zip_entry_t *e;
39  int changed;
40  zip_uint8_t unchanged_opsys;
41  zip_uint32_t unchanged_attributes;
42 
43  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
44  return -1;
45 
46  if (ZIP_IS_RDONLY(za)) {
48  return -1;
49  }
50 
51  e = za->entry + idx;
52 
53  unchanged_opsys = (e->orig ? (zip_uint8_t)(e->orig->version_madeby >> 8) : (zip_uint8_t)ZIP_OPSYS_DEFAULT);
54  unchanged_attributes = e->orig ? e->orig->ext_attrib : ZIP_EXT_ATTRIB_DEFAULT;
55 
56  changed = (opsys != unchanged_opsys || attributes != unchanged_attributes);
57 
58  if (changed) {
59  if (e->changes == NULL) {
60  if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
62  return -1;
63  }
64  }
65  e->changes->version_madeby = (zip_uint16_t)((opsys << 8) | (e->changes->version_madeby & 0xff));
66  e->changes->ext_attrib = attributes;
67  e->changes->changed |= ZIP_DIRENT_ATTRIBUTES;
68  }
69  else if (e->changes) {
70  e->changes->changed &= ~ZIP_DIRENT_ATTRIBUTES;
71  if (e->changes->changed == 0) {
72  _zip_dirent_free(e->changes);
73  e->changes = NULL;
74  }
75  else {
76  e->changes->version_madeby = (zip_uint16_t)((unchanged_opsys << 8) | (e->changes->version_madeby & 0xff));
77  e->changes->ext_attrib = unchanged_attributes;
78  }
79  }
80 
81  return 0;
82 }
#define ZIP_DIRENT_ATTRIBUTES
Definition: zipint.h:320
#define ZIP_EXT_ATTRIB_DEFAULT
Definition: zipint.h:93

References _zip_dirent_clone(), _zip_dirent_free(), _zip_get_dirent(), e, zip::entry, zip::error, setup::idx, NULL, za, ZIP_DIRENT_ATTRIBUTES, ZIP_ER_MEMORY, ZIP_ER_RDONLY, zip_error_set(), ZIP_EXT_ATTRIB_DEFAULT, ZIP_IS_RDONLY, and ZIP_OPSYS_DEFAULT.

Referenced by zip_dir_add().

◆ zip_file_set_mtime()

ZIP_EXTERN int zip_file_set_mtime ( zip_t _Nonnull,
zip_uint64_t  idx,
time_t  mtime,
zip_flags_t  flags 
)

Definition at line 44 of file zip_file_set_mtime.c.

44  {
45  zip_entry_t *e;
46 
47  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
48  return -1;
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
55  e = za->entry + idx;
56 
57  if (e->orig != NULL && e->orig->encryption_method == ZIP_EM_TRAD_PKWARE && !ZIP_ENTRY_CHANGED(e, ZIP_DIRENT_ENCRYPTION_METHOD) && !ZIP_ENTRY_DATA_CHANGED(e)) {
59  return -1;
60  }
61 
62  if (e->changes == NULL) {
63  if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
65  return -1;
66  }
67  }
68 
69  e->changes->last_mod = mtime;
70  e->changes->changed |= ZIP_DIRENT_LAST_MOD;
71 
72  return 0;
73 }
#define ZIP_ER_OPNOTSUPP
Definition: zip.h:133
#define ZIP_DIRENT_LAST_MOD
Definition: zipint.h:321

References _zip_dirent_clone(), _zip_get_dirent(), e, zip::entry, zip::error, setup::idx, NULL, za, ZIP_DIRENT_ENCRYPTION_METHOD, ZIP_DIRENT_LAST_MOD, ZIP_EM_TRAD_PKWARE, ZIP_ENTRY_CHANGED, ZIP_ENTRY_DATA_CHANGED, ZIP_ER_MEMORY, ZIP_ER_OPNOTSUPP, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.

Referenced by set_file_mtime(), set_file_mtime_all(), and zip_file_set_dostime().

◆ zip_file_strerror()

ZIP_EXTERN const char* _Nonnull zip_file_strerror ( zip_file_t _Nonnull)

Definition at line 39 of file zip_file_strerror.c.

39  {
40  return zip_error_strerror(&zf->error);
41 }
ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull)

References zip_file::error, and zip_error_strerror().

Referenced by cat(), and test_file().

◆ zip_fopen()

ZIP_EXTERN zip_file_t* _Nullable zip_fopen ( zip_t _Nonnull,
const char *  _Nonnull,
zip_flags_t  flags 
)

Definition at line 39 of file zip_fopen.c.

39  {
41 
42  if ((idx = zip_name_locate(za, fname, flags)) < 0)
43  return NULL;
44 
46 }
ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t)
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index_encrypted(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, const char *_Nullable)

References zip::default_password, flags, create_tags_rz::fname, setup::idx, NULL, za, zip_fopen_index_encrypted(), and zip_name_locate().

Referenced by do_read(), and main().

◆ zip_fopen_encrypted()

ZIP_EXTERN zip_file_t* _Nullable zip_fopen_encrypted ( zip_t _Nonnull,
const char *  _Nonnull,
zip_flags_t  flags,
const char *  _Nullable 
)

Definition at line 39 of file zip_fopen_encrypted.c.

39  {
41 
42  if ((idx = zip_name_locate(za, fname, flags)) < 0)
43  return NULL;
44 
45  return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, password);
46 }

References flags, create_tags_rz::fname, setup::idx, NULL, za, zip_fopen_index_encrypted(), and zip_name_locate().

◆ zip_fopen_index()

ZIP_EXTERN zip_file_t* _Nullable zip_fopen_index ( zip_t _Nonnull,
zip_uint64_t  index,
zip_flags_t  flags 
)

◆ zip_fopen_index_encrypted()

ZIP_EXTERN zip_file_t* _Nullable zip_fopen_index_encrypted ( zip_t _Nonnull,
zip_uint64_t  index,
zip_flags_t  flags,
const char *  _Nullable 
)

Definition at line 44 of file zip_fopen_index_encrypted.c.

44  {
45  zip_file_t *zf;
47 
48  if (password != NULL && password[0] == '\0') {
49  password = NULL;
50  }
51 
52  if ((src = _zip_source_zip_new(za, index, flags, 0, 0, password, &za->error)) == NULL)
53  return NULL;
54 
55  if (zip_source_open(src) < 0) {
58  return NULL;
59  }
60 
61  if ((zf = _zip_file_new(za)) == NULL) {
63  return NULL;
64  }
65 
66  zf->src = src;
67 
68  return zf;
69 }
ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull)
zip_source_t * src
Definition: zipint.h:311
static zip_file_t * _zip_file_new(zip_t *za)

References _zip_error_set_from_source(), _zip_file_new(), _zip_source_zip_new(), zip::error, flags, NULL, zip_file::src, src, za, zip_source_free(), and zip_source_open().

Referenced by zip_fopen(), zip_fopen_encrypted(), and zip_fopen_index().

◆ zip_fread()

ZIP_EXTERN zip_int64_t zip_fread ( zip_file_t _Nonnull,
void *  _Nonnull,
zip_uint64_t  toread 
)

Definition at line 39 of file zip_fread.c.

39  {
40  zip_int64_t n;
41 
42  if (!zf)
43  return -1;
44 
45  if (zf->error.zip_err != 0)
46  return -1;
47 
48  if (toread > ZIP_INT64_MAX) {
49  zip_error_set(&zf->error, ZIP_ER_INVAL, 0);
50  return -1;
51  }
52 
53  if ((zf->eof) || (toread == 0))
54  return 0;
55 
56  if ((n = zip_source_read(zf->src, outbuf, toread)) < 0) {
57  _zip_error_set_from_source(&zf->error, zf->src);
58  return -1;
59  }
60 
61  return n;
62 }
unsigned char outbuf[SIZE]
Definition: gun.c:162
ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t)
#define ZIP_INT64_MAX
Definition: zipconf.h:54

References _zip_error_set_from_source(), zip_file::eof, zip_file::error, n, outbuf, zip_file::src, ZIP_ER_INVAL, zip_error::zip_err, zip_error_set(), ZIP_INT64_MAX, and zip_source_read().

Referenced by cat(), do_read(), LLVMFuzzerTestOneInput(), main(), rz_io_zip_slurp_file(), and test_file().

◆ zip_fseek()

ZIP_EXTERN zip_int8_t zip_fseek ( zip_file_t _Nonnull,
zip_int64_t  offset,
int  whence 
)

Definition at line 38 of file zip_fseek.c.

38  {
39  if (!zf)
40  return -1;
41 
42  if (zf->error.zip_err != 0)
43  return -1;
44 
45  if (zip_source_seek(zf->src, offset, whence) < 0) {
46  _zip_error_set_from_source(&zf->error, zf->src);
47  return -1;
48  }
49 
50  return 0;
51 }

References _zip_error_set_from_source(), zip_file::error, zip_file::src, zip_error::zip_err, and zip_source_seek().

Referenced by main(), and seek().

◆ zip_ftell()

ZIP_EXTERN zip_int64_t zip_ftell ( zip_file_t _Nonnull)

Definition at line 38 of file zip_ftell.c.

38  {
39  zip_int64_t res;
40 
41  if (!zf)
42  return -1;
43 
44  if (zf->error.zip_err != 0)
45  return -1;
46 
47  res = zip_source_tell(zf->src);
48  if (res < 0) {
49  _zip_error_set_from_source(&zf->error, zf->src);
50  return -1;
51  }
52 
53  return res;
54 }
ZIP_EXTERN zip_int64_t zip_source_tell(zip_source_t *_Nonnull)

References _zip_error_set_from_source(), zip_file::error, zip_file::src, zip_error::zip_err, and zip_source_tell().

◆ zip_get_archive_comment()

ZIP_EXTERN const char* _Nullable zip_get_archive_comment ( zip_t _Nonnull,
int _Nullable,
zip_flags_t  flags 
)

Definition at line 41 of file zip_get_archive_comment.c.

41  {
42  zip_string_t *comment;
44  const zip_uint8_t *str;
45 
46  if ((flags & ZIP_FL_UNCHANGED) || (za->comment_changes == NULL))
47  comment = za->comment_orig;
48  else
49  comment = za->comment_changes;
50 
51  if ((str = _zip_string_get(comment, &len, flags, &za->error)) == NULL)
52  return NULL;
53 
54  if (lenp)
55  *lenp = (int)len;
56 
57  return (const char *)str;
58 }

References _zip_string_get(), zip::comment_changes, zip::comment_orig, zip::error, flags, int, len, NULL, cmd_descs_generate::str, za, and ZIP_FL_UNCHANGED.

Referenced by get_archive_comment(), and list_zip().

◆ zip_get_archive_flag()

ZIP_EXTERN int zip_get_archive_flag ( zip_t _Nonnull,
zip_flags_t  flag,
zip_flags_t  flags 
)

Definition at line 39 of file zip_get_archive_flag.c.

39  {
40  unsigned int fl;
41 
42  fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags;
43 
44  return (fl & flag) ? 1 : 0;
45 }
unsigned int flags
Definition: zipint.h:283
unsigned int ch_flags
Definition: zipint.h:284

References zip::ch_flags, flags, zip::flags, za, and ZIP_FL_UNCHANGED.

◆ zip_get_error()

ZIP_EXTERN zip_error_t* _Nonnull zip_get_error ( zip_t _Nonnull)

Definition at line 46 of file zip_error_get.c.

46  {
47  return &za->error;
48 }

References zip::error, and za.

Referenced by do_read(), and source_nul().

◆ zip_get_file_comment()

ZIP_EXTERN const char* _Nullable zip_get_file_comment ( zip_t _Nonnull,
zip_uint64_t  idx,
int _Nullable,
int  flags 
)

Definition at line 40 of file zip_get_file_comment.c.

40  {
42  const char *s;
43 
44  if ((s = zip_file_get_comment(za, idx, &len, (zip_flags_t)flags)) != NULL) {
45  if (lenp)
46  *lenp = (int)len;
47  }
48 
49  return s;
50 }
ZIP_EXTERN const char *_Nullable zip_file_get_comment(zip_t *_Nonnull, zip_uint64_t, zip_uint32_t *_Nullable, zip_flags_t)
zip_uint32_t zip_flags_t
Definition: zip.h:347

References flags, setup::idx, int, len, NULL, s, za, and zip_file_get_comment().

Referenced by get_file_comment().

◆ zip_get_name()

ZIP_EXTERN const char* _Nullable zip_get_name ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_flags_t  flags 
)

Definition at line 41 of file zip_get_name.c.

41  {
42  return _zip_get_name(za, idx, flags, &za->error);
43 }

References _zip_get_name(), zip::error, flags, setup::idx, and za.

Referenced by get_file_comment(), merge_zip(), zip_file_rename(), and zip_stat_index().

◆ zip_get_num_entries()

ZIP_EXTERN zip_int64_t zip_get_num_entries ( zip_t _Nonnull,
zip_flags_t  flags 
)

Definition at line 39 of file zip_get_num_entries.c.

39  {
41 
42  if (za == NULL)
43  return -1;
44 
45  if (flags & ZIP_FL_UNCHANGED) {
46  n = za->nentry;
47  while (n > 0 && za->entry[n - 1].orig == NULL)
48  --n;
49  return (zip_int64_t)n;
50  }
51  return (zip_int64_t)za->nentry;
52 }

References zip::entry, flags, n, zip::nentry, NULL, zip_entry::orig, za, and ZIP_FL_UNCHANGED.

Referenced by get_num_entries(), list_zip(), LLVMFuzzerTestOneInput(), main(), merge_zip(), and set_file_mtime_all().

◆ zip_get_num_files()

ZIP_EXTERN int zip_get_num_files ( zip_t _Nonnull)

Definition at line 41 of file zip_get_num_files.c.

41  {
42  if (za == NULL)
43  return -1;
44 
45  if (za->nentry > INT_MAX) {
47  return -1;
48  }
49 
50  return (int)za->nentry;
51 }
#define INT_MAX
Definition: cp-demangle.c:131

References zip::error, INT_MAX, zip::nentry, NULL, za, ZIP_ER_OPNOTSUPP, and zip_error_set().

Referenced by rz_io_zip_alloc_zipfileobj(), rz_io_zip_get_by_file_idx(), and rz_io_zip_get_files().

◆ zip_libzip_version()

ZIP_EXTERN const char* _Nonnull zip_libzip_version ( void  )

Definition at line 39 of file zip_libzip_version.c.

39  {
40  return LIBZIP_VERSION;
41 }
#define LIBZIP_VERSION
Definition: zipconf.h:11

References LIBZIP_VERSION.

◆ zip_name_locate()

ZIP_EXTERN zip_int64_t zip_name_locate ( zip_t _Nonnull,
const char *  _Nonnull,
zip_flags_t  flags 
)

Definition at line 44 of file zip_name_locate.c.

44  {
45  return _zip_name_locate(za, fname, flags, &za->error);
46 }
zip_int64_t _zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags, zip_error_t *error)

References _zip_name_locate(), zip::error, flags, create_tags_rz::fname, and za.

Referenced by main(), merge_zip(), name_locate(), rz_io_zip_flush_file(), zip_fopen(), zip_fopen_encrypted(), and zip_stat().

◆ zip_open()

ZIP_EXTERN zip_t* _Nullable zip_open ( const char *  _Nonnull,
int  _flags,
int _Nullable 
)

Definition at line 54 of file zip_open.c.

54  {
55  zip_t *za;
57  struct zip_error error;
58 
60  if ((src = zip_source_file_create(fn, 0, -1, &error)) == NULL) {
61  _zip_set_open_error(zep, &error, 0);
63  return NULL;
64  }
65 
66  if ((za = zip_open_from_source(src, _flags, &error)) == NULL) {
68  _zip_set_open_error(zep, &error, 0);
70  return NULL;
71  }
72 
74  return za;
75 }
ZIP_EXTERN zip_source_t *_Nullable zip_source_file_create(const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable)
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
Definition: sflib.h:186
ZIP_EXTERN zip_t * zip_open_from_source(zip_source_t *src, int _flags, zip_error_t *error)
Definition: zip_open.c:79

References _zip_set_open_error(), error(), fn, NULL, src, za, zip_error_fini(), zip_error_init(), zip_open_from_source(), zip_source_file_create(), and zip_source_free().

Referenced by add_from_zip(), list_zip(), main(), merge_zip(), read_from_file(), and rz_io_zip_open_archive().

◆ zip_open_from_source()

ZIP_EXTERN zip_t* _Nullable zip_open_from_source ( zip_source_t _Nonnull,
int  _flags,
zip_error_t _Nullable 
)

Definition at line 79 of file zip_open.c.

79  {
80  unsigned int flags;
81  zip_int64_t supported;
82  exists_t exists;
83 
84  if (_flags < 0 || src == NULL) {
86  return NULL;
87  }
88  flags = (unsigned int)_flags;
89 
90  supported = zip_source_supports(src);
93  return NULL;
94  }
96  flags |= ZIP_RDONLY;
97  }
98 
101  return NULL;
102  }
103 
104  exists = _zip_file_exists(src, error);
105  switch (exists) {
106  case EXISTS_ERROR:
107  return NULL;
108 
109  case EXISTS_NOT:
110  if ((flags & ZIP_CREATE) == 0) {
112  return NULL;
113  }
114  return _zip_allocate_new(src, flags, error);
115 
116  default: {
117  zip_t *za;
118  if (flags & ZIP_EXCL) {
120  return NULL;
121  }
122  if (zip_source_open(src) < 0) {
124  return NULL;
125  }
126 
127  if (flags & ZIP_TRUNCATE) {
129  }
130  else {
131  /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL, just like open() */
132  za = _zip_open(src, flags, error);
133  }
134 
135  if (za == NULL) {
137  return NULL;
138  }
139  return za;
140  }
141  }
142 }
#define ZIP_SOURCE_SUPPORTS_WRITABLE
Definition: zip.h:261
#define ZIP_ER_EXISTS
Definition: zip.h:115
#define ZIP_EXCL
Definition: zip.h:68
#define ZIP_CREATE
Definition: zip.h:67
static zip_t * _zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error)
Definition: zip_open.c:504
zip_t * _zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error)
Definition: zip_open.c:146
static exists_t _zip_file_exists(zip_source_t *src, zip_error_t *error)
Definition: zip_open.c:525
exists_t
Definition: zip_open.c:41
@ EXISTS_NOT
Definition: zip_open.c:41
@ EXISTS_ERROR
Definition: zip_open.c:41

References _zip_allocate_new(), _zip_error_set_from_source(), _zip_file_exists(), _zip_open(), error(), EXISTS_ERROR, EXISTS_NOT, flags, int, NULL, src, za, ZIP_CREATE, ZIP_ER_EXISTS, ZIP_ER_INVAL, ZIP_ER_NOENT, ZIP_ER_OPNOTSUPP, ZIP_ER_RDONLY, zip_error_set(), ZIP_EXCL, ZIP_RDONLY, zip_source_close(), zip_source_open(), zip_source_supports(), ZIP_SOURCE_SUPPORTS_SEEKABLE, ZIP_SOURCE_SUPPORTS_WRITABLE, and ZIP_TRUNCATE.

Referenced by LLVMFuzzerTestOneInput(), main(), read_from_file(), read_hole(), read_to_memory(), windows_open(), zip_fdopen(), and zip_open().

◆ zip_register_cancel_callback_with_state()

ZIP_EXTERN int zip_register_cancel_callback_with_state ( zip_t _Nonnull,
zip_cancel_callback  _Nullable,
void(*)(void *_Nullable _Nullable,
void *  _Nullable 
)

Referenced by cancel().

◆ zip_register_progress_callback()

ZIP_EXTERN void zip_register_progress_callback ( zip_t _Nonnull,
zip_progress_callback_t  _Nullable 
)

Definition at line 277 of file zip_progress.c.

277  {
278  struct legacy_ud *ud;
279 
280  if (progress_callback == NULL) {
282  }
283 
284  if ((ud = (struct legacy_ud *)malloc(sizeof(*ud))) == NULL) {
285  return;
286  }
287 
289 
291  free(ud);
292  }
293 }
zip_progress_callback_t callback
Definition: zip_progress.c:265
ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t *za, double precision, zip_progress_callback callback, void(*ud_free)(void *), void *ud)
Definition: zip_progress.c:211
static void _zip_legacy_progress_callback(zip_t *za, double progress, void *vud)
Definition: zip_progress.c:270
static void progress_callback(zip_t *archive, double percentage, void *ud)
Definition: ziptool.c:398

References _zip_legacy_progress_callback(), legacy_ud::callback, free(), malloc(), NULL, progress_callback(), za, and zip_register_progress_callback_with_state().

◆ zip_register_progress_callback_with_state()

ZIP_EXTERN int zip_register_progress_callback_with_state ( zip_t _Nonnull,
double  ,
zip_progress_callback  _Nullable,
void(*)(void *_Nullable _Nullable,
void *  _Nullable 
)

Referenced by print_progress().

◆ zip_rename()

ZIP_EXTERN int zip_rename ( zip_t _Nonnull,
zip_uint64_t  idx,
const char *  _Nonnull 
)

Definition at line 40 of file zip_rename.c.

40  {
41  return zip_file_rename(za, idx, name, 0);
42 }
ZIP_EXTERN int zip_file_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull, zip_flags_t)

References setup::idx, za, and zip_file_rename().

Referenced by zrename().

◆ zip_replace()

ZIP_EXTERN int zip_replace ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_source_t _Nonnull 
)

Definition at line 40 of file zip_replace.c.

40  {
41  return zip_file_replace(za, idx, source, 0);
42 }
ZIP_EXTERN int zip_file_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull, zip_flags_t)

References setup::idx, source, za, and zip_file_replace().

Referenced by main(), merge_zip(), and rz_io_zip_flush_file().

◆ zip_set_archive_comment()

ZIP_EXTERN int zip_set_archive_comment ( zip_t _Nonnull,
const char *  _Nullable,
zip_uint16_t  len 
)

Definition at line 41 of file zip_set_archive_comment.c.

41  {
42  zip_string_t *cstr;
43 
44  if (ZIP_IS_RDONLY(za)) {
46  return -1;
47  }
48 
49  if (len > 0 && comment == NULL) {
51  return -1;
52  }
53 
54  if (len > 0) {
55  if ((cstr = _zip_string_new((const zip_uint8_t *)comment, len, ZIP_FL_ENC_GUESS, &za->error)) == NULL)
56  return -1;
57 
59  _zip_string_free(cstr);
61  return -1;
62  }
63  }
64  else
65  cstr = NULL;
66 
69 
70  if (((za->comment_orig && _zip_string_equal(za->comment_orig, cstr)) || (za->comment_orig == NULL && cstr == NULL))) {
71  _zip_string_free(cstr);
72  za->comment_changed = 0;
73  }
74  else {
75  za->comment_changes = cstr;
76  za->comment_changed = 1;
77  }
78 
79  return 0;
80 }
bool comment_changed
Definition: zipint.h:290
@ ZIP_ENCODING_CP437
Definition: zipint.h:258

References _zip_guess_encoding(), _zip_string_equal(), _zip_string_free(), _zip_string_new(), zip::comment_changed, zip::comment_changes, zip::comment_orig, zip::error, len, NULL, za, ZIP_ENCODING_CP437, ZIP_ENCODING_UNKNOWN, ZIP_ER_INVAL, ZIP_ER_RDONLY, zip_error_set(), ZIP_FL_ENC_GUESS, and ZIP_IS_RDONLY.

Referenced by set_archive_comment().

◆ zip_set_archive_flag()

ZIP_EXTERN int zip_set_archive_flag ( zip_t _Nonnull,
zip_flags_t  flag,
int  value 
)

Definition at line 39 of file zip_set_archive_flag.c.

39  {
40  unsigned int new_flags;
41 
42  if (value)
43  new_flags = za->ch_flags | flag;
44  else
45  new_flags = za->ch_flags & ~flag;
46 
47  if (new_flags == za->ch_flags)
48  return 0;
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
55  if ((flag & ZIP_AFL_RDONLY) && value && (za->ch_flags & ZIP_AFL_RDONLY) == 0) {
56  if (_zip_changed(za, NULL)) {
58  return -1;
59  }
60  }
61 
62  za->ch_flags = new_flags;
63 
64  return 0;
65 }
static int value
Definition: cmd_api.c:93
#define ZIP_AFL_RDONLY
Definition: zip.h:94
#define ZIP_ER_CHANGED
Definition: zip.h:120

References _zip_changed(), zip::ch_flags, zip::error, NULL, value, za, ZIP_AFL_RDONLY, ZIP_ER_CHANGED, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.

◆ zip_set_default_password()

ZIP_EXTERN int zip_set_default_password ( zip_t _Nonnull,
const char *  _Nullable 
)

Definition at line 42 of file zip_set_default_password.c.

42  {
43  if (za == NULL)
44  return -1;
45 
47 
48  if (passwd && passwd[0] != '\0') {
49  if ((za->default_password = strdup(passwd)) == NULL) {
51  return -1;
52  }
53  }
54  else
56 
57  return 0;
58 }

References zip::default_password, zip::error, free(), NULL, strdup(), za, ZIP_ER_MEMORY, and zip_error_set().

Referenced by main(), and set_password().

◆ zip_set_file_comment()

ZIP_EXTERN int zip_set_file_comment ( zip_t _Nonnull,
zip_uint64_t  idx,
const char *  _Nullable,
int  len 
)

Definition at line 40 of file zip_set_file_comment.c.

40  {
41  if (len < 0 || len > ZIP_UINT16_MAX) {
43  return -1;
44  }
45  return zip_file_set_comment(za, idx, comment, (zip_uint16_t)len, 0);
46 }
ZIP_EXTERN int zip_file_set_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, zip_uint16_t, zip_flags_t)

References zip::error, setup::idx, len, za, ZIP_ER_INVAL, zip_error_set(), zip_file_set_comment(), and ZIP_UINT16_MAX.

◆ zip_set_file_compression()

ZIP_EXTERN int zip_set_file_compression ( zip_t _Nonnull,
zip_uint64_t  idx,
zip_int32_t  method,
zip_uint32_t  flags 
)

Definition at line 39 of file zip_set_file_compression.c.

39  {
40  zip_entry_t *e;
41  zip_int32_t old_method;
42 
43  if (idx >= za->nentry) {
45  return -1;
46  }
47 
48  if (ZIP_IS_RDONLY(za)) {
50  return -1;
51  }
52 
53  if (!zip_compression_method_supported(method, true)) {
55  return -1;
56  }
57 
58  e = za->entry + idx;
59 
60  old_method = (e->orig == NULL ? ZIP_CM_DEFAULT : e->orig->comp_method);
61 
62  /* TODO: do we want to recompress if level is set? Only if it's
63  * different than what bit flags tell us, but those are not
64  * defined for all compression methods, or not directly mappable
65  * to levels */
66 
67  if (method == old_method) {
68  if (e->changes) {
69  e->changes->changed &= ~ZIP_DIRENT_COMP_METHOD;
70  e->changes->compression_level = 0;
71  if (e->changes->changed == 0) {
72  _zip_dirent_free(e->changes);
73  e->changes = NULL;
74  }
75  }
76  }
77  else {
78  if (e->changes == NULL) {
79  if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
81  return -1;
82  }
83  }
84 
85  e->changes->comp_method = method;
86  e->changes->compression_level = (zip_uint16_t)flags;
87  e->changes->changed |= ZIP_DIRENT_COMP_METHOD;
88  }
89 
90  return 0;
91 }
ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress)
#define ZIP_CM_DEFAULT
Definition: zip.h:148
#define ZIP_ER_COMPNOTSUPP
Definition: zip.h:121
int32_t zip_int32_t
Definition: zipconf.h:36

References _zip_dirent_clone(), _zip_dirent_free(), e, zip::entry, zip::error, flags, setup::idx, zip::nentry, NULL, za, ZIP_CM_DEFAULT, zip_compression_method_supported(), ZIP_DIRENT_COMP_METHOD, ZIP_ER_COMPNOTSUPP, ZIP_ER_INVAL, ZIP_ER_MEMORY, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.

Referenced by set_file_compression().

◆ zip_source_begin_write()

ZIP_EXTERN int zip_source_begin_write ( zip_source_t _Nonnull)

Definition at line 39 of file zip_source_begin_write.c.

39  {
41  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
42  return -1;
43  }
44 
46  return -1;
47  }
48 
49  src->write_state = ZIP_SOURCE_WRITE_OPEN;
50 
51  return 0;
52 }
zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command)
@ ZIP_SOURCE_WRITE_OPEN
Definition: zipint.h:377
#define ZIP_SOURCE_IS_OPEN_WRITING(src)
Definition: zipint.h:403

References _zip_source_call(), NULL, src, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_IS_OPEN_WRITING, and ZIP_SOURCE_WRITE_OPEN.

Referenced by copy_source(), and zip_close().

◆ zip_source_begin_write_cloning()

ZIP_EXTERN int zip_source_begin_write_cloning ( zip_source_t _Nonnull,
zip_uint64_t  offset 
)

Definition at line 39 of file zip_source_begin_write_cloning.c.

39  {
41  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
42  return -1;
43  }
44 
46  return -1;
47  }
48 
49  src->write_state = ZIP_SOURCE_WRITE_OPEN;
50 
51  return 0;
52 }

References _zip_source_call(), NULL, src, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_BEGIN_WRITE_CLONING, ZIP_SOURCE_IS_OPEN_WRITING, and ZIP_SOURCE_WRITE_OPEN.

Referenced by zip_close().

◆ zip_source_buffer()

ZIP_EXTERN zip_source_t* _Nullable zip_source_buffer ( zip_t _Nonnull,
const void *  _Nullable,
zip_uint64_t  len,
int  freep 
)

Definition at line 88 of file zip_source_buffer.c.

88  {
89  if (za == NULL)
90  return NULL;
91 
92  return zip_source_buffer_with_attributes_create(data, len, freep, NULL, &za->error);
93 }
zip_source_t * zip_source_buffer_with_attributes_create(const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes, zip_error_t *error)

References zip::error, len, NULL, za, and zip_source_buffer_with_attributes_create().

Referenced by add(), main(), replace_file_contents(), rz_io_zip_flush_file(), and zip_dir_add().

◆ zip_source_buffer_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_buffer_create ( const void *  _Nullable,
zip_uint64_t  len,
int  freep,
zip_error_t _Nullable 
)

Definition at line 97 of file zip_source_buffer.c.

97  {
99 }

References error(), len, NULL, and zip_source_buffer_with_attributes_create().

Referenced by LLVMFuzzerTestOneInput(), main(), and read_to_memory().

◆ zip_source_buffer_fragment()

ZIP_EXTERN zip_source_t* _Nullable zip_source_buffer_fragment ( zip_t _Nonnull,
const zip_buffer_fragment_t _Nonnull,
zip_uint64_t  nfragments,
int  freep 
)

Definition at line 123 of file zip_source_buffer.c.

123  {
124  if (za == NULL) {
125  return NULL;
126  }
127 
128  return zip_source_buffer_fragment_with_attributes_create(fragments, nfragments, freep, NULL, &za->error);
129 }
zip_source_t * zip_source_buffer_fragment_with_attributes_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_file_attributes_t *attributes, zip_error_t *error)

References zip::error, NULL, za, and zip_source_buffer_fragment_with_attributes_create().

◆ zip_source_buffer_fragment_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_buffer_fragment_create ( const zip_buffer_fragment_t _Nullable,
zip_uint64_t  nfragments,
int  freep,
zip_error_t _Nullable 
)

Definition at line 133 of file zip_source_buffer.c.

133  {
134  return zip_source_buffer_fragment_with_attributes_create(fragments, nfragments, freep, NULL, error);
135 }

References error(), NULL, and zip_source_buffer_fragment_with_attributes_create().

Referenced by read_to_memory().

◆ zip_source_close()

ZIP_EXTERN int zip_source_close ( zip_source_t _Nonnull)

Definition at line 39 of file zip_source_close.c.

39  {
41  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
42  return -1;
43  }
44 
45  src->open_count--;
46  if (src->open_count == 0) {
48 
50  if (zip_source_close(src->src) < 0) {
51  zip_error_set(&src->error, ZIP_ER_INTERNAL, 0);
52  }
53  }
54  }
55 
56  return 0;
57 }
int zip_source_close(zip_source_t *src)
#define ZIP_SOURCE_IS_LAYERED(src)
Definition: zipint.h:404
#define ZIP_SOURCE_IS_OPEN_READING(src)
Definition: zipint.h:402

References _zip_source_call(), NULL, src, ZIP_ER_INTERNAL, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_CLOSE, zip_source_close(), ZIP_SOURCE_IS_LAYERED, and ZIP_SOURCE_IS_OPEN_READING.

Referenced by copy_source(), main(), write_memory_src_to_file(), zip_discard(), zip_open_from_source(), zip_source_close(), zip_source_commit_write(), zip_source_free(), zip_source_open(), and zip_source_remove().

◆ zip_source_commit_write()

ZIP_EXTERN int zip_source_commit_write ( zip_source_t _Nonnull)

Definition at line 39 of file zip_source_commit_write.c.

39  {
41  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
42  return -1;
43  }
44 
45  if (src->open_count > 1) {
46  zip_error_set(&src->error, ZIP_ER_INUSE, 0);
47  return -1;
48  }
49  else if (ZIP_SOURCE_IS_OPEN_READING(src)) {
50  if (zip_source_close(src) < 0) {
51  return -1;
52  }
53  }
54 
56  src->write_state = ZIP_SOURCE_WRITE_FAILED;
57  return -1;
58  }
59 
60  src->write_state = ZIP_SOURCE_WRITE_CLOSED;
61 
62  return 0;
63 }
#define ZIP_ER_INUSE
Definition: zip.h:134
@ ZIP_SOURCE_WRITE_CLOSED
Definition: zipint.h:376
@ ZIP_SOURCE_WRITE_FAILED
Definition: zipint.h:378

References _zip_source_call(), NULL, src, ZIP_ER_INUSE, ZIP_ER_INVAL, zip_error_set(), zip_source_close(), ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_IS_OPEN_READING, ZIP_SOURCE_IS_OPEN_WRITING, ZIP_SOURCE_WRITE_CLOSED, and ZIP_SOURCE_WRITE_FAILED.

Referenced by copy_source(), and zip_close().

◆ zip_source_error()

ZIP_EXTERN zip_error_t* _Nonnull zip_source_error ( zip_source_t _Nonnull)

◆ zip_source_file()

ZIP_EXTERN zip_source_t* _Nullable zip_source_file ( zip_t _Nonnull,
const char *  _Nonnull,
zip_uint64_t  start,
zip_int64_t  len 
)

Definition at line 93 of file zip_source_file_stdio_named.c.

93  {
94  if (za == NULL)
95  return NULL;
96 
98 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
Definition: sflib.h:133
ZIP_EXTERN zip_source_t * zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error)

References zip::error, create_tags_rz::fname, len, NULL, start, za, and zip_source_file_create().

Referenced by add_file().

◆ zip_source_file_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_file_create ( const char *  _Nonnull,
zip_uint64_t  start,
zip_int64_t  length,
zip_error_t _Nullable 
)

Definition at line 102 of file zip_source_file_stdio_named.c.

102  {
103  if (fname == NULL || length < -1) {
105  return NULL;
106  }
107 
109 }
zip_source_t * zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error)
static zip_source_file_operations_t ops_stdio_named

References error(), create_tags_rz::fname, free(), length, malloc(), NULL, ops_stdio_named, source, start, ZIP_ER_INVAL, ZIP_ER_MEMORY, zip_error_set(), zip_source_file_common_new(), and zip_source_win32w_create().

Referenced by open_file(), read_from_file(), zip_open(), and zip_source_file().

◆ zip_source_filep()

ZIP_EXTERN zip_source_t* _Nullable zip_source_filep ( zip_t _Nonnull,
FILE *  _Nonnull,
zip_uint64_t  start,
zip_int64_t  len 
)

Definition at line 70 of file zip_source_file_stdio.c.

70  {
71  if (za == NULL) {
72  return NULL;
73  }
74 
76 }
Definition: gzappend.c:170
ZIP_EXTERN zip_source_t * zip_source_filep_create(FILE *file, zip_uint64_t start, zip_int64_t length, zip_error_t *error)

References zip::error, len, NULL, start, za, and zip_source_filep_create().

Referenced by add_file(), and main().

◆ zip_source_filep_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_filep_create ( FILE *  _Nonnull,
zip_uint64_t  start,
zip_int64_t  length,
zip_error_t _Nullable 
)

Definition at line 80 of file zip_source_file_stdio.c.

80  {
81  if (file == NULL || length < -1) {
83  return NULL;
84  }
85 
87 }
static zip_source_file_operations_t ops_stdio_read

References error(), length, NULL, ops_stdio_read, start, ZIP_ER_INVAL, zip_error_set(), and zip_source_file_common_new().

Referenced by zip_fdopen(), and zip_source_filep().

◆ zip_source_free()

ZIP_EXTERN void zip_source_free ( zip_source_t _Nullable)

Definition at line 41 of file zip_source_free.c.

41  {
42  if (src == NULL)
43  return;
44 
45  if (src->refcount > 0) {
46  src->refcount--;
47  }
48  if (src->refcount > 0) {
49  return;
50  }
51 
53  src->open_count = 1; /* force close */
55  }
58  }
59 
60  if (src->source_archive && !src->source_closed) {
61  _zip_deregister_source(src->source_archive, src);
62  }
63 
65 
66  if (src->src) {
67  zip_source_free(src->src);
68  }
69 
70  free(src);
71 }
ZIP_EXTERN void zip_source_free(zip_source_t *src)
void _zip_deregister_source(zip_t *za, zip_source_t *src)

References _zip_deregister_source(), _zip_source_call(), free(), NULL, src, zip_source_close(), ZIP_SOURCE_FREE, zip_source_free(), ZIP_SOURCE_IS_OPEN_READING, ZIP_SOURCE_IS_OPEN_WRITING, and zip_source_rollback_write().

Referenced by _zip_source_zip_new(), _zip_unchange_data(), add(), add_data(), add_file(), add_from_zip(), add_nul(), LLVMFuzzerTestOneInput(), main(), merge_zip(), read_from_file(), read_hole(), read_to_memory(), replace_file_contents(), rz_io_zip_flush_file(), windows_open(), zip_close(), zip_dir_add(), zip_discard(), zip_fclose(), zip_fdopen(), zip_fopen_index_encrypted(), zip_open(), zip_source_free(), and ziptool_post_close().

◆ zip_source_function()

ZIP_EXTERN zip_source_t* _Nullable zip_source_function ( zip_t _Nonnull,
zip_source_callback  _Nonnull,
void *  _Nullable 
)

Definition at line 41 of file zip_source_function.c.

41  {
42  if (za == NULL) {
43  return NULL;
44  }
45 
46  return zip_source_function_create(zcb, ud, &za->error);
47 }
ZIP_EXTERN zip_source_t * zip_source_function_create(zip_source_callback zcb, void *ud, zip_error_t *error)

References zip::error, NULL, za, and zip_source_function_create().

Referenced by source_nul().

◆ zip_source_function_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_function_create ( zip_source_callback  _Nonnull,
void *  _Nullable,
zip_error_t _Nullable 
)

Definition at line 51 of file zip_source_function.c.

51  {
52  zip_source_t *zs;
53 
54  if ((zs = _zip_source_new(error)) == NULL)
55  return NULL;
56 
57  zs->cb.f = zcb;
58  zs->ud = ud;
59 
61  if (zs->supports < 0) {
63  }
64 
65  return zs;
66 }
ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t,...)
void * ud
Definition: zipint.h:389
zip_source_callback f
Definition: zipint.h:386
union zip_source::@410 cb
zip_int64_t supports
Definition: zipint.h:391
zip_source_t * _zip_source_new(zip_error_t *error)

References _zip_source_new(), zip_source::cb, error(), zip_source::f, NULL, zip_source::supports, zip_source::ud, zip_source_make_command_bitmap(), ZIP_SOURCE_SUPPORTS, and ZIP_SOURCE_SUPPORTS_READABLE.

Referenced by source_hole_create(), zip_source_buffer_fragment_with_attributes_create(), zip_source_file_common_new(), and zip_source_function().

◆ zip_source_get_file_attributes()

ZIP_EXTERN int zip_source_get_file_attributes ( zip_source_t _Nonnull,
zip_file_attributes_t _Nonnull 
)

Definition at line 43 of file zip_source_get_file_attributes.c.

43  {
44  if (src->source_closed) {
45  return -1;
46  }
47  if (attributes == NULL) {
48  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
49  return -1;
50  }
51 
52  zip_file_attributes_init(attributes);
53 
55  if (_zip_source_call(src, attributes, sizeof(*attributes), ZIP_SOURCE_GET_FILE_ATTRIBUTES) < 0) {
56  return -1;
57  }
58  }
59 
61  zip_file_attributes_t lower_attributes;
62 
63  if (zip_source_get_file_attributes(src->src, &lower_attributes) < 0) {
64  _zip_error_set_from_source(&src->error, src->src);
65  return -1;
66  }
67 
68  if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM) && (attributes->valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM) == 0) {
69  attributes->host_system = lower_attributes.host_system;
70  attributes->valid |= ZIP_FILE_ATTRIBUTES_HOST_SYSTEM;
71  }
72  if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_ASCII) && (attributes->valid & ZIP_FILE_ATTRIBUTES_ASCII) == 0) {
73  attributes->ascii = lower_attributes.ascii;
74  attributes->valid |= ZIP_FILE_ATTRIBUTES_ASCII;
75  }
76  if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED)) {
77  if (attributes->valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED) {
78  attributes->version_needed = ZIP_MAX(lower_attributes.version_needed, attributes->version_needed);
79  }
80  else {
81  attributes->version_needed = lower_attributes.version_needed;
82  attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED;
83  }
84  }
85  if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES) && (attributes->valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES) == 0) {
86  attributes->external_file_attributes = lower_attributes.external_file_attributes;
88  }
89  if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS)) {
90  if (attributes->valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS) {
91  /* only take from lower level what is not defined at current level */
92  lower_attributes.general_purpose_bit_mask &= ~attributes->general_purpose_bit_mask;
93 
94  attributes->general_purpose_bit_flags |= lower_attributes.general_purpose_bit_flags & lower_attributes.general_purpose_bit_mask;
95  attributes->general_purpose_bit_mask |= lower_attributes.general_purpose_bit_mask;
96  }
97  else {
99  attributes->general_purpose_bit_flags = lower_attributes.general_purpose_bit_flags;
100  attributes->general_purpose_bit_mask = lower_attributes.general_purpose_bit_mask;
101  }
102  }
103  }
104 
105  return 0;
106 }
#define ZIP_FILE_ATTRIBUTES_ASCII
Definition: zip.h:330
#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM
Definition: zip.h:329
#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES
Definition: zip.h:332
#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS
Definition: zip.h:333
#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED
Definition: zip.h:331
zip_uint8_t host_system
Definition: zip.h:321
zip_uint16_t general_purpose_bit_mask
Definition: zip.h:326
zip_uint8_t ascii
Definition: zip.h:322
zip_uint16_t general_purpose_bit_flags
Definition: zip.h:325
zip_uint8_t version_needed
Definition: zip.h:323
zip_uint32_t external_file_attributes
Definition: zip.h:324
zip_uint64_t valid
Definition: zip.h:319
int zip_source_get_file_attributes(zip_source_t *src, zip_file_attributes_t *attributes)
ZIP_EXTERN void zip_file_attributes_init(zip_file_attributes_t *attributes)
#define ZIP_MAX(a, b)
Definition: zipint.h:472

References _zip_error_set_from_source(), _zip_source_call(), zip_file_attributes::ascii, zip_file_attributes::external_file_attributes, zip_file_attributes::general_purpose_bit_flags, zip_file_attributes::general_purpose_bit_mask, zip_file_attributes::host_system, NULL, src, zip_file_attributes::valid, zip_file_attributes::version_needed, ZIP_ER_INVAL, zip_error_set(), ZIP_FILE_ATTRIBUTES_ASCII, ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES, ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS, ZIP_FILE_ATTRIBUTES_HOST_SYSTEM, zip_file_attributes_init(), ZIP_FILE_ATTRIBUTES_VERSION_NEEDED, ZIP_MAX, ZIP_SOURCE_GET_FILE_ATTRIBUTES, zip_source_get_file_attributes(), ZIP_SOURCE_IS_LAYERED, and ZIP_SOURCE_MAKE_COMMAND_BITMASK.

Referenced by add_data(), compress_callback(), and zip_source_get_file_attributes().

◆ zip_source_is_deleted()

ZIP_EXTERN int zip_source_is_deleted ( zip_source_t _Nonnull)

Definition at line 39 of file zip_source_is_deleted.c.

39  {
40  return src->write_state == ZIP_SOURCE_WRITE_REMOVED;
41 }
@ ZIP_SOURCE_WRITE_REMOVED
Definition: zipint.h:379

References src, and ZIP_SOURCE_WRITE_REMOVED.

Referenced by main().

◆ zip_source_keep()

ZIP_EXTERN void zip_source_keep ( zip_source_t _Nonnull)

Definition at line 70 of file zip_source_function.c.

70  {
71  src->refcount++;
72 }

References src.

Referenced by _zip_open(), add_data(), main(), read_to_memory(), and zip_source_layered_create().

◆ zip_source_make_command_bitmap()

ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap ( zip_source_cmd_t  cmd0,
  ... 
)

Definition at line 47 of file zip_source_supports.c.

47  {
48  zip_int64_t bitmap;
49  va_list ap;
50 
51  bitmap = ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd0);
52 
53 
54  va_start(ap, cmd0);
55  for (;;) {
56  int cmd = va_arg(ap, int);
57  if (cmd < 0) {
58  break;
59  }
61  }
62  va_end(ap);
63 
64  return bitmap;
65 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79

References cmd, and ZIP_SOURCE_MAKE_COMMAND_BITMASK.

Referenced by _zip_source_window_new(), compress_callback(), crc_read(), pkware_decrypt(), pkware_encrypt(), read_data(), source_hole_cb(), source_nul_cb(), winzip_aes_decrypt(), winzip_aes_encrypt(), zip_source_file_common_new(), and zip_source_function_create().

◆ zip_source_open()

ZIP_EXTERN int zip_source_open ( zip_source_t _Nonnull)

Definition at line 38 of file zip_source_open.c.

38  {
39  if (src->source_closed) {
40  return -1;
41  }
42  if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) {
43  zip_error_set(&src->error, ZIP_ER_DELETED, 0);
44  return -1;
45  }
46 
49  zip_error_set(&src->error, ZIP_ER_INUSE, 0);
50  return -1;
51  }
52  }
53  else {
55  if (zip_source_open(src->src) < 0) {
56  _zip_error_set_from_source(&src->error, src->src);
57  return -1;
58  }
59  }
60 
61  if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_OPEN) < 0) {
63  zip_source_close(src->src);
64  }
65  return -1;
66  }
67  }
68 
69  src->eof = false;
70  src->had_read_error = false;
71  _zip_error_clear(&src->error);
72  src->bytes_read = 0;
73  src->open_count++;
74 
75  return 0;
76 }
#define ZIP_ER_DELETED
Definition: zip.h:128
ZIP_EXTERN int zip_source_open(zip_source_t *src)

References _zip_error_clear(), _zip_error_set_from_source(), _zip_source_call(), NULL, src, ZIP_ER_DELETED, ZIP_ER_INUSE, zip_error_set(), zip_source_close(), ZIP_SOURCE_IS_LAYERED, ZIP_SOURCE_IS_OPEN_READING, ZIP_SOURCE_MAKE_COMMAND_BITMASK, ZIP_SOURCE_OPEN, zip_source_open(), ZIP_SOURCE_SEEK, zip_source_supports(), and ZIP_SOURCE_WRITE_REMOVED.

Referenced by copy_source(), main(), write_memory_src_to_file(), zip_fopen_index_encrypted(), zip_open_from_source(), and zip_source_open().

◆ zip_source_read()

ZIP_EXTERN zip_int64_t zip_source_read ( zip_source_t _Nonnull,
void *  _Nonnull,
zip_uint64_t  len 
)

Definition at line 39 of file zip_source_read.c.

39  {
40  zip_uint64_t bytes_read;
41  zip_int64_t n;
42 
43  if (src->source_closed) {
44  return -1;
45  }
46  if (!ZIP_SOURCE_IS_OPEN_READING(src) || len > ZIP_INT64_MAX || (len > 0 && data == NULL)) {
47  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
48  return -1;
49  }
50 
51  if (src->had_read_error) {
52  return -1;
53  }
54 
55  if (_zip_source_eof(src)) {
56  return 0;
57  }
58 
59  if (len == 0) {
60  return 0;
61  }
62 
63  bytes_read = 0;
64  while (bytes_read < len) {
65  if ((n = _zip_source_call(src, (zip_uint8_t *)data + bytes_read, len - bytes_read, ZIP_SOURCE_READ)) < 0) {
66  src->had_read_error = true;
67  if (bytes_read == 0) {
68  return -1;
69  }
70  else {
71  return (zip_int64_t)bytes_read;
72  }
73  }
74 
75  if (n == 0) {
76  src->eof = 1;
77  break;
78  }
79 
80  bytes_read += (zip_uint64_t)n;
81  }
82 
83  if (src->bytes_read + bytes_read < src->bytes_read) {
84  src->bytes_read = ZIP_UINT64_MAX;
85  }
86  else {
87  src->bytes_read += bytes_read;
88  }
89  return (zip_int64_t)bytes_read;
90 }
bool _zip_source_eof(zip_source_t *src)

References _zip_source_call(), _zip_source_eof(), len, n, NULL, src, ZIP_ER_INVAL, zip_error_set(), ZIP_INT64_MAX, ZIP_SOURCE_IS_OPEN_READING, ZIP_SOURCE_READ, and ZIP_UINT64_MAX.

Referenced by _zip_file_get_end(), _zip_read(), compress_read(), copy_source(), crc_read(), decrypt_header(), main(), pkware_decrypt(), pkware_encrypt(), verify_hmac(), window_read(), winzip_aes_decrypt(), winzip_aes_encrypt(), write_memory_src_to_file(), and zip_fread().

◆ zip_source_rollback_write()

ZIP_EXTERN void zip_source_rollback_write ( zip_source_t _Nonnull)

◆ zip_source_seek()

ZIP_EXTERN int zip_source_seek ( zip_source_t _Nonnull,
zip_int64_t  offset,
int  whence 
)

Definition at line 39 of file zip_source_seek.c.

39  {
41 
42  if (src->source_closed) {
43  return -1;
44  }
45  if (!ZIP_SOURCE_IS_OPEN_READING(src) || (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)) {
46  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
47  return -1;
48  }
49 
50  args.offset = offset;
51  args.whence = whence;
52 
53  if (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0) {
54  return -1;
55  }
56 
57  src->eof = 0;
58  return 0;
59 }
int args
Definition: mipsasm.c:18
#define SEEK_CUR
Definition: zip.c:80
#define SEEK_END
Definition: zip.c:84

References _zip_source_call(), args, SEEK_CUR, SEEK_END, SEEK_SET, src, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_IS_OPEN_READING, and ZIP_SOURCE_SEEK.

Referenced by _zip_checkcons(), _zip_dirent_size(), _zip_file_get_end(), _zip_file_get_offset(), _zip_find_central_dir(), _zip_read_cdir(), _zip_read_eocd64(), _zip_read_local_ef(), crc_read(), window_read(), zip_close(), and zip_fseek().

◆ zip_source_seek_compute_offset()

ZIP_EXTERN zip_int64_t zip_source_seek_compute_offset ( zip_uint64_t  offset,
zip_uint64_t  length,
void *  _Nonnull,
zip_uint64_t  data_length,
zip_error_t _Nullable 
)

Definition at line 63 of file zip_source_seek.c.

63  {
64  zip_int64_t new_offset;
66 
67  if (args == NULL) {
68  return -1;
69  }
70 
71  switch (args->whence) {
72  case SEEK_CUR:
73  new_offset = (zip_int64_t)offset + args->offset;
74  break;
75 
76  case SEEK_END:
77  new_offset = (zip_int64_t)length + args->offset;
78  break;
79 
80  case SEEK_SET:
81  new_offset = args->offset;
82  break;
83 
84  default:
86  return -1;
87  }
88 
89  if (new_offset < 0 || (zip_uint64_t)new_offset > length) {
91  return -1;
92  }
93 
94  return new_offset;
95 }
#define ZIP_SOURCE_GET_ARGS(type, data, len, error)
Definition: zip.h:279

References args, error(), length, NULL, SEEK_CUR, SEEK_END, SEEK_SET, ZIP_ER_INVAL, zip_error_set(), and ZIP_SOURCE_GET_ARGS.

Referenced by buffer_seek(), read_file(), and window_read().

◆ zip_source_seek_write()

ZIP_EXTERN int zip_source_seek_write ( zip_source_t _Nonnull,
zip_int64_t  offset,
int  whence 
)

Definition at line 39 of file zip_source_seek_write.c.

39  {
41 
42  if (!ZIP_SOURCE_IS_OPEN_WRITING(src) || (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)) {
43  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
44  return -1;
45  }
46 
47  args.offset = offset;
48  args.whence = whence;
49 
50  return (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK_WRITE) < 0 ? -1 : 0);
51 }

References _zip_source_call(), args, SEEK_CUR, SEEK_END, SEEK_SET, src, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_IS_OPEN_WRITING, and ZIP_SOURCE_SEEK_WRITE.

Referenced by add_data().

◆ zip_source_stat()

ZIP_EXTERN int zip_source_stat ( zip_source_t _Nonnull,
zip_stat_t _Nonnull 
)

Definition at line 39 of file zip_source_stat.c.

39  {
40  if (src->source_closed) {
41  return -1;
42  }
43  if (st == NULL) {
44  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
45  return -1;
46  }
47 
48  zip_stat_init(st);
49 
51  if (zip_source_stat(src->src, st) < 0) {
52  _zip_error_set_from_source(&src->error, src->src);
53  return -1;
54  }
55  }
56 
57  if (_zip_source_call(src, st, sizeof(*st), ZIP_SOURCE_STAT) < 0) {
58  return -1;
59  }
60 
61  return 0;
62 }
ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull)
Definition: zip_stat_init.c:40
ZIP_EXTERN int zip_source_stat(zip_source_t *src, zip_stat_t *st)

References _zip_error_set_from_source(), _zip_source_call(), NULL, src, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_IS_LAYERED, ZIP_SOURCE_STAT, zip_source_stat(), and zip_stat_init().

Referenced by _zip_file_exists(), _zip_open(), add_data(), compress_callback(), crc_read(), decrypt_header(), encrypt_header(), main(), write_memory_src_to_file(), zip_source_stat(), zip_source_winzip_aes_decode(), and zip_stat_index().

◆ zip_source_tell()

ZIP_EXTERN zip_int64_t zip_source_tell ( zip_source_t _Nonnull)

Definition at line 39 of file zip_source_tell.c.

39  {
40  if (src->source_closed) {
41  return -1;
42  }
44  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
45  return -1;
46  }
47 
49  if (src->bytes_read > ZIP_INT64_MAX) {
51  return -1;
52  }
53  return (zip_int64_t)src->bytes_read;
54  }
55 
57 }
#define EOVERFLOW
Definition: compat.h:75
#define ZIP_ER_TELL
Definition: zip.h:135

References _zip_source_call(), EOVERFLOW, NULL, src, ZIP_ER_INVAL, ZIP_ER_TELL, zip_error_set(), ZIP_INT64_MAX, ZIP_SOURCE_IS_OPEN_READING, ZIP_SOURCE_MAKE_COMMAND_BITMASK, ZIP_SOURCE_SEEK, and ZIP_SOURCE_TELL.

Referenced by _zip_find_central_dir(), _zip_read_cdir(), crc_read(), window_read(), and zip_ftell().

◆ zip_source_tell_write()

ZIP_EXTERN zip_int64_t zip_source_tell_write ( zip_source_t _Nonnull)

Definition at line 39 of file zip_source_tell_write.c.

39  {
41  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
42  return -1;
43  }
44 
46 }

References _zip_source_call(), NULL, src, ZIP_ER_INVAL, zip_error_set(), ZIP_SOURCE_IS_OPEN_WRITING, and ZIP_SOURCE_TELL_WRITE.

Referenced by _zip_cdir_write(), add_data(), write_cdir(), and zip_close().

◆ zip_source_window_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_window_create ( zip_source_t _Nonnull,
zip_uint64_t  start,
zip_int64_t  len,
zip_error_t _Nullable 
)

Definition at line 62 of file zip_source_window.c.

62  {
63  return _zip_source_window_new(src, start, len, NULL, 0, NULL, 0, error);
64 }
zip_source_t * _zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_file_attributes_t *attributes, zip_t *source_archive, zip_uint64_t source_index, zip_error_t *error)

References _zip_source_window_new(), error(), len, NULL, src, and start.

Referenced by _zip_source_zip_new().

◆ zip_source_write()

ZIP_EXTERN zip_int64_t zip_source_write ( zip_source_t _Nonnull,
const void *  _Nullable,
zip_uint64_t  length 
)

Definition at line 39 of file zip_source_write.c.

39  {
41  zip_error_set(&src->error, ZIP_ER_INVAL, 0);
42  return -1;
43  }
44 
45  return _zip_source_call(src, (void *)data, length, ZIP_SOURCE_WRITE);
46 }

References _zip_source_call(), length, src, ZIP_ER_INVAL, zip_error_set(), ZIP_INT64_MAX, ZIP_SOURCE_IS_OPEN_WRITING, and ZIP_SOURCE_WRITE.

Referenced by _zip_write(), and copy_source().

◆ zip_source_zip()

ZIP_EXTERN zip_source_t* _Nullable zip_source_zip ( zip_t _Nonnull,
zip_t _Nonnull,
zip_uint64_t  srcidx,
zip_flags_t  flags,
zip_uint64_t  start,
zip_int64_t  len 
)

Definition at line 57 of file zip_source_zip.c.

57  {
58  return zip_source_zip_create(srcza, srcidx, flags, start, len, &za->error);
59 }
ZIP_EXTERN zip_source_t * zip_source_zip_create(zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len, zip_error_t *error)

References zip::error, flags, len, start, za, and zip_source_zip_create().

Referenced by add_from_zip(), and merge_zip().

◆ zip_source_zip_create()

ZIP_EXTERN zip_source_t* _Nullable zip_source_zip_create ( zip_t _Nonnull,
zip_uint64_t  srcidx,
zip_flags_t  flags,
zip_uint64_t  start,
zip_int64_t  len,
zip_error_t _Nullable 
)

Definition at line 39 of file zip_source_zip.c.

39  {
40  if (len < -1) {
42  return NULL;
43  }
44 
45  if (len == -1)
46  len = 0;
47 
48  if (start == 0 && len == 0)
50  else
52 
53  return _zip_source_zip_new(srcza, srcidx, flags, start, (zip_uint64_t)len, NULL, error);
54 }
#define ZIP_FL_COMPRESSED
Definition: zip.h:78

References _zip_source_zip_new(), error(), flags, len, NULL, start, ZIP_ER_INVAL, zip_error_set(), and ZIP_FL_COMPRESSED.

Referenced by zip_source_zip().

◆ zip_stat()

ZIP_EXTERN int zip_stat ( zip_t _Nonnull,
const char *  _Nonnull,
zip_flags_t  flags,
zip_stat_t _Nonnull 
)

Definition at line 39 of file zip_stat.c.

39  {
41 
42  if ((idx = zip_name_locate(za, fname, flags)) < 0)
43  return -1;
44 
45  return zip_stat_index(za, (zip_uint64_t)idx, flags, st);
46 }
ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull)

References flags, create_tags_rz::fname, setup::idx, za, zip_name_locate(), and zip_stat_index().

◆ zip_stat_index()

ZIP_EXTERN int zip_stat_index ( zip_t _Nonnull,
zip_uint64_t  index,
zip_flags_t  flags,
zip_stat_t _Nonnull 
)

Definition at line 39 of file zip_stat_index.c.

39  {
40  const char *name;
41  zip_dirent_t *de;
42 
43  if ((de = _zip_get_dirent(za, index, flags, NULL)) == NULL)
44  return -1;
45 
46  if ((name = zip_get_name(za, index, flags)) == NULL)
47  return -1;
48 
49 
50  if ((flags & ZIP_FL_UNCHANGED) == 0 && ZIP_ENTRY_DATA_CHANGED(za->entry + index)) {
51  zip_entry_t *entry = za->entry + index;
52 
53  if (zip_source_stat(entry->source, st) < 0) {
55  return -1;
56  }
57 
58  if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
59  st->mtime = de->last_mod;
60  st->valid |= ZIP_STAT_MTIME;
61  }
62  }
63  else {
64  zip_stat_init(st);
65 
66  st->crc = de->crc;
67  st->size = de->uncomp_size;
68  st->mtime = de->last_mod;
69  st->comp_size = de->comp_size;
70  st->comp_method = (zip_uint16_t)de->comp_method;
71  st->encryption_method = de->encryption_method;
73  }
74 
75  st->index = index;
76  st->name = name;
77  st->valid |= ZIP_STAT_INDEX | ZIP_STAT_NAME;
78 
79  return 0;
80 }
#define ZIP_STAT_NAME
Definition: zip.h:290
#define ZIP_STAT_SIZE
Definition: zip.h:292
#define ZIP_STAT_COMP_METHOD
Definition: zip.h:296
ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull)
#define ZIP_STAT_ENCRYPTION_METHOD
Definition: zip.h:297
#define ZIP_STAT_COMP_SIZE
Definition: zip.h:293
#define ZIP_STAT_MTIME
Definition: zip.h:294
#define ZIP_STAT_INDEX
Definition: zip.h:291
#define ZIP_STAT_CRC
Definition: zip.h:295
time_t last_mod
Definition: zipint.h:337
zip_uint64_t uncomp_size
Definition: zipint.h:340
zip_uint32_t crc
Definition: zipint.h:338
zip_int32_t comp_method
Definition: zipint.h:336
bool crc_valid
Definition: zipint.h:331

References _zip_get_dirent(), zip_stat::comp_method, zip_dirent::comp_method, zip_stat::comp_size, zip_dirent::comp_size, zip_stat::crc, zip_dirent::crc, zip_dirent::crc_valid, zip_stat::encryption_method, zip_dirent::encryption_method, zip::entry, zip::error, flags, zip_stat::index, zip_dirent::last_mod, zip_stat::mtime, name, zip_stat::name, NULL, zip_stat::size, zip_dirent::uncomp_size, zip_stat::valid, za, ZIP_DIRENT_LAST_MOD, ZIP_ENTRY_DATA_CHANGED, ZIP_ER_CHANGED, zip_error_set(), ZIP_FL_UNCHANGED, zip_get_name(), zip_source_stat(), ZIP_STAT_COMP_METHOD, ZIP_STAT_COMP_SIZE, ZIP_STAT_CRC, ZIP_STAT_ENCRYPTION_METHOD, ZIP_STAT_INDEX, zip_stat_init(), ZIP_STAT_MTIME, ZIP_STAT_NAME, and ZIP_STAT_SIZE.

Referenced by _zip_source_zip_new(), confirm_replace(), list_zip(), rz_io_zip_alloc_zipfileobj(), rz_io_zip_get_by_file_idx(), rz_io_zip_get_files(), rz_io_zip_slurp_file(), zip_stat(), and zstat().

◆ zip_stat_init()

ZIP_EXTERN void zip_stat_init ( zip_stat_t _Nonnull)

◆ zip_strerror()

◆ zip_unchange()

ZIP_EXTERN int zip_unchange ( zip_t _Nonnull,
zip_uint64_t  idx 
)

Definition at line 41 of file zip_unchange.c.

41  {
42  return _zip_unchange(za, idx, 0);
43 }

References _zip_unchange(), setup::idx, and za.

Referenced by unchange_one().

◆ zip_unchange_all()

ZIP_EXTERN int zip_unchange_all ( zip_t _Nonnull)

Definition at line 39 of file zip_unchange_all.c.

39  {
40  int ret;
42 
43  if (!_zip_hash_revert(za->names, &za->error)) {
44  return -1;
45  }
46 
47  ret = 0;
48  for (i = 0; i < za->nentry; i++)
49  ret |= _zip_unchange(za, i, 1);
50 
51  ret |= zip_unchange_archive(za);
52 
53  return ret;
54 }
ZIP_EXTERN int zip_unchange_archive(zip_t *_Nonnull)
bool _zip_hash_revert(zip_hash_t *hash, zip_error_t *error)
Definition: zip_hash.c:369

References _zip_hash_revert(), _zip_unchange(), zip::error, i, zip::names, zip::nentry, za, and zip_unchange_archive().

Referenced by main(), and unchange_all().

◆ zip_unchange_archive()

ZIP_EXTERN int zip_unchange_archive ( zip_t _Nonnull)

Definition at line 41 of file zip_unchange_archive.c.

41  {
42  if (za->comment_changed) {
45  za->comment_changed = 0;
46  }
47 
48  za->ch_flags = za->flags;
49 
50  return 0;
51 }

References _zip_string_free(), zip::ch_flags, zip::comment_changed, zip::comment_changes, zip::flags, NULL, and za.

Referenced by zip_unchange_all().