12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #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);
- opcContainerClose(c, OPC_CLOSE_NOW);
- } else {
- printf("ERROR: \"%s\" could not be opened.\n", argv[1]);
- err=OPC_ERROR_STREAM;
- }
- }
- opcFreeLibrary();
- } 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);
- }
|