diff options
author | Aleksander Piotrowski <alek@cvs.openbsd.org> | 2006-05-06 16:09:32 +0000 |
---|---|---|
committer | Aleksander Piotrowski <alek@cvs.openbsd.org> | 2006-05-06 16:09:32 +0000 |
commit | 0941726c718d0c63478583c6d822d4a893c9b7a9 (patch) | |
tree | c5afe263729a3dff78207e39d910197f0f1450fd /lib/libexpat/examples | |
parent | 4202274c4958484629e8a5c593c1dd7dcf582469 (diff) |
Update to 2.0.0; keep our local changes
ok espie@, djm@
Diffstat (limited to 'lib/libexpat/examples')
-rw-r--r-- | lib/libexpat/examples/elements.c | 27 | ||||
-rw-r--r-- | lib/libexpat/examples/outline.c | 23 |
2 files changed, 42 insertions, 8 deletions
diff --git a/lib/libexpat/examples/elements.c b/lib/libexpat/examples/elements.c index 4ed4da6a346..421a1ce7793 100644 --- a/lib/libexpat/examples/elements.c +++ b/lib/libexpat/examples/elements.c @@ -2,31 +2,48 @@ reads an XML document from standard input and writes a line with the name of each element to standard output indenting child elements by one tab stop more than their parent element. + It must be used with Expat compiled for UTF-8 output. */ #include <stdio.h> #include "expat.h" -static void +#ifdef XML_LARGE_SIZE +#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 +#define XML_FMT_INT_MOD "I64" +#else +#define XML_FMT_INT_MOD "ll" +#endif +#else +#define XML_FMT_INT_MOD "l" +#endif + +static void XMLCALL startElement(void *userData, const char *name, const char **atts) { int i; - int *depthPtr = userData; + int *depthPtr = (int *)userData; for (i = 0; i < *depthPtr; i++) putchar('\t'); puts(name); *depthPtr += 1; } -static void +static void XMLCALL endElement(void *userData, const char *name) { - int *depthPtr = userData; + int *depthPtr = (int *)userData; *depthPtr -= 1; } +#ifdef AMIGA_SHARED_LIB +#include <proto/expat.h> +int +amiga_main(int argc, char *argv[]) +#else int main(int argc, char *argv[]) +#endif { char buf[BUFSIZ]; XML_Parser parser = XML_ParserCreate(NULL); @@ -39,7 +56,7 @@ main(int argc, char *argv[]) done = len < sizeof(buf); if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { fprintf(stderr, - "%s at line %d\n", + "%s at line %" XML_FMT_INT_MOD "u\n", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); return 1; diff --git a/lib/libexpat/examples/outline.c b/lib/libexpat/examples/outline.c index 10f6d1db5b8..807ddb89e03 100644 --- a/lib/libexpat/examples/outline.c +++ b/lib/libexpat/examples/outline.c @@ -18,19 +18,30 @@ * * Read an XML document from standard input and print an element * outline on standard output. + * Must be used with Expat compiled for UTF-8 output. */ #include <stdio.h> #include <expat.h> +#ifdef XML_LARGE_SIZE +#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 +#define XML_FMT_INT_MOD "I64" +#else +#define XML_FMT_INT_MOD "ll" +#endif +#else +#define XML_FMT_INT_MOD "l" +#endif + #define BUFFSIZE 8192 char Buff[BUFFSIZE]; int Depth; -static void +static void XMLCALL start(void *data, const char *el, const char **attr) { int i; @@ -48,14 +59,20 @@ start(void *data, const char *el, const char **attr) Depth++; } -static void +static void XMLCALL end(void *data, const char *el) { Depth--; } +#ifdef AMIGA_SHARED_LIB +#include <proto/expat.h> +int +amiga_main(int argc, char *argv[]) +#else int main(int argc, char *argv[]) +#endif { XML_Parser p = XML_ParserCreate(NULL); if (! p) { @@ -77,7 +94,7 @@ main(int argc, char *argv[]) done = feof(stdin); if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) { - fprintf(stderr, "Parse error at line %d:\n%s\n", + fprintf(stderr, "Parse error at line %" XML_FMT_INT_MOD "u:\n%s\n", XML_GetCurrentLineNumber(p), XML_ErrorString(XML_GetErrorCode(p))); exit(-1); |