aboutsummaryrefslogtreecommitdiff
path: root/expat/examples
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-10-18 13:24:37 +0200
committermarha <marha@users.sourceforge.net>2013-10-18 13:27:05 +0200
commit5880b059e9a156336daf32a73bed72def6ba90f2 (patch)
tree376112133a13389f5599e008c9f858c35f0cd70b /expat/examples
parentb8a77c943fa53005b6cdb1ab792acf5ff0a131be (diff)
downloadvcxsrv-5880b059e9a156336daf32a73bed72def6ba90f2.tar.gz
vcxsrv-5880b059e9a156336daf32a73bed72def6ba90f2.tar.bz2
vcxsrv-5880b059e9a156336daf32a73bed72def6ba90f2.zip
Added expat-2.1.0
Diffstat (limited to 'expat/examples')
-rw-r--r--expat/examples/elements.c65
-rw-r--r--expat/examples/elements.dsp103
-rw-r--r--expat/examples/outline.c106
-rw-r--r--expat/examples/outline.dsp103
4 files changed, 377 insertions, 0 deletions
diff --git a/expat/examples/elements.c b/expat/examples/elements.c
new file mode 100644
index 000000000..6b8f85501
--- /dev/null
+++ b/expat/examples/elements.c
@@ -0,0 +1,65 @@
+/* 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/expat/examples/elements.dsp b/expat/examples/elements.dsp
new file mode 100644
index 000000000..d3fa3682c
--- /dev/null
+++ b/expat/examples/elements.dsp
@@ -0,0 +1,103 @@
+# Microsoft Developer Studio Project File - Name="elements" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=elements - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "elements.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "elements.mak" CFG="elements - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "elements - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "elements - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "elements - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\win32\bin\Release"
+# PROP Intermediate_Dir "..\win32\tmp\Release-elements"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\lib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "XML_STATIC" /FD /c
+# SUBTRACT CPP /X /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
+# ADD LINK32 libexpatMT.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\win32\bin\Release" /out:"..\win32\bin\Release\elements.exe"
+
+!ELSEIF "$(CFG)" == "elements - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\win32\bin\Debug"
+# PROP Intermediate_Dir "..\win32\tmp\Debug-elements"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "..\lib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "XML_STATIC" /FR /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 libexpatMT.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\win32\bin\Debug" /out:"..\win32\bin\Debug\elements.exe"
+
+!ENDIF
+
+# Begin Target
+
+# Name "elements - Win32 Release"
+# Name "elements - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\elements.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/expat/examples/outline.c b/expat/examples/outline.c
new file mode 100644
index 000000000..3a3c83855
--- /dev/null
+++ b/expat/examples/outline.c
@@ -0,0 +1,106 @@
+/*****************************************************************
+ * 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;
+}
diff --git a/expat/examples/outline.dsp b/expat/examples/outline.dsp
new file mode 100644
index 000000000..0c063fd4e
--- /dev/null
+++ b/expat/examples/outline.dsp
@@ -0,0 +1,103 @@
+# Microsoft Developer Studio Project File - Name="outline" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=outline - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "outline.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "outline.mak" CFG="outline - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "outline - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "outline - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "outline - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\win32\bin\Release"
+# PROP Intermediate_Dir "..\win32\tmp\Release-outline"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\lib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /X /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
+# ADD LINK32 libexpat.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\win32\bin\Release" /out:"..\win32\bin\Release\outline.exe"
+
+!ELSEIF "$(CFG)" == "outline - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\win32\bin\Debug"
+# PROP Intermediate_Dir "..\win32\tmp\Debug-outline"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\lib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 libexpat.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\win32\bin\Debug" /out:"..\win32\bin\Debug\outline.exe"
+
+!ENDIF
+
+# Begin Target
+
+# Name "outline - Win32 Release"
+# Name "outline - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\outline.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project