From da73ecf650f8a2209217bc8062716c371dbbe192 Mon Sep 17 00:00:00 2001 From: mazze Date: Wed, 6 Jun 2012 23:18:54 +0000 Subject: [PATCH] Bring expat_au.library back to life. It's now a pertask library because of functions like malloc(), free(), time. Tests are now build from the examples. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@44971 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/expat/elements.c | 65 ---------------- test/expat/mmakefile.src | 26 ------- test/expat/outline.c | 107 -------------------------- test/expat/test.xml | 68 ----------------- workbench/libs/expat/examples/mmakefile.src | 16 ++++ workbench/libs/expat/expat.pc.aros | 11 +++ workbench/libs/expat/lib/amilib.h | 38 ++++++++++ workbench/libs/expat/lib/arosconfig.h | 112 ++++++++++++++++++++++++++++ workbench/libs/expat/lib/expat.h | 4 + workbench/libs/expat/lib/expat_au.conf | 12 ++- workbench/libs/expat/lib/init-aros.c | 46 ++++++++++++ workbench/libs/expat/lib/mmakefile.src | 63 ++++++++++------ workbench/libs/expat/lib/xmlparse.c | 2 + workbench/libs/expat/lib/xmlrole.c | 2 + workbench/libs/expat/lib/xmltok.c | 2 + 15 files changed, 285 insertions(+), 289 deletions(-) delete mode 100644 test/expat/elements.c delete mode 100644 test/expat/mmakefile.src delete mode 100644 test/expat/outline.c delete mode 100644 test/expat/test.xml create mode 100644 workbench/libs/expat/examples/mmakefile.src create mode 100644 workbench/libs/expat/expat.pc.aros create mode 100644 workbench/libs/expat/lib/amilib.h create mode 100644 workbench/libs/expat/lib/arosconfig.h create mode 100644 workbench/libs/expat/lib/init-aros.c rewrite workbench/libs/expat/lib/mmakefile.src (65%) diff --git a/test/expat/elements.c b/test/expat/elements.c deleted file mode 100644 index 6cf10f62a7..0000000000 --- a/test/expat/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 -#include "expat.h" - -#if defined(__amigaos__) && defined(__USE_INLINE__) -#include -#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)), - (unsigned long)XML_GetCurrentLineNumber(parser)); - return 1; - } - } while (!done); - XML_ParserFree(parser); - return 0; -} diff --git a/test/expat/mmakefile.src b/test/expat/mmakefile.src deleted file mode 100644 index 48d9bb45a3..0000000000 --- a/test/expat/mmakefile.src +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright © 2012, The AROS Development Team. All rights reserved. -# $Id$ - -include $(TOP)/config/make.cfg - -FILES := elements outline -EXEDIR := $(AROS_TESTS)/expat - -#MM- test : test-expat -#MM- test-quick : test-expat-quick - -#MM test-expat : includes linklibs workbench-libs-expat test-expat-copy - -%build_progs mmake=test-expat \ - files=$(FILES) targetdir=$(EXEDIR) \ - uselibs="expat" - -#MM -test-expat-copy : $(EXEDIR)/test.xml - $(NOP) - -$(EXEDIR)/test.xml : $(SRCDIR)/$(CURDIR)/test.xml - $(MKDIR) $(EXEDIR) - $(CP) $< $@ - -%common diff --git a/test/expat/outline.c b/test/expat/outline.c deleted file mode 100644 index 26cfa84d10..0000000000 --- a/test/expat/outline.c +++ /dev/null @@ -1,107 +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 -#include -#include - -#if defined(__amigaos__) && defined(__USE_INLINE__) -#include -#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", - (unsigned long)XML_GetCurrentLineNumber(p), - XML_ErrorString(XML_GetErrorCode(p))); - exit(-1); - } - - if (done) - break; - } - XML_ParserFree(p); - return 0; -} diff --git a/test/expat/test.xml b/test/expat/test.xml deleted file mode 100644 index d34b33d424..0000000000 --- a/test/expat/test.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workbench/libs/expat/examples/mmakefile.src b/workbench/libs/expat/examples/mmakefile.src new file mode 100644 index 0000000000..b77d135966 --- /dev/null +++ b/workbench/libs/expat/examples/mmakefile.src @@ -0,0 +1,16 @@ +# $Id$ +include $(TOP)/config/make.cfg + +#MM workbench-libs-expat-examples : \ +#MM workbench-libs-expat-lib \ +#MM includes \ +#MM linklibs + +FILES := elements outline +EXEDIR := $(AROS_TESTS)/expat + +%build_progs mmake=workbench-libs-expat-examples \ + files=$(FILES) targetdir=$(EXEDIR) \ + uselibs="expat" + +%common diff --git a/workbench/libs/expat/expat.pc.aros b/workbench/libs/expat/expat.pc.aros new file mode 100644 index 0000000000..63a03e6b38 --- /dev/null +++ b/workbench/libs/expat/expat.pc.aros @@ -0,0 +1,11 @@ +prefix=/Development +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: expat +Version: 2.1.0 +Description: expat XML parser +URL: http://www.libexpat.org +Libs: -L${libdir} -lexpat +Cflags: -I${includedir} diff --git a/workbench/libs/expat/lib/amilib.h b/workbench/libs/expat/lib/amilib.h new file mode 100644 index 0000000000..054369f7c5 --- /dev/null +++ b/workbench/libs/expat/lib/amilib.h @@ -0,0 +1,38 @@ +#ifndef _AMILIB_H +#define _AMILIB_H + +/* Copyright 2012 The AROS Development Team. All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +struct ExpatBase +{ + struct Library _lib; + struct Library *_aroscbase; +}; + +#endif /* _AMILIB_H */ diff --git a/workbench/libs/expat/lib/arosconfig.h b/workbench/libs/expat/lib/arosconfig.h new file mode 100644 index 0000000000..3eecc18537 --- /dev/null +++ b/workbench/libs/expat/lib/arosconfig.h @@ -0,0 +1,112 @@ +/* expat_config.h.in. Generated from configure.in by autoheader. */ + +#include + +/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ +#if AROS_BIG_ENDIAN +# define BYTEORDER 4321 +#else +# define BYTEORDER 4321 +#endif + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* whether byteorder is bigendian */ +#if AROS_BIG_ENDIAN +# define WORDS_BIGENDIAN 1 +#else +# undef WORDS_BIGENDIAN +#endif + +/* Define to specify how much context to retain around the current parse + point. */ +#define XML_CONTEXT_BYTES 1024 + +/* Define to make parameter entity parsing functionality available. */ +#define XML_DTD + +/* Define to make XML Namespaces functionality available. */ +#define XML_NS + +/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */ +#undef __func__ + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `long int' if does not define. */ +#undef off_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/workbench/libs/expat/lib/expat.h b/workbench/libs/expat/lib/expat.h index 9a21680be4..be574da174 100644 --- a/workbench/libs/expat/lib/expat.h +++ b/workbench/libs/expat/lib/expat.h @@ -1040,6 +1040,10 @@ XML_GetFeatureList(void); #define XML_MINOR_VERSION 1 #define XML_MICRO_VERSION 0 +#if defined(__AROS__) && !defined(AROS_EXPAT_STATICLIB) +# include +#endif + #ifdef __cplusplus } #endif diff --git a/workbench/libs/expat/lib/expat_au.conf b/workbench/libs/expat/lib/expat_au.conf index c7e9e2a270..31ca0609de 100644 --- a/workbench/libs/expat/lib/expat_au.conf +++ b/workbench/libs/expat/lib/expat_au.conf @@ -1,16 +1,26 @@ ##begin config basename Expat libbase ExpatBase -libbasetype struct Library +libbasetype struct ExpatBase version 2.1 date 06.06.2012 copyright Copyright (C) 2001-2012 Expat maintainers, 2012 The AROS Development Team +options pertaskbase ##end config +##begin cdefprivate +#include "amilib.h" +##end cdefprivate + ##begin cdef #include ##end cdef +##begin startup +#include +AROS_IMPORT_ASM_SYM(void *, dummyarosc, aroscbase); +##end startup + ##begin functionlist XML_Parser XML_ParserCreate(const XML_Char * encodingName) XML_Parser XML_ParserCreateNS(const XML_Char * encodingName, XML_Char nsSep) diff --git a/workbench/libs/expat/lib/init-aros.c b/workbench/libs/expat/lib/init-aros.c new file mode 100644 index 0000000000..543f3e61f2 --- /dev/null +++ b/workbench/libs/expat/lib/init-aros.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2012 The AROS Development Team. All rights reserved. + See the file COPYING for copying permission. +*/ + +#include +#include LC_LIBDEFS_FILE + +#define DEBUG 1 +#include + +IPTR aroscbase_offset; + + +static int InitFunc(LIBBASETYPEPTR LIBBASE) +{ + D(bug("Inside Init func of expat.library\n")); + + aroscbase_offset = offsetof(LIBBASETYPE, _aroscbase); + + return TRUE; +} + +static int OpenFunc(LIBBASETYPEPTR LIBBASE) +{ + D(bug("Opening expat.library\n")); + + LIBBASE->_aroscbase = OpenLibrary("arosc.library", 0); + + D(bug("[expat.library::OpenLib] aroscbase=%p\n", LIBBASE->_aroscbase)); + + return LIBBASE->_aroscbase != NULL; +} + +static int CloseFunc(LIBBASETYPEPTR LIBBASE) +{ + D(bug("Closing expat.library\n")); + + CloseLibrary(LIBBASE->_aroscbase); + + return TRUE; +} + + +ADD2INITLIB(InitFunc, 0); +ADD2OPENLIB(OpenFunc, 0); +ADD2CLOSELIB(CloseFunc, 0); diff --git a/workbench/libs/expat/lib/mmakefile.src b/workbench/libs/expat/lib/mmakefile.src dissimilarity index 65% index 3bb7ad9e68..30ffd19293 100644 --- a/workbench/libs/expat/lib/mmakefile.src +++ b/workbench/libs/expat/lib/mmakefile.src @@ -1,22 +1,41 @@ -# $Id$ -include $(TOP)/config/make.cfg - -#MM workbench-libs-expat-includes : \ -#MM kernel-exec-includes includes-copy - -#MM workbench-libs-expat : linklibs - -CFILES := xmlparse xmlrole xmltok - -# USER_CFLAGS := -# USER_INCLUDES := -I$(SRCDIR)/$(CURDIR)/include - -%build_module mmake=workbench-libs-expat modname=expat_au modtype=library \ - files=$(CFILES) linklibname=expat - - -INCLUDE_FILES := expat.h -%copy_includes - - -%common +# $Id$ +include $(TOP)/config/make.cfg + +#MM- workbench-libs-expat : \ +#MM workbench-libs-expat-lib \ +#MM workbench-libs-expat-examples \ +#MM workbench-libs-expat-pc + +#MM- workbench-libs-expat-quick : \ +#MM workbench-libs-expat-lib-quick \ +#MM workbench-libs-expat-examples-quick + +#MM- workbench-libs-expat-clean : \ +#MM workbench-libs-expat-lib-clean \ +#MM workbench-libs-expat-examples-clean + +#MM workbench-libs-expat-lib : linklibs + +#MM- workbench-libs-expat-includes : \ +#MM kernel-exec-includes includes-copy + + +CFILES := xmlparse xmlrole xmltok + +%build_module mmake=workbench-libs-expat-lib modname=expat_au modtype=library \ + files="init-aros $(CFILES)" uselibs="arosc_rel" linklibname=expat + + +INCLUDE_FILES := expat.h expat_external.h +%copy_includes + + +#MM +workbench-libs-expat-pc : $(AROS_LIB)/pkgconfig/expat.pc + +$(AROS_LIB)/pkgconfig/expat.pc : $(SRCDIR)/$(CURDIR)/../expat.pc.aros + @$(IF) $(TEST) ! -d $(AROS_LIB)/pkgconfig ; then $(MKDIR) $(AROS_LIB)/pkgconfig ; else $(NOP) ; fi + $(CP) $^ $@ + + +%common diff --git a/workbench/libs/expat/lib/xmlparse.c b/workbench/libs/expat/lib/xmlparse.c index f35aa36ba8..0a0bb67f8b 100644 --- a/workbench/libs/expat/lib/xmlparse.c +++ b/workbench/libs/expat/lib/xmlparse.c @@ -16,6 +16,8 @@ #include "macconfig.h" #elif defined(__amigaos__) #include "amigaconfig.h" +#elif defined(__AROS__) +#include "arosconfig.h" #elif defined(__WATCOMC__) #include "watcomconfig.h" #elif defined(HAVE_EXPAT_CONFIG_H) diff --git a/workbench/libs/expat/lib/xmlrole.c b/workbench/libs/expat/lib/xmlrole.c index 44772e21dd..7cf9d6f7b5 100644 --- a/workbench/libs/expat/lib/xmlrole.c +++ b/workbench/libs/expat/lib/xmlrole.c @@ -10,6 +10,8 @@ #include "macconfig.h" #elif defined(__amigaos__) #include "amigaconfig.h" +#elif defined(__AROS__) +#include "arosconfig.h" #elif defined(__WATCOMC__) #include "watcomconfig.h" #else diff --git a/workbench/libs/expat/lib/xmltok.c b/workbench/libs/expat/lib/xmltok.c index bf09dfc72b..ac8433dbd2 100644 --- a/workbench/libs/expat/lib/xmltok.c +++ b/workbench/libs/expat/lib/xmltok.c @@ -10,6 +10,8 @@ #include "macconfig.h" #elif defined(__amigaos__) #include "amigaconfig.h" +#elif defined(__AROS__) +#include "arosconfig.h" #elif defined(__WATCOMC__) #include "watcomconfig.h" #else -- 2.11.4.GIT