Add first test to parse cdh
This commit is contained in:
parent
d7f7d4386d
commit
fe7ca3c37a
1 changed files with 29 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "libmineziper_zip.h"
|
#include "libmineziper_zip.h"
|
||||||
|
|
||||||
#define BUF_SIZE 10000
|
#define BUF_SIZE 0xfffff
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
@ -16,11 +16,37 @@ int main(int argc, char** argv)
|
||||||
zip zip;
|
zip zip;
|
||||||
raw raw;
|
raw raw;
|
||||||
|
|
||||||
raw.size = fread(buf, BUF_SIZE, 1, stream);
|
raw.size = fread(buf, 1, BUF_SIZE, stream);
|
||||||
buf[BUF_SIZE] = '\0';
|
buf[BUF_SIZE] = '\0';
|
||||||
raw.buf = buf;
|
raw.buf = buf;
|
||||||
|
|
||||||
find_cdh(&raw, &zip);
|
get_eocd(&raw, &zip);
|
||||||
|
get_cdh(&raw, &zip);
|
||||||
|
|
||||||
|
printf(
|
||||||
|
"eocd = {\n nb of entry: %x\n off cd: %d\n size cd: 0x%x\n}\n",
|
||||||
|
zip.eocd->number_of_entries,
|
||||||
|
zip.eocd->off_cdh,
|
||||||
|
zip.eocd->size_cdh);
|
||||||
|
|
||||||
|
for (int i = 0; i < zip.eocd->number_of_entries; i++)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"cdh %d = {\n sig: 0x%x\n off lfh: 0x%x\n "
|
||||||
|
"comp size: 0x%x\n uncomp size: 0x%x\n filename: ",
|
||||||
|
i,
|
||||||
|
zip.cdh[i]->sig,
|
||||||
|
zip.cdh[i]->off_lfh,
|
||||||
|
zip.cdh[i]->compressed_size,
|
||||||
|
zip.cdh[i]->uncompressed_size);
|
||||||
|
|
||||||
|
for (int j = 0; j < zip.cdh[i]->filename_length; j++)
|
||||||
|
{
|
||||||
|
printf("%c", ((char*) zip.cdh[i])[sizeof(CDH) + j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n}\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue