14 #define READ_8(adr) ((unsigned char)*(adr)) 15 #define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) 16 #define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) 18 #define WRITE_8(buff, n) do { \ 19 *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ 21 #define WRITE_16(buff, n) do { \ 22 WRITE_8((unsigned char*)(buff), n); \ 23 WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ 25 #define WRITE_32(buff, n) do { \ 26 WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ 27 WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ 33 const char* fileOutTmp;
35 uLong* bytesRecovered;
38 FILE* fpZip = fopen(file,
"rb");
39 FILE* fpOut = fopen(fileOut,
"wb");
40 FILE* fpOutCD = fopen(fileOutTmp,
"wb");
41 if (fpZip !=
NULL && fpOut !=
NULL) {
49 while ( fread(header, 1, 30, fpZip) == 30 ) {
50 int currentOffset =
offset;
53 if (
READ_32(header) == 0x04034b50) {
55 unsigned int gpflag =
READ_16(header + 6);
58 unsigned int filedate =
READ_16(header + 12);
59 unsigned int crc =
READ_32(header + 14);
60 unsigned int cpsize =
READ_32(header + 18);
61 unsigned int uncpsize =
READ_32(header + 22);
62 unsigned int fnsize =
READ_16(header + 26);
63 unsigned int extsize =
READ_16(header + 28);
64 filename[0] = extra[0] =
'\0';
67 if (fwrite(header, 1, 30, fpOut) == 30) {
76 if (fnsize <
sizeof(filename)) {
77 if (fread(filename, 1, fnsize, fpZip) == fnsize) {
78 if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {
99 if (extsize <
sizeof(extra)) {
100 if (fread(extra, 1, extsize, fpZip) == extsize) {
101 if (fwrite(extra, 1, extsize, fpOut) == extsize) {
126 if ((
int)fread(data, 1, dataSize, fpZip) == dataSize) {
127 if ((
int)fwrite(data, 1, dataSize, fpOut) == dataSize) {
151 int comsize = (
int) strlen(comment);
168 WRITE_32(header + 42, currentOffset);
170 if (fwrite(header, 1, 46, fpOutCD) == 46) {
175 if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
188 if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {
198 if ((
int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
226 int comsize = (
int) strlen(comment);
227 if (entriesZip > 0xffff) {
240 if (fwrite(header, 1, 22, fpOutCD) == 22) {
244 if ((
int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
257 fpOutCD = fopen(fileOutTmp,
"rb");
258 if (fpOutCD !=
NULL) {
261 while ( (nRead = (
int)fread(buffer, 1,
sizeof(buffer), fpOutCD)) > 0) {
262 if ((
int)fwrite(buffer, 1, nRead, fpOut) != nRead) {
276 (
void)
remove(fileOutTmp);
280 if (nRecovered !=
NULL) {
283 if (bytesRecovered !=
NULL) {
284 *bytesRecovered = totalBytes;
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
uLong filetime(char *f, tm_zip *tmzip, uLong *dt)
GLsizei GLsizei GLenum GLenum const GLvoid * data
png_infop png_sPLT_tpp entries