summaryrefslogtreecommitdiffstats
path: root/contrib/expat/examples
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-12-10 21:15:25 +0000
committerdelphij <delphij@FreeBSD.org>2009-12-10 21:15:25 +0000
commitec9b7e31858761e82682d82f4a00e6661922bc95 (patch)
treeaff2519e37814701a4cd95799dce8cd013dbece7 /contrib/expat/examples
parenteef7fc6660961eb9e0913c4fe68b72df0f9fb8c3 (diff)
downloadFreeBSD-src-ec9b7e31858761e82682d82f4a00e6661922bc95.zip
FreeBSD-src-ec9b7e31858761e82682d82f4a00e6661922bc95.tar.gz
Flattern all tags and dist tree for expat.
Diffstat (limited to 'contrib/expat/examples')
-rw-r--r--contrib/expat/examples/elements.c65
-rw-r--r--contrib/expat/examples/outline.c106
2 files changed, 0 insertions, 171 deletions
diff --git a/contrib/expat/examples/elements.c b/contrib/expat/examples/elements.c
deleted file mode 100644
index 6b8f855..0000000
--- a/contrib/expat/examples/elements.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* This is simple demonstration of how to use expat. This program
- 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"
-
-#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
-
-static void XMLCALL
-startElement(void *userData, const char *name, const char **atts)
-{
- int i;
- int *depthPtr = (int *)userData;
- for (i = 0; i < *depthPtr; i++)
- putchar('\t');
- puts(name);
- *depthPtr += 1;
-}
-
-static void XMLCALL
-endElement(void *userData, const char *name)
-{
- int *depthPtr = (int *)userData;
- *depthPtr -= 1;
-}
-
-int
-main(int argc, char *argv[])
-{
- char buf[BUFSIZ];
- XML_Parser parser = XML_ParserCreate(NULL);
- int done;
- int depth = 0;
- XML_SetUserData(parser, &depth);
- XML_SetElementHandler(parser, startElement, endElement);
- do {
- int len = (int)fread(buf, 1, sizeof(buf), stdin);
- done = len < sizeof(buf);
- if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
- fprintf(stderr,
- "%s at line %" XML_FMT_INT_MOD "u\n",
- XML_ErrorString(XML_GetErrorCode(parser)),
- XML_GetCurrentLineNumber(parser));
- return 1;
- }
- } while (!done);
- XML_ParserFree(parser);
- return 0;
-}
diff --git a/contrib/expat/examples/outline.c b/contrib/expat/examples/outline.c
deleted file mode 100644
index 3a3c838..0000000
--- a/contrib/expat/examples/outline.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*****************************************************************
- * outline.c
- *
- * Copyright 1999, Clark Cooper
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the license contained in the
- * COPYING file that comes with the expat distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * 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 XMLCALL
-start(void *data, const char *el, const char **attr)
-{
- int i;
-
- for (i = 0; i < Depth; i++)
- printf(" ");
-
- printf("%s", el);
-
- for (i = 0; attr[i]; i += 2) {
- printf(" %s='%s'", attr[i], attr[i + 1]);
- }
-
- printf("\n");
- Depth++;
-}
-
-static void XMLCALL
-end(void *data, const char *el)
-{
- Depth--;
-}
-
-int
-main(int argc, char *argv[])
-{
- XML_Parser p = XML_ParserCreate(NULL);
- if (! p) {
- fprintf(stderr, "Couldn't allocate memory for parser\n");
- exit(-1);
- }
-
- XML_SetElementHandler(p, start, end);
-
- for (;;) {
- int done;
- int len;
-
- 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 %" 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;
-}
OpenPOWER on IntegriCloud