75#define zmalloc(len) malloc(len)
77#define zfree(p) free(p)
151#define UNZ_END_OF_LIST_OF_FILE (-100)
152#define UNZ_ERRNO (Z_ERRNO)
154#define UNZ_PARAMERROR (-102)
155#define UNZ_BADZIPFILE (-103)
156#define UNZ_INTERNALERROR (-104)
157#define UNZ_CRCERROR (-105)
158#define UNZ_PASSWORD (-106)
166#define ZLIB_VERSION "1.1.3"
171#define Z_SYNC_FLUSH 2
172#define Z_FULL_FLUSH 3
177#define Z_NO_COMPRESSION 0
178#define Z_BEST_SPEED 1
179#define Z_BEST_COMPRESSION 9
180#define Z_DEFAULT_COMPRESSION (-1)
184#define Z_HUFFMAN_ONLY 2
185#define Z_DEFAULT_STRATEGY 0
199#define CASE_SENSITIVE 1
200#define CASE_INSENSITIVE 2
206#define Z_STREAM_END 1
209#define Z_STREAM_ERROR (-2)
210#define Z_DATA_ERROR (-3)
211#define Z_MEM_ERROR (-4)
212#define Z_BUF_ERROR (-5)
213#define Z_VERSION_ERROR (-6)
390 const Byte* dictionary,
469const char*
zError (
int err);
477typedef unsigned short ush;
491 "insufficient memory",
493 "incompatible version",
498#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
500#define ERR_RETURN(strm,err) \
501 return (strm->msg = (char*)ERR_MSG(err), (err))
507#define STORED_BLOCK 0
508#define STATIC_TREES 1
516#define PRESET_DICT 0x20
526#define zmemzero(dest, len) memset(dest, 0, len)
529#define LuAssert(cond,msg)
534#define LuTracecv(c,x)
541#define ZALLOC(strm, items, size) \
542 (*((strm)->zalloc))((strm)->opaque, (items), (size))
543#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
549#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
721#define UPDBITS {s->bitb=b;s->bitk=k;}
722#define UPDIN {z->avail_in=n;z->total_in+=(uLong)(p-z->next_in);z->next_in=p;}
723#define UPDOUT {s->write=q;}
724#define UPDATE {UPDBITS UPDIN UPDOUT}
725#define LEAVE {UPDATE return inflate_flush(s,z,r);}
727#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
728#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
729#define NEXTBYTE (n--,*p++)
730#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
731#define DUMPBITS(j) {b>>=(j);k-=(j);}
733#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
734#define LOADOUT {q=s->write;m=(uInt)WAVAIL;m;}
735#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
736#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
737#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
738#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
740#define LOAD {LOADIN LOADOUT}
747 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
748 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
762 {{{96, 7}}, 256}, {{{0, 8}}, 80}, {{{0, 8}}, 16}, {{{84, 8}}, 115},
763 {{{82, 7}}, 31}, {{{0, 8}}, 112}, {{{0, 8}}, 48}, {{{0, 9}}, 192},
764 {{{80, 7}}, 10}, {{{0, 8}}, 96}, {{{0, 8}}, 32}, {{{0, 9}}, 160},
765 {{{0, 8}}, 0}, {{{0, 8}}, 128}, {{{0, 8}}, 64}, {{{0, 9}}, 224},
766 {{{80, 7}}, 6}, {{{0, 8}}, 88}, {{{0, 8}}, 24}, {{{0, 9}}, 144},
767 {{{83, 7}}, 59}, {{{0, 8}}, 120}, {{{0, 8}}, 56}, {{{0, 9}}, 208},
768 {{{81, 7}}, 17}, {{{0, 8}}, 104}, {{{0, 8}}, 40}, {{{0, 9}}, 176},
769 {{{0, 8}}, 8}, {{{0, 8}}, 136}, {{{0, 8}}, 72}, {{{0, 9}}, 240},
770 {{{80, 7}}, 4}, {{{0, 8}}, 84}, {{{0, 8}}, 20}, {{{85, 8}}, 227},
771 {{{83, 7}}, 43}, {{{0, 8}}, 116}, {{{0, 8}}, 52}, {{{0, 9}}, 200},
772 {{{81, 7}}, 13}, {{{0, 8}}, 100}, {{{0, 8}}, 36}, {{{0, 9}}, 168},
773 {{{0, 8}}, 4}, {{{0, 8}}, 132}, {{{0, 8}}, 68}, {{{0, 9}}, 232},
774 {{{80, 7}}, 8}, {{{0, 8}}, 92}, {{{0, 8}}, 28}, {{{0, 9}}, 152},
775 {{{84, 7}}, 83}, {{{0, 8}}, 124}, {{{0, 8}}, 60}, {{{0, 9}}, 216},
776 {{{82, 7}}, 23}, {{{0, 8}}, 108}, {{{0, 8}}, 44}, {{{0, 9}}, 184},
777 {{{0, 8}}, 12}, {{{0, 8}}, 140}, {{{0, 8}}, 76}, {{{0, 9}}, 248},
778 {{{80, 7}}, 3}, {{{0, 8}}, 82}, {{{0, 8}}, 18}, {{{85, 8}}, 163},
779 {{{83, 7}}, 35}, {{{0, 8}}, 114}, {{{0, 8}}, 50}, {{{0, 9}}, 196},
780 {{{81, 7}}, 11}, {{{0, 8}}, 98}, {{{0, 8}}, 34}, {{{0, 9}}, 164},
781 {{{0, 8}}, 2}, {{{0, 8}}, 130}, {{{0, 8}}, 66}, {{{0, 9}}, 228},
782 {{{80, 7}}, 7}, {{{0, 8}}, 90}, {{{0, 8}}, 26}, {{{0, 9}}, 148},
783 {{{84, 7}}, 67}, {{{0, 8}}, 122}, {{{0, 8}}, 58}, {{{0, 9}}, 212},
784 {{{82, 7}}, 19}, {{{0, 8}}, 106}, {{{0, 8}}, 42}, {{{0, 9}}, 180},
785 {{{0, 8}}, 10}, {{{0, 8}}, 138}, {{{0, 8}}, 74}, {{{0, 9}}, 244},
786 {{{80, 7}}, 5}, {{{0, 8}}, 86}, {{{0, 8}}, 22}, {{{192, 8}}, 0},
787 {{{83, 7}}, 51}, {{{0, 8}}, 118}, {{{0, 8}}, 54}, {{{0, 9}}, 204},
788 {{{81, 7}}, 15}, {{{0, 8}}, 102}, {{{0, 8}}, 38}, {{{0, 9}}, 172},
789 {{{0, 8}}, 6}, {{{0, 8}}, 134}, {{{0, 8}}, 70}, {{{0, 9}}, 236},
790 {{{80, 7}}, 9}, {{{0, 8}}, 94}, {{{0, 8}}, 30}, {{{0, 9}}, 156},
791 {{{84, 7}}, 99}, {{{0, 8}}, 126}, {{{0, 8}}, 62}, {{{0, 9}}, 220},
792 {{{82, 7}}, 27}, {{{0, 8}}, 110}, {{{0, 8}}, 46}, {{{0, 9}}, 188},
793 {{{0, 8}}, 14}, {{{0, 8}}, 142}, {{{0, 8}}, 78}, {{{0, 9}}, 252},
794 {{{96, 7}}, 256}, {{{0, 8}}, 81}, {{{0, 8}}, 17}, {{{85, 8}}, 131},
795 {{{82, 7}}, 31}, {{{0, 8}}, 113}, {{{0, 8}}, 49}, {{{0, 9}}, 194},
796 {{{80, 7}}, 10}, {{{0, 8}}, 97}, {{{0, 8}}, 33}, {{{0, 9}}, 162},
797 {{{0, 8}}, 1}, {{{0, 8}}, 129}, {{{0, 8}}, 65}, {{{0, 9}}, 226},
798 {{{80, 7}}, 6}, {{{0, 8}}, 89}, {{{0, 8}}, 25}, {{{0, 9}}, 146},
799 {{{83, 7}}, 59}, {{{0, 8}}, 121}, {{{0, 8}}, 57}, {{{0, 9}}, 210},
800 {{{81, 7}}, 17}, {{{0, 8}}, 105}, {{{0, 8}}, 41}, {{{0, 9}}, 178},
801 {{{0, 8}}, 9}, {{{0, 8}}, 137}, {{{0, 8}}, 73}, {{{0, 9}}, 242},
802 {{{80, 7}}, 4}, {{{0, 8}}, 85}, {{{0, 8}}, 21}, {{{80, 8}}, 258},
803 {{{83, 7}}, 43}, {{{0, 8}}, 117}, {{{0, 8}}, 53}, {{{0, 9}}, 202},
804 {{{81, 7}}, 13}, {{{0, 8}}, 101}, {{{0, 8}}, 37}, {{{0, 9}}, 170},
805 {{{0, 8}}, 5}, {{{0, 8}}, 133}, {{{0, 8}}, 69}, {{{0, 9}}, 234},
806 {{{80, 7}}, 8}, {{{0, 8}}, 93}, {{{0, 8}}, 29}, {{{0, 9}}, 154},
807 {{{84, 7}}, 83}, {{{0, 8}}, 125}, {{{0, 8}}, 61}, {{{0, 9}}, 218},
808 {{{82, 7}}, 23}, {{{0, 8}}, 109}, {{{0, 8}}, 45}, {{{0, 9}}, 186},
809 {{{0, 8}}, 13}, {{{0, 8}}, 141}, {{{0, 8}}, 77}, {{{0, 9}}, 250},
810 {{{80, 7}}, 3}, {{{0, 8}}, 83}, {{{0, 8}}, 19}, {{{85, 8}}, 195},
811 {{{83, 7}}, 35}, {{{0, 8}}, 115}, {{{0, 8}}, 51}, {{{0, 9}}, 198},
812 {{{81, 7}}, 11}, {{{0, 8}}, 99}, {{{0, 8}}, 35}, {{{0, 9}}, 166},
813 {{{0, 8}}, 3}, {{{0, 8}}, 131}, {{{0, 8}}, 67}, {{{0, 9}}, 230},
814 {{{80, 7}}, 7}, {{{0, 8}}, 91}, {{{0, 8}}, 27}, {{{0, 9}}, 150},
815 {{{84, 7}}, 67}, {{{0, 8}}, 123}, {{{0, 8}}, 59}, {{{0, 9}}, 214},
816 {{{82, 7}}, 19}, {{{0, 8}}, 107}, {{{0, 8}}, 43}, {{{0, 9}}, 182},
817 {{{0, 8}}, 11}, {{{0, 8}}, 139}, {{{0, 8}}, 75}, {{{0, 9}}, 246},
818 {{{80, 7}}, 5}, {{{0, 8}}, 87}, {{{0, 8}}, 23}, {{{192, 8}}, 0},
819 {{{83, 7}}, 51}, {{{0, 8}}, 119}, {{{0, 8}}, 55}, {{{0, 9}}, 206},
820 {{{81, 7}}, 15}, {{{0, 8}}, 103}, {{{0, 8}}, 39}, {{{0, 9}}, 174},
821 {{{0, 8}}, 7}, {{{0, 8}}, 135}, {{{0, 8}}, 71}, {{{0, 9}}, 238},
822 {{{80, 7}}, 9}, {{{0, 8}}, 95}, {{{0, 8}}, 31}, {{{0, 9}}, 158},
823 {{{84, 7}}, 99}, {{{0, 8}}, 127}, {{{0, 8}}, 63}, {{{0, 9}}, 222},
824 {{{82, 7}}, 27}, {{{0, 8}}, 111}, {{{0, 8}}, 47}, {{{0, 9}}, 190},
825 {{{0, 8}}, 15}, {{{0, 8}}, 143}, {{{0, 8}}, 79}, {{{0, 9}}, 254},
826 {{{96, 7}}, 256}, {{{0, 8}}, 80}, {{{0, 8}}, 16}, {{{84, 8}}, 115},
827 {{{82, 7}}, 31}, {{{0, 8}}, 112}, {{{0, 8}}, 48}, {{{0, 9}}, 193},
828 {{{80, 7}}, 10}, {{{0, 8}}, 96}, {{{0, 8}}, 32}, {{{0, 9}}, 161},
829 {{{0, 8}}, 0}, {{{0, 8}}, 128}, {{{0, 8}}, 64}, {{{0, 9}}, 225},
830 {{{80, 7}}, 6}, {{{0, 8}}, 88}, {{{0, 8}}, 24}, {{{0, 9}}, 145},
831 {{{83, 7}}, 59}, {{{0, 8}}, 120}, {{{0, 8}}, 56}, {{{0, 9}}, 209},
832 {{{81, 7}}, 17}, {{{0, 8}}, 104}, {{{0, 8}}, 40}, {{{0, 9}}, 177},
833 {{{0, 8}}, 8}, {{{0, 8}}, 136}, {{{0, 8}}, 72}, {{{0, 9}}, 241},
834 {{{80, 7}}, 4}, {{{0, 8}}, 84}, {{{0, 8}}, 20}, {{{85, 8}}, 227},
835 {{{83, 7}}, 43}, {{{0, 8}}, 116}, {{{0, 8}}, 52}, {{{0, 9}}, 201},
836 {{{81, 7}}, 13}, {{{0, 8}}, 100}, {{{0, 8}}, 36}, {{{0, 9}}, 169},
837 {{{0, 8}}, 4}, {{{0, 8}}, 132}, {{{0, 8}}, 68}, {{{0, 9}}, 233},
838 {{{80, 7}}, 8}, {{{0, 8}}, 92}, {{{0, 8}}, 28}, {{{0, 9}}, 153},
839 {{{84, 7}}, 83}, {{{0, 8}}, 124}, {{{0, 8}}, 60}, {{{0, 9}}, 217},
840 {{{82, 7}}, 23}, {{{0, 8}}, 108}, {{{0, 8}}, 44}, {{{0, 9}}, 185},
841 {{{0, 8}}, 12}, {{{0, 8}}, 140}, {{{0, 8}}, 76}, {{{0, 9}}, 249},
842 {{{80, 7}}, 3}, {{{0, 8}}, 82}, {{{0, 8}}, 18}, {{{85, 8}}, 163},
843 {{{83, 7}}, 35}, {{{0, 8}}, 114}, {{{0, 8}}, 50}, {{{0, 9}}, 197},
844 {{{81, 7}}, 11}, {{{0, 8}}, 98}, {{{0, 8}}, 34}, {{{0, 9}}, 165},
845 {{{0, 8}}, 2}, {{{0, 8}}, 130}, {{{0, 8}}, 66}, {{{0, 9}}, 229},
846 {{{80, 7}}, 7}, {{{0, 8}}, 90}, {{{0, 8}}, 26}, {{{0, 9}}, 149},
847 {{{84, 7}}, 67}, {{{0, 8}}, 122}, {{{0, 8}}, 58}, {{{0, 9}}, 213},
848 {{{82, 7}}, 19}, {{{0, 8}}, 106}, {{{0, 8}}, 42}, {{{0, 9}}, 181},
849 {{{0, 8}}, 10}, {{{0, 8}}, 138}, {{{0, 8}}, 74}, {{{0, 9}}, 245},
850 {{{80, 7}}, 5}, {{{0, 8}}, 86}, {{{0, 8}}, 22}, {{{192, 8}}, 0},
851 {{{83, 7}}, 51}, {{{0, 8}}, 118}, {{{0, 8}}, 54}, {{{0, 9}}, 205},
852 {{{81, 7}}, 15}, {{{0, 8}}, 102}, {{{0, 8}}, 38}, {{{0, 9}}, 173},
853 {{{0, 8}}, 6}, {{{0, 8}}, 134}, {{{0, 8}}, 70}, {{{0, 9}}, 237},
854 {{{80, 7}}, 9}, {{{0, 8}}, 94}, {{{0, 8}}, 30}, {{{0, 9}}, 157},
855 {{{84, 7}}, 99}, {{{0, 8}}, 126}, {{{0, 8}}, 62}, {{{0, 9}}, 221},
856 {{{82, 7}}, 27}, {{{0, 8}}, 110}, {{{0, 8}}, 46}, {{{0, 9}}, 189},
857 {{{0, 8}}, 14}, {{{0, 8}}, 142}, {{{0, 8}}, 78}, {{{0, 9}}, 253},
858 {{{96, 7}}, 256}, {{{0, 8}}, 81}, {{{0, 8}}, 17}, {{{85, 8}}, 131},
859 {{{82, 7}}, 31}, {{{0, 8}}, 113}, {{{0, 8}}, 49}, {{{0, 9}}, 195},
860 {{{80, 7}}, 10}, {{{0, 8}}, 97}, {{{0, 8}}, 33}, {{{0, 9}}, 163},
861 {{{0, 8}}, 1}, {{{0, 8}}, 129}, {{{0, 8}}, 65}, {{{0, 9}}, 227},
862 {{{80, 7}}, 6}, {{{0, 8}}, 89}, {{{0, 8}}, 25}, {{{0, 9}}, 147},
863 {{{83, 7}}, 59}, {{{0, 8}}, 121}, {{{0, 8}}, 57}, {{{0, 9}}, 211},
864 {{{81, 7}}, 17}, {{{0, 8}}, 105}, {{{0, 8}}, 41}, {{{0, 9}}, 179},
865 {{{0, 8}}, 9}, {{{0, 8}}, 137}, {{{0, 8}}, 73}, {{{0, 9}}, 243},
866 {{{80, 7}}, 4}, {{{0, 8}}, 85}, {{{0, 8}}, 21}, {{{80, 8}}, 258},
867 {{{83, 7}}, 43}, {{{0, 8}}, 117}, {{{0, 8}}, 53}, {{{0, 9}}, 203},
868 {{{81, 7}}, 13}, {{{0, 8}}, 101}, {{{0, 8}}, 37}, {{{0, 9}}, 171},
869 {{{0, 8}}, 5}, {{{0, 8}}, 133}, {{{0, 8}}, 69}, {{{0, 9}}, 235},
870 {{{80, 7}}, 8}, {{{0, 8}}, 93}, {{{0, 8}}, 29}, {{{0, 9}}, 155},
871 {{{84, 7}}, 83}, {{{0, 8}}, 125}, {{{0, 8}}, 61}, {{{0, 9}}, 219},
872 {{{82, 7}}, 23}, {{{0, 8}}, 109}, {{{0, 8}}, 45}, {{{0, 9}}, 187},
873 {{{0, 8}}, 13}, {{{0, 8}}, 141}, {{{0, 8}}, 77}, {{{0, 9}}, 251},
874 {{{80, 7}}, 3}, {{{0, 8}}, 83}, {{{0, 8}}, 19}, {{{85, 8}}, 195},
875 {{{83, 7}}, 35}, {{{0, 8}}, 115}, {{{0, 8}}, 51}, {{{0, 9}}, 199},
876 {{{81, 7}}, 11}, {{{0, 8}}, 99}, {{{0, 8}}, 35}, {{{0, 9}}, 167},
877 {{{0, 8}}, 3}, {{{0, 8}}, 131}, {{{0, 8}}, 67}, {{{0, 9}}, 231},
878 {{{80, 7}}, 7}, {{{0, 8}}, 91}, {{{0, 8}}, 27}, {{{0, 9}}, 151},
879 {{{84, 7}}, 67}, {{{0, 8}}, 123}, {{{0, 8}}, 59}, {{{0, 9}}, 215},
880 {{{82, 7}}, 19}, {{{0, 8}}, 107}, {{{0, 8}}, 43}, {{{0, 9}}, 183},
881 {{{0, 8}}, 11}, {{{0, 8}}, 139}, {{{0, 8}}, 75}, {{{0, 9}}, 247},
882 {{{80, 7}}, 5}, {{{0, 8}}, 87}, {{{0, 8}}, 23}, {{{192, 8}}, 0},
883 {{{83, 7}}, 51}, {{{0, 8}}, 119}, {{{0, 8}}, 55}, {{{0, 9}}, 207},
884 {{{81, 7}}, 15}, {{{0, 8}}, 103}, {{{0, 8}}, 39}, {{{0, 9}}, 175},
885 {{{0, 8}}, 7}, {{{0, 8}}, 135}, {{{0, 8}}, 71}, {{{0, 9}}, 239},
886 {{{80, 7}}, 9}, {{{0, 8}}, 95}, {{{0, 8}}, 31}, {{{0, 9}}, 159},
887 {{{84, 7}}, 99}, {{{0, 8}}, 127}, {{{0, 8}}, 63}, {{{0, 9}}, 223},
888 {{{82, 7}}, 27}, {{{0, 8}}, 111}, {{{0, 8}}, 47}, {{{0, 9}}, 191},
889 {{{0, 8}}, 15}, {{{0, 8}}, 143}, {{{0, 8}}, 79}, {{{0, 9}}, 255}
893 {{{80, 5}}, 1}, {{{87, 5}}, 257}, {{{83, 5}}, 17}, {{{91, 5}}, 4097},
894 {{{81, 5}}, 5}, {{{89, 5}}, 1025}, {{{85, 5}}, 65}, {{{93, 5}}, 16385},
895 {{{80, 5}}, 3}, {{{88, 5}}, 513}, {{{84, 5}}, 33}, {{{92, 5}}, 8193},
896 {{{82, 5}}, 9}, {{{90, 5}}, 2049}, {{{86, 5}}, 129}, {{{192, 5}}, 24577},
897 {{{80, 5}}, 2}, {{{87, 5}}, 385}, {{{83, 5}}, 25}, {{{91, 5}}, 6145},
898 {{{81, 5}}, 7}, {{{89, 5}}, 1537}, {{{85, 5}}, 97}, {{{93, 5}}, 24577},
899 {{{80, 5}}, 4}, {{{88, 5}}, 769}, {{{84, 5}}, 49}, {{{92, 5}}, 12289},
900 {{{82, 5}}, 13}, {{{90, 5}}, 3073}, {{{86, 5}}, 193}, {{{192, 5}}, 24577}
989#define exop word.what.Exop
990#define bits word.what.Bits
1056 LuTracev((stderr,
"inflate: codes new\n"));
1080 for (;;)
switch (c->
mode)
1085 if (m >= 258 && n >= 10)
1105 e = (
uInt)(t->exop);
1110 "inflate: literal '%c'\n" :
1111 "inflate: literal 0x%02x\n", t->
base));
1130 LuTracevv((stderr,
"inflate: end of block\n"));
1135 z->
msg = (
char*)
"invalid literal/length code";
1152 e = (
uInt)(t->exop);
1167 z->
msg = (
char*)
"invalid distance code";
1179 while (f < s->window)
1224 LuTracev((stderr,
"inflate: codes free\n"));
1240 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
1301 LuTracev((stderr,
"inflate: blocks reset\n"));
1327 LuTracev((stderr,
"inflate: blocks allocated\n"));
1358 LuTracev((stderr,
"inflate: stored block%s\n",
1359 s->
last ?
" (last)" :
""));
1366 LuTracev((stderr,
"inflate: fixed codes block%s\n",
1367 s->
last ?
" (last)" :
""));
1384 LuTracev((stderr,
"inflate: dynamic codes block%s\n",
1385 s->
last ?
" (last)" :
""));
1392 z->
msg = (
char*)
"invalid block type";
1399 if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
1402 z->
msg = (
char*)
"invalid stored block lengths";
1425 LuTracev((stderr,
"inflate: stored end, %lu total out\n",
1434 if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
1437 z->
msg = (
char*)
"too many length or distance symbols";
1442 t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
1450 LuTracev((stderr,
"inflate: table sizes ok\n"));
1475 LuTracev((stderr,
"inflate: bits tree ok\n"));
1496 i = c == 18 ? 7 : c - 14;
1497 j = c == 18 ? 11 : 3;
1504 if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
1509 z->
msg = (
char*)
"invalid bit length repeat";
1544 LuTracev((stderr,
"inflate: trees ok\n"));
1561 LuTracev((stderr,
"inflate: codes end, %lu total out\n",
1595 LuTracev((stderr,
"inflate: blocks freed\n"));
1609 " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
1632 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
1633 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
1638 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
1639 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112
1643 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
1644 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
1645 8193, 12289, 16385, 24577
1649 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
1650 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
1731#define C2 C0 C0 C0 C0
1732#define C4 C2 C2 C2 C2
1752 for (j = 1; j <=
BMAX; j++)
1758 for (i =
BMAX; i; i--)
1768 for (y = 1 << j; j < i; j++, y <<= 1)
1769 if ((y -= c[j]) < 0)
1771 if ((y -= c[i]) < 0)
1782 *xp++ = (j += *p++);
1791 if ((j = *p++) != 0)
1822 z = z > (
uInt)l ? l : z;
1823 if ((f = 1 << (j = k - w)) > a + 1)
1831 if ((f <<= 1) <= *++xp)
1841 u[h] = q = hp + *hn;
1859 r.bits = (
Byte)(k - w);
1864 r.exop = (
Byte)(*p < 256 ? 0 : 32 + 64);
1869 r.exop = (
Byte)(e[*p - s] + 16 + 64);
1870 r.
base = d[*p++ - s];
1875 for (j = i >> w; j < z; j += f)
1879 for (j = 1 << (k - 1); i & j; j >>= 1)
1884 mask = (1 << w) - 1;
1885 while ((i & mask) != x[h])
1889 mask = (1 << w) - 1;
1914 tb, bb, hp, &hn, v);
1916 z->
msg = (
char*)
"oversubscribed dynamic bit lengths tree";
1919 z->
msg = (
char*)
"incomplete dynamic bit lengths tree";
1948 if (r !=
Z_OK || *bl == 0)
1951 z->
msg = (
char*)
"oversubscribed literal/length tree";
1954 z->
msg = (
char*)
"incomplete literal/length tree";
1963 if (r !=
Z_OK || (*bd == 0 && nl > 257))
1966 z->
msg = (
char*)
"oversubscribed distance tree";
1969 z->
msg = (
char*)
"incomplete distance tree";
1974 z->
msg = (
char*)
"empty distance tree with lengths";
2015#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
2016#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
2056 if ((e = (t = tl + ((
uInt)b & ml))->
exop) == 0)
2060 "inflate: * literal '%c'\n" :
2061 "inflate: * literal 0x%02x\n", t->
base));
2075 LuTracevv((stderr,
"inflate: * length %u\n", c));
2079 e = (t = td + ((
uInt)b & md))->
exop;
2090 LuTracevv((stderr,
"inflate: * distance %u\n", d));
2101 while (r < s->window);
2145 else if ((e & 64) == 0)
2152 z->
msg = (
char*)
"invalid distance code";
2167 "inflate: * literal '%c'\n" :
2168 "inflate: * literal 0x%02x\n", t->
base));
2176 LuTracevv((stderr,
"inflate: * end of block\n"));
2183 z->
msg = (
char*)
"invalid literal/length code";
2190 while (m >= 258 && n >= 10);
2217 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
2218 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
2219 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
2220 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
2221 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
2222 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
2223 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
2224 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
2225 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
2226 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
2227 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
2228 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
2229 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
2230 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
2231 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
2232 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
2233 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
2234 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
2235 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
2236 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
2237 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
2238 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
2239 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
2240 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
2241 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
2242 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
2243 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
2244 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
2245 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
2246 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
2247 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
2248 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
2249 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
2250 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
2251 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
2252 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
2253 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
2254 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
2255 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
2256 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
2257 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
2258 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
2259 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
2260 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
2261 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
2262 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
2263 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
2264 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
2265 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
2266 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
2267 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
2276#define CRC_DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
2277#define CRC_DO2(buf) CRC_DO1(buf); CRC_DO1(buf);
2278#define CRC_DO4(buf) CRC_DO2(buf); CRC_DO2(buf);
2279#define CRC_DO8(buf) CRC_DO4(buf); CRC_DO4(buf);
2285 crc = crc ^ 0xffffffffL;
2296 return crc ^ 0xffffffffL;
2303#define CRC32(c, b) (crc_table[((int)(c)^(b))&0xff]^((c)>>8))
2306 keys[0] =
CRC32(keys[0], c);
2307 keys[1] += keys[0] & 0xFF;
2308 keys[1] = keys[1] * 134775813L + 1;
2309 keys[2] =
CRC32(keys[2], keys[1] >> 24);
2313 unsigned temp = ((unsigned)keys[2] & 0xffff) | 2;
2314 return (
char)(((temp * (temp ^ 1)) >> 8) & 0xff);
2336#define AD_DO1(buf,i) {s1 += buf[i]; s2 += s1;}
2337#define AD_DO2(buf,i) AD_DO1(buf,i); AD_DO1(buf,i+1);
2338#define AD_DO4(buf,i) AD_DO2(buf,i); AD_DO2(buf,i+2);
2339#define AD_DO8(buf,i) AD_DO4(buf,i); AD_DO4(buf,i+4);
2340#define AD_DO16(buf) AD_DO8(buf,0); AD_DO8(buf,8);
2345 unsigned long s1 = adler & 0xffff;
2346 unsigned long s2 = (adler >> 16) & 0xffff;
2374 return (s2 << 16) | s1;
2407 items += size - size;
2408 return (
voidpf)calloc(items, size);
2480 LuTracev((stderr,
"inflate: reset\n"));
2492 LuTracev((stderr,
"inflate: end\n"));
2500 int stream_size =
sizeof(
z_stream);
2543 if (w < 8 || w > 15)
2558 LuTracev((stderr,
"inflate: allocated\n"));
2567#define IM_NEEDBYTE {if(z->avail_in==0)return r;r=f;}
2568#define IM_NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
2588 z->
msg = (
char*)
"unknown compression method";
2595 z->
msg = (
char*)
"invalid window size";
2606 z->
msg = (
char*)
"incorrect header check";
2610 LuTracev((stderr,
"inflate: zlib header ok\n"));
2638 z->
msg = (
char*)
"need dictionary";
2680 z->
msg = (
char*)
"incorrect data check";
2684 LuTracev((stderr,
"inflate: zlib check ok\n"));
2707#define UNZ_BUFSIZE (16384)
2708#define UNZ_MAXFILENAMEINZIP (256)
2709#define SIZECENTRALDIRITEM (0x2e)
2710#define SIZEZIPLOCALHEADER (0x1e)
2748 bool canseek =
false;
2750 bool mustclosehandle =
false;
2757 mustclosehandle =
false;
2758#ifdef DuplicateHandle
2759 BOOL res = DuplicateHandle(GetCurrentProcess(), hf, GetCurrentProcess(), &h, 0,
FALSE, DUPLICATE_SAME_ACCESS);
2760 if (!res) mustclosehandle =
true;
2765 h = CreateFile((
const TCHAR*)z, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
2766 if (h == INVALID_HANDLE_VALUE)
2771 mustclosehandle =
true;
2774 DWORD res = SetFilePointer(h, 0, 0, FILE_CURRENT);
2775 canseek = (res != 0xFFFFFFFF);
2809 CloseHandle(stream->
h);
2824 return SetFilePointer(stream->
h, 0, NULL, FILE_CURRENT) - stream->
initial_offset;
2835 if (whence == SEEK_SET)
2836 SetFilePointer(stream->
h, stream->
initial_offset + offset, 0, FILE_BEGIN);
2837 else if (whence == SEEK_CUR)
2838 SetFilePointer(stream->
h, offset, NULL, FILE_CURRENT);
2839 else if (whence == SEEK_END)
2840 SetFilePointer(stream->
h, offset, NULL, FILE_END);
2849 if (whence == SEEK_SET)
2850 stream->
pos = offset;
2851 else if (whence == SEEK_CUR)
2852 stream->
pos += offset;
2853 else if (whence == SEEK_END)
2854 stream->
pos = stream->
len + offset;
2862 unsigned int toread = (
unsigned int)(size * n);
2866 BOOL res = ReadFile(stream->
h, ptr, toread, &red, NULL);
2868 stream->
herr =
true;
2871 if (stream->
pos + toread > stream->
len)
2872 toread = stream->
len - stream->
pos;
2873 memcpy(ptr, (
char*)stream->
buf + stream->
pos, toread);
2904 unsigned long keys[3];
2961 int err = (int)
lufread(&c, 1, 1, fin);
2990 x += ((
uLong)i) << 8;
3010 x += ((
uLong)i) << 8;
3014 x += ((
uLong)i) << 16;
3018 x += ((
uLong)i) << 24;
3033 char c1 = *(fileName1++);
3034 char c2 = *(fileName2++);
3035 if ((c1 >=
'a') && (c1 <=
'z'))
3037 if ((c2 >=
'a') && (c2 <=
'z'))
3040 return ((c2 ==
'\0') ? 0 : -1);
3060 if (iCaseSensitivity == 1)
3061 return strcmp(fileName1, fileName2);
3066#define BUFREADCOMMENT (0x400)
3074 if (
lufseek(fin, 0, SEEK_END) != 0)
3078 uLong uMaxBack = 0xffff;
3079 if (uMaxBack > uSizeFile)
3080 uMaxBack = uSizeFile;
3085 uLong uPosFound = 0xFFFFFFFF;
3087 uLong uBackRead = 4;
3088 while (uBackRead < uMaxBack)
3090 uLong uReadSize, uReadPos ;
3093 uBackRead = uMaxBack;
3096 uReadPos = uSizeFile - uBackRead ;
3098 if (
lufseek(fin, uReadPos, SEEK_SET) != 0)
3102 for (i = (
int)uReadSize - 3; (i--) >= 0;)
3104 if (((*(buf + i)) == 0x50) && ((*(buf + i + 1)) == 0x4b) && ((*(buf + i + 2)) == 0x05) && ((*(buf + i + 3)) == 0x06))
3106 uPosFound = uReadPos + i;
3113 if (buf)
zfree(buf);
3136 uLong central_pos, uL;
3138 if (central_pos == 0xFFFFFFFF)
3140 if (
lufseek(fin, central_pos, SEEK_SET) != 0)
3150 uLong number_disk_with_CD;
3157 uLong number_entry_CD;
3160 if ((number_entry_CD != us.
gi.
number_entry) || (number_disk_with_CD != 0) || (number_disk != 0))
3223 *pglobal_info = s->
gi;
3232 uDate = (
uLong)(ulDosDate >> 16);
3234 ptm->
tm_mon = (
uInt)((((uDate) & 0x1E0) / 0x20) - 1) ;
3235 ptm->
tm_year = (
uInt)(((uDate & 0x0FE00) / 0x0200) + 1980) ;
3237 ptm->
tm_hour = (
uInt) ((ulDosDate & 0xF800) / 0x800);
3238 ptm->
tm_min = (
uInt) ((ulDosDate & 0x7E0) / 0x20) ;
3239 ptm->
tm_sec = (
uInt) (2 * (ulDosDate & 0x1f)) ;
3246 *pfile_info_internal,
3248 uLong fileNameBufferSize,
3250 uLong extraFieldBufferSize,
3252 uLong commentBufferSize);
3256 uLong fileNameBufferSize,
void* extraField,
uLong extraFieldBufferSize,
3257 char* szComment,
uLong commentBufferSize)
3278 else if (uMagic != 0x02014b50)
3329 if ((err ==
UNZ_OK) && (szFileName != NULL))
3338 uSizeRead = fileNameBufferSize;
3340 if ((file_info.
size_filename > 0) && (fileNameBufferSize > 0))
3347 if ((err ==
UNZ_OK) && (extraField != NULL))
3353 uSizeRead = extraFieldBufferSize;
3373 if ((err ==
UNZ_OK) && (szComment != NULL))
3382 uSizeRead = commentBufferSize;
3400 if ((err ==
UNZ_OK) && (pfile_info != NULL))
3401 *pfile_info = file_info;
3403 if ((err ==
UNZ_OK) && (pfile_info_internal != NULL))
3404 *pfile_info_internal = file_info_internal;
3415 char* szFileName,
uLong fileNameBufferSize,
void* extraField,
uLong extraFieldBufferSize,
3416 char* szComment,
uLong commentBufferSize)
3419 extraField, extraFieldBufferSize, szComment, commentBufferSize);
3436 NULL, 0, NULL, 0, NULL, 0);
3463 NULL, 0, NULL, 0, NULL, 0);
3480 uLong num_fileSaved;
3481 uLong pos_in_central_dirSaved;
3503 szCurrentFileName,
sizeof(szCurrentFileName) - 1,
3522 uLong* poffset_local_extrafield,
uInt* psize_local_extrafield)
3524 uLong uMagic, uData, uFlags;
3525 uLong size_filename;
3526 uLong size_extra_field;
3530 *poffset_local_extrafield = 0;
3531 *psize_local_extrafield = 0;
3541 else if (uMagic != 0x04034b50)
3566 ((uFlags & 8) == 0))
3572 ((uFlags & 8) == 0))
3578 ((uFlags & 8) == 0))
3587 *piSizeVar += (
uInt)size_filename;
3593 *psize_local_extrafield = (
uInt)size_extra_field;
3595 *piSizeVar += (
uInt)size_extra_field;
3613 uLong offset_local_extrafield;
3614 uInt size_local_extrafield;
3626 &offset_local_extrafield, &size_local_extrafield) !=
UNZ_OK)
3630 if (pfile_in_zip_read_info == NULL)
3640 if (pfile_in_zip_read_info != 0)
zfree(pfile_in_zip_read_info);
3653 pfile_in_zip_read_info->
crc32 = 0;
3655 pfile_in_zip_read_info->
file = s->
file;
3685 pfile_in_zip_read_info->
keys[0] = 305419896L;
3686 pfile_in_zip_read_info->
keys[1] = 591751049L;
3687 pfile_in_zip_read_info->
keys[2] = 878082192L;
3688 for (
const char* cp = password; cp != 0 && *cp != 0; cp++)
Uupdate_keys(pfile_in_zip_read_info->
keys, *cp);
3713 if (reached_eof != 0) *reached_eof =
false;
3720 if (pfile_in_zip_read_info == NULL)
3722 if ((pfile_in_zip_read_info->
read_buffer == NULL))
3744 if (reached_eof != 0)
3745 *reached_eof =
true;
3760 for (
unsigned int i = 0; i < uReadThis; i++) buf[i] =
zdecode(pfile_in_zip_read_info->
keys, buf[i]);
3764 unsigned int uDoEncHead = pfile_in_zip_read_info->
encheadleft;
3769 char bufcrc = pfile_in_zip_read_info->
stream.
next_in[uDoEncHead - 1];
3773 pfile_in_zip_read_info->
encheadleft -= uDoEncHead;
3776 if (bufcrc != pfile_in_zip_read_info->
crcenctest)
3803 if (reached_eof != 0)
3804 *reached_eof =
true;
3809 uLong uTotalOutBefore, uTotalOutAfter;
3810 const Byte* bufBefore;
3819 uOutThis = uTotalOutAfter - uTotalOutBefore;
3820 pfile_in_zip_read_info->
crc32 =
ucrc32(pfile_in_zip_read_info->
crc32, bufBefore, (
uInt)(uOutThis));
3822 iRead += (
uInt)(uTotalOutAfter - uTotalOutBefore);
3825 if (reached_eof != 0)
3826 *reached_eof =
true;
3850 if (pfile_in_zip_read_info == NULL)
3867 if (pfile_in_zip_read_info == NULL)
3896 if (pfile_in_zip_read_info == NULL)
3903 return (
int)size_to_read;
3905 if (len > size_to_read)
3906 read_now = (
uInt)size_to_read;
3908 read_now = (
uInt)len ;
3916 if (
lufread(buf, (
uInt)size_to_read, 1, pfile_in_zip_read_info->
file) != 1)
3919 return (
int)read_now;
3935 if (pfile_in_zip_read_info == NULL)
3941 if (pfile_in_zip_read_info->
crc32 != pfile_in_zip_read_info->
crc32_wait)
3957 if (pfile_in_zip_read_info != 0)
zfree(pfile_in_zip_read_info);
3976 uReadThis = uSizeBuf;
3989 return (
int)uReadThis;
4005 LONGLONG i = Int32x32To64(t, 10000000) + 116444736000000000;
4007 ft.dwLowDateTime = (DWORD) i;
4008 ft.dwHighDateTime = (DWORD)(i >> 32);
4017 st.wYear = (WORD)(((dosdate >> 9) & 0x7f) + 1980);
4018 st.wMonth = (WORD)((dosdate >> 5) & 0xf);
4019 st.wDay = (WORD)(dosdate & 0x1f);
4020 st.wHour = (WORD)((dostime >> 11) & 0x1f);
4021 st.wMinute = (WORD)((dostime >> 5) & 0x3f);
4022 st.wSecond = (WORD)((dostime & 0x1f) * 2);
4023 st.wMilliseconds = 0;
4025 SystemTimeToFileTime(&st, &ft);
4038 password =
new char[strlen(pwd) + 1];
4058 ZRESULT Open(
void* z,
unsigned int len, DWORD flags);
4061 ZRESULT Unzip(
int index,
void* dst,
unsigned int len, DWORD flags);
4072#ifdef GetCurrentDirectory
4073 GetCurrentDirectory(MAX_PATH,
rootdir);
4078 if (lastchar !=
'\\' && lastchar !=
'/')
4084 DWORD res = SetFilePointer(z, 0, 0, FILE_CURRENT);
4085 bool canseek = (res != 0xFFFFFFFF);
4103 if (lastchar !=
'\\' && lastchar !=
'/')
4115 if (index ==
czei && index != -1)
4125 ze->
atime.dwLowDateTime = 0;
4126 ze->
atime.dwHighDateTime = 0;
4127 ze->
ctime.dwLowDateTime = 0;
4128 ze->
ctime.dwHighDateTime = 0;
4129 ze->
mtime.dwLowDateTime = 0;
4130 ze->
mtime.dwHighDateTime = 0;
4144 unsigned int extralen, iSizeVar;
4145 unsigned long offset;
4151 unsigned char* extra =
new unsigned char[extralen];
4159 TCHAR tfn[MAX_PATH];
4161 MultiByteToWideChar(CP_UTF8, 0, fn, -1, tfn, MAX_PATH);
4171 const TCHAR* sfn = tfn;
4174 if (sfn[0] != 0 && sfn[1] ==
':')
4190 c = _tcsstr(sfn,
_T(
"\\..\\"));
4196 c = _tcsstr(sfn,
_T(
"\\../"));
4202 c = _tcsstr(sfn,
_T(
"/../"));
4208 c = _tcsstr(sfn,
_T(
"/..\\"));
4216 _tcscpy(ze->
name, sfn);
4223 bool isdir = (a & 0x40000000) != 0;
4224 bool readonly = (a & 0x00800000) == 0;
4227 bool hidden =
false, system =
false, archive =
true;
4230 if (host == 0 || host == 7 || host == 11 || host == 14)
4232 readonly = (a & 0x00000001) != 0;
4233 hidden = (a & 0x00000002) != 0;
4234 system = (a & 0x00000004) != 0;
4235 isdir = (a & 0x00000010) != 0;
4236 archive = (a & 0x00000020) != 0;
4240 ze->
attr |= FILE_ATTRIBUTE_DIRECTORY;
4242 ze->
attr |= FILE_ATTRIBUTE_ARCHIVE;
4244 ze->
attr |= FILE_ATTRIBUTE_HIDDEN;
4246 ze->
attr |= FILE_ATTRIBUTE_READONLY;
4248 ze->
attr |= FILE_ATTRIBUTE_SYSTEM;
4252 WORD dostime = (WORD)(ufi.
dosDate & 0xFFFF);
4253 WORD dosdate = (WORD)((ufi.
dosDate >> 16) & 0xFFFF);
4256 LocalFileTimeToFileTime(&ftd, &ft);
4262 unsigned int epos = 0;
4263 while (epos + 4 < extralen)
4266 etype[0] = extra[epos + 0];
4267 etype[1] = extra[epos + 1];
4269 int size = extra[epos + 2];
4270 if (strcmp(etype,
"UT") != 0)
4275 int flags = extra[epos + 4];
4276 bool hasmtime = (flags & 1) != 0;
4277 bool hasatime = (flags & 2) != 0;
4278 bool hasctime = (flags & 4) != 0;
4282 lutime_t mtime = ((extra[epos + 0]) << 0) | ((extra[epos + 1]) << 8) | ((extra[epos + 2]) << 16) | ((extra[epos + 3]) << 24);
4288 lutime_t atime = ((extra[epos + 0]) << 0) | ((extra[epos + 1]) << 8) | ((extra[epos + 2]) << 16) | ((extra[epos + 3]) << 24);
4294 lutime_t ctime = ((extra[epos + 0]) << 0) | ((extra[epos + 1]) << 8) | ((extra[epos + 2]) << 16) | ((extra[epos + 3]) << 24);
4310 char name[MAX_PATH];
4312 WideCharToMultiByte(CP_UTF8, 0, tname, -1,
name, MAX_PATH, 0, 0);
4314 strcpy(
name, tname);
4345 if (rootdir != 0 && GetFileAttributes(rootdir) == 0xFFFFFFFF)
4346 CreateDirectory(rootdir, 0);
4349 const TCHAR* lastslash = dir, *c = lastslash;
4352 if (*c ==
'/' || *c ==
'\\') lastslash = c;
4355 const TCHAR*
name = lastslash;
4356 if (lastslash != dir)
4358 TCHAR tmp[MAX_PATH];
4359 memcpy(tmp, dir,
sizeof(TCHAR) * (lastslash - dir));
4360 tmp[lastslash - dir] = 0;
4367 _tcscpy(cd, rootdir);
4369 if (GetFileAttributes(cd) == 0xFFFFFFFF)
4370 CreateDirectory(cd, NULL);
4423 if ((ze.
attr & FILE_ATTRIBUTE_DIRECTORY) != 0)
4427 const TCHAR* dir = (
const TCHAR*)dst;
4428 bool isabsolute = (dir[0] ==
'/' || dir[0] ==
'\\' || (dir[0] != 0 && dir[1] ==
':'));
4441 const TCHAR* ufn = (
const TCHAR*)dst;
4449 const TCHAR*
name = ufn;
4450 const TCHAR* c =
name;
4453 if (*c ==
'/' || *c ==
'\\')
name = c + 1;
4456 TCHAR dir[MAX_PATH];
4461 dir[
name - ufn] = 0;
4463 bool isabsolute = (dir[0] ==
'/' || dir[0] ==
'\\' || (dir[0] != 0 && dir[1] ==
':'));
4466 wsprintf(fn,
_T(
"%s%s"), dir,
name);
4475 h = CreateFile(fn, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, ze.
attr, NULL);
4477 if (h == INVALID_HANDLE_VALUE)
4481 unzbuf =
new char[16384];
4485 for (; haderr == 0;)
4502 BOOL bres = WriteFile(h,
unzbuf, res, &writ, NULL);
4548 const TCHAR* msg =
_T(
"unknown zip result code");
4552 msg =
_T(
"Success");
4555 msg =
_T(
"Culdn't duplicate handle");
4558 msg =
_T(
"Couldn't create/open file");
4561 msg =
_T(
"Failed to allocate memory");
4564 msg =
_T(
"Error writing to file");
4567 msg =
_T(
"File not found in the zipfile");
4570 msg =
_T(
"Still more data to unzip");
4573 msg =
_T(
"Zipfile is corrupt or not a zipfile");
4576 msg =
_T(
"Error reading file");
4579 msg =
_T(
"Correct password required");
4582 msg =
_T(
"Caller: faulty arguments");
4585 msg =
_T(
"Caller: the file had already been partially unzipped");
4588 msg =
_T(
"Caller: can only get memory of a memory zipfile");
4591 msg =
_T(
"Caller: not enough space allocated for memory zipfile");
4594 msg =
_T(
"Caller: there was a previous error");
4597 msg =
_T(
"Caller: additions to the zip have already been ended");
4600 msg =
_T(
"Caller: mixing creation and opening of zip");
4603 msg =
_T(
"Zip-bug: internal initialisation not completed");
4606 msg =
_T(
"Zip-bug: trying to seek the unseekable");
4609 msg =
_T(
"Zip-bug: the anticipated size turned out wrong");
4612 msg =
_T(
"Zip-bug: tried to change mind, but not allowed");
4615 msg =
_T(
"Zip-bug: an internal error during flation");
4618 unsigned int mlen = (
unsigned int)_tcslen(msg);
4619 if (buf == 0 || len == 0)
4621 unsigned int n = mlen;
4624 _tcsncpy(buf, msg, n);
4654HZIP
OpenZip(
const TCHAR* fn,
const char* password)
4658HZIP
OpenZip(
void* z,
unsigned int len,
const char* password)
4774 if (hz == 0)
return false;
4776 return (han->
flag == 1);
ZRESULT Get(int index, ZIPENTRY *ze)
ZRESULT Find(const TCHAR *name, bool ic, int *index, ZIPENTRY *ze)
ZRESULT Open(void *z, unsigned int len, DWORD flags)
ZRESULT Unzip(int index, void *dst, unsigned int len, DWORD flags)
ZRESULT SetUnzipBaseDir(const TCHAR *dir)
if(nReturnType==EIGENVALUES)
for(unsigned int i=0;i< _mMatrix.rows();i++)
unsigned long initial_offset
uLong rest_read_compressed
uLong byte_before_the_zipfile
uLong rest_read_uncompressed
uLong offset_local_extrafield
uInt size_local_extrafield
uLong pos_local_extrafield
struct inflate_blocks_state::@33::@35 decode
inflate_codes_statef * codes
union inflate_blocks_state::@33 sub
struct inflate_blocks_state::@33::@34 trees
const inflate_huft * ltree
struct inflate_codes_state::@36::@37 code
struct inflate_codes_state::@36::@38 copy
const inflate_huft * tree
union inflate_codes_state::@36 sub
const inflate_huft * dtree
union inflate_huft_s::@31 word
struct inflate_huft_s::@31::@32 what
union internal_state::@39 sub
struct internal_state::@39::@40 check
inflate_blocks_statef * blocks
unsigned long size_file_comment
unsigned long disk_num_start
unsigned long version_needed
unsigned long internal_fa
unsigned long external_fa
unsigned long size_filename
unsigned long compressed_size
unsigned long size_file_extra
unsigned long uncompressed_size
unsigned long compression_method
unsigned long size_comment
unsigned long number_entry
unz_file_info_internal cur_file_info_internal
uLong byte_before_the_zipfile
file_in_zip_read_info_s * pfile_in_zip_read
unz_file_info cur_file_info
struct internal_state * state
void(* free_func)(voidpf opaque, voidpf address)
int inflate_codes(inflate_blocks_statef *, z_streamp, int)
const uLong * get_crc_table(void)
int unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity)
void inflate_blocks_reset(inflate_blocks_statef *, z_streamp, uLong *)
struct unz_file_info_internal_s unz_file_info_internal
int inflateInit2(z_streamp z)
int inflate_trees_fixed(uInt *, uInt *, const inflate_huft **, const inflate_huft **, z_streamp)
int inflate_flush(inflate_blocks_statef *, z_streamp, int)
int luferror(LUFILE *stream)
const uLong crc_table[256]
int unzStringFileNameCompare(const char *fileName1, const char *fileName2, int iCaseSensitivity)
ZRESULT GetZipItem(HZIP hz, int index, ZIPENTRY *ze)
FILETIME dosdatetime2filetime(WORD dosdate, WORD dostime)
void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz *ptm)
int unzlocal_CheckCurrentFileCoherencyHeader(unz_s *s, uInt *piSizeVar, uLong *poffset_local_extrafield, uInt *psize_local_extrafield)
int inflateSyncPoint(z_streamp z)
int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
const char unzip_inflate_copyright[]
void EnsureDirectory(const TCHAR *rootdir, const TCHAR *dir)
int unzlocal_getShort(LUFILE *fin, uLong *pX)
#define ZALLOC(strm, items, size)
#define SIZEZIPLOCALHEADER
bool IsZipHandleU(HZIP hz)
unsigned __int32 lutime_t
ZRESULT FindZipItem(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze)
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
FILETIME timet2filetime(const lutime_t t)
char zdecode(unsigned long *keys, char c)
const inflate_huft fixed_tl[]
void inflate_set_dictionary(inflate_blocks_statef *s, const Byte *d, uInt n)
int unzlocal_GetCurrentFileInfoInternal(unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
int inflateSync(z_streamp strm)
ZRESULT SetUnzipBaseDir(HZIP hz, const TCHAR *dir)
uLong ucrc32(uLong crc, const Byte *buf, uInt len)
int inflate_blocks(inflate_blocks_statef *, z_streamp, int)
int unzlocal_getByte(LUFILE *fin, int *pi)
int unzCloseCurrentFile(unzFile file)
const char * zlibVersion()
int inflate_fast(uInt, uInt, const inflate_huft *, const inflate_huft *, inflate_blocks_statef *, z_streamp)
#define ZFREE(strm, addr)
const uInt inflate_mask[17]
int inflate(z_streamp strm, int flush)
int lufclose(LUFILE *stream)
z_off_t unztell(unzFile file)
struct unz_global_info_s unz_global_info
int inflate_trees_dynamic(uInt, uInt, uInt *, uInt *, uInt *, inflate_huft **, inflate_huft **, inflate_huft *, z_streamp)
const char * zError(int err)
#define UNZ_INTERNALERROR
int inflate_trees_bits(uInt *, uInt *, inflate_huft **, inflate_huft *, z_streamp)
ZRESULT UnzipItemInternal(HZIP hz, int index, void *dst, unsigned int len, DWORD flags)
uLong unzlocal_SearchCentralDir(LUFILE *fin)
ZRESULT CloseZipU(HZIP hz)
LUFILE * lufopen(void *z, unsigned int len, DWORD flags, ZRESULT *err)
uLong(* check_func)(uLong check, const Byte *buf, uInt len)
inflate_codes_statef * inflate_codes_new(uInt, uInt, const inflate_huft *, const inflate_huft *, z_streamp)
#define UNZ_MAXFILENAMEINZIP
int inflateReset(z_streamp strm)
unzFile unzOpenInternal(LUFILE *fin)
ZRESULT UnzipItem(HZIP hz, int index, const TCHAR *fn)
int unzlocal_getLong(LUFILE *fin, uLong *pX)
struct z_stream_s z_stream
struct unz_file_info_s unz_file_info
uLong adler32(uLong adler, const Byte *buf, uInt len)
HZIP OpenZipInternal(void *z, unsigned int len, DWORD flags, const char *password)
unsigned int FormatZipMessageU(ZRESULT code, TCHAR *buf, unsigned int len)
int lufseek(LUFILE *stream, long offset, int whence)
int inflateEnd(z_streamp strm)
int inflateSetDictionary(z_streamp strm, const Byte *dictionary, uInt dictLength)
inflate_blocks_statef * inflate_blocks_new(z_streamp z, check_func c, uInt w)
const inflate_huft fixed_td[]
size_t lufread(void *ptr, size_t size, size_t n, LUFILE *stream)
void zcfree(voidpf opaque, voidpf ptr)
#define UNZ_END_OF_LIST_OF_FILE
int unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
int unzOpenCurrentFile(unzFile file, const char *password)
ZRESULT UnzipItemHandle(HZIP hz, int index, HANDLE h)
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
const char *const z_errmsg[10]
#define SIZECENTRALDIRITEM
HZIP OpenZipHandle(HANDLE h, const char *password)
HZIP OpenZip(const TCHAR *fn, const char *password)
char Udecrypt_byte(unsigned long *keys)
int unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info)
int inflate_blocks_sync_point(inflate_blocks_statef *s)
int huft_build(uInt *, uInt, uInt, const uInt *, const uInt *, inflate_huft **, uInt *, inflate_huft *, uInt *, uInt *)
void Uupdate_keys(unsigned long *keys, char c)
int unzGoToNextFile(unzFile file)
int strcmpcasenosensitive_internal(const char *fileName1, const char *fileName2)
int inflate_blocks_free(inflate_blocks_statef *, z_streamp)
long int luftell(LUFILE *stream)
int unzGoToFirstFile(unzFile file)
int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
const char unz_copyright[]
void inflate_codes_free(inflate_codes_statef *, z_streamp)
int unzClose(unzFile file)
int unzReadCurrentFile(unzFile file, voidp buf, unsigned len, bool *reached_eof)