Bugfix: In configuration::find_parameter(), check if the parameter node exists
authorarjen <arjen>
Sat, 28 Sep 2002 06:48:46 +0000 (06:48 +0000)
committerarjen <arjen>
Sat, 28 Sep 2002 06:48:46 +0000 (06:48 +0000)
before retrieving its contents.

src/configuration.cpp

index 6c2b7bc..7772621 100644 (file)
@@ -6,7 +6,7 @@
 ***********************
 **      FILE NAME      : configuration.cpp
 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      :  Implementation of configuration class
 **
 
 /*****************************
    $Log: configuration.cpp,v $
-   Revision 1.1  2002-07-25 08:01:26  arjen
+   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.
+
+   Revision 1.1  2002/07/25 08:01:26  arjen
    First checkin, AXE release 0.2
 
 *****************************/
 
-static const char *RCSID = "$Id: configuration.cpp,v 1.1 2002-07-25 08:01:26 arjen Exp $";
+static const char *RCSID = "$Id: configuration.cpp,v 1.2 2002-09-28 06:48:46 arjen Exp $";
 
 #include "configuration.h"
 
@@ -78,9 +82,9 @@ bool configuration::read(const String name)
    if (system != NULL)
    {
       root = xmlDocGetRootElement(system);
-      if (app_name != (char *)root->name)
+      if (app_name != (const char *)root->name)
       {
-         cerr << "Wrong config file.\n";
+         std::cerr << "Wrong config file.\n";
          xmlFreeDoc(system);
          system = NULL;
       }
@@ -89,9 +93,9 @@ bool configuration::read(const String name)
    if (user != NULL)
    {
       root = xmlDocGetRootElement(user);
-      if (app_name != (char *)root->name)
+      if (app_name != (const char *)root->name)
       {
-         cerr << "Wrong config file.\n";
+         std::cerr << "Wrong config file.\n";
          xmlFreeDoc(user);
          user = NULL;
       }
@@ -165,7 +169,10 @@ String configuration::find_parameter(const String section, const String paramete
       if (section_node != NULL)
       {
          param_node = xmlFindTag(section_node->childs, parameter);
-         param_node = param_node->childs;
+         if (param_node != NULL)
+         {
+            param_node = param_node->childs;
+         }
          if (param_node != NULL)
          {
             param_value = (char *)param_node->content;