*
* 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;
Depth++;
}
-static void
+static void XMLCALL
end(void *data, const char *el)
{
Depth--;
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);
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);
if (done)
break;
}
+ XML_ParserFree(p);
return 0;
}