summaryrefslogtreecommitdiffstats
path: root/contrib/expat/examples/outline.c
diff options
context:
space:
mode:
authorcokane <cokane@FreeBSD.org>2008-05-08 13:51:16 +0000
committercokane <cokane@FreeBSD.org>2008-05-08 13:51:16 +0000
commiteef7fc6660961eb9e0913c4fe68b72df0f9fb8c3 (patch)
tree140a049e6dfd3941649feaf205e3a527a7543b00 /contrib/expat/examples/outline.c
parent676528b41eb1d7ef205f19c99dcb9585d9105d85 (diff)
downloadFreeBSD-src-eef7fc6660961eb9e0913c4fe68b72df0f9fb8c3.zip
FreeBSD-src-eef7fc6660961eb9e0913c4fe68b72df0f9fb8c3.tar.gz
Virgin import (trimmed) of eXpat v2.0.1. Discussed and tested with
sam and phk who are the two consumers of this library. If there is any other fallout, email me and I will take care of it. Approved by: sam, phk
Diffstat (limited to 'contrib/expat/examples/outline.c')
-rw-r--r--contrib/expat/examples/outline.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/contrib/expat/examples/outline.c b/contrib/expat/examples/outline.c
index 10f6d1d..3a3c838 100644
--- a/contrib/expat/examples/outline.c
+++ b/contrib/expat/examples/outline.c
@@ -18,19 +18,34 @@
*
* 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>
+#if defined(__amigaos__) && defined(__USE_INLINE__)
+#include <proto/expat.h>
+#endif
+
+#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,7 +63,7 @@ start(void *data, const char *el, const char **attr)
Depth++;
}
-static void
+static void XMLCALL
end(void *data, const char *el)
{
Depth--;
@@ -69,7 +84,7 @@ main(int argc, char *argv[])
int done;
int len;
- len = fread(Buff, 1, BUFFSIZE, stdin);
+ len = (int)fread(Buff, 1, BUFFSIZE, stdin);
if (ferror(stdin)) {
fprintf(stderr, "Read error\n");
exit(-1);
@@ -77,7 +92,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);
@@ -86,5 +101,6 @@ main(int argc, char *argv[])
if (done)
break;
}
+ XML_ParserFree(p);
return 0;
}
OpenPOWER on IntegriCloud