Uses the XML2 library
[AXE.git] / src / configuration.cpp
index 7772621..c4cce46 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : configuration.cpp
 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
-**      VERSION NUMBER : $Revision: 1.2 $
+**      VERSION NUMBER : $Revision: 1.3 $
 **
 **  DESCRIPTION      :  Implementation of configuration class
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Jul 23, 2002
-**      LAST UPDATE     : Jul 24, 2002
+**      LAST UPDATE     : Nov 02, 2002
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: configuration.cpp,v $
-   Revision 1.2  2002-09-28 06:48:46  arjen
+   Revision 1.3  2002-11-02 14:35:15  arjen
+   Uses the XML2 library
+   BugFix: segfault when finding a parameters that is not in the user-sepcific
+   config tree.
+
+   Revision 1.2  2002/09/28 06:48:46  arjen
    Bugfix: In configuration::find_parameter(), check if the parameter node exists
    before retrieving its contents.
 
@@ -33,7 +38,7 @@
 
 *****************************/
 
-static const char *RCSID = "$Id: configuration.cpp,v 1.2 2002-09-28 06:48:46 arjen Exp $";
+static const char *RCSID = "$Id: configuration.cpp,v 1.3 2002-11-02 14:35:15 arjen Exp $";
 
 #include "configuration.h"
 
@@ -148,7 +153,7 @@ xmlNodePtr configuration::xmlFindTag(xmlNodePtr node, const String tag)
 **  VARS CHANGED   :
 **  FUNCTIONS USED :
 **  SEE ALSO       :
-**  LAST MODIFIED  : Jul 24, 2002
+**  LAST MODIFIED  : Nov 02, 2002
 **=========================================================================
 */
 
@@ -165,13 +170,13 @@ String configuration::find_parameter(const String section, const String paramete
    if (system)
    {
       root_node    = xmlDocGetRootElement(system);
-      section_node = xmlFindTag(root_node->childs, section);
+      section_node = xmlFindTag(root_node->children, section);
       if (section_node != NULL)
       {
-         param_node = xmlFindTag(section_node->childs, parameter);
+         param_node = xmlFindTag(section_node->children, parameter);
          if (param_node != NULL)
          {
-            param_node = param_node->childs;
+            param_node = param_node->children;
          }
          if (param_node != NULL)
          {
@@ -186,11 +191,14 @@ String configuration::find_parameter(const String section, const String paramete
    if (user)
    {
       root_node    = xmlDocGetRootElement(user);
-      section_node = xmlFindTag(root_node->childs, section);
+      section_node = xmlFindTag(root_node->children, section);
       if (section_node != NULL)
       {
-         param_node = xmlFindTag(section_node->childs, parameter);
-         param_node = param_node->childs;
+         param_node = xmlFindTag(section_node->children, parameter);
+         if (param_node != NULL)
+         {
+            param_node = param_node->children;
+         }
          if (param_node != NULL)
          {
             param_value = (char *)param_node->content;