[libxml2] OS400: implement XPath macros as procedures for ILE/RPG support.



commit 02fd12987418007568cd9bad12eef08a75fb134b
Author: Patrick Monnerat <pm datasphere ch>
Date:   Mon May 5 18:16:22 2014 +0200

    OS400: implement XPath macros as procedures for ILE/RPG support.

 os400/README400             |   10 +++++-----
 os400/libxmlrpg/xpath.rpgle |   18 ++++++++++++++++++
 os400/make-src.sh           |    2 +-
 os400/rpgsupport.c          |   30 +++++++++++++++++++++++++++++-
 os400/rpgsupport.h          |    9 ++++++++-
 5 files changed, 61 insertions(+), 8 deletions(-)
---
diff --git a/os400/README400 b/os400/README400
index dd1d1a5..6c16de9 100644
--- a/os400/README400
+++ b/os400/README400
@@ -189,11 +189,11 @@ const char *    xmlVasprintf(xmlDictPtr * dict,
 ILE/RPG binding:
 
   All standard types and procedures are provided. Since ILE/RPG does not
-support macros, they have not been ported, with the exceptions of the
-global/threaded variables access macros. These variables can be read with
-function get_xxx(void), where xxxx is the name of the variable; they may be
-set by calling function set_xxxx(value), where value is of the same type as
-the variable.
+support macros, they have not been ported, with the exceptions of the more
+useful ones and the global/threaded variables access macros. These variables
+can be read with function get_xxx(void), where xxxx is the name of the
+variable; they may be set by calling function set_xxxx(value), where value is
+of the same type as the variable.
 
   The C va_list is not implemented as such in ILE/RPG. Functions implementing
 va_list and associated methods are provided:
diff --git a/os400/libxmlrpg/xpath.rpgle b/os400/libxmlrpg/xpath.rpgle
index 209e6c9..a31a4ac 100644
--- a/os400/libxmlrpg/xpath.rpgle
+++ b/os400/libxmlrpg/xpath.rpgle
@@ -628,4 +628,22 @@
 
       /undefine XML_TESTVAL
       /endif
+      *
+      * C macros implemented as procedures for ILE/RPG support.
+      *
+      /if defined(LIBXML_XPATH_ENABLED)
+     d xmlXPathNodeSetGetLength...
+     d                 pr            10i 0 extproc('__xmlXPathNodeSetGetLength')
+     d  ns                                 value like(xmlNodeSetPtr)
+      *
+     d xmlXPathNodeSetItem...
+     d                 pr                  extproc('__xmlXPathNodeSetItem')
+     d                                     like(xmlNodePtr)
+     d  ns                                 value like(xmlNodeSetPtr)
+     d  index                        10i 0 value
+      *
+     d xmlXPathNodeSetIsEmpty...
+     d                 pr            10i 0 extproc('__xmlXPathNodeSetIsEmpty')
+     d  ns                                 value like(xmlNodeSetPtr)
+      /endif                                                                    LIBXML_XPATH_ENABLED
       /endif                                                                    XML_XPATH_H__
diff --git a/os400/make-src.sh b/os400/make-src.sh
index ccc8ec7..88248b0 100644
--- a/os400/make-src.sh
+++ b/os400/make-src.sh
@@ -193,7 +193,7 @@ for PGMEXP in ${PGMEXPS}
 do      SIGNATURE=`echo "${PGMEXP}" | sed 's/^LIBXML2_//'`
         eval ENTRIES=\"\${${PGMEXP}}\"
         echo " STRPGMEXP PGMLVL(*${PGMLVL}) SIGNATURE('${SIGNATURE}')"
-        for ENTRY in ${OS400SYMS} ${ENTRIES}
+        for ENTRY in ${ENTRIES} ${OS400SYMS}
         do      echo " EXPORT    SYMBOL('${ENTRY}')"
         done
         echo ' ENDPGMEXP'
diff --git a/os400/rpgsupport.c b/os400/rpgsupport.c
index 189212b..74f3859 100644
--- a/os400/rpgsupport.c
+++ b/os400/rpgsupport.c
@@ -11,6 +11,7 @@
 #include <stdarg.h>
 
 #include "libxml/xmlmemory.h"
+#include "libxml/xpath.h"
 #include "libxml/parser.h"
 
 #include "rpgsupport.h"
@@ -204,8 +205,35 @@ __xmlVaArg(char * * list, void * dest, size_t argsize)
 
 
 void
-_xmlVaEnd(char * * list)
+__xmlVaEnd(char * * list)
 
 {
         /* Nothing to do. */
 }
+
+
+#ifdef LIBXML_XPATH_ENABLED
+int
+__xmlXPathNodeSetGetLength(xmlNodeSetPtr ns)
+
+{
+       return ns? ns->nodeNr: 0;
+}
+
+
+xmlNodePtr
+__xmlXPathNodeSetItem(xmlNodeSetPtr ns, int index)
+
+{
+       return ns && index >= 0 && index < ns->nodeNr && ns->nodeTab?
+           ns->nodeTab[index]: 0;
+}
+
+
+int
+__xmlXPathNodeSetIsEmpty(xmlNodeSetPtr ns)
+
+{
+       return !ns || !ns->nodeNr || !ns->nodeTab;
+}
+#endif
diff --git a/os400/rpgsupport.h b/os400/rpgsupport.h
index 29a62cc..20752f5 100644
--- a/os400/rpgsupport.h
+++ b/os400/rpgsupport.h
@@ -12,6 +12,7 @@
 #include <sys/types.h>
 
 #include <libxml/xmlmemory.h>
+#include <libxml/xpath.h>
 
 
 XMLPUBFUN xmlFreeFunc   __get_xmlFree(void);
@@ -136,6 +137,12 @@ XMLPUBFUN xmlOutputBufferPtr
 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);
+XMLPUBFUN void          __xmlVaEnd(char * * list);
+
+#ifdef LIBXML_XPATH_ENABLED
+XMLPUBFUN int          __xmlXPathNodeSetGetLength(xmlNodeSetPtr ns);
+XMLPUBFUN xmlNodePtr   __xmlXPathNodeSetItem(xmlNodeSetPtr ns, int index);
+XMLPUBFUN int          __xmlXPathNodeSetIsEmpty(xmlNodeSetPtr ns);
+#endif
 
 #endif


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