diff --git a/expat/expat.mak b/expat/expat.mak new file mode 100755 index 00000000..5f5d8ada --- /dev/null +++ b/expat/expat.mak @@ -0,0 +1,477 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +!IF "$(CFG)" == "" +CFG=xmlec - Win32 Debug +!MESSAGE No configuration specified. Defaulting to xmlec - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "xmltok - Win32 Release" && "$(CFG)" != "xmltok - Win32 Debug"\ + && "$(CFG)" != "xmlec - Win32 Release" && "$(CFG)" != "xmlec - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "xmltok.mak" CFG="xmlec - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "xmltok - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "xmltok - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "xmlec - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "xmlec - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project + +!IF "$(CFG)" == "xmltok - 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 "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\xmltok.dll" + +CLEAN : + -@erase "$(INTDIR)\wxmltok.obj" + -@erase "$(INTDIR)\xmltok.obj" + -@erase "$(OUTDIR)\xmltok.dll" + -@erase "$(OUTDIR)\xmltok.exp" + -@erase "$(OUTDIR)\xmltok.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ + /Fp"$(INTDIR)/xmltok.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/xmltok.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# SUBTRACT LINK32 /nodefaultlib +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\ + /pdb:"$(OUTDIR)/xmltok.pdb" /machine:I386 /out:"$(OUTDIR)/xmltok.dll"\ + /implib:"$(OUTDIR)/xmltok.lib" +LINK32_OBJS= \ + "$(INTDIR)\wxmltok.obj" \ + "$(INTDIR)\xmltok.obj" + +"$(OUTDIR)\xmltok.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "xmltok - 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 "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +OUTDIR=.\Debug +INTDIR=.\Debug + +ALL : "$(OUTDIR)\xmltok.dll" + +CLEAN : + -@erase "$(INTDIR)\vc40.idb" + -@erase "$(INTDIR)\vc40.pdb" + -@erase "$(INTDIR)\wxmltok.obj" + -@erase "$(INTDIR)\xmltok.obj" + -@erase "$(OUTDIR)\xmltok.dll" + -@erase "$(OUTDIR)\xmltok.exp" + -@erase "$(OUTDIR)\xmltok.ilk" + -@erase "$(OUTDIR)\xmltok.lib" + -@erase "$(OUTDIR)\xmltok.pdb" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +CPP_PROJ=/nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\ + /Fp"$(INTDIR)/xmltok.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c +CPP_OBJS=.\Debug/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/xmltok.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes\ + /pdb:"$(OUTDIR)/xmltok.pdb" /debug /machine:I386 /out:"$(OUTDIR)/xmltok.dll"\ + /implib:"$(OUTDIR)/xmltok.lib" +LINK32_OBJS= \ + "$(INTDIR)\wxmltok.obj" \ + "$(INTDIR)\xmltok.obj" + +"$(OUTDIR)\xmltok.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "xmlec - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "xmlec\Release" +# PROP BASE Intermediate_Dir "xmlec\Release" +# PROP BASE Target_Dir "xmlec" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "xmlec\Release" +# PROP Intermediate_Dir "xmlec\Release" +# PROP Target_Dir "xmlec" +OUTDIR=.\xmlec\Release +INTDIR=.\xmlec\Release + +ALL : "xmltok - Win32 Release" ".\Release\xmlec.exe" + +CLEAN : + -@erase "$(INTDIR)\xmlec.obj" + -@erase ".\Release\xmlec.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ + /Fp"$(INTDIR)/xmlec.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\xmlec\Release/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/xmlec.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"Release/xmlec.exe" +LINK32_FLAGS=setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\ + /pdb:"$(OUTDIR)/xmlec.pdb" /machine:I386 /out:"Release/xmlec.exe" +LINK32_OBJS= \ + "$(INTDIR)\xmlec.obj" \ + ".\Release\xmltok.lib" + +".\Release\xmlec.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "xmlec - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "xmlec\Debug" +# PROP BASE Intermediate_Dir "xmlec\Debug" +# PROP BASE Target_Dir "xmlec" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "xmlec\Debug" +# PROP Intermediate_Dir "xmlec\Debug" +# PROP Target_Dir "xmlec" +OUTDIR=.\xmlec\Debug +INTDIR=.\xmlec\Debug + +ALL : "xmltok - Win32 Debug" ".\Debug\xmlec.exe" + +CLEAN : + -@erase "$(INTDIR)\vc40.idb" + -@erase "$(INTDIR)\vc40.pdb" + -@erase "$(INTDIR)\xmlec.obj" + -@erase "$(OUTDIR)\xmlec.pdb" + -@erase ".\Debug\xmlec.exe" + -@erase ".\Debug\xmlec.ilk" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c +CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "." /D "WIN32" /D "_DEBUG" /D\ + "_CONSOLE" /Fp"$(INTDIR)/xmlec.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c +CPP_OBJS=.\xmlec\Debug/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/xmlec.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 +# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/xmlec.exe" +LINK32_FLAGS=setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib\ + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\ + odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes\ + /pdb:"$(OUTDIR)/xmlec.pdb" /debug /machine:I386 /out:"Debug/xmlec.exe" +LINK32_OBJS= \ + "$(INTDIR)\xmlec.obj" \ + ".\Debug\xmltok.lib" + +".\Debug\xmlec.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + +################################################################################ +# Begin Target + +# Name "xmltok - Win32 Release" +# Name "xmltok - Win32 Debug" + +!IF "$(CFG)" == "xmltok - Win32 Release" + +!ELSEIF "$(CFG)" == "xmltok - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\xmltok.c + +!IF "$(CFG)" == "xmltok - Win32 Release" + +DEP_CPP_XMLTO=\ + ".\XmlTok.h"\ + + +"$(INTDIR)\xmltok.obj" : $(SOURCE) $(DEP_CPP_XMLTO) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "xmltok - Win32 Debug" + +DEP_CPP_XMLTO=\ + ".\XmlTok.h"\ + + +"$(INTDIR)\xmltok.obj" : $(SOURCE) $(DEP_CPP_XMLTO) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\wxmltok.c + +!IF "$(CFG)" == "xmltok - Win32 Release" + +DEP_CPP_WXMLT=\ + ".\xmltok.c"\ + ".\XmlTok.h"\ + + +"$(INTDIR)\wxmltok.obj" : $(SOURCE) $(DEP_CPP_WXMLT) "$(INTDIR)" ".\xmltok.c" + + +!ELSEIF "$(CFG)" == "xmltok - Win32 Debug" + +DEP_CPP_WXMLT=\ + ".\xmltok.c"\ + ".\XmlTok.h"\ + + +"$(INTDIR)\wxmltok.obj" : $(SOURCE) $(DEP_CPP_WXMLT) "$(INTDIR)" ".\xmltok.c" + + +!ENDIF + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "xmlec - Win32 Release" +# Name "xmlec - Win32 Debug" + +!IF "$(CFG)" == "xmlec - Win32 Release" + +!ELSEIF "$(CFG)" == "xmlec - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Project Dependency + +# Project_Dep_Name "xmltok" + +!IF "$(CFG)" == "xmlec - Win32 Release" + +"xmltok - Win32 Release" : + $(MAKE) /$(MAKEFLAGS) /F ".\xmltok.mak" CFG="xmltok - Win32 Release" + +!ELSEIF "$(CFG)" == "xmlec - Win32 Debug" + +"xmltok - Win32 Debug" : + $(MAKE) /$(MAKEFLAGS) /F ".\xmltok.mak" CFG="xmltok - Win32 Debug" + +!ENDIF + +# End Project Dependency +################################################################################ +# Begin Source File + +SOURCE=.\xmlec\xmlec.c +DEP_CPP_XMLEC=\ + ".\XmlTok.h"\ + + +"$(INTDIR)\xmlec.obj" : $(SOURCE) $(DEP_CPP_XMLEC) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/expat/expat.pj b/expat/expat.pj new file mode 100755 index 00000000..07c9be56 --- /dev/null +++ b/expat/expat.pj @@ -0,0 +1,3 @@ +--MKS Project-- +$Revision: 1.17 $ +EndOptions diff --git a/expat/xmlec/xmlec.c b/expat/xmlec/xmlec.c new file mode 100755 index 00000000..ff51ac36 --- /dev/null +++ b/expat/xmlec/xmlec.c @@ -0,0 +1,286 @@ +#include + +#ifdef _MSC_VER +#define FILEMAP +#endif + +#ifdef _MSC_VER +#define XMLTOKAPI __declspec(dllimport) +#endif +#include "XmlTok.h" + +#ifdef FILEMAP + +#define STRICT 1 +#include + +static +int XmlSkipProlog(const char **s, const char *end, const char **nextTokP); + +int XmlParse(const char *s, size_t n, const char *filename) +{ + unsigned nElements = 0; + const char *start = s; + const char *end = s + n; + const char *next; + int tok = XmlSkipProlog(&s, end, &next); + for (;;) { + switch (tok) { + case XML_TOK_NONE: + if (nElements == 0) { + fprintf(stderr, "%s: no instance\n", filename); + return 0; + } + printf("%8u %s\n", nElements, filename); + return 1; + case XML_TOK_INVALID: + fprintf(stderr, "%s: well-formedness error at byte %lu\n", + filename, (unsigned long)(s - start)); + return 0; + case XML_TOK_PARTIAL: + fprintf(stderr, "%s: unclosed token started at byte %lu\n", + filename, (unsigned long)(s - start)); + return 0; + case XML_TOK_COMMENT: + break; + case XML_TOK_START_TAG: + nElements++; + break; + default: + break; + } + s = next; + tok = XmlContentTok(s, end, &next); + } + /* not reached */ +} + +static +int XmlSkipProlog(const char **startp, const char *end, const char **nextTokP) +{ + const char *s = *startp; + for (;;) { + int tok = XmlPrologTok(s, end, nextTokP); + switch (tok) { + case XML_TOK_NONE: + case XML_TOK_INVALID: + case XML_TOK_PARTIAL: + case XML_TOK_START_TAG: + *startp = s; + return tok; + default: + break; + } + s = *nextTokP; + } + /* not reached */ +} + +static +int doFile(const char *name) +{ + HANDLE f; + HANDLE m; + DWORD size; + const char *p; + int ret; + + f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (f == INVALID_HANDLE_VALUE) { + fprintf(stderr, "%s: CreateFile failed\n", name); + return 0; + } + size = GetFileSize(f, NULL); + m = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL); + if (m == NULL) { + fprintf(stderr, "%s: CreateFileMapping failed\n", name); + CloseHandle(f); + return 0; + } + p = (const char *)MapViewOfFile(m, FILE_MAP_READ, 0, 0, 0); + if (p == NULL) { + CloseHandle(m); + CloseHandle(f); + fprintf(stderr, "%s: MapViewOfFile failed\n", name); + return 0; + } + ret = XmlParse(p, size, name); + UnmapViewOfFile(p); + CloseHandle(m); + CloseHandle(f); + return ret; +} + +#else /* not FILEMAP */ + +#include +#include +#include +#include +#include + +struct XmlTokBuffer { + char *buf; + char *end; + char *ptr; + size_t size; + int fd; + int doneProlog; + int eof; + unsigned long endOffset; +}; + +#define XmlTokBufferOffset(tb) ((tb)->endOffset - ((tb)->end - (tb)->ptr)) +#define READSIZE 1024 + +void outOfMemory() +{ + fprintf(stderr, "out of memory\n"); + exit(1); +} + +void XmlTokBufferInit(struct XmlTokBuffer *tb, int fd) +{ + tb->buf = malloc(READSIZE); + if (!tb->buf) + outOfMemory(); + tb->end = tb->buf; + tb->ptr = tb->buf; + tb->size = READSIZE; + tb->fd = fd; + tb->doneProlog = 0; + tb->eof = 0; + tb->endOffset = 0; +} + +void XmlTokBufferFree(struct XmlTokBuffer *tb) +{ + free(tb->buf); +} + +int XmlGetToken(struct XmlTokBuffer *tb, const char **tokStart, size_t *tokLength) +{ + int tok; + for (;;) { + int nBytes; + const char *start = tb->ptr; + if (!tb->doneProlog) { + tok = XmlPrologTok(start, tb->end, &tb->ptr); + if (tok == XML_TOK_START_TAG) + tb->doneProlog = 1; + } + else + tok = XmlContentTok(start, tb->end, &tb->ptr); + if (tok >= 0) { + *tokStart = start; + *tokLength = tb->ptr - start; + break; + } + if (tb->eof) + break; + /* Read in multiples of READSIZE, unless read() has previously + less than it could. */ + if (tb->end == tb->buf + tb->size) { + size_t keep = tb->end - tb->ptr; + if (keep == 0) + tb->ptr = tb->end = tb->buf; + else if (keep + READSIZE <= tb->size) { + unsigned nBlocks = (tb->size - keep)/READSIZE; + char *newEnd = tb->buf + tb->size - (nBlocks * READSIZE); + memmove(newEnd - keep, tb->ptr, keep); + tb->end = newEnd; + tb->ptr = newEnd - keep; + } + else { + char *newBuf, *newEnd; + tb->size += READSIZE; + newBuf = malloc(tb->size); + if (!newBuf) + outOfMemory(); + newEnd = newBuf + tb->size - READSIZE; + memcpy(newEnd - keep, tb->ptr, keep); + free(tb->buf); + tb->buf = newBuf; + tb->end = newEnd; + tb->ptr = newEnd - keep; + } + } + nBytes = read(tb->fd, tb->end, (tb->buf + tb->size) - tb->end); + if (nBytes == 0) { + tb->eof = 1; + break; + } + if (nBytes < 0) + return XML_TOK_NONE; + tb->end += nBytes; + tb->endOffset += nBytes; + } + return tok; +} + +int doFile(const char *filename) +{ + unsigned nElements = 0; + struct XmlTokBuffer buf; + int fd = open(filename, O_RDONLY|O_BINARY); + + if (fd < 0) { + fprintf(stderr, "%s: cannot open\n", filename); + return 0; + } + XmlTokBufferInit(&buf, fd); + for (;;) { + const char *tokStr; + size_t tokLen; + int tok = XmlGetToken(&buf, &tokStr, &tokLen); + switch (tok) { + case XML_TOK_NONE: + if (nElements == 0) { + fprintf(stderr, "%s: no instance\n", filename); + return 0; + } + printf("%8u %s\n", nElements, filename); + close(fd); + XmlTokBufferFree(&buf); + return 1; + case XML_TOK_INVALID: + fprintf(stderr, "%s: well-formedness error at byte %lu\n", + filename, XmlTokBufferOffset(&buf)); + + close(fd); + XmlTokBufferFree(&buf); + return 0; + case XML_TOK_PARTIAL: + fprintf(stderr, "%s: unclosed token started at byte %lu\n", + filename, XmlTokBufferOffset(&buf)); + close(fd); + XmlTokBufferFree(&buf); + return 0; + case XML_TOK_COMMENT: + break; + case XML_TOK_START_TAG: + nElements++; + break; + default: + break; + } + } + +} + +#endif /* not FILEMAP */ + +int main(int argc, char **argv) +{ + int i; + int ret = 0; + if (argc == 1) { + fprintf(stderr, "usage: %s filename ...\n", argv[0]); + return 1; + } + for (i = 1; i < argc; i++) + if (!doFile(argv[i])) + ret = 1; + return ret; +} diff --git a/expat/xmltok/xmltok.c b/expat/xmltok/xmltok.c new file mode 100755 index 00000000..547d6449 --- /dev/null +++ b/expat/xmltok/xmltok.c @@ -0,0 +1,360 @@ +#ifdef _MSC_VER +#define XMLTOKAPI __declspec(dllexport) +#endif + +#include "xmltok.h" + +#ifdef UNICODE +typedef wchar_t TCHAR; +#else +typedef char TCHAR; +#endif + +#define DIGIT_CASES \ + case '0': case '1': case '2': case '3': case '4': \ + case '5': case '6': case '7': case '8': case '9': + +#define HEX_DIGIT_CASES DIGIT_CASES \ + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': \ + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + +#define S_CASES case ' ': case '\t': case '\r': case '\n': + +/* ptr points to character following "') { + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + *nextTokPtr = ptr + 1; + return XML_TOK_COMMENT; + } + } + } + } + return XML_TOK_PARTIAL; +} + +/* ptr points to character following "') { + *nextTokPtr = ptr + 2; + return XML_TOK_PI; + } + } + } + return XML_TOK_PARTIAL; +} + +/* ptr points to character following "<" */ + +static +int scanStartTag(const TCHAR *ptr, const TCHAR *end, const TCHAR **nextTokPtr) +{ + for (; ptr != end; ++ptr) { + switch (*ptr) { + case '>': + *nextTokPtr = ptr + 1; + return XML_TOK_START_TAG; + case '/': + if (++ptr == end) + return XML_TOK_PARTIAL; + if (*ptr != '>') { + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + *nextTokPtr = ptr + 1; + return XML_TOK_EMPTY_ELEMENT; + } + } + return XML_TOK_PARTIAL; +} + +/* ptr points to character following "': + *nextTokPtr = ptr + 1; + return XML_TOK_END_TAG; + } + } + return XML_TOK_PARTIAL; +} + +/* ptr points to character following "&#X" */ + +static +int scanHexCharRef(const TCHAR *ptr, const TCHAR *end, const TCHAR **nextTokPtr) +{ + if (ptr != end) { + switch (*ptr) { + HEX_DIGIT_CASES + break; + default: + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + for (++ptr; ptr != end; ++ptr) { + switch (*ptr) { + HEX_DIGIT_CASES + break; + case ';': + *nextTokPtr = ptr + 1; + return XML_TOK_CHAR_REF; + default: + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + } + } + return XML_TOK_PARTIAL; +} + +/* ptr points to character following "&#" */ + +static +int scanCharRef(const TCHAR *ptr, const TCHAR *end, const TCHAR **nextTokPtr) +{ + if (ptr != end) { + switch (*ptr) { + case 'x': + case 'X': + return scanHexCharRef(ptr + 1, end, nextTokPtr); + DIGIT_CASES + break; + default: + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + for (++ptr; ptr != end; ++ptr) { + switch (*ptr) { + DIGIT_CASES + break; + case ';': + *nextTokPtr = ptr + 1; + return XML_TOK_CHAR_REF; + default: + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + } + } + return XML_TOK_PARTIAL; +} + +static +int scanEntityRef(const TCHAR *ptr, const TCHAR *end, const TCHAR **nextTokPtr) +{ + for (; ptr != end; ++ptr) { + switch (*ptr) { + case ';': + *nextTokPtr = ptr + 1; + return XML_TOK_ENTITY_REF; + } + } + return XML_TOK_PARTIAL; +} + +/* ptr points to character following " */ + if (end - ptr < 9) + return XML_TOK_PARTIAL; + for (i = 0; i < 6; i++, ptr++) { + if (*ptr != "CDATA["[i]) { + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + } + end -= 2; + for (; ptr != end; ++ptr) { + if (*ptr == ']') { + if (ptr[1] == ']' && ptr[2] == '>') { + *nextTokPtr = ptr + 3; + return XML_TOK_CDATA_SECTION; + } + } + } + return XML_TOK_PARTIAL; + +} + +int XmlContentTok(const TCHAR *ptr, const TCHAR *end, const TCHAR **nextTokPtr) +{ + if (ptr != end) { + switch (*ptr) { + case '<': + { + ++ptr; + if (ptr == end) + return XML_TOK_PARTIAL; + switch (*ptr) { + case '!': + if (++ptr == end) + return XML_TOK_PARTIAL; + switch (*ptr) { + case '-': + return scanComment(ptr + 1, end, nextTokPtr); + case '[': + return scanCdataSection(ptr + 1, end, nextTokPtr); + } + *nextTokPtr = ptr; + return XML_TOK_INVALID; + case '?': + return scanPi(ptr + 1, end, nextTokPtr); + case '/': + return scanEndTag(ptr + 1, end, nextTokPtr); + case '>': + S_CASES + *nextTokPtr = ptr; + return XML_TOK_INVALID; + default: + return scanStartTag(ptr, end, nextTokPtr); + } + } + case '&': + { + ++ptr; + if (ptr == end) + return XML_TOK_PARTIAL; + switch (*ptr) { + case '#': + return scanCharRef(ptr + 1, end, nextTokPtr); + S_CASES + case ';': + *nextTokPtr = ptr; + return XML_TOK_INVALID; + } + return scanEntityRef(ptr + 1, end, nextTokPtr); + } + default: + { + for (++ptr; ptr != end; ++ptr) { + switch (*ptr) { + case '&': + case '<': + *nextTokPtr = ptr; + return XML_TOK_DATA_CHARS; + } + } + *nextTokPtr = ptr; + return XML_TOK_DATA_CHARS; + } + } + } + return XML_TOK_NONE; +} + +int XmlPrologTok(const TCHAR *ptr, const TCHAR *end, const TCHAR **nextTokPtr) +{ + if (ptr != end) { + switch (*ptr) { + case '"': + { + for (++ptr; ptr != end; ++ptr) { + if (*ptr == '"') { + *nextTokPtr = ptr + 1; + return XML_TOK_LITERAL; + } + } + return XML_TOK_PARTIAL; + } + case '\'': + { + for (++ptr; ptr != end; ++ptr) { + if (*ptr == '\'') { + *nextTokPtr = ptr + 1; + return XML_TOK_LITERAL; + } + } + return XML_TOK_PARTIAL; + } + case '<': + { + ++ptr; + if (ptr == end) + return XML_TOK_PARTIAL; + switch (*ptr) { + case '!': + return scanDecl(ptr + 1, end, nextTokPtr); + case '?': + return scanPi(ptr + 1, end, nextTokPtr); + case '/': + *nextTokPtr = ptr; + return XML_TOK_INVALID; + default: + return XmlContentTok(ptr - 1, end, nextTokPtr); + } + } + default: + { + for (++ptr; ptr != end; ++ptr) { + switch (*ptr) { + case '<': + case '"': + case '\'': + *nextTokPtr = ptr; + return XML_TOK_PROLOG_CHARS; + } + } + *nextTokPtr = ptr; + return XML_TOK_PROLOG_CHARS; + } + } + } + return XML_TOK_NONE; +} diff --git a/expat/xmltok/xmltok.h b/expat/xmltok/xmltok.h new file mode 100755 index 00000000..457979d2 --- /dev/null +++ b/expat/xmltok/xmltok.h @@ -0,0 +1,85 @@ +#ifndef XmlTok_INCLUDED +#define XmlTok_INCLUDED 1 + +#ifndef XMLTOKAPI +#define XMLTOKAPI /* as nothing */ +#endif + +#include + +/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */ +#define XML_TOK_NONE -2 /* The string to be scanned is empty */ +#define XML_TOK_PARTIAL -1 +#define XML_TOK_INVALID 0 +#define XML_TOK_COMMENT 1 +#define XML_TOK_PI 2 /* processing instruction */ + +/* The following tokens are returned only by XmlPrologTok */ +#define XML_TOK_LITERAL 3 +#define XML_TOK_PROLOG_CHARS 4 + +/* The following token is returned by XmlPrologTok when it detects the end +of the prolog and is also returned by XmlContentTok */ + +#define XML_TOK_START_TAG 5 + +/* The following tokens are returned only by XmlContentTok */ + +#define XML_TOK_END_TAG 6 +#define XML_TOK_EMPTY_ELEMENT 7 /* empty element tag */ +#define XML_TOK_DATA_CHARS 8 +#define XML_TOK_CDATA_SECTION 9 +#define XML_TOK_ENTITY_REF 10 +#define XML_TOK_CHAR_REF 11 /* numeric character reference */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +Scan the string starting at ptr until the end of the next complete token, +but do not scan past eptr. Return an integer giving the type of token. + +Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set. + +Return XML_TOK_PARTIAL when the string does not contain a complete token; +nextTokPtr will not be set. + +Return XML_TOK_INVALID when the string does not start a valid token; nextTokPtr +will be set to point to the character which made the token invalid. + +Otherwise the string starts with a valid token; nextTokPtr will be set to point +to the character following the end of that token. + +Each data character counts as a single token, but adjacent data characters +may be returned together. Similarly for characters in the prolog outside +literals, comments and processing instructions. +*/ + +int XMLTOKAPI XmlPrologTokA(const char *ptr, + const char *eptr, + const char **nextTokPtr); +int XMLTOKAPI XmlContentTokA(const char *ptr, + const char *eptr, + const char **nextTokPtr); + +int XMLTOKAPI XmlPrologTokW(const wchar_t *ptr, + const wchar_t *eptr, + const wchar_t **nextTokPtr); +int XMLTOKAPI XmlContentTokW(const wchar_t *ptr, + const wchar_t *eptr, + const wchar_t **nextTokPtr); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define XmlPrologTok XmlPrologTokW +#define XmlContentTok XmlContentTokW +#else +#define XmlPrologTok XmlPrologTokA +#define XmlContentTok XmlContentTokA +#endif + +#endif /* not XmlTok_INCLUDED */