Demonstrates low level ZIP read functionality as needed by the high level opcContainer API.
#include <stdio.h>
#include <libxml/xmlstring.h>
#include <time.h>
#include <zlib.h>
#ifdef WIN32
#include <crtdbg.h>
#endif
void *userctx,
char buf[100];
int ret=0;
while((ret=read(iocontext, buf, sizeof(buf)))>0) {
crc=crc32(crc, (const Bytef*)buf, ret);
}
return OPC_ERROR_NONE;
}
const xmlChar *name=NULL;
xmlFree((void*)name);
return OPC_ERROR_NONE;
}
int main( int argc, const char* argv[] )
{
#ifdef WIN32
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
time_t start_time=time(NULL);
if (argc>2) {
if (NULL!=zip) {
if (OPC_ERROR_NONE==err) {
-1!=segment_id;
const xmlChar *name=NULL;
if (!rels_segment && 0==xmlStrcmp(name, _X(argv[2]))) {
printf("extracting \"%s\"\n", name);
if (NULL!=stream) {
crc=crc32(crc, (const Bytef*)buf, ret);
}
}
} else {
printf("skip \"%s\" %s\n", name, (rels_segment?"(.rels)":""));
}
}
}
} else {
}
}
}
}
time_t end_time=time(NULL);
fprintf(stderr, "time %.2lfsec\n", difftime(end_time, start_time));
#ifdef WIN32
#endif
return (OPC_ERROR_NONE==err?0:3);
}