[libxml2] OS400: implement some macros as functions for ILE/RPG language support (that as no macros).



commit 7d888f07d86454025e4629ee36fdb5b3876f62ea
Author: Patrick Monnerat <pm datasphere ch>
Date:   Tue Mar 4 17:15:23 2014 +0100

    OS400: implement some macros as functions for ILE/RPG language support (that as no macros).

 os400/rpgsupport.c |  211 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 os400/rpgsupport.h |  141 +++++++++++++++++++++++++++++++++++
 2 files changed, 352 insertions(+), 0 deletions(-)
---
diff --git a/os400/rpgsupport.c b/os400/rpgsupport.c
new file mode 100644
index 0000000..189212b
--- /dev/null
+++ b/os400/rpgsupport.c
@@ -0,0 +1,211 @@
+/**
+***     Additional procedures for ILE/RPG support.
+***
+***     See Copyright for the status of this software.
+***
+***     Author: Patrick Monnerat <pm datasphere ch>, DATASPHERE S.A.
+**/
+
+#include <sys/types.h>
+
+#include <stdarg.h>
+
+#include "libxml/xmlmemory.h"
+#include "libxml/parser.h"
+
+#include "rpgsupport.h"
+
+
+/**
+***     ILE/RPG cannot directly derefence a pointer value an has no macros.
+***     The following additional procedures supply these functions.
+***     In addition, the following code is adjusted for threads control at
+***             compile time via the C macros.
+**/
+
+#define THREADED_VAR(name, type)                                        \
+                type __get_##name(void) { return name; }                \
+                void __set_##name(type arg) { name = arg; }
+
+
+THREADED_VAR(xmlFree, xmlFreeFunc)
+
+void
+__call_xmlFree(void * mem)
+
+{
+        xmlFree(mem);
+}
+
+
+THREADED_VAR(xmlMalloc, xmlMallocFunc)
+
+void *
+__call_xmlMalloc(size_t size)
+
+{
+        return xmlMalloc(size);
+}
+
+
+THREADED_VAR(xmlMallocAtomic, xmlMallocFunc)
+
+void *
+__call_xmlMallocAtomic(size_t size)
+
+{
+        return xmlMallocAtomic(size);
+}
+
+
+THREADED_VAR(xmlRealloc, xmlReallocFunc)
+
+void *
+__call_xmlRealloc(void * mem, size_t size)
+
+{
+        return xmlRealloc(mem, size);
+}
+
+
+THREADED_VAR(xmlMemStrdup, xmlStrdupFunc)
+
+char *
+__call_xmlMemStrdup(const char * str)
+
+{
+        return xmlMemStrdup(str);
+}
+
+
+#ifdef LIBXML_DOCB_ENABLED
+THREADED_VAR(docbDefaultSAXHandler, xmlSAXHandlerV1)
+#endif
+
+
+#ifdef LIBXML_HTML_ENABLED
+THREADED_VAR(htmlDefaultSAXHandler, xmlSAXHandlerV1)
+#endif
+
+
+THREADED_VAR(xmlLastError, xmlError)
+
+THREADED_VAR(oldXMLWDcompatibility, int)
+THREADED_VAR(xmlBufferAllocScheme, xmlBufferAllocationScheme)
+THREADED_VAR(xmlDefaultBufferSize, int)
+THREADED_VAR(xmlDefaultSAXHandler, xmlSAXHandlerV1)
+THREADED_VAR(xmlDefaultSAXLocator, xmlSAXLocator)
+THREADED_VAR(xmlDoValidityCheckingDefaultValue, int)
+
+/* No caller to xmlGenericError() because the argument list is unknown. */
+THREADED_VAR(xmlGenericError, xmlGenericErrorFunc)
+
+
+THREADED_VAR(xmlStructuredError, xmlStructuredErrorFunc)
+
+void
+__call_xmlStructuredError(void * userData, xmlErrorPtr error)
+
+{
+        xmlStructuredError(userData, error);
+}
+
+THREADED_VAR(xmlGenericErrorContext, void *)
+THREADED_VAR(xmlStructuredErrorContext, void *)
+THREADED_VAR(xmlGetWarningsDefaultValue, int)
+THREADED_VAR(xmlIndentTreeOutput, int)
+THREADED_VAR(xmlTreeIndentString, const char *)
+THREADED_VAR(xmlKeepBlanksDefaultValue, int)
+THREADED_VAR(xmlLineNumbersDefaultValue, int)
+THREADED_VAR(xmlLoadExtDtdDefaultValue, int)
+THREADED_VAR(xmlParserDebugEntities, int)
+THREADED_VAR(xmlParserVersion, const char *)
+THREADED_VAR(xmlPedanticParserDefaultValue, int)
+THREADED_VAR(xmlSaveNoEmptyTags, int)
+THREADED_VAR(xmlSubstituteEntitiesDefaultValue, int)
+
+
+THREADED_VAR(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc)
+
+void
+__call_xmlRegisterNodeDefaultValue(xmlNodePtr node)
+
+{
+        xmlRegisterNodeDefaultValue(node);
+}
+
+
+THREADED_VAR(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc)
+
+void
+__call_xmlDeregisterNodeDefaultValue(xmlNodePtr node)
+
+{
+        xmlDeregisterNodeDefaultValue(node);
+}
+
+
+THREADED_VAR(xmlParserInputBufferCreateFilenameValue, xmlParserInputBufferCreateFilenameFunc)
+
+xmlParserInputBufferPtr
+__call_xmlParserInputBufferCreateFilenameValue(const char *URI,
+                                                        xmlCharEncoding enc)
+
+{
+        return xmlParserInputBufferCreateFilenameValue(URI, enc);
+}
+
+
+THREADED_VAR(xmlOutputBufferCreateFilenameValue, xmlOutputBufferCreateFilenameFunc)
+
+xmlOutputBufferPtr
+__call_xmlOutputBufferCreateFilenameValue(const char *URI,
+                        xmlCharEncodingHandlerPtr encoder, int compression)
+
+{
+        return xmlOutputBufferCreateFilenameValue(URI, encoder, compression);
+}
+
+
+
+/**
+***     va_list support.
+**/
+
+void
+__xmlVaStart(char * * list, char * lastargaddr, size_t lastargsize)
+
+{
+        list[1] = lastargaddr + lastargsize;
+}
+
+
+void *
+__xmlVaArg(char * * list, void * dest, size_t argsize)
+
+{
+        size_t align;
+
+        if (!argsize)
+                return (void *) NULL;
+
+        for (align = 16; align > argsize; align >>= 1)
+                ;
+
+        align--;
+        list[0] = list[1] + (align - (((size_t) list[0] - 1) & align));
+        list[1] = list[0] + argsize;
+
+        if (dest)
+                memcpy(dest, list[0], argsize);
+
+        return (void *) list[0];
+}
+
+
+void
+_xmlVaEnd(char * * list)
+
+{
+        /* Nothing to do. */
+}
diff --git a/os400/rpgsupport.h b/os400/rpgsupport.h
new file mode 100644
index 0000000..29a62cc
--- /dev/null
+++ b/os400/rpgsupport.h
@@ -0,0 +1,141 @@
+/**
+***     Additional delarations for ILE/RPG support.
+***
+***     See Copyright for the status of this software.
+***
+***     Author: Patrick Monnerat <pm datasphere ch>, DATASPHERE S.A.
+**/
+
+#ifndef __RPGSUPPORT_H__
+#define __RPGSUPPORT_H__
+
+#include <sys/types.h>
+
+#include <libxml/xmlmemory.h>
+
+
+XMLPUBFUN xmlFreeFunc   __get_xmlFree(void);
+XMLPUBFUN void          __set_xmlFree(xmlFreeFunc freefunc);
+XMLPUBFUN void          __call_xmlFree(void * mem);
+XMLPUBFUN xmlMallocFunc __get_xmlMalloc(void);
+XMLPUBFUN void          __set_xmlMalloc(xmlMallocFunc allocfunc);
+XMLPUBFUN void *        __call_xmlMalloc(size_t size);
+XMLPUBFUN xmlMallocFunc __get_xmlMallocAtomic(void);
+XMLPUBFUN void          __set_xmlMallocAtomic(xmlMallocFunc allocfunc);
+XMLPUBFUN void *        __call_xmlMallocAtomic(size_t size);
+XMLPUBFUN xmlReallocFunc __get_xmlRealloc(void);
+XMLPUBFUN void          __set_xmlRealloc(xmlReallocFunc reallocfunc);
+XMLPUBFUN void *        __call_xmlRealloc(void * mem, size_t size);
+XMLPUBFUN xmlStrdupFunc __get_xmlMemStrdup(void);
+XMLPUBFUN void          __set_xmlMemStrdup(xmlStrdupFunc strdupfunc);
+XMLPUBFUN char *        __call_xmlMemStrdup(const char * str);
+
+#ifdef LIBXML_DOCB_ENABLED
+XMLPUBFUN xmlSAXHandlerV1 __get_docbDefaultSAXHandler(void);
+XMLPUBFUN void          __set_docbDefaultSAXHandler(xmlSAXHandlerV1 hdlr);
+#endif
+
+#ifdef LIBXML_HTML_ENABLED
+XMLPUBFUN xmlSAXHandlerV1 __get_htmlDefaultSAXHandler(void);
+XMLPUBFUN void          __set_htmlDefaultSAXHandler(xmlSAXHandlerV1 hdlr);
+#endif
+
+XMLPUBFUN xmlError      __get_xmlLastError(void);
+XMLPUBFUN void          __set_xmlLastError(xmlError err);
+
+XMLPUBFUN int           __get_oldXMLWDcompatibility(void);
+XMLPUBFUN void          __set_oldXMLWDcompatibility(int val);
+
+XMLPUBFUN xmlBufferAllocationScheme __get_xmlBufferAllocScheme(void);
+XMLPUBFUN void          __set_xmlBufferAllocScheme(xmlBufferAllocationScheme val);
+
+XMLPUBFUN int           __get_xmlDefaultBufferSize(void);
+XMLPUBFUN void          __set_xmlDefaultBufferSize(int val);
+
+XMLPUBFUN xmlSAXHandlerV1 __get_xmlDefaultSAXHandler(void);
+XMLPUBFUN void          __set_xmlDefaultSAXHandler(xmlSAXHandlerV1 val);
+
+XMLPUBFUN xmlSAXLocator __get_xmlDefaultSAXLocator(void);
+XMLPUBFUN void          __set_xmlDefaultSAXLocator(xmlSAXLocator val);
+
+XMLPUBFUN int           __get_xmlDoValidityCheckingDefaultValue(void);
+XMLPUBFUN void          __set_xmlDoValidityCheckingDefaultValue(int val);
+
+XMLPUBFUN xmlGenericErrorFunc __get_xmlGenericError(void);
+XMLPUBFUN void          __set_xmlGenericError(xmlGenericErrorFunc val);
+
+XMLPUBFUN xmlStructuredErrorFunc __get_xmlStructuredError(void);
+XMLPUBFUN void          __set_xmlStructuredError(xmlStructuredErrorFunc val);
+XMLPUBFUN void          __call_xmlStructuredError(void *userData, xmlErrorPtr error);
+
+XMLPUBFUN void *        __get_xmlGenericErrorContext(void);
+XMLPUBFUN void          __set_xmlGenericErrorContext(void * val);
+
+XMLPUBFUN void *        __get_xmlStructuredErrorContext(void);
+XMLPUBFUN void          __set_xmlStructuredErrorContext(void * val);
+
+XMLPUBFUN int           __get_xmlGetWarningsDefaultValue(void);
+XMLPUBFUN void          __set_xmlGetWarningsDefaultValue(int val);
+
+XMLPUBFUN int           __get_xmlIndentTreeOutput(void);
+XMLPUBFUN void          __set_xmlIndentTreeOutput(int val);
+
+XMLPUBFUN const char *  __get_xmlTreeIndentString(void);
+XMLPUBFUN void          __set_xmlTreeIndentString(const char * val);
+
+XMLPUBFUN int           __get_xmlKeepBlanksDefaultValue(void);
+XMLPUBFUN void          __set_xmlKeepBlanksDefaultValue(int val);
+
+XMLPUBFUN int           __get_xmlLineNumbersDefaultValue(void);
+XMLPUBFUN void          __set_xmlLineNumbersDefaultValue(int val);
+
+XMLPUBFUN int           __get_xmlLoadExtDtdDefaultValue(void);
+XMLPUBFUN void          __set_xmlLoadExtDtdDefaultValue(int val);
+
+XMLPUBFUN int           __get_xmlParserDebugEntities(void);
+XMLPUBFUN void          __set_xmlParserDebugEntities(int val);
+
+XMLPUBFUN const char *  __get_xmlParserVersion(void);
+XMLPUBFUN void          __set_xmlParserVersion(const char * val);
+
+XMLPUBFUN int           __get_xmlPedanticParserDefaultValue(void);
+XMLPUBFUN void          __set_xmlPedanticParserDefaultValue(int val);
+
+XMLPUBFUN int           __get_xmlSaveNoEmptyTags(void);
+XMLPUBFUN void          __set_xmlSaveNoEmptyTags(int val);
+
+XMLPUBFUN int           __get_xmlSubstituteEntitiesDefaultValue(void);
+XMLPUBFUN void          __set_xmlSubstituteEntitiesDefaultValue(int val);
+
+XMLPUBFUN xmlRegisterNodeFunc __get_xmlRegisterNodeDefaultValue(void);
+XMLPUBFUN void          __set_xmlRegisterNodeDefaultValue(xmlRegisterNodeFunc val);
+XMLPUBFUN void          __call_xmlRegisterNodeDefaultValue(xmlNodePtr node);
+
+XMLPUBFUN xmlDeregisterNodeFunc __get_xmlDeregisterNodeDefaultValue(void);
+XMLPUBFUN void          __set_xmlDeregisterNodeDefaultValue(xmlDeregisterNodeFunc val);
+XMLPUBFUN void          __call_xmlDeregisterNodeDefaultValue(xmlNodePtr node);
+
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
+                        __get_xmlParserInputBufferCreateFilenameValue(void);
+XMLPUBFUN void          __set_xmlParserInputBufferCreateFilenameValue(
+                                xmlParserInputBufferCreateFilenameFunc val);
+XMLPUBFUN xmlParserInputBufferPtr
+                __call_xmlParserInputBufferCreateFilenameValue(const char *URI,
+                                                        xmlCharEncoding enc);
+
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc
+                        __get_xmlOutputBufferCreateFilenameValue(void);
+XMLPUBFUN void          __set_xmlOutputBufferCreateFilenameValue(
+                                xmlOutputBufferCreateFilenameFunc val);
+XMLPUBFUN xmlOutputBufferPtr
+                        __call_xmlOutputBufferCreateFilenameValue(const char *URI,
+                                xmlCharEncodingHandlerPtr encoder,
+                                int compression);
+
+
+XMLPUBFUN void          __xmlVaStart(char * * list,
+                                char * lastargaddr, size_t lastargsize);
+XMLPUBFUN void *        __xmlVaArg(char * * list, void * dest, size_t argsize);
+XMLPUBFUN void          _xmlVaEnd(char * * list);
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]