| 1 |
#ifndef _ZZIP_FORMATS_H |
| 2 |
#define _ZZIP_FORMATS_H |
| 3 |
|
| 4 |
#include <zzip/types.h> |
| 5 |
#include <zzip/format.h> |
| 6 |
#include <zzip/stdint.h> |
| 7 |
#include <zzip/__hints.h> |
| 8 |
|
| 9 |
/* linux knows "byteswap.h" giving us an optimized variant */ |
| 10 |
#ifdef ZZIP_HAVE_BYTESWAP_H |
| 11 |
#include <byteswap.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifdef __cplusplus |
| 15 |
extern "C" { |
| 16 |
#endif |
| 17 |
|
| 18 |
/* get 16/32 bits from little-endian zip-file to host byteorder */ |
| 19 |
extern uint32_t __zzip_get32(zzip_byte_t * s) ZZIP_GNUC_CONST; |
| 20 |
extern uint16_t __zzip_get16(zzip_byte_t * s) ZZIP_GNUC_CONST; |
| 21 |
extern void __zzip_set32(zzip_byte_t * s, uint32_t v); |
| 22 |
extern void __zzip_set16(zzip_byte_t * s, uint16_t v); |
| 23 |
|
| 24 |
extern uint64_t __zzip_get64(zzip_byte_t * s) ZZIP_GNUC_CONST; |
| 25 |
extern void __zzip_set64(zzip_byte_t * s, uint64_t v); |
| 26 |
|
| 27 |
/* just in case that you use a non-configure-d setup (e.g. MSVC) */ |
| 28 |
#ifndef ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED |
| 29 |
# if defined __mips__ || defined __sparc__ || defined __powerpc__ || defined __arm__ || defined __ia64__ |
| 30 |
# define ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED 11 |
| 31 |
# endif |
| 32 |
#endif |
| 33 |
|
| 34 |
/* on linux with a cisc processor we can use the bswap for some extra speed */ |
| 35 |
#ifdef ZZIP_WORDS_BIGENDIAN |
| 36 |
# ifndef ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED |
| 37 |
# if defined bswap_16 && defined bswap_32 && defined bswap_64 /* i.e. linux */ |
| 38 |
# define _ZZIP_USE_BSWAP |
| 39 |
# endif |
| 40 |
# endif |
| 41 |
#endif |
| 42 |
|
| 43 |
/* little endian on intel cisc processors is the original zip format byteorder */ |
| 44 |
#ifndef ZZIP_WORDS_BIGENDIAN |
| 45 |
# ifndef ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED |
| 46 |
# if defined __i386__ || defined __x86_64__ || defined _M_X86 || defined _M_X64 |
| 47 |
# define _ZZIP_USE_DEREF |
| 48 |
# endif |
| 49 |
# endif |
| 50 |
#endif |
| 51 |
|
| 52 |
#ifdef _ZZIP_USE_BSWAP |
| 53 |
#define ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) |
| 54 |
#define ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) |
| 55 |
#define ZZIP_GET64(__p) bswap_64(*(uint64_t*)(__p)) |
| 56 |
#define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) |
| 57 |
#define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x))) |
| 58 |
#define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = bswap_64((uint64_t)(__x))) |
| 59 |
#elif defined _ZZIP_USE_DEREF |
| 60 |
#define ZZIP_GET16(__p) (*(uint16_t*)(__p)) |
| 61 |
#define ZZIP_GET32(__p) (*(uint32_t*)(__p)) |
| 62 |
#define ZZIP_GET64(__p) (*(uint64_t*)(__p)) |
| 63 |
#define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = (uint16_t)(__x)) |
| 64 |
#define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = (uint32_t)(__x)) |
| 65 |
#define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = (uint64_t)(__x)) |
| 66 |
#else |
| 67 |
#define ZZIP_GET64(__p) (__zzip_get64((__p))) |
| 68 |
#define ZZIP_GET32(__p) (__zzip_get32((__p))) |
| 69 |
#define ZZIP_GET16(__p) (__zzip_get16((__p))) |
| 70 |
#define ZZIP_SET64(__p,__x) (__zzip_set64((__p),(__x))) |
| 71 |
#define ZZIP_SET32(__p,__x) (__zzip_set32((__p),(__x))) |
| 72 |
#define ZZIP_SET16(__p,__x) (__zzip_set16((__p),(__x))) |
| 73 |
#endif |
| 74 |
|
| 75 |
/* ..................... bitcorrect physical access .................... */ |
| 76 |
|
| 77 |
/* zzip_file_header - the local file header */ |
| 78 |
#define zzip_file_header_get_magic(__p) ZZIP_GET32((__p)->z_magic) |
| 79 |
#define zzip_file_header_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) |
| 80 |
#define zzip_file_header_get_flags(__p) ZZIP_GET16((__p)->z_flags) |
| 81 |
#define zzip_file_header_set_flags(__p,__x) ZZIP_SET16((__p)->z_flags,(__x)) |
| 82 |
#define zzip_file_header_get_compr(__p) ZZIP_GET16((__p)->z_compr) |
| 83 |
#define zzip_file_header_set_compr(__p,__x) ZZIP_SET16((__p)->z_compr,(__x)) |
| 84 |
#define zzip_file_header_get_crc32(__p) ZZIP_GET32((__p)->z_crc32) |
| 85 |
#define zzip_file_header_set_crc32(__p,__x) ZZIP_SET32((__p)->z_crc32,(__x)) |
| 86 |
#define zzip_file_header_get_csize(__p) ZZIP_GET32((__p)->z_csize) |
| 87 |
#define zzip_file_header_set_csize(__p,__x) ZZIP_SET32((__p)->z_csize,(__x)) |
| 88 |
#define zzip_file_header_get_usize(__p) ZZIP_GET32((__p)->z_usize) |
| 89 |
#define zzip_file_header_set_usize(__p,__x) ZZIP_SET32((__p)->z_usize,(__x)) |
| 90 |
#define zzip_file_header_get_namlen(__p) ZZIP_GET16((__p)->z_namlen) |
| 91 |
#define zzip_file_header_set_namlen(__p,__x) ZZIP_SET16((__p)->z_namlen,(__x)) |
| 92 |
#define zzip_file_header_get_extras(__p) ZZIP_GET16((__p)->z_extras) |
| 93 |
#define zzip_file_header_set_extras(__p,__x) ZZIP_SET16((__p)->z_extras,(__x)) |
| 94 |
#define zzip_file_header_sizeof_tails(__p) (zzip_file_header_get_namlen(__p)+\ |
| 95 |
zzip_file_header_get_extras(__p) ) |
| 96 |
#define zzip_file_header_check_magic(__p) ZZIP_FILE_HEADER_CHECKMAGIC((__p)) |
| 97 |
|
| 98 |
/* zzip_file_trailer - data descriptor per file block */ |
| 99 |
#define zzip_file_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic) |
| 100 |
#define zzip_file_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) |
| 101 |
#define zzip_file_header_get_crc32(__p) ZZIP_GET32((__p)->z_crc32) |
| 102 |
#define zzip_file_trailer_set_crc32(__p,__x) ZZIP_SET32((__p)->z_crc32,(__x)) |
| 103 |
#define zzip_file_trailer_get_csize(__p) ZZIP_GET32((__p)->z_csize) |
| 104 |
#define zzip_file_trailer_set_csize(__p,__x) ZZIP_SET32((__p)->z_csize,(__x)) |
| 105 |
#define zzip_file_trailer_get_usize(__p) ZZIP_GET32((__p)->z_usize) |
| 106 |
#define zzip_file_trailer_set_usize(__p,__x) ZZIP_SET32((__p)->z_usize,(__x)) |
| 107 |
#define zzip_file_trailer_sizeof_tails(__p) 0 |
| 108 |
#define zzip_file_trailer_check_magic(__p) ZZIP_FILE_TRAILER_CHECKMAGIC((__p)) |
| 109 |
/* zzip_disk_entry (currently named zzip_root_dirent) */ |
| 110 |
#define zzip_disk_entry_get_magic(__p) ZZIP_GET32((__p)->z_magic) |
| 111 |
#define zzip_disk_entry_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) |
| 112 |
#define zzip_disk_entry_get_flags(__p) ZZIP_GET16((__p)->z_flags) |
| 113 |
#define zzip_disk_entry_set_flags(__p,__x) ZZIP_SET16((__p)->z_flags,(__x)) |
| 114 |
#define zzip_disk_entry_get_compr(__p) ZZIP_GET16((__p)->z_compr) |
| 115 |
#define zzip_disk_entry_set_compr(__p,__x) ZZIP_SET16((__p)->z_compr,(__x)) |
| 116 |
#define zzip_disk_entry_get_crc32(__p) ZZIP_GET32((__p)->z_crc32) |
| 117 |
#define zzip_disk_entry_set_crc32(__p,__x) ZZIP_SET32((__p)->z_crc32,(__x)) |
| 118 |
#define zzip_disk_entry_get_csize(__p) ZZIP_GET32((__p)->z_csize) |
| 119 |
#define zzip_disk_entry_set_csize(__p,__x) ZZIP_SET32((__p)->z_csize,(__x)) |
| 120 |
#define zzip_disk_entry_get_usize(__p) ZZIP_GET32((__p)->z_usize) |
| 121 |
#define zzip_disk_entry_set_usize(__p,__x) ZZIP_SET32((__p)->z_usize,(__x)) |
| 122 |
#define zzip_disk_entry_get_namlen(__p) ZZIP_GET16((__p)->z_namlen) |
| 123 |
#define zzip_disk_entry_set_namlen(__p,__x) ZZIP_SET16((__p)->z_namlen,(__x)) |
| 124 |
#define zzip_disk_entry_get_extras(__p) ZZIP_GET16((__p)->z_extras) |
| 125 |
#define zzip_disk_entry_set_extras(__p,__x) ZZIP_SET16((__p)->z_extras,(__x)) |
| 126 |
#define zzip_disk_entry_get_comment(__p) ZZIP_GET16((__p)->z_comment) |
| 127 |
#define zzip_disk_entry_set_comment(__p,__x) ZZIP_SET16((__p)->z_comment,(__x)) |
| 128 |
#define zzip_disk_entry_get_diskstart(__p) ZZIP_GET16((__p)->z_diskstart) |
| 129 |
#define zzip_disk_entry_set_diskstart(__p,__x) ZZIP_SET16((__p)->z_diskstart,(__x)) |
| 130 |
#define zzip_disk_entry_get_filetype(__p) ZZIP_GET16((__p)->z_filetype) |
| 131 |
#define zzip_disk_entry_set_filetype(__p,__x) ZZIP_SET16((__p)->z_filetype,(__x)) |
| 132 |
#define zzip_disk_entry_get_filemode(__p) ZZIP_GET32((__p)->z_filemode) |
| 133 |
#define zzip_disk_entry_set_filemode(__p,__x) ZZIP_SET32((__p)->z_filemode,(__x)) |
| 134 |
#define zzip_disk_entry_get_offset(__p) ZZIP_GET32((__p)->z_offset) |
| 135 |
#define zzip_disk_entry_set_offset(__p,__x) ZZIP_SET32((__p)->z_offset,(__x)) |
| 136 |
#define zzip_disk_entry_sizeof_tails(__p) (zzip_disk_entry_get_namlen(__p) +\ |
| 137 |
zzip_disk_entry_get_extras(__p) +\ |
| 138 |
zzip_disk_entry_get_comment(__p) ) |
| 139 |
#define zzip_disk_entry_check_magic(__p) ZZIP_DISK_ENTRY_CHECKMAGIC((__p)) |
| 140 |
|
| 141 |
/* zzip_disk_trailer - the zip archive entry point */ |
| 142 |
#define zzip_disk_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic) |
| 143 |
#define zzip_disk_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) |
| 144 |
#define zzip_disk_trailer_get_disk(__p) ZZIP_GET16((__p)->z_disk) |
| 145 |
#define zzip_disk_trailer_set_disk(__p,__x) ZZIP_SET16((__p)->z_disk,(__x)) |
| 146 |
#define zzip_disk_trailer_get_finaldisk(__p) ZZIP_GET16((__p)->z_finaldisk) |
| 147 |
#define zzip_disk_trailer_set_finaldisk(__p,__x) ZZIP_SET16((__p)->z_finaldisk,(__x)) |
| 148 |
#define zzip_disk_trailer_get_entries(__p) ZZIP_GET16((__p)->z_entries) |
| 149 |
#define zzip_disk_trailer_set_entries(__p,__x) ZZIP_SET16((__p)->z_entries,(__x)) |
| 150 |
#define zzip_disk_trailer_get_finalentries(__p) ZZIP_GET16((__p)->z_finalentries) |
| 151 |
#define zzip_disk_trailer_set_finalentries(__p,__x) ZZIP_SET16((__p)->z_finalentries,(__x)) |
| 152 |
#define zzip_disk_trailer_get_rootsize(__p) ZZIP_GET32((__p)->z_rootsize) |
| 153 |
#define zzip_disk_trailer_set_rootsize(__p,__x) ZZIP_SET32((__p)->z_rootsize,(__x)) |
| 154 |
#define zzip_disk_trailer_get_rootseek(__p) ZZIP_GET32((__p)->z_rootseek) |
| 155 |
#define zzip_disk_trailer_set_rootseek(__p,__x) ZZIP_SET32((__p)->z_rootseek,(__x)) |
| 156 |
#define zzip_disk_trailer_get_comment(__p) ZZIP_GET16((__p)->z_comment) |
| 157 |
#define zzip_disk_trailer_set_comment(__p,__x) ZZIP_SET16((__p)->z_comment,(__x)) |
| 158 |
#define zzip_disk_trailer_sizeof_tails(__p) ( zzip_disk_entry_get_comment(__p)) |
| 159 |
#define zzip_disk_trailer_check_magic(__p) ZZIP_DISK_TRAILER_CHECKMAGIC((__p)) |
| 160 |
|
| 161 |
/* extra field should be type + size + data + type + size + data ... */ |
| 162 |
#define zzip_extra_block_get_datatype(__p) ZZIP_GET16((zzip_byte_t*)(__p)) |
| 163 |
#define zzip_extra_block_set_datatype(__p,__x) ZZIP_SET16((zzip_byte_t*)(__p),__x) |
| 164 |
#define zzip_extra_block_get_datasize(__p) ZZIP_GET16((zzip_byte_t*)(__p)+2) |
| 165 |
#define zzip_extra_block_set_datasize(__p,__x) ZZIP_SET16((zzip_byte_t*)(__p)+2,__x) |
| 166 |
|
| 167 |
#define zzip_extra_zip64_get_datatype(__p) ZZIP_GET16((__p)->z_datatype) |
| 168 |
#define zzip_extra_zip64_set_datatype(__p,__x) ZZIP_SET16((__p)->z_datatype,(__x)) |
| 169 |
#define zzip_extra_zip64_get_datasize(__p) ZZIP_GET16((__p)->z_datasize) |
| 170 |
#define zzip_extra_zip64_set_datasize(__p,__x) ZZIP_SET16((__p)->z_datasize,(__x)) |
| 171 |
#define zzip_extra_zip64_get_usize(__p) ZZIP_GET64((__p)->z_usize) |
| 172 |
#define zzip_extra_zip64_set_usize(__p,__x ) ZZIP_SET64((__p)->z_usize,(__x)) |
| 173 |
#define zzip_extra_zip64_get_csize(__p) ZZIP_GET64((__p)->z_csize) |
| 174 |
#define zzip_extra_zip64_set_csize(__p,__x ) ZZIP_SET64((__p)->z_csize,(__x)) |
| 175 |
#define zzip_extra_zip64_get_offset(__p) ZZIP_GET64((__p)->z_offset) |
| 176 |
#define zzip_extra_zip64_set_offset(__p,__x) ZZIP_SET64((__p)->z_offset,(__x)) |
| 177 |
#define zzip_extra_zip64_get_diskstart(__p) ZZIP_GET32((__p)->z_diskstart) |
| 178 |
#define zzip_extra_zip64_set_diskstart(__p,__x) ZZIP_SET32((__p)->z_diskstart,(__x)) |
| 179 |
|
| 180 |
/* zzip64_disk_locator - used inside the old central directory */ |
| 181 |
#define zzip_disk64_locator_get_magic(__p) ZZIP_GET32((__p)->z_magic) |
| 182 |
#define zzip_disk64_locator_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) |
| 183 |
#define zzip_disk64_locator_get_rootdisk(__p) ZZIP_GET32((__p)->z_rootdisk) |
| 184 |
#define zzip_disk64_locator_set_rootdisk(__p,__x) ZZIP_SET32((__p)->z_rootdisk,(__x)) |
| 185 |
#define zzip_disk64_locator_get_rootseek(__p) ZZIP_GET64((__p)->z_rootseek) |
| 186 |
#define zzip_disk64_locator_set_rootseek(__p,__x) ZZIP_SET64((__p)->z_rootseek,(__x)) |
| 187 |
#define zzip_disk64_locator_get_numdisks(__p) ZZIP_GET32((__p)->z_numdisks) |
| 188 |
#define zzip_disk64_locator_set_numdisks(__p,__x) ZZIP_SET32((__p)->z_numdisks,(__x)) |
| 189 |
#define zzip_disk64_locator_check_magic(__p) ZZIP_DISK64_LOCATOR_CHECKMAGIC((__p)) |
| 190 |
|
| 191 |
/* zzip64_disk_trailer - the zip64 archive entry point */ |
| 192 |
#define zzip_disk64_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic) |
| 193 |
#define zzip_disk64_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x)) |
| 194 |
#define zzip_disk64_trailer_get_size(__p) ZZIP_GET64((__p)->z_size) |
| 195 |
#define zzip_disk64_trailer_set_size(__p,__x) ZZIP_SET64((__p)->z_size,(__x)) |
| 196 |
#define zzip_disk64_trailer_get_disk(__p) ZZIP_GET32((__p)->z_disk) |
| 197 |
#define zzip_disk64_trailer_set_disk(__p,__x) ZZIP_SET32((__p)->z_disk,(__x)) |
| 198 |
#define zzip_disk64_trailer_get_finaldisk(__p) ZZIP_GET32((__p)->z_finaldisk) |
| 199 |
#define zzip_disk64_trailer_set_finaldisk(__p,__x) ZZIP_SET32((__p)->z_finaldisk,(__x)) |
| 200 |
#define zzip_disk64_trailer_get_entries(__p) ZZIP_GET64((__p)->z_entries) |
| 201 |
#define zzip_disk64_trailer_set_entries(__p,__x) ZZIP_SET64((__p)->z_entries,(__x)) |
| 202 |
#define zzip_disk64_trailer_get_finalentries(__p) ZZIP_GET64((__p)->z_finalentries) |
| 203 |
#define zzip_disk64_trailer_set_finalentries(__p,__x) ZZIP_SET64((__p)->z_finalentries,(__x)) |
| 204 |
#define zzip_disk64_trailer_get_rootsize(__p) ZZIP_GET64((__p)->z_rootsize) |
| 205 |
#define zzip_disk64_trailer_set_rootsize(__p,__x) ZZIP_SET64((__p)->z_rootsize,(__x)) |
| 206 |
#define zzip_disk64_trailer_get_rootseek(__p) ZZIP_GET64((__p)->z_rootseek) |
| 207 |
#define zzip_disk64_trailer_set_rootseek(__p,__x) ZZIP_SET64((__p)->z_rootseek,(__x)) |
| 208 |
#define zzip_disk64_trailer_check_magic(__p) ZZIP_DISK64_TRAILER_CHECKMAGIC((__p)) |
| 209 |
|
| 210 |
/* .............. some logical typed access wrappers ....................... */ |
| 211 |
|
| 212 |
/* zzip_file_header - the local file header */ |
| 213 |
#define zzip_file_header_csize(__p) ((zzip_size_t) \ |
| 214 |
zzip_file_header_get_csize(__p)) |
| 215 |
#define zzip_file_header_usize(__p) ((zzip_size_t) \ |
| 216 |
zzip_file_header_get_usize(__p)) |
| 217 |
#define zzip_file_header_namlen(__p) ((zzip_size_t) \ |
| 218 |
zzip_file_header_get_namlen(__p)) |
| 219 |
#define zzip_file_header_extras(__p) ((zzip_size_t) \ |
| 220 |
zzip_file_header_get_extras(__p)) |
| 221 |
#define zzip_file_header_sizeof_tail(__p) ((zzip_size_t) \ |
| 222 |
zzip_file_header_sizeof_tails(__p)) |
| 223 |
#define zzip_file_header_sizeto_end(__p) ((zzip_size_t) \ |
| 224 |
(zzip_file_header_sizeof_tail(__p) + zzip_file_header_headerlength)) |
| 225 |
#define zzip_file_header_skipto_end(__p) ((void*) (__p) + \ |
| 226 |
(zzip_file_header_sizeof_tail(__p) + zzip_file_header_headerlength)) |
| 227 |
|
| 228 |
#define zzip_file_header_to_filename(__p) ((char*) \ |
| 229 |
((char*)(__p) + zzip_file_header_headerlength)) |
| 230 |
#define zzip_file_header_to_extras(__p) ((char*) \ |
| 231 |
(zzip_file_header_to_filename(__p) + zzip_file_header_namlen(__p))) |
| 232 |
#define zzip_file_header_to_data(__p) ((zzip_byte_t*) \ |
| 233 |
(zzip_file_header_to_extras(__p) + zzip_file_header_extras(__p))) |
| 234 |
#define zzip_file_header_to_trailer(__p) ((struct zzip_file_trailer*) \ |
| 235 |
(zzip_file_header_to_data(__p) + zzip_file_header_csize(__p))) |
| 236 |
|
| 237 |
/* zzip_file_trailer - data descriptor per file block */ |
| 238 |
#define zzip_file_trailer_csize(__p) ((zzip_size_t) \ |
| 239 |
zzip_file_trailer_get_csize(__p)) |
| 240 |
#define zzip_file_trailer_usize(__p) ((zzip_size_t) \ |
| 241 |
zzip_file_trailer_get_usize(__p)) |
| 242 |
#define zzip_file_trailer_sizeof_tail(__p) ((zzip_size_t) \ |
| 243 |
zzip_file_trailer_sizeof_tails(__p)) |
| 244 |
#define zzip_file_trailer_sizeto_end(__p) ((zzip_size_t) \ |
| 245 |
(zzip_file_trailer_sizeof_tail(__p) + zzip_file_trailer_headerlength)) |
| 246 |
#define zzip_file_trailer_skipto_end(__p) ((void*) (__p) + \ |
| 247 |
(zzip_file_trailer_sizeof_tail(__p) + zzip_file_trailer_headerlength)) |
| 248 |
|
| 249 |
/* zzip_disk_entry (currently named zzip_root_dirent) */ |
| 250 |
#define zzip_disk_entry_csize(__p) ((zzip_size_t) \ |
| 251 |
zzip_disk_entry_get_csize(__p)) |
| 252 |
#define zzip_disk_entry_usize(__p) ((zzip_size_t) \ |
| 253 |
zzip_disk_entry_get_usize(__p)) |
| 254 |
#define zzip_disk_entry_namlen(__p) ((zzip_size_t) \ |
| 255 |
zzip_disk_entry_get_namlen(__p)) |
| 256 |
#define zzip_disk_entry_extras(__p) ((zzip_size_t) \ |
| 257 |
zzip_disk_entry_get_extras(__p)) |
| 258 |
#define zzip_disk_entry_comment(__p) ((zzip_size_t) \ |
| 259 |
zzip_disk_entry_get_comment(__p)) |
| 260 |
#define zzip_disk_entry_diskstart(__p) ((int) \ |
| 261 |
zzip_disk_entry_get_diskstart(__p)) |
| 262 |
#define zzip_disk_entry_filetype(__p) ((int) \ |
| 263 |
zzip_disk_entry_get_filetype(__p)) |
| 264 |
#define zzip_disk_entry_filemode(__p) ((int) \ |
| 265 |
zzip_disk_entry_get_filemode(__p)) |
| 266 |
#define zzip_disk_entry_fileoffset(__p) ((zzip_off_t) \ |
| 267 |
zzip_disk_entry_get_offset(__p)) |
| 268 |
#define zzip_disk_entry_sizeof_tail(__p) ((zzip_size_t) \ |
| 269 |
zzip_disk_entry_sizeof_tails(__p)) |
| 270 |
#define zzip_disk_entry_sizeto_end(__p) ((zzip_size_t) \ |
| 271 |
(zzip_disk_entry_sizeof_tail(__p) + zzip_disk_entry_headerlength)) |
| 272 |
#define zzip_disk_entry_skipto_end(__p) ((zzip_byte_t*) (__p) + \ |
| 273 |
(zzip_disk_entry_sizeof_tail(__p) + zzip_disk_entry_headerlength)) |
| 274 |
|
| 275 |
#define zzip_disk_entry_to_filename(__p) ((char*) \ |
| 276 |
((char*)(__p) + zzip_disk_entry_headerlength)) |
| 277 |
#define zzip_disk_entry_to_extras(__p) ((char*) \ |
| 278 |
(zzip_disk_entry_to_filename(__p) + zzip_disk_entry_namlen(__p))) |
| 279 |
#define zzip_disk_entry_to_comment(__p) ((char*) \ |
| 280 |
(zzip_disk_entry_to_extras(__p) + zzip_disk_entry_extras(__p))) |
| 281 |
#define zzip_disk_entry_to_next_entry(__p) ((struct zzip_disk_entry*) \ |
| 282 |
(zzip_disk_entry_to_comment(__p) + zzip_disk_entry_comment(__p))) |
| 283 |
|
| 284 |
/* zzip_disk_trailer - the zip archive entry point */ |
| 285 |
#define zzip_disk_trailer_localdisk(__p) ((int) \ |
| 286 |
zzip_disk_trailer_get_disk(__p)) |
| 287 |
#define zzip_disk_trailer_finaldisk(__p) ((int) \ |
| 288 |
zzip_disk_trailer_get_finaldisk(__p)) |
| 289 |
#define zzip_disk_trailer_localentries(__p) ((int) \ |
| 290 |
zzip_disk_trailer_get_entries(__p)) |
| 291 |
#define zzip_disk_trailer_finalentries(__p) ((int) \ |
| 292 |
zzip_disk_trailer_get_finalentries(__p)) |
| 293 |
#define zzip_disk_trailer_rootsize(__p) ((zzip_off_t) \ |
| 294 |
zzip_disk_trailer_get_rootsize(__p)) |
| 295 |
#define zzip_disk_trailer_rootseek(__p) ((zzip_off_t) \ |
| 296 |
zzip_disk_trailer_get_rootseek(__p)) |
| 297 |
#define zzip_disk_trailer_comment(__p) ((zzip_size_t) \ |
| 298 |
zzip_disk_trailer_get_comment(__p)) |
| 299 |
#define zzip_disk_trailer_sizeof_tail(__p) ((zzip_size_t) \ |
| 300 |
zzip_disk_trailer_sizeof_tails(__p)) |
| 301 |
#define zzip_disk_trailer_sizeto_end(__p) ((zzip_size_t) \ |
| 302 |
(zzip_disk_trailer_sizeof_tail(__p) + zzip_disk_trailer_headerlength)) |
| 303 |
#define zzip_disk_trailer_skipto_end(__p) ((void*) (__p) \ |
| 304 |
(zzip_disk_trailer_sizeof_tail(__p) + zzip_disk_trailer_headerlength)) |
| 305 |
|
| 306 |
#define zzip_disk_trailer_to_comment(__p) ((char*) \ |
| 307 |
((char*)(__p) + zzip_disk_trailer_headerlength)) |
| 308 |
#define zzip_disk_trailer_to_endoffile(__p) ((void*) \ |
| 309 |
(zzip_disk_trailer_to_comment(__p) + zzip_disk_trailer_comment(__p))) |
| 310 |
|
| 311 |
#define zzip_extra_zip64_csize(__p) ((zzip_size_t) \ |
| 312 |
zzip_extra_zip64_get_csize(__p)) |
| 313 |
#define zzip_extra_zip64_usize(__p) ((zzip_size_t) \ |
| 314 |
zzip_extra_zip64_get_usize(__p)) |
| 315 |
#define zzip_extra_zip64_offset(__p) ((zzip_off_t) \ |
| 316 |
zzip_extra_zip64_get_offset(__p)) |
| 317 |
#define zzip_extra_zip64_diskstart(__p) ((zzip_size_t) \ |
| 318 |
zzip_extra_zip64_get_diskstart(__p)) |
| 319 |
|
| 320 |
#define zzip_disk64_locator_rootseek(__p) ((zzip_off64_t) \ |
| 321 |
zzip_disk64_locator_get_rootseek(__p)) |
| 322 |
|
| 323 |
/* zzip_disk64_trailer - the zip archive entry point */ |
| 324 |
#define zzip_disk64_trailer_localdisk(__p) ((int) \ |
| 325 |
zzip_disk64_trailer_get_disk(__p)) |
| 326 |
#define zzip_disk64_trailer_finaldisk(__p) ((int) \ |
| 327 |
zzip_disk64_trailer_get_finaldisk(__p)) |
| 328 |
#define zzip_disk64_trailer_localentries(__p) ((int) \ |
| 329 |
zzip_disk64_trailer_get_entries(__p)) |
| 330 |
#define zzip_disk64_trailer_finalentries(__p) ((int) \ |
| 331 |
zzip_disk64_trailer_get_finalentries(__p)) |
| 332 |
#define zzip_disk64_trailer_rootsize(__p) ((zzip_off64_t) \ |
| 333 |
zzip_disk64_trailer_get_rootsize(__p)) |
| 334 |
#define zzip_disk64_trailer_rootseek(__p) ((zzip_off64_t) \ |
| 335 |
zzip_disk64_trailer_get_rootseek(__p)) |
| 336 |
#define zzip_disk64_trailer_sizeof_tail(__p) ((zzip_size_t) \ |
| 337 |
zzip_disk64_trailer_get_size(__p) - zzip_disk64_trailer_headerlength) |
| 338 |
#define zzip_disk64_trailer_sizeto_end(__p) ((zzip_size_t) \ |
| 339 |
zzip_disk64_trailer_get_size(__p)) |
| 340 |
#define zzip_disk64_trailer_skipto_end(__p) ((void*) \ |
| 341 |
((char*)(__p) + zzip_disk64_sizeto_end(__p))) |
| 342 |
|
| 343 |
/* extra field should be type + size + data + type + size + data ... */ |
| 344 |
#define zzip_extra_block_sizeof_tail(__p) ((zzip_size_t) \ |
| 345 |
(zzip_extra_block_get_datasize(__p))) |
| 346 |
#define zzip_extra_block_sizeto_end(__p) ((zzip_size_t) \ |
| 347 |
(zzip_extra_block_sizeof_tail(__p) + zzip_extra_block_headerlength)) |
| 348 |
#define zzip_extra_block_skipto_end(__p) ((void*) (__p) \ |
| 349 |
(zzip_extra_block_sizeof_tail(__p) + zzip_extra_block_headerlength)) |
| 350 |
|
| 351 |
/* ................... and put these to the next level ................ */ |
| 352 |
|
| 353 |
#define zzip_file_header_data_encrypted(__p) \ |
| 354 |
ZZIP_IS_ENCRYPTED( zzip_file_header_get_flags(__p) ) |
| 355 |
#define zzip_file_header_data_comprlevel(__p) \ |
| 356 |
ZZIP_IS_COMPRLEVEL( zzip_file_header_get_flags(__p) ) |
| 357 |
#define zzip_file_header_data_streamed(__p) \ |
| 358 |
ZZIP_IS_STREAMED( zzip_file_header_get_flags(__p) ) |
| 359 |
#define zzip_file_header_data_stored(__p) \ |
| 360 |
( ZZIP_IS_STORED == zzip_file_header_get_compr(__p) ) |
| 361 |
#define zzip_file_header_data_deflated(__p) \ |
| 362 |
( ZZIP_IS_DEFLATED == zzip_file_header_get_compr(__p) ) |
| 363 |
|
| 364 |
#define zzip_disk_entry_data_encrypted(__p) \ |
| 365 |
ZZIP_IS_ENCRYPTED( zzip_disk_entry_get_flags(__p) ) |
| 366 |
#define zzip_disk_entry_data_comprlevel(__p) \ |
| 367 |
ZZIP_IS_COMPRLEVEL( zzip_disk_entry_get_flags(__p) ) |
| 368 |
#define zzip_disk_entry_data_streamed(__p) \ |
| 369 |
ZZIP_IS_STREAMED( zzip_disk_entry_get_flags(__p) ) |
| 370 |
#define zzip_disk_entry_data_stored(__p) \ |
| 371 |
( ZZIP_IS_STORED == zzip_disk_entry_get_compr(__p) ) |
| 372 |
#define zzip_disk_entry_data_deflated(__p) \ |
| 373 |
( ZZIP_IS_DEFLATED == zzip_disk_entry_get_compr(__p) ) |
| 374 |
#define zzip_disk_entry_data_ascii(__p) \ |
| 375 |
( zzip_disk_entry_get_filetype(__p) & 1) |
| 376 |
|
| 377 |
#define zzip_file_header_data_not_deflated(__p) \ |
| 378 |
(zzip_file_header_data_stored(__p)) |
| 379 |
#define zzip_file_header_data_std_deflated(__p) \ |
| 380 |
(zzip_file_header_data_deflated(__p) && \ |
| 381 |
zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_STD_COMPR) |
| 382 |
#define zzip_file_header_data_max_deflated(__p) \ |
| 383 |
(zzip_file_header_data_deflated(__p) && \ |
| 384 |
zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_MAX_COMPR) |
| 385 |
#define zzip_file_header_data_low_deflated(__p) \ |
| 386 |
(zzip_file_header_data_deflated(__p) && \ |
| 387 |
zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_LOW_COMPR) |
| 388 |
#define zzip_file_header_data_min_deflated(__p) \ |
| 389 |
(zzip_file_header_data_deflated(__p) && \ |
| 390 |
zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_MIN_COMPR) |
| 391 |
|
| 392 |
#define zzip_disk_entry_data_not_deflated(__p) \ |
| 393 |
(zzip_disk_entry_data_stored(__p)) |
| 394 |
#define zzip_disk_entry_data_std_deflated(__p) \ |
| 395 |
(zzip_disk_entry_data_deflated(__p) && \ |
| 396 |
zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_STD_COMPR) |
| 397 |
#define zzip_disk_entry_data_max_deflated(__p) \ |
| 398 |
(zzip_disk_entry_data_deflated(__p) && \ |
| 399 |
zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_MAX_COMPR) |
| 400 |
#define zzip_disk_entry_data_low_deflated(__p) \ |
| 401 |
(zzip_disk_entry_data_deflated(__p) && \ |
| 402 |
zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_LOW_COMPR) |
| 403 |
#define zzip_disk_entry_data_min_deflated(__p) \ |
| 404 |
(zzip_disk_entry_data_deflated(__p) && \ |
| 405 |
zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_MIN_COMPR) |
| 406 |
|
| 407 |
#ifdef __cplusplus |
| 408 |
} |
| 409 |
#endif |
| 410 |
#endif |