Index: trunk/src/lib/util/ini_parser.cc
===================================================================
--- trunk/src/lib/util/ini_parser.cc	(revision 5935)
+++ trunk/src/lib/util/ini_parser.cc	(revision 5936)
@@ -63,6 +63,5 @@
   while(!this->sections.empty())
   {
-    
-    IniSection section = this->sections.front();
+     IniSection section = this->sections.front();
     
     // in all entries of the sections
@@ -79,4 +78,5 @@
     this->sections.pop_front();
   }
+  this->currentSection = this->sections.end();
   this->setFileName(NULL);
 }
@@ -196,5 +196,5 @@
  * @return true on success false otherwise
  */
-bool IniParser::writeFile(const char* fileName)
+bool IniParser::writeFile(const char* fileName) const
 {
   FILE*    stream;           //!< The stream we use to read the file.
@@ -209,10 +209,10 @@
   else
   {
-    std::list<IniSection>::iterator section;
+    std::list<IniSection>::const_iterator section;
     for (section = this->sections.begin(); section != this->sections.end(); section++)
       {
         fprintf(stream, "\n [%s]\n", (*section).name);
 	
-        std::list<IniEntry>::iterator entry;
+        std::list<IniEntry>::const_iterator entry;
         for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
           fprintf(stream, "   %s = %s\n", (*entry).name, (*entry).value);
@@ -238,5 +238,5 @@
   this->currentSection = --this->sections.end();
   if (!this->sections.empty())
-    this->currentEntry = (*this->currentSection).entries.begin();
+      this->currentEntry = (*this->currentSection).entries.begin();
   PRINTF(5)("Added Section %s\n", sectionName);
   return true;
@@ -248,6 +248,6 @@
  * @param sectionName: the name of the section to set the cursor to
  * @return true on success or false if the section could not be found
-*/
-bool IniParser::getSection( const char* sectionName)
+ */
+bool IniParser::getSection(const char* sectionName)
 {
   std::list<IniSection>::iterator section;
@@ -259,5 +259,4 @@
 	return true;
       }
-
   return false;
 }
@@ -267,5 +266,5 @@
  * @brief moves to the first section
  */
-void IniParser::getFirstSection()
+void IniParser::firstSection()
 {
   this->currentSection = this->sections.begin();
@@ -283,10 +282,6 @@
   if (this->currentSection == this->sections.end())
     return NULL;
-  else
-  {
-    this->currentSection++;
-  }
-    if (this->currentSection == this->sections.end())
-      return NULL;
+
+  this->currentSection++;
 
   if (this->currentSection != this->sections.end())
@@ -303,7 +298,8 @@
  * @brief moves to the first Variable of the current Section
  */
-void IniParser::getFirstVar()
-{
-  if (this->currentSection != this->sections.end())
+void IniParser::firstVar()
+{
+  if (!this->sections.empty() &&
+      this->currentSection != this->sections.end())
     this->currentEntry = (*this->currentSection).entries.begin();
 }
@@ -342,5 +338,5 @@
 {
   std::list<IniSection>::iterator section;
-
+  
   if (sectionName != NULL)
   {
@@ -351,4 +347,6 @@
   else
     section = this->currentSection;
+  if (section == this->sections.end())
+    return false;
 
   if (section == this->sections.end())
@@ -364,5 +362,8 @@
     (*section).entries.back().value = new char[strlen(value)+1];
     strcpy((*section).entries.back().value, value);
-    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n", entryName, value, (*section).name);
+    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
+	      (*section).entries.back().name,
+	      (*section).entries.back().value,
+	      (*section).name);
     return true;
   }
@@ -387,5 +388,4 @@
     if (sectionName != NULL)
       {
-
 	for (section = this->sections.begin(); section != this->sections.end(); section++)
 	  {
@@ -399,4 +399,7 @@
     else
       section = this->currentSection;
+    
+   if (section == this->sections.end())
+     return (defaultValue);
 
     std::list<IniEntry>::const_iterator entry;
@@ -420,7 +423,9 @@
 const char* IniParser::getCurrentSection() const 
 {
- return (this->currentSection!=NULL) ? 
-   this->currentSection->name :
-   NULL;
+  if (!this->sections.empty() &&
+      this->currentSection != this->sections.end()) 
+    return this->currentSection->name;
+  else
+    return NULL;
  }
 
@@ -432,4 +437,5 @@
 {
  if (!this->sections.empty() &&
+     this->currentSection != this->sections.end() &&
      this->currentEntry != (*this->currentSection).entries.end())
    return (*this->currentEntry).name;
@@ -443,6 +449,7 @@
 const char* IniParser::getCurrentValue() const 
 {
-  if (!this->sections.empty() 
-      && this->currentEntry != (*this->currentSection).entries.end())
+  if (!this->sections.empty() &&
+      this->currentSection != this->sections.end() &&
+      this->currentEntry != (*this->currentSection).entries.end())
     return (*this->currentEntry).value;
   else
