95 { 0,
"Stored (no compression)" },
97 { 2,
"Reduced with compression factor 1" },
98 { 3,
"Reduced with compression factor 2" },
99 { 4,
"Reduced with compression factor 3" },
100 { 5,
"Reduced with compression factor 4" },
102 { 7,
"Reserved for Tokenizing compression algorithm" },
104 { 9,
"Enhanced Deflating using Deflate64(tm)" },
105 { 10,
"PKWARE Data Compression Library Imploding (old IBM TERSE)" },
106 { 11,
"11 (Reserved by PKWARE)" },
108 { 13,
"13 (Reserved by PKWARE)" },
109 { 14,
"LZMA (EFS)" },
110 { 15,
"15 (Reserved by PKWARE)" },
111 { 16,
"16 (Reserved by PKWARE)" },
112 { 17,
"17 (Reserved by PKWARE)" },
113 { 18,
"IBM TERSE (new)" },
114 { 19,
"IBM LZ77 z Architecture (PFS)" },
115 { 20,
"Zstandard compressed data (obsolete)" },
116 { 93,
"Zstandard compressed data" },
117 { 95,
"XZ compressed data" },
118 { 97,
"WavPack compressed data" },
119 { 98,
"PPMd version I, Rev 1" },
120 { 99,
"WinZIP AES Encryption" },
126 { 0x0001,
"Zip64 extended information" },
127 { 0x0007,
"AV Info" },
128 { 0x0008,
"Reserved for extended language encoding data (PFS)" },
131 { 0x000c,
"OpenVMS" },
133 { 0x000e,
"Reserved for file stream and fork descriptors" },
134 { 0x000f,
"Patch Descriptor" },
135 { 0x0014,
"PKCS#7 Store for X.509 Certificates" },
136 { 0x0015,
"X.509 Certificate ID and Signature for individual file" },
137 { 0x0016,
"X.509 Certificate ID for Central Directory" },
138 { 0x0017,
"Strong Encryption Header" },
139 { 0x0018,
"Record Management Controls" },
140 { 0x0019,
"PKCS#7 Encryption Recipient Certificate List" },
141 { 0x0065,
"IBM S/390 (Z390), AS/400 (I400) attributes - uncompressed" },
142 { 0x0066,
"Reserved for IBM S/390 (Z390), AS/400 (I400) attributes - compressed" },
143 { 0x4690,
"POSZIP 4690 (reserved)" },
146 { 0x07c8,
"Info-ZIP Macintosh (old)" },
147 { 0x2605,
"ZipIt Macintosh (first version)" },
148 { 0x2705,
"ZipIt Macintosh 1.3.5+ (w/o full filename)" },
149 { 0x2805,
"ZipIt Macintosh 1.3.5+" },
150 { 0x334d,
"Info-ZIP Macintosh (new)" },
151 { 0x4154,
"Tandem NSK" },
152 { 0x4341,
"Acorn/SparkFS" },
153 { 0x4453,
"Windows NT security descriptor" },
154 { 0x4704,
"VM/CMS" },
156 { 0x4854,
"Theos, old unofficial port" },
157 { 0x4b46,
"FWKCS MD5" },
158 { 0x4c41,
"OS/2 access control list (text ACL)" },
159 { 0x4d49,
"Info-ZIP OpenVMS (obsolete)" },
160 { 0x4d63,
"Macintosh SmartZIP" },
161 { 0x4f4c,
"Xceed original location extra field" },
162 { 0x5356,
"AOS/VS (ACL)" },
163 { 0x5455,
"extended timestamp" },
164 { 0x554e,
"Xceed unicode extra field" },
165 { 0x5855,
"Info-ZIP UNIX (original)" },
166 { 0x6375,
"Info-ZIP UTF-8 comment field" },
167 { 0x6542,
"BeOS (BeBox, PowerMac, etc.)" },
169 { 0x7075,
"Info-ZIP UTF-8 name field" },
170 { 0x7441,
"AtheOS (AtheOS/Syllable attributes)" },
171 { 0x756e,
"ASi UNIX" },
172 { 0x7855,
"Info-ZIP UNIX" },
173 { 0x7875,
"Info-ZIP UNIX 3rd generation" },
174 { 0x9901,
"WinZIP AES encryption" },
175 { 0xa220,
"Microsoft Open Packaging Growth Hint" },
176 { 0xcafe,
"executable Java JAR file" },
177 { 0xfb4a,
"SMS/QDOS" },
178 { 0xfd4a,
"SMS/QDOS" },
185 #define PROGRAM "zipcmp"
187 #define USAGE "usage: %s [-hipqtVv] archive1 archive2\n"
192 -h display this help message\n\
193 -C check archive consistencies\n\
194 -i compare names ignoring case distinctions\n\
195 -p compare as many details as possible\n\
197 -s print a summary\n\
198 -t test zip files (compare file contents to checksum)\n\
199 -V display version number\n\
200 -v be verbose (print differences, default)\n\
202 Report bugs to <libzip@nih.at>.\n";
205 Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner\n\
206 " PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n";
208 #define OPTIONS "hVCipqstv"
211 #define BOTH_ARE_ZIPS(a) (a[0].za && a[1].za)
214 static int compare_list(
char *
const name[2],
const void *
list[2],
const zip_uint64_t list_length[2],
int element_size,
int (*
cmp)(
const void *
a,
const void *
b),
int (*ignore)(
const void *
list,
int last,
const void *other),
int (*
check)(
char *
const name[2],
const void *
a,
const void *
b),
void (*print)(
char side,
const void *element),
void (*start_file)(
const void *element));
217 static int ef_order(
const void *
a,
const void *
b);
218 static void ef_print(
char side,
const void *
p);
220 static int entry_cmp(
const void *p1,
const void *p2);
221 static int entry_ignore(
const void *p1,
int last,
const void *o);
229 static int list_directory(
const char *
name,
struct archive *
a);
310 for (
i = 0;
i < 2;
i++) {
316 a[
i].comment_length = 0;
320 fprintf(stderr,
"%s: reading directories not supported\n",
progname);
323 if (list_directory(zn[
i],
a +
i) < 0)
359 for (
i = 0;
i < 2;
i++) {
365 for (j = 0; j <
a[
i].nentry; j++) {
389 compute_crc(
const char *
fname) {
397 fprintf(stderr,
"%s: can't open %s: %s\n",
progname,
fname, strerror(errno));
406 fprintf(stderr,
"%s: read error on %s: %s\n",
progname,
fname, strerror(errno));
435 size_t prefix_length;
440 if ((fts = fts_open(
names, FTS_NOCHDIR | FTS_LOGICAL,
NULL)) ==
NULL) {
441 fprintf(stderr,
"%s: can't open directory '%s': %s\n",
progname,
name, strerror(errno));
444 prefix_length = strlen(
name) + 1;
448 while ((ent = fts_read(fts))) {
451 switch (ent->fts_info) {
470 if (
a->nentry >= nalloc) {
472 if (nalloc >
SIZE_MAX /
sizeof(
a->entry[0])) {
473 fprintf(stderr,
"%s: malloc failure\n",
progname);
476 a->entry =
realloc(
a->entry,
sizeof(
a->entry[0]) * nalloc);
477 if (
a->entry ==
NULL) {
478 fprintf(stderr,
"%s: malloc failure\n",
progname);
483 if (ent->fts_info == FTS_D) {
486 if (ent->fts_path[prefix_length - 1] ==
'\0') {
490 dir_name =
malloc(strlen(ent->fts_path + prefix_length) + 2);
491 if (dir_name ==
NULL) {
492 fprintf(stderr,
"%s: malloc failure\n",
progname);
495 sprintf(dir_name,
"%s/", ent->fts_path + prefix_length);
496 a->entry[
a->nentry].name = dir_name;
497 a->entry[
a->nentry].size = 0;
498 a->entry[
a->nentry].crc = 0;
501 a->entry[
a->nentry].name =
strdup(ent->fts_path + prefix_length);
503 if ((crc = compute_crc(ent->fts_accpath)) < 0) {
515 if (fts_close(fts)) {
516 fprintf(stderr,
"%s: error closing directory '%s': %s\n",
progname,
a->name, strerror(errno));
547 fprintf(stderr,
"%s: malloc failure\n",
progname);
551 for (
i = 0;
i <
a->nentry;
i++) {
554 a->entry[
i].size = st.
size;
555 a->entry[
i].crc = st.
crc;
564 a->entry[
i].comp_method = 0;
565 a->entry[
i].n_extra_fields = 0;
576 a->comment_length = 0;
595 return memcmp(
c1,
c2, (
size_t)l2);
599 static int compare_list(
char *
const name[2],
const void *
list[2],
const zip_uint64_t list_length[2],
int element_size,
int (*
cmp)(
const void *
a,
const void *
b),
int (*ignore)(
const void *
list,
int last,
const void *other),
int (*
check)(
char *
const name[2],
const void *
a,
const void *
b),
void (*print)(
char side,
const void *element),
void (*start_file)(
const void *element)) {
604 #define INC(k) (i[k]++, list[k] = ((const char *)list[k]) + element_size)
607 if (ignore && ignore(list[k], i[k] >= list_length[k] - 1, i[1-k] < list_length[1-k] ? list[1-k] : NULL)) { \
610 print((k) ? '+' : '-', list[k]); \
611 (k) ? plus_count++ : minus_count++; \
617 while (
i[0] < list_length[0] &&
i[1] < list_length[1]) {
643 for (j = 0; j < 2; j++) {
644 while (
i[j] < list_length[j]) {
665 if ((
e->extra_fields = (
struct ef *)
malloc(
sizeof(
e->extra_fields[0]) *
e->n_extra_fields)) ==
NULL)
668 for (
i = 0;
i < n_local;
i++) {
669 e->extra_fields[
i].name =
e->name;
671 if (
e->extra_fields[
i].data ==
NULL)
675 for (;
i <
e->n_extra_fields;
i++) {
676 e->extra_fields[
i].name =
e->name;
678 if (
e->extra_fields[
i].data ==
NULL)
683 qsort(
e->extra_fields,
e->n_extra_fields,
sizeof(
e->extra_fields[0]),
ef_order);
705 const struct ef *
a, *
b;
710 if (
a->flags !=
b->flags)
711 return a->flags -
b->flags;
713 return a->id -
b->id;
714 if (
a->size !=
b->size)
715 return a->size -
b->size;
716 return memcmp(
a->data,
b->data,
a->size);
722 const struct ef *
ef = (
struct ef *)
p;
730 const struct entry *e1, *e2;
733 e1 = (
struct entry *)p1;
734 e2 = (
struct entry *)p2;
754 const struct entry *other = (
const struct entry *)o;
780 const struct entry *e1, *e2;
783 e1 = (
struct entry *)p1;
784 e2 = (
struct entry *)p2;
856 fprintf(stderr,
"%s: %s: file %s (index %" PRIu64 "): unexpected length %x (should be %x)\n",
progname, zipname,
filename,
idx, ncrc,
crc);
865 static char unknown[16];
876 unknown[
sizeof(unknown) - 1] =
'\0';
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c1
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c2
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
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
void diff_output_file(diff_output_t *output, char side, const char *name, zip_uint64_t size, zip_uint32_t crc)
void diff_output_data(diff_output_t *output, int side, const zip_uint8_t *data, zip_uint64_t data_length, const char *fmt,...)
void diff_output(diff_output_t *output, int side, const char *fmt,...)
void diff_output_end_file(diff_output_t *output)
void diff_output_start_file(diff_output_t *output, const char *name, zip_uint64_t size, zip_uint32_t crc)
void diff_output_init(diff_output_t *output, int verbose, char *const archive_names[])
size_t map(int syms, int left, int len)
RZ_API void Ht_() free(HtName_(Ht) *ht)
static void list(RzEgg *egg)
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 void zip_error_init_with_code(zip_error_t *_Nonnull, int)
ZIP_EXTERN int zip_fclose(zip_file_t *_Nonnull)
ZIP_EXTERN const char *_Nonnull zip_file_strerror(zip_file_t *_Nonnull)
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
ZIP_EXTERN const char *_Nullable zip_get_archive_comment(zip_t *_Nonnull, int *_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_int64_t zip_fread(zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t)
ZIP_EXTERN int zip_close(zip_t *_Nonnull)
ZIP_EXTERN void zip_error_fini(zip_error_t *_Nonnull)
ZIP_EXTERN zip_t *_Nullable zip_open(const char *_Nonnull, int, int *_Nullable)
ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull)
ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull)
ZIP_EXTERN zip_int64_t zip_get_num_entries(zip_t *_Nonnull, zip_flags_t)
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
ZIP_EXTERN const char *_Nonnull zip_strerror(zip_t *_Nonnull)
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
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")
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
zip_uint16_t n_extra_fields
zip_uint32_t comment_length
const char *_Nullable name
void error(const char *msg)
if(dbg->bits==RZ_SYS_BITS_64)
static void entry_print(char side, const void *p)
static int entry_ignore(const void *p1, int last, const void *o)
static const char * map_enum(const enum_map_t *map, uint32_t value)
static void ef_print(char side, const void *p)
static int is_directory(const char *name)
static int compare_zip(char *const zn[])
const enum_map_t extra_fields[]
static int entry_cmp(const void *p1, const void *p2)
static int test_file(zip_t *za, zip_uint64_t idx, const char *zipname, const char *filename, zip_uint64_t size, zip_uint32_t crc)
static int ef_compare(char *const name[2], const struct entry *e1, const struct entry *e2)
static int compare_list(char *const name[2], const void *list[2], const zip_uint64_t list_length[2], int element_size, int(*cmp)(const void *a, const void *b), int(*ignore)(const void *list, int last, const void *other), int(*check)(char *const name[2], const void *a, const void *b), void(*print)(char side, const void *element), void(*start_file)(const void *element))
static void entry_start_file(const void *p)
const enum_map_t comp_methods[]
static int comment_compare(const char *c1, size_t l1, const char *c2, size_t l2)
static int ef_order(const void *a, const void *b)
static int entry_paranoia_checks(char *const name[2], const void *p1, const void *p2)
static int ef_read(zip_t *za, zip_uint64_t idx, struct entry *e)
static int list_zip(const char *name, struct archive *a)
int main(int argc, char *const argv[])
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)