[libgda] Removing server operation DTD



commit 636d220eda9f6213455aecfd9571ecb775a7a3bb
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Apr 14 18:53:47 2019 -0500

    Removing server operation DTD
    
    Fix implementation for param list DTD.

 libgda/gda-init.c             | 23 -----------------------
 libgda/gda-server-operation.c | 37 ++++++++++++++++++++++++++++++++++---
 libgda/gda-set.c              | 32 ++++++++++----------------------
 3 files changed, 44 insertions(+), 48 deletions(-)
---
diff --git a/libgda/gda-init.c b/libgda/gda-init.c
index 8e903181b..fa0df6b7d 100644
--- a/libgda/gda-init.c
+++ b/libgda/gda-init.c
@@ -54,7 +54,6 @@
  *     #endif
  *     IMPORT extern gchar *_gda_server_op_dtd;
  */
-xmlDtdPtr       _gda_server_op_dtd = NULL;
 xmlDtdPtr              _gda_db_catalog_dtd = NULL;
 
 static gchar          *gda_lang_locale = "";
@@ -156,28 +155,6 @@ gda_init (void)
        /* binreloc */
        gda_gbr_init ();
 
-       /* server operation DTD */
-       _gda_server_op_dtd = NULL;
-       file = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "dtd", "libgda-server-operation.dtd", 
NULL);
-       if (g_file_test (file, G_FILE_TEST_EXISTS))
-               _gda_server_op_dtd = xmlParseDTD (NULL, (xmlChar*)file);
-
-       if (!_gda_server_op_dtd) {
-               if (g_getenv ("GDA_TOP_SRC_DIR")) {
-                       g_free (file);
-                       file = g_build_filename (g_getenv ("GDA_TOP_SRC_DIR"), "libgda", 
"libgda-server-operation.dtd", NULL);
-                       _gda_server_op_dtd = xmlParseDTD (NULL, (xmlChar*)file);
-               }
-               if (!_gda_server_op_dtd)
-                       g_message (_("Could not parse '%s': "
-                                    "Validation for XML files for server operations will not be performed 
(some weird errors may occur)"),
-                                  file);
-       }
-
-       if (_gda_server_op_dtd)
-               _gda_server_op_dtd->name = xmlStrdup((xmlChar*) "serv_op");
-       g_free (file);
-
   /* GdaDbCreator DTD */
   _gda_db_catalog_dtd = NULL;
        file = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "dtd",
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index 6152a69f4..45f0f63fb 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -37,6 +37,7 @@
 #include <libgda/gda-data-model-private.h>
 #include <libgda/gda-data-model-import.h>
 #include <libgda/gda-data-model-array.h>
+#include <libgda/binreloc/gda-binreloc.h>
 #include "gda-util.h"
 #include <string.h>
 #ifdef HAVE_LOCALE_H
@@ -96,7 +97,6 @@ enum
        PROP_SPEC_RESOURCE
 };
 
-extern xmlDtdPtr _gda_server_op_dtd;
 static GObjectClass *parent_class = NULL;
 
 typedef struct _Node {
@@ -711,6 +711,9 @@ use_xml_spec (GdaServerOperation *op, xmlDocPtr doc, const gchar *xmlfile)
        xmlValidCtxtPtr validc;
        int xmlcheck;
        xmlDtdPtr old_dtd = NULL;
+  xmlDtdPtr _gda_server_op_dtd = NULL;
+  GFile *file;
+  gchar *path;
        
        validc = g_new0 (xmlValidCtxt, 1);
        validc->userData = op;
@@ -721,7 +724,33 @@ use_xml_spec (GdaServerOperation *op, xmlDocPtr doc, const gchar *xmlfile)
        xmlDoValidityCheckingDefaultValue = 1;
        
        /* replace the DTD with ours */
-       if (_gda_server_op_dtd) {
+  /* server operation DTD */
+       path = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "dtd", "libgda-server-operation.dtd", 
NULL);
+  file = g_file_new_for_path (path);
+       if (g_file_query_exists (file, NULL)) {
+               _gda_server_op_dtd = xmlParseDTD (NULL, (xmlChar*) path);
+  }
+
+       if (!_gda_server_op_dtd) {
+               if (g_getenv ("GDA_TOP_SRC_DIR")) {
+      gchar *ipath;
+
+                       ipath = g_build_filename (g_getenv ("GDA_TOP_SRC_DIR"), "libgda", 
"libgda-server-operation.dtd", NULL);
+                       _gda_server_op_dtd = xmlParseDTD (NULL, (xmlChar*) ipath);
+      g_free (ipath);
+               }
+               if (!_gda_server_op_dtd)
+                       g_message (_("Could not parse '%s': "
+                                    "Validation for XML files for server operations will not be performed 
(some weird errors may occur)"),
+                                  path);
+       }
+  g_free (path);
+  g_object_unref (file);
+
+       if (_gda_server_op_dtd)
+               _gda_server_op_dtd->name = xmlStrdup((xmlChar*) "serv_op");
+
+  if (_gda_server_op_dtd) {
                old_dtd = doc->intSubset;
                doc->intSubset = _gda_server_op_dtd;
        }
@@ -759,8 +788,10 @@ use_xml_spec (GdaServerOperation *op, xmlDocPtr doc, const gchar *xmlfile)
        
        xmlDoValidityCheckingDefaultValue = xmlcheck;
        g_free (validc);
-       if (_gda_server_op_dtd)
+       if (_gda_server_op_dtd) {
                doc->intSubset = old_dtd;
+    xmlFreeDtd (_gda_server_op_dtd);
+  }
        priv->xml_spec_doc = doc;
 
        return TRUE;
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index e391d3b64..01848353e 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -40,6 +40,7 @@
 #include "gda-server-provider.h"
 #include "gda-util.h"
 #include <libgda/gda-custom-marshal.h>
+#include <libgda/binreloc/gda-binreloc.h>
 
 extern gchar *gda_lang_locale;
 
@@ -1340,9 +1341,6 @@ gda_set_new_from_spec_string (const gchar *xml_spec, GError **error)
                gchar *err_str = NULL;
                xmlDtdPtr old_dtd = NULL;
          xmlDtdPtr gda_paramlist_dtd = NULL;
-    GString *dtdpath;
-    GFile *gda_data_dir;
-    gchar *gda_data_dir_path;
     GFile *file;
          gchar *path;
 
@@ -1356,36 +1354,26 @@ gda_set_new_from_spec_string (const gchar *xml_spec, GError **error)
 
     /* replace the DTD with ours */
                /* paramlist DTD */
-    gda_data_dir = g_file_new_for_path (LIBGDA_ABI_NAME);
-    gda_data_dir_path = g_file_get_uri (gda_data_dir);
-    dtdpath = g_string_new (gda_data_dir_path);
-    g_free (gda_data_dir_path);
-    g_object_unref (gda_data_dir);
-    g_string_append (dtdpath, "/dtd/libgda-paramlist.dtd");
-    file = g_file_new_for_path (dtdpath->str);
-    g_string_free (dtdpath, TRUE);
+    path = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "dtd", "libgda-paramlist.dtd", NULL);
+    file = g_file_new_for_path (path);
          if (g_file_query_exists (file, NULL)) {
-           path = g_file_get_path (file);
       gda_paramlist_dtd = xmlParseDTD (NULL, (xmlChar*) path);
-      g_free (path);
     }
-    g_object_unref (file);
 
          if (!gda_paramlist_dtd) {
                  if (g_getenv ("GDA_TOP_SRC_DIR")) {
-        dtdpath = g_string_new (g_getenv ("GDA_TOP_SRC_DIR"));
-        g_string_append (dtdpath, "/libgda/libgda-paramlist.dtd");
-        file = g_file_new_for_path (dtdpath->str);
-        g_string_free (dtdpath, TRUE);
-        path = g_file_get_path (file);
-                         gda_paramlist_dtd = xmlParseDTD (NULL, (xmlChar*) path);
-        g_free (path);
-        g_object_unref (file);
+        gchar *ipath;
+
+                         ipath = g_build_filename (g_getenv ("GDA_TOP_SRC_DIR"), "libgda", 
"libgda-paramlist.dtd", NULL);
+                         gda_paramlist_dtd = xmlParseDTD (NULL, (xmlChar*) ipath);
+        g_free (ipath);
                  }
                  if (!gda_paramlist_dtd)
                          g_message (_("Could not parse '%s': XML data import validation will not be 
performed (some weird errors may occur)"),
                                     path);
          }
+    g_free (path);
+    g_object_unref (file);
          if (gda_paramlist_dtd) {
                  gda_paramlist_dtd->name = xmlStrdup((xmlChar*) "data-set-spec");
     }


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