libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 9828a49040d8b3f336aa2dea5a9a9f0bde85e2ae
parent 41069e92b3386845287e69307187d38f92213c3a
Author: LRN <lrn1986@gmail.com>
Date:   Sat,  4 Aug 2012 19:26:25 +0000

Slightly better abort for W32

Diffstat:
Msrc/include/platform.h | 6++++++
Msrc/main/extractor_logging.c | 2+-
Msrc/main/extractor_plugins.c | 2+-
Msrc/main/test_extractor.c | 32++++++++++++++++----------------
4 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/include/platform.h b/src/include/platform.h @@ -75,4 +75,10 @@ #include <mach-o/ldsyms.h> #endif +#if !WINDOWS +#define ABORT() abort() +#else +#define ABORT() DebugBreak () +#endif + #endif diff --git a/src/main/extractor_logging.c b/src/main/extractor_logging.c @@ -62,7 +62,7 @@ EXTRACTOR_abort_ (const char *file, #if DEBUG EXTRACTOR_log_ (file, line, "Assertion failed.\n"); #endif - abort (); + ABORT (); } /* end of extractor_logging.c */ diff --git a/src/main/extractor_plugins.c b/src/main/extractor_plugins.c @@ -308,7 +308,7 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev, cpy[pos++] = '\0'; /* replace ':' by termination */ break; default: - abort (); + ABORT (); } if ('-' == cpy[last]) { diff --git a/src/main/test_extractor.c b/src/main/test_extractor.c @@ -54,81 +54,81 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) if (4 != ec->read (ec->cls, &dp, 4)) { fprintf (stderr, "Reading at offset 0 failed\n"); - abort (); + ABORT (); } if (0 != strncmp ("test", dp, 4)) { fprintf (stderr, "Unexpected data at offset 0\n"); - abort (); + ABORT (); } if ( (1024 * 150 != ec->get_size (ec->cls)) && (UINT64_MAX != ec->get_size (ec->cls)) ) { fprintf (stderr, "Unexpected file size returned (expected 150k)\n"); - abort (); + ABORT (); } if (1024 * 100 + 4 != ec->seek (ec->cls, 1024 * 100 + 4, SEEK_SET)) { fprintf (stderr, "Failure to seek (SEEK_SET)\n"); - abort (); + ABORT (); } if (1 != ec->read (ec->cls, &dp, 1)) { fprintf (stderr, "Failure to read at 100k + 4\n"); - abort (); + ABORT (); } if ((1024 * 100 + 4) % 256 != * (unsigned char *) dp) { fprintf (stderr, "Unexpected data at offset 100k + 4\n"); - abort (); + ABORT (); } if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) != ec->seek (ec->cls, - (1024 * 50 + 7), SEEK_CUR)) { fprintf (stderr, "Failure to seek (SEEK_SET)\n"); - abort (); + ABORT (); } if (1 != ec->read (ec->cls, &dp, 1)) { fprintf (stderr, "Failure to read at 50k - 3\n"); - abort (); + ABORT (); } if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != * (unsigned char *) dp) { fprintf (stderr, "Unexpected data at offset 100k - 3\n"); - abort (); + ABORT (); } if (1024 * 150 != ec->seek (ec->cls, 0, SEEK_END)) { fprintf (stderr, "Failure to seek (SEEK_END)\n"); - abort (); + ABORT (); } if (0 != ec->read (ec->cls, &dp, 1)) { fprintf (stderr, "Failed to receive EOF at 150k\n"); - abort (); + ABORT (); } if (1024 * 150 - 2 != ec->seek (ec->cls, -2, SEEK_END)) { fprintf (stderr, "Failure to seek (SEEK_END - 2)\n"); - abort (); + ABORT (); } if (1 != ec->read (ec->cls, &dp, 1)) { fprintf (stderr, "Failure to read at 150k - 3\n"); - abort (); + ABORT (); } if ((1024 * 150 - 2) % 256 != * (unsigned char *) dp) { fprintf (stderr, "Unexpected data at offset 150k - 3\n"); - abort (); + ABORT (); } if (0 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT, EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!", strlen ("Hello world!") + 1)) { fprintf (stderr, "Unexpected return value from 'proc'\n"); - abort (); + ABORT (); } /* The test assumes that client orders us to stop extraction * after seeing "Goodbye!". @@ -138,7 +138,7 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) strlen ("Goodbye!") + 1)) { fprintf (stderr, "Unexpected return value from 'proc'\n"); - abort (); + ABORT (); } }