libopc
opc_dump.c

Demonstrates the the use of opcContainerOpen, opcContainerClose and opcContainerDump.

/*
Dump all information about an OPC container.
Ussage:
opc_dump FILENAME
Sample:
opc_dump OOXMLI1.docx
*/
#include <opc/opc.h>
#include <stdio.h>
#include <time.h>
#ifdef WIN32
#include <crtdbg.h>
#endif
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);
opc_error_t err=OPC_ERROR_NONE;
if (OPC_ERROR_NONE==opcInitLibrary()) {
if (2==argc) {
opcContainer *c=NULL;
if (NULL!=(c=opcContainerOpen(_X(argv[1]), OPC_OPEN_READ_ONLY, NULL, NULL))) {
opcContainerDump(c, stdout);
} else {
printf("ERROR: \"%s\" could not be opened.\n", argv[1]);
err=OPC_ERROR_STREAM;
}
}
} else if (2==argc) {
printf("ERROR: initialization of libopc failed.\n");
err=OPC_ERROR_STREAM;
} else {
printf("opc_dump FILENAME.\n\n");
printf("Sample: opc_dump test.docx\n");
}
time_t end_time=time(NULL);
fprintf(stderr, "time %.2lfsec\n", difftime(end_time, start_time));
#ifdef WIN32
OPC_ASSERT(!_CrtDumpMemoryLeaks());
#endif
return (OPC_ERROR_NONE==err?0:3);
}