summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/connect/ha_connect.cc3
-rw-r--r--storage/connect/libdoc.cpp149
-rw-r--r--storage/connect/libdoc.h152
-rw-r--r--storage/connect/plgdbutl.cpp2
4 files changed, 157 insertions, 149 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 35cb0f03c3c..861d1edb12c 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -146,8 +146,7 @@
#define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b))
#ifdef LIBXML2_SUPPORT
-void XmlInitParserLib(void);
-void XmlCleanupParserLib(void);
+#include "libdoc.h"
#endif // LIBXML2_SUPPORT
/***********************************************************************/
diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp
index 6e69322425e..45f379350f5 100644
--- a/storage/connect/libdoc.cpp
+++ b/storage/connect/libdoc.cpp
@@ -25,6 +25,155 @@
#include "sql_string.h"
+/******************************************************************/
+/* Declaration of XML document processing using libxml2 */
+/* Author: Olivier Bertrand 2007-2012 */
+/******************************************************************/
+#include "plgxml.h"
+
+typedef class LIBXMLDOC *PXDOC2;
+typedef class XML2NODE *PNODE2;
+typedef class XML2ATTR *PATTR2;
+typedef class XML2NODELIST *PLIST2;
+
+/******************************************************************/
+/* XML2 block. Must have the same layout than FBLOCK up to Type. */
+/******************************************************************/
+typedef struct _x2block { /* Loaded XML file block */
+ struct _x2block *Next;
+ LPCSTR Fname; /* Point on file name */
+ size_t Length; /* Used to tell if read mode */
+ short Count; /* Nb of times file is used */
+ short Type; /* TYPE_FB_XML */
+ int Retcode; /* Return code from Load */
+ xmlDocPtr Docp; /* Document interface pointer */
+// xmlXPathContextPtr Ctxp;
+// xmlXPathObjectPtr Xop;
+ } X2BLOCK, *PX2BLOCK;
+
+/******************************************************************/
+/* Declaration of libxml2 document. */
+/******************************************************************/
+class LIBXMLDOC : public XMLDOCUMENT {
+ friend class XML2NODE;
+ friend class XML2ATTR;
+ public:
+ // Constructor
+ LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
+
+ // Properties
+ virtual short GetDocType(void) {return TYPE_FB_XML2;}
+ virtual void *GetDocPtr(void) {return Docp;}
+ virtual void SetNofree(bool b) {Nofreelist = b;}
+
+ // Methods
+ virtual bool Initialize(PGLOBAL g);
+ virtual bool ParseFile(char *fn);
+ virtual bool NewDoc(PGLOBAL g, char *ver);
+ virtual void AddComment(PGLOBAL g, char *com);
+ virtual PXNODE GetRoot(PGLOBAL g);
+ virtual PXNODE NewRoot(PGLOBAL g, char *name);
+ virtual PXNODE NewPnode(PGLOBAL g, char *name);
+ virtual PXATTR NewPattr(PGLOBAL g);
+ virtual PXLIST NewPlist(PGLOBAL g);
+ virtual int DumpDoc(PGLOBAL g, char *ofn);
+ virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
+ virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
+
+ protected:
+// bool CheckDocument(FILE *of, xmlNodePtr np);
+ xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp);
+ int Decode(xmlChar *cnt, char *buf, int n);
+ xmlChar *Encode(PGLOBAL g, char *txt);
+
+ // Members
+ xmlDocPtr Docp;
+ xmlNodeSetPtr Nlist;
+ xmlXPathContextPtr Ctxp;
+ xmlXPathObjectPtr Xop;
+ char *Buf; // Temporary
+ bool Nofreelist;
+}; // end of class LIBXMLDOC
+
+/******************************************************************/
+/* Declaration of libxml2 node. */
+/******************************************************************/
+class XML2NODE : public XMLNODE {
+ friend class LIBXMLDOC;
+ friend class XML2NODELIST;
+ public:
+ // Properties
+ virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;}
+ virtual int GetType(void);
+ virtual PXNODE GetNext(PGLOBAL g);
+ virtual PXNODE GetChild(PGLOBAL g);
+
+ // Methods
+ virtual RCODE GetContent(PGLOBAL g, char *buf, int len);
+ virtual bool SetContent(PGLOBAL g, char *txtp, int len);
+ virtual PXNODE Clone(PGLOBAL g, PXNODE np);
+ virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
+ virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
+ virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
+ virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
+ virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
+ virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
+ virtual void AddText(PGLOBAL g, char *txtp);
+ virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
+
+ protected:
+ // Constructor
+ XML2NODE(PXDOC dp, xmlNodePtr np);
+
+ // Members
+ xmlDocPtr Docp;
+ xmlChar *Content;
+ xmlNodePtr Nodep;
+}; // end of class XML2NODE
+
+/******************************************************************/
+/* Declaration of libxml2 node list. */
+/******************************************************************/
+class XML2NODELIST : public XMLNODELIST {
+ friend class LIBXMLDOC;
+ friend class XML2NODE;
+ public:
+ // Methods
+ virtual int GetLength(void);
+ virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
+
+ protected:
+ // Constructor
+ XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp);
+
+ // Members
+ xmlNodeSetPtr Listp;
+}; // end of class XML2NODELIST
+
+/******************************************************************/
+/* Declaration of libxml2 attribute. */
+/******************************************************************/
+class XML2ATTR : public XMLATTRIBUTE {
+ friend class LIBXMLDOC;
+ friend class XML2NODE;
+ public:
+ // Properties
+//virtual char *GetText(void);
+
+ // Methods
+ virtual bool SetText(PGLOBAL g, char *txtp, int len);
+
+ protected:
+ // Constructor
+ XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np);
+
+ // Members
+ xmlAttrPtr Atrp;
+ xmlNodePtr Parent;
+}; // end of class XML2ATTR
+
+
+
extern "C" {
extern char version[];
extern int trace;
diff --git a/storage/connect/libdoc.h b/storage/connect/libdoc.h
index 7971f4d1395..a0cead4e904 100644
--- a/storage/connect/libdoc.h
+++ b/storage/connect/libdoc.h
@@ -1,146 +1,6 @@
-/******************************************************************/
-/* Declaration of XML document processing using libxml2 */
-/* Author: Olivier Bertrand 2007-2012 */
-/******************************************************************/
-#include "plgxml.h"
-
-typedef class LIBXMLDOC *PXDOC2;
-typedef class XML2NODE *PNODE2;
-typedef class XML2ATTR *PATTR2;
-typedef class XML2NODELIST *PLIST2;
-
-/******************************************************************/
-/* XML2 block. Must have the same layout than FBLOCK up to Type. */
-/******************************************************************/
-typedef struct _x2block { /* Loaded XML file block */
- struct _x2block *Next;
- LPCSTR Fname; /* Point on file name */
- size_t Length; /* Used to tell if read mode */
- short Count; /* Nb of times file is used */
- short Type; /* TYPE_FB_XML */
- int Retcode; /* Return code from Load */
- xmlDocPtr Docp; /* Document interface pointer */
-// xmlXPathContextPtr Ctxp;
-// xmlXPathObjectPtr Xop;
- } X2BLOCK, *PX2BLOCK;
-
-/******************************************************************/
-/* Declaration of libxml2 document. */
-/******************************************************************/
-class LIBXMLDOC : public XMLDOCUMENT {
- friend class XML2NODE;
- friend class XML2ATTR;
- public:
- // Constructor
- LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp);
-
- // Properties
- virtual short GetDocType(void) {return TYPE_FB_XML2;}
- virtual void *GetDocPtr(void) {return Docp;}
- virtual void SetNofree(bool b) {Nofreelist = b;}
-
- // Methods
- virtual bool Initialize(PGLOBAL g);
- virtual bool ParseFile(char *fn);
- virtual bool NewDoc(PGLOBAL g, char *ver);
- virtual void AddComment(PGLOBAL g, char *com);
- virtual PXNODE GetRoot(PGLOBAL g);
- virtual PXNODE NewRoot(PGLOBAL g, char *name);
- virtual PXNODE NewPnode(PGLOBAL g, char *name);
- virtual PXATTR NewPattr(PGLOBAL g);
- virtual PXLIST NewPlist(PGLOBAL g);
- virtual int DumpDoc(PGLOBAL g, char *ofn);
- virtual void CloseDoc(PGLOBAL g, PFBLOCK xp);
- virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
-
- protected:
-// bool CheckDocument(FILE *of, xmlNodePtr np);
- xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp);
- int Decode(xmlChar *cnt, char *buf, int n);
- xmlChar *Encode(PGLOBAL g, char *txt);
-
- // Members
- xmlDocPtr Docp;
- xmlNodeSetPtr Nlist;
- xmlXPathContextPtr Ctxp;
- xmlXPathObjectPtr Xop;
- char *Buf; // Temporary
- bool Nofreelist;
-}; // end of class LIBXMLDOC
-
-/******************************************************************/
-/* Declaration of libxml2 node. */
-/******************************************************************/
-class XML2NODE : public XMLNODE {
- friend class LIBXMLDOC;
- friend class XML2NODELIST;
- public:
- // Properties
- virtual char *GetName(PGLOBAL g) {return (char*)Nodep->name;}
- virtual int GetType(void);
- virtual PXNODE GetNext(PGLOBAL g);
- virtual PXNODE GetChild(PGLOBAL g);
-
- // Methods
- virtual RCODE GetContent(PGLOBAL g, char *buf, int len);
- virtual bool SetContent(PGLOBAL g, char *txtp, int len);
- virtual PXNODE Clone(PGLOBAL g, PXNODE np);
- virtual PXLIST GetChildElements(PGLOBAL g, char *xp, PXLIST lp);
- virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
- virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
- virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
- virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
- virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
- virtual void AddText(PGLOBAL g, char *txtp);
- virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
-
- protected:
- // Constructor
- XML2NODE(PXDOC dp, xmlNodePtr np);
-
- // Members
- xmlDocPtr Docp;
- xmlChar *Content;
- xmlNodePtr Nodep;
-}; // end of class XML2NODE
-
-/******************************************************************/
-/* Declaration of libxml2 node list. */
-/******************************************************************/
-class XML2NODELIST : public XMLNODELIST {
- friend class LIBXMLDOC;
- friend class XML2NODE;
- public:
- // Methods
- virtual int GetLength(void);
- virtual PXNODE GetItem(PGLOBAL g, int n, PXNODE np);
-
- protected:
- // Constructor
- XML2NODELIST(PXDOC dp, xmlNodeSetPtr lp);
-
- // Members
- xmlNodeSetPtr Listp;
-}; // end of class XML2NODELIST
-
-/******************************************************************/
-/* Declaration of libxml2 attribute. */
-/******************************************************************/
-class XML2ATTR : public XMLATTRIBUTE {
- friend class LIBXMLDOC;
- friend class XML2NODE;
- public:
- // Properties
-//virtual char *GetText(void);
-
- // Methods
- virtual bool SetText(PGLOBAL g, char *txtp, int len);
-
- protected:
- // Constructor
- XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np);
-
- // Members
- xmlAttrPtr Atrp;
- xmlNodePtr Parent;
-}; // end of class XML2ATTR
+#ifndef LIBDOC_H_INCLUDED
+#define LIBDOC_H_INCLUDED
+void XmlInitParserLib(void);
+void XmlCleanupParserLib(void);
+void CloseXML2File(PGLOBAL, PFBLOCK, bool);
+#endif
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index 73b468c9209..6884930a3b1 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -127,7 +127,7 @@ void CloseXMLFile(PGLOBAL, PFBLOCK, bool);
#endif // DOMDOC_SUPPORT
#ifdef LIBXML2_SUPPORT
-void CloseXML2File(PGLOBAL, PFBLOCK, bool);
+#include "libdoc.h"
#endif // LIBXML2_SUPPORT