myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 457efd5092


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 457efd5092d04f2bf79010fd98f3bde3ae44495a
Date: Tue, 29 Sep 2009 21:27:47 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  457efd5092d04f2bf79010fd98f3bde3ae44495a (commit)
       via  71efb52308209edc2e10c0f098b99445fb6582ee (commit)
       via  e2384d1de2a637500956b0676477b8d01da840c3 (commit)
       via  a77d3a8e5c37806253dcd582f9043229752e5647 (commit)
       via  b1421c10711c1452f3d4e868e13eea41195479f6 (commit)
       via  bd33850e68efef748d30e7e5012fd76258d1b559 (commit)
       via  5e54aa000139364bef420bcca875ac3b1b604f95 (commit)
       via  3574c14dc0924a1f0cb14176370c26356917171e (commit)
       via  999eb4c28da000f75405c8d59a155e394a216ffd (commit)
      from  b96d1c45627f35ff04385d5a7b5f8c5735947767 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 457efd5092d04f2bf79010fd98f3bde3ae44495a
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 23:27:35 2009 +0200

    Data read from the XML file is not copied on an internal buffer before.

diff --git a/myserver/include/base/xml/xml_parser.h 
b/myserver/include/base/xml/xml_parser.h
index b3936ff..f2ab251 100644
--- a/myserver/include/base/xml/xml_parser.h
+++ b/myserver/include/base/xml/xml_parser.h
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -101,7 +101,6 @@ private:
   xmlXPathContextPtr xpathCtx;
   bool useXpath;
   xmlDocPtr doc;
-  string buffer;
   xmlNodePtr cur;
   xmlNodePtr prevCur;
   xmlNodePtr lastNode;
diff --git a/myserver/src/base/xml/xml_parser.cpp 
b/myserver/src/base/xml/xml_parser.cpp
index cd12803..94b0463 100644
--- a/myserver/src/base/xml/xml_parser.cpp
+++ b/myserver/src/base/xml/xml_parser.cpp
@@ -31,9 +31,9 @@ extern "C"
  * \param len Length
  * \return Returns the length
  */
-static int MemBufWriteCallback(void * context, const char * buffer, int len)
+static int MemBufWriteCallback (void * context, const char * buffer, int len)
 {
-  ((MemBuf *)context)->addBuffer((const void *)buffer, len);
+  ((MemBuf *)context)->addBuffer ((const void *)buffer, len);
   return len;
 }
 
@@ -43,7 +43,7 @@ static int MemBufWriteCallback(void * context, const char * 
buffer, int len)
  * \param context Context
  * \return Returns 0
  */
-static int MemBufCloseCallback(void * context)
+static int MemBufCloseCallback (void *context)
 {
   return 0;
 }
@@ -54,9 +54,9 @@ static int MemBufCloseCallback(void * context)
  * Calls xmlInitParser()
  * @return Returns true
  */
-bool XmlParser::startXML()
+bool XmlParser::startXML ()
 {
-  xmlInitParser();
+  xmlInitParser ();
   return 1;
 }
 
@@ -65,9 +65,9 @@ bool XmlParser::startXML()
  * Cleans up the libxml2 library.
  * @return Returns true
  */
-bool XmlParser::cleanXML()
+bool XmlParser::cleanXML ()
 {
-  xmlCleanupParser();
+  xmlCleanupParser ();
   return 1;
 }
 
@@ -78,48 +78,46 @@ bool XmlParser::cleanXML()
  * \param useXpath Specify if XPath is enabled.
  * \return Returns 0 on success, non zero values on failure
  */
-int XmlParser::open(const char* filename, bool useXpath)
+int XmlParser::open (const char* filename, bool useXpath)
 {
   cur = NULL;
   this->useXpath = useXpath;
 
-  if(!FilesUtility::fileExists(filename))
+  if (!FilesUtility::fileExists (filename))
     return -1;
 
-  if(doc!= NULL)
+  if (doc!= NULL)
     close();
 
-  doc = xmlParseFile(filename);
+  doc = xmlParseFile (filename);
 
-  if(doc == NULL)
+  if (doc == NULL)
     return -1;
 
-  cur = xmlDocGetRootElement(doc);
-
-  if(!cur)
+  cur = xmlDocGetRootElement (doc);
+  if (!cur)
   {
-    close();
+    close ();
     return -1;
   }
 
-  mtime = FilesUtility::getLastModTime(filename);
+  mtime = FilesUtility::getLastModTime (filename);
 
-  if(mtime == static_cast<time_t>(-1))
+  if (mtime == static_cast<time_t>(-1))
   {
-    close();
+    close ();
     return -1;
   }
 
-  if(useXpath)
+  if (useXpath)
   {
-    xpathCtx = xmlXPathNewContext(doc);
-    if(xpathCtx == NULL)
+    xpathCtx = xmlXPathNewContext (doc);
+    if (xpathCtx == NULL)
     {
-      close();
+      close ();
       return -1;
     }
   }
-
   return 0;
 }
 
@@ -128,7 +126,7 @@ int XmlParser::open(const char* filename, bool useXpath)
  * Gets the last modification time of the file
  * @return Returns last modification time
  */
-time_t XmlParser::getLastModTime()
+time_t XmlParser::getLastModTime ()
 {
   return mtime;
 }
@@ -139,51 +137,50 @@ time_t XmlParser::getLastModTime()
  * \param useXpath Specify if XPath is enabled.
  * \return Returns 0 on succes, non 0 on failure
  */
-int XmlParser::openMemBuf(MemBuf & memory, bool useXpath)
+int XmlParser::openMemBuf (MemBuf & memory, bool useXpath)
 {
   mtime = 0;
   cur = NULL;
   this->useXpath = useXpath;
 
-  if(memory.getLength() == 0)
+  if (memory.getLength () == 0)
     return -1;
 
-  if(!doc)
-  {
-    doc = xmlParseMemory((const char * )memory.getBuffer(),
-                         memory.getLength());
-  }
+  if (!doc)
+    {
+      doc = xmlParseMemory ((const char * )memory.getBuffer (),
+                            memory.getLength ());
+    }
   else
-    close();
+    close ();
 
-  if(!doc)
+  if (!doc)
     return -1;
 
-  cur = xmlDocGetRootElement(doc);
-
-  if(!cur)
-  {
-    close();
-    return -1;
-  }
+  cur = xmlDocGetRootElement (doc);
 
-  if(useXpath)
-  {
-    xpathCtx = xmlXPathNewContext(doc);
-    if(xpathCtx == NULL)
+  if (!cur)
     {
-      close();
+      close ();
       return -1;
     }
-  }
 
+  if (useXpath)
+    {
+      xpathCtx = xmlXPathNewContext (doc);
+    if (xpathCtx == NULL)
+      {
+      close ();
+      return -1;
+      }
+    }
   return 0;
 }
 
 /**
  * Constructor of the XmlParser class
  */
-XmlParser::XmlParser()
+XmlParser::XmlParser ()
 {
   doc = NULL;
   cur = NULL;
@@ -198,16 +195,16 @@ XmlParser::XmlParser()
  * Destructor of the XmlParser class
  * Destroys the XmlParser object
  */
-XmlParser::~XmlParser()
+XmlParser::~XmlParser ()
 {
-  close();
+  close ();
 }
 
 /**
  * Returns the XML document
  * @return Returns XML document
  */
-xmlDocPtr XmlParser::getDoc()
+xmlDocPtr XmlParser::getDoc ()
 {
   return doc;
 }
@@ -217,44 +214,23 @@ xmlDocPtr XmlParser::getDoc()
  * \param vName vName of the root child elment
  * \return Returns the value of the vName
  */
-char *XmlParser::getValue(const char* vName)
+char *XmlParser::getValue (const char* vName)
 {
   char *ret = NULL;
   xmlNodePtr lcur;
-  cur = xmlDocGetRootElement(doc);
+  cur = xmlDocGetRootElement (doc);
 
-  if(!cur)
+  if (!cur)
     return 0;
 
   lcur = cur->xmlChildrenNode;
-  buffer.assign("");
 
-  while(lcur)
+  while (lcur)
   {
-    if(!xmlStrcmp(lcur->name, (const xmlChar *)vName))
+    if (!xmlStrcmp (lcur->name, (const xmlChar *)vName))
     {
       lastNode = lcur;
-
-      if(lcur->children->content)
-      {
-        int inlen = strlen((const char*)lcur->children->content);
-        int outlen = inlen * 2;
-        char* tmpBuff = new char[outlen];
-        if(UTF8Toisolat1((unsigned char*)tmpBuff, &outlen,
-                              (unsigned char*)lcur->children->content, &inlen) 
>= 0)
-        {
-          tmpBuff[outlen] = '\0';
-          buffer.assign(tmpBuff);
-        }
-        else
-          buffer.assign((char*)lcur->children->content);
-
-        delete [] tmpBuff;
-
-        ret = (char*)buffer.c_str();
-      }
-
-      break;
+      return (char*)lcur->children->content;
     }
 
     lcur = lcur->next;
@@ -270,24 +246,22 @@ char *XmlParser::getValue(const char* vName)
  * \param value
  * \return Returns 0 on success, non zero on failures
  */
-int XmlParser::setValue(const char* vName, const char *value)
+int XmlParser::setValue (const char* vName, const char *value)
 {
   xmlNodePtr lcur = cur->xmlChildrenNode;
-  buffer.assign("");
-
-  while(lcur)
+  while (lcur)
   {
-    if(!xmlStrcmp(lcur->name, (const xmlChar *)vName))
+    if (!xmlStrcmp (lcur->name, (const xmlChar *)vName))
     {
       lastNode = lcur;
 
-      if(lcur->children->content)
-        strcpy((char*)lcur->children->content, value);
+      if (lcur->children->content)
+        strcpy ((char*)lcur->children->content, value);
 
       return 0;
     }
 
-    lcur=lcur->next;
+    lcur = lcur->next;
   }
 
   return 1;
@@ -300,21 +274,20 @@ int XmlParser::setValue(const char* vName, const char 
*value)
  * \param attr Attribute
  * \return
  */
-char *XmlParser::getAttr(const char* field, const char *attr)
+char *XmlParser::getAttr (const char* field, const char *attr)
 {
   xmlNodePtr lcur = cur->xmlChildrenNode;
-  buffer.assign("");
 
-  while(lcur)
+  while (lcur)
   {
-    if(!xmlStrcmp(lcur->name, (const xmlChar *)field))
+    if (!xmlStrcmp (lcur->name, (const xmlChar *)field))
     {
       lastNode = lcur;
       xmlAttr *attrs =  lcur->properties;
 
-      while(attrs)
+      while (attrs)
       {
-        if(!xmlStrcmp(attrs->name, (const xmlChar *)attr))
+        if (!xmlStrcmp (attrs->name, (const xmlChar *)attr))
         {
           return (char*)attrs->children->content;
         }
@@ -335,26 +308,26 @@ char *XmlParser::getAttr(const char* field, const char 
*attr)
  *\return NULL on errors.
  *\return The XmlXPathResult containing the result.
  */
-XmlXPathResult* XmlParser::evaluateXpath(const char* expr)
+XmlXPathResult* XmlParser::evaluateXpath (const char* expr)
 {
   xmlXPathObjectPtr xpathObj;
 
-  if(!useXpath)
+  if (!useXpath)
     return NULL;
 
-  xpathObj = xmlXPathEvalExpression((const xmlChar*)expr, xpathCtx);
+  xpathObj = xmlXPathEvalExpression ((const xmlChar*)expr, xpathCtx);
 
-  if(xpathObj == NULL)
+  if (xpathObj == NULL)
     return NULL;
 
-  return new XmlXPathResult(xpathObj);
+  return new XmlXPathResult (xpathObj);
 }
 
 
 /**
  * Frees the memory, use by the XmlParser class
  */
-int XmlParser::close()
+int XmlParser::close ()
 {
   int ret = 1;
 
@@ -364,10 +337,8 @@ int XmlParser::close()
       ret = 0;
     }
 
-  if(useXpath && xpathCtx)
-    {
-      xmlXPathFreeContext(xpathCtx);
-    }
+  if (useXpath && xpathCtx)
+    xmlXPathFreeContext(xpathCtx);
 
   doc = NULL;
   cur = NULL;
@@ -387,9 +358,9 @@ int XmlParser::close()
  */
 int XmlParser::save(const char *filename,int *nbytes)
 {
-  int err = xmlSaveFile(filename,doc);
+  int err = xmlSaveFile (filename,doc);
 
-  if(nbytes)
+  if (nbytes)
     *nbytes = err;
 
   return err;
@@ -404,22 +375,22 @@ int XmlParser::save(const char *filename,int *nbytes)
  * \param nbytes Amount of bytes
  * \return Returns 0 on success, non 0 on failures
  */
-int XmlParser::saveMemBuf(MemBuf & memory,int *nbytes)
+int XmlParser::saveMemBuf (MemBuf & memory,int *nbytes)
 {
   /*! Initialize the callback struct. */
   xmlOutputBufferPtr callback;
-  callback = xmlOutputBufferCreateIO(MemBufWriteCallback,
-                                       MemBufCloseCallback,
-                                       (void *)&memory,
-                                       NULL);
+  callback = xmlOutputBufferCreateIO (MemBufWriteCallback,
+                                      MemBufCloseCallback,
+                                      (void *)&memory,
+                                      NULL);
 
   /*! Clear the buffer */
-  memory.free();
+  memory.free ();
 
   /*! Let libxml2 fill the MemBuf class with our interal callbacks. */
-  int err = xmlSaveFileTo(callback, doc, NULL);
+  int err = xmlSaveFileTo (callback, doc, NULL);
 
-  if(nbytes)
+  if (nbytes)
     *nbytes = err;
 
   return err;
@@ -430,18 +401,18 @@ int XmlParser::saveMemBuf(MemBuf & memory,int *nbytes)
  * Starts a new XML tree for a new file
  * \param root roote elment entry
  */
-void XmlParser::newfile(const char * root)
+void XmlParser::newfile (const char * root)
 {
-  if(doc != NULL)
+  if (doc != NULL)
     close();
 
-  doc = xmlNewDoc((const xmlChar*)"1.0");
-  cur = xmlNewDocNode(doc, NULL, (const xmlChar*)root, NULL);
+  doc = xmlNewDoc ((const xmlChar*)"1.0");
+  cur = xmlNewDocNode (doc, NULL, (const xmlChar*)root, NULL);
 
-  xmlDocSetRootElement(doc, cur);
+  xmlDocSetRootElement (doc, cur);
 
-  addLineFeed();
-  addLineFeed();
+  addLineFeed ();
+  addLineFeed ();
 }
 
 
@@ -450,12 +421,12 @@ void XmlParser::newfile(const char * root)
  * \param name Child name
  * \param value Value of the child
  */
-void XmlParser::addChild(const char * name, const char * value)
+void XmlParser::addChild (const char * name, const char * value)
 {
-  lastNode = xmlNewTextChild(cur, NULL, (const xmlChar*)name,
-                               (const xmlChar*)value);
+  lastNode = xmlNewTextChild (cur, NULL, (const xmlChar*)name,
+                              (const xmlChar*)value);
 
-  addLineFeed();
+  addLineFeed ();
 }
 
 
@@ -464,16 +435,15 @@ void XmlParser::addChild(const char * name, const char * 
value)
  * Only one level for now
  * \param name Name of the sub group
  */
-void XmlParser::addGroup(const char * name)
+void XmlParser::addGroup (const char * name)
 {
-  if(prevCur == NULL)
-  {
-    prevCur = cur;
-    cur = xmlNewTextChild(cur, NULL, (const xmlChar*)name, NULL);
-    lastNode = cur;
-
-    addLineFeed();
-  }
+  if (prevCur == NULL)
+    {
+      prevCur = cur;
+      cur = xmlNewTextChild (cur, NULL, (const xmlChar*)name, NULL);
+      lastNode = cur;
+      addLineFeed ();
+    }
 }
 
 
@@ -481,15 +451,14 @@ void XmlParser::addGroup(const char * name)
  * Ends the sub group, if any
  * Only one level for now
  */
-void XmlParser::endGroup()
+void XmlParser::endGroup ()
 {
-  if(prevCur != NULL)
+  if (prevCur != NULL)
   {
     cur = prevCur;
     prevCur = NULL;
-
-    addLineFeed();
-    addLineFeed();
+    addLineFeed ();
+    addLineFeed ();
   }
 }
 
@@ -499,25 +468,25 @@ void XmlParser::endGroup()
  * \param name Name
  * \param value Value
  */
-void XmlParser::setAttr(const char * name, const char * value)
+void XmlParser::setAttr (const char * name, const char * value)
 {
-  if(lastNode == NULL)
+  if (lastNode == NULL)
     return;
 
-  xmlSetProp(lastNode, (const xmlChar*)name, (const xmlChar*)value);
+  xmlSetProp (lastNode, (const xmlChar*)name, (const xmlChar*)value);
 }
 
 
 /**
  * Adds a line feed to the XML data
  */
-void XmlParser::addLineFeed()
+void XmlParser::addLineFeed ()
 {
 #ifdef WIN32
-    xmlNodePtr endline = xmlNewDocText(doc, (const xmlChar *)"\r\n");
+    xmlNodePtr endline = xmlNewDocText (doc, (const xmlChar *)"\r\n");
 #else
-    xmlNodePtr endline = xmlNewDocText(doc, (const xmlChar *)"\n");
+    xmlNodePtr endline = xmlNewDocText (doc, (const xmlChar *)"\n");
 #endif
 
-  xmlAddChild(cur, endline);
+  xmlAddChild (cur, endline);
 }



commit 71efb52308209edc2e10c0f098b99445fb6582ee
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 23:16:10 2009 +0200

    Clear the buffer every time a command is sent.

diff --git a/misc/el_control_client/myserver-control.el 
b/misc/el_control_client/myserver-control.el
index bc5da99..7812922 100644
--- a/misc/el_control_client/myserver-control.el
+++ b/misc/el_control_client/myserver-control.el
@@ -30,7 +30,6 @@
 
 (defun myserver-control-init (server port)
   "Initialize a connection to the specified SERVER using the PORT."
-  (when (get-buffer "myserver") (kill-buffer "myserver"))
   (let ((proc (starttls-open-stream "myserver" 
                                        (get-buffer-create "myserver")
                                        server
@@ -43,8 +42,8 @@
   "Send the message MSG to the specified PROC and
    return the response header lines."
   (process-send-string proc msg)
-      
   (with-current-buffer "myserver"
+    (erase-buffer)
     (let ((i 3)
           (np 0)
           (start 0)



commit e2384d1de2a637500956b0676477b8d01da840c3
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 23:15:24 2009 +0200

    Access to the global configuration is done trough the `MainConfiguration' 
interface.  Realize this new interface in the `XmlMainConfiguration' class that 
accesses a XML stored configuration.

diff --git a/myserver/configure.ac b/myserver/configure.ac
index 5a8ceef..a3c7f6b 100644
--- a/myserver/configure.ac
+++ b/myserver/configure.ac
@@ -403,6 +403,7 @@ AC_CONFIG_FILES([ po/Makefile.in
     include/log/Makefile
     include/log/stream/Makefile
     include/conf/Makefile
+    include/conf/main/Makefile
     include/conf/mime/Makefile
     include/conf/security/Makefile
     include/conf/vhost/Makefile
@@ -457,6 +458,7 @@ AC_CONFIG_FILES([ po/Makefile.in
     src/log/Makefile
     src/log/stream/Makefile
     src/conf/Makefile
+    src/conf/main/Makefile
     src/conf/mime/Makefile
     src/conf/security/Makefile
     src/conf/vhost/Makefile
diff --git a/myserver/include/conf/Makefile.am 
b/myserver/include/conf/Makefile.am
index 69c7d29..a51b361 100644
--- a/myserver/include/conf/Makefile.am
+++ b/myserver/include/conf/Makefile.am
@@ -1,3 +1,3 @@
 confincludedir=$(includedir)/myserver/include/conf
 confinclude_HEADERS = nodetree.h xml_conf.h
-SUBDIRS = mime security vhost
+SUBDIRS = main mime security vhost
diff --git a/myserver/include/conf/main/Makefile.am 
b/myserver/include/conf/main/Makefile.am
new file mode 100644
index 0000000..65dc283
--- /dev/null
+++ b/myserver/include/conf/main/Makefile.am
@@ -0,0 +1,3 @@
+mainincludedir=$(includedir)/myserver/include/conf/main
+maininclude_HEADERS = main_configuration.h xml_main_configuration.h
+SUBDIRS =
diff --git a/myserver/include/conf/main/main_configuration.h 
b/myserver/include/conf/main/main_configuration.h
new file mode 100644
index 0000000..6dbbc0e
--- /dev/null
+++ b/myserver/include/conf/main/main_configuration.h
@@ -0,0 +1,42 @@
+/* -*- mode: c++ -*- */
+/*
+MyServer
+Copyright (C) 2009 Free Software Foundation, Inc.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef MAIN_CONFIGURATION_H
+# define MAIN_CONFIGURATION_H
+
+# include "stdafx.h"
+#include <string>
+using namespace std;
+
+/*! Define the interface to read from the main configuration file.  */
+class MainConfiguration
+{
+public:
+  MainConfiguration ();
+  ~MainConfiguration ();
+  virtual char *getValue (const char* field) = 0;
+  virtual char *getValue (string const &field);
+  virtual int close ()
+  {
+    return 0;
+  }
+private:
+
+};
+
+#endif
diff --git a/myserver/include/conf/main/xml_main_configuration.h 
b/myserver/include/conf/main/xml_main_configuration.h
new file mode 100644
index 0000000..ec82f82
--- /dev/null
+++ b/myserver/include/conf/main/xml_main_configuration.h
@@ -0,0 +1,64 @@
+/* -*- mode: c++ -*- */
+/*
+MyServer
+Copyright (C) 2009 Free Software Foundation, Inc.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef XML_MAIN_CONFIGURATION_H
+# define XML_MAIN_CONFIGURATION_H
+
+# include "stdafx.h"
+# include <include/conf/main/main_configuration.h>
+# include <include/base/xml/xml_parser.h>
+
+
+class XmlMainConfiguration : public MainConfiguration
+{
+public:
+  virtual int open (const char* filename)
+  {
+    return xmlParser.open (filename);
+  }
+
+  virtual int open (string const &filename)
+  {
+    return open (filename.c_str());
+  };
+
+  virtual char *getValue (const char* field)
+  {
+    return xmlParser.getValue (field);
+  }
+
+  virtual char *getValue (string const &field)
+  {
+    return getValue (field.c_str());
+  };
+
+  virtual int close ()
+  {
+    return xmlParser.close ();
+  }
+
+  virtual xmlDocPtr getDoc ()
+  {
+    return xmlParser.getDoc ();
+  }
+
+private:
+  XmlParser xmlParser;
+};
+
+#endif
diff --git a/myserver/include/server/server.h b/myserver/include/server/server.h
index ae85ab6..347117c 100644
--- a/myserver/include/server/server.h
+++ b/myserver/include/server/server.h
@@ -47,6 +47,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 # include <include/conf/security/security_manager.h>
 # include <include/conf/security/auth_method_factory.h>
 # include <include/conf/security/validator_factory.h>
+# include <include/conf/main/main_configuration.h>
 
 # include <include/base/slab/slab.h>
 
@@ -163,12 +164,12 @@ public:
 
   LogManager *getLogManager () { return logManager; }
 
-  XmlParser *getXmlConfiguration ();
+  MainConfiguration *getConfiguration ();
 private:
   friend class ClientsThread;
   XmlValidator *xmlValidator;
 
-  XmlParser configurationFileManager;
+  MainConfiguration *configurationFileManager;
 
 # ifdef WIN32
   friend int __stdcall control_handler(u_long control_type);
diff --git a/myserver/src/base/xml/xml_parser.cpp 
b/myserver/src/base/xml/xml_parser.cpp
index 770a3c8..cd12803 100644
--- a/myserver/src/base/xml/xml_parser.cpp
+++ b/myserver/src/base/xml/xml_parser.cpp
@@ -356,22 +356,25 @@ XmlXPathResult* XmlParser::evaluateXpath(const char* expr)
  */
 int XmlParser::close()
 {
-  if(doc)
-  {
-    xmlFreeDoc(doc);
-  }
+  int ret = 1;
+
+  if (doc)
+    {
+      xmlFreeDoc (doc);
+      ret = 0;
+    }
 
   if(useXpath && xpathCtx)
-  {
-    xmlXPathFreeContext(xpathCtx);
-  }
+    {
+      xmlXPathFreeContext(xpathCtx);
+    }
 
   doc = NULL;
   cur = NULL;
   prevCur = NULL;
   lastNode = NULL;
 
-  return 0;
+  return ret;
 }
 
 /**
diff --git a/myserver/src/conf/Makefile.am b/myserver/src/conf/Makefile.am
index 00cd655..8cd6693 100644
--- a/myserver/src/conf/Makefile.am
+++ b/myserver/src/conf/Makefile.am
@@ -1,6 +1,6 @@
 lib_LIBRARIES = libconf.a
 libconf_a_SOURCES = nodetree.cpp xml_conf.cpp
-SUBDIRS = mime security vhost
+SUBDIRS = main mime security vhost
 AM_CPPFLAGS = $(all_includes)
 
 install:
diff --git a/myserver/src/conf/main/Makefile.am 
b/myserver/src/conf/main/Makefile.am
new file mode 100644
index 0000000..440c502
--- /dev/null
+++ b/myserver/src/conf/main/Makefile.am
@@ -0,0 +1,4 @@
+lib_LIBRARIES = libmain.a
+libmain_a_SOURCES = main_configuration.cpp xml_main_configuration.cpp
+SUBDIRS =
+AM_CPPFLAGS = $(all_includes)
diff --git a/myserver/src/conf/main/main_configuration.cpp 
b/myserver/src/conf/main/main_configuration.cpp
new file mode 100644
index 0000000..98dc366
--- /dev/null
+++ b/myserver/src/conf/main/main_configuration.cpp
@@ -0,0 +1,35 @@
+/*
+  MyServer
+  Copyright (C) 2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <include/conf/main/main_configuration.h>
+
+
+MainConfiguration::MainConfiguration ()
+{
+
+}
+
+MainConfiguration::~MainConfiguration ()
+{
+
+}
+
+char *MainConfiguration::getValue (string const &field)
+{
+  return getValue (field.c_str());
+};
+
diff --git a/myserver/src/conf/main/xml_main_configuration.cpp 
b/myserver/src/conf/main/xml_main_configuration.cpp
new file mode 100644
index 0000000..637ab4f
--- /dev/null
+++ b/myserver/src/conf/main/xml_main_configuration.cpp
@@ -0,0 +1,18 @@
+/*
+  MyServer
+  Copyright (C) 2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <include/conf/main/xml_main_configuration.h>
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index c9d0848..fc8396b 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -32,6 +32,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <include/base/socket/ssl_socket.h>
 
 #include <include/conf/xml_conf.h>
+#include <include/conf/main/xml_main_configuration.h>
 
 #include <cstdarg>
 
@@ -89,6 +90,7 @@ Server::Server () : connectionsScheduler (this),
   xmlValidator = new XmlValidator ();
   initLogManager ();
   connectionsPoolLock.init ();
+  configurationFileManager = NULL;
 }
 
 void
@@ -159,6 +161,9 @@ Server::~Server ()
   if (logManager)
     delete logManager;
 
+  if (configurationFileManager)
+    delete configurationFileManager;
+
   connectionsPoolLock.destroy ();
 }
 
@@ -317,7 +322,9 @@ int Server::postLoad ()
     }
 
 
-  configurationFileManager.close ();
+  configurationFileManager->close ();
+  delete configurationFileManager;
+  configurationFileManager = NULL;
 
   return 0;
 }
@@ -746,17 +753,15 @@ int Server::terminate ()
   return 0;
 }
 
-
 /*!
  * Get a pointer to the configuration file.  It is
  * valid only at startup!
  */
-XmlParser *Server::getXmlConfiguration ()
+MainConfiguration *Server::getConfiguration ()
 {
-  return &configurationFileManager;
+  return configurationFileManager;
 }
 
-
 /*!
  * Here is loaded the configuration of the server.
  * The configuration file is a XML file.
@@ -765,12 +770,12 @@ XmlParser *Server::getXmlConfiguration ()
 int Server::initialize ()
 {
   const char *data;
+  XmlMainConfiguration *xmlMainConf;
 
 #ifdef WIN32
   envString = GetEnvironmentStrings ();
 #endif
   connectionsMutex = new Mutex ();
-
   threadsMutex = new Mutex ();
 
   /* Store the default values.  */
@@ -785,10 +790,17 @@ int Server::initialize ()
   maxConnections = 0;
   maxConnectionsToAccept = 0;
 
-  if (configurationFileManager.open (mainConfigurationFile.c_str ()))
-    return -1;
 
-  readHashedData (xmlDocGetRootElement (configurationFileManager.getDoc 
())->xmlChildrenNode);
+  xmlMainConf = new XmlMainConfiguration ();
+  if (xmlMainConf->open (mainConfigurationFile.c_str ()))
+    {
+      delete xmlMainConf;
+      return -1;
+    }
+
+  configurationFileManager = xmlMainConf;
+
+  readHashedData (xmlDocGetRootElement (xmlMainConf->getDoc 
())->xmlChildrenNode);
 
   /*
    * Process console colors information.
diff --git a/myserver/tests/Makefile.am b/myserver/tests/Makefile.am
index 83007d8..2aa10d9 100644
--- a/myserver/tests/Makefile.am
+++ b/myserver/tests/Makefile.am
@@ -10,7 +10,8 @@ test_log_manager.cpp test_log_stream_factory.cpp test_md5.cpp 
test_mem_buff.cpp
 test_multicast.cpp test_mutex.cpp test_pipe.cpp test_plugin_info.cpp 
test_recursive_mutex.cpp test_regex.cpp test_safetime.cpp \
 test_security_cache.cpp test_security_domain.cpp test_security_manager.cpp 
test_security_token.cpp test_semaphore.cpp test_slab.cpp \
 test_socket.cpp test_socket_pair.cpp test_socket_stream_creator.cpp 
test_ssl_socket.cpp test_thread.cpp test_unix_socket.cpp \
-test_url.cpp test_utility.cpp test_validator.cpp test_validator_factory.cpp 
test_xml.cpp test_xml_validator.cpp test_nodetree.cpp
+test_url.cpp test_utility.cpp test_validator.cpp test_validator_factory.cpp 
test_xml.cpp test_xml_main_configuration.cpp \
+test_xml_validator.cpp test_nodetree.cpp
 
 tests_suite_LDADD = ../src/libmyserver.a $(CPPUNIT_LDFLAGS) $(PTHREAD_LIB) 
$(IDN_LIB) $(XNET_LIB) $(EVENT_LIB) $(DL_LIB) $(SSL_LIB) $(ZLIB_LIB) 
$(XML_LIBS) $(LDFLAGS)
 
diff --git a/myserver/tests/test_xml_main_configuration.cpp 
b/myserver/tests/test_xml_main_configuration.cpp
new file mode 100644
index 0000000..91cd8b9
--- /dev/null
+++ b/myserver/tests/test_xml_main_configuration.cpp
@@ -0,0 +1,56 @@
+/*
+ MyServer
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <include/conf/main/xml_main_configuration.h>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestXmlMainConfiguration : public CppUnit::TestFixture
+{
+  /* FIXME: Actually these tests don't really check if things work, simply they
+     check that they don't work when they shouldn't.  */
+       CPPUNIT_TEST_SUITE (TestXmlMainConfiguration);
+       CPPUNIT_TEST (testOpen);
+       CPPUNIT_TEST (testGetDoc);
+       CPPUNIT_TEST (testClose);
+       CPPUNIT_TEST_SUITE_END ();
+
+public:
+       void setUp () {}
+       void tearDown () {}
+       void testOpen ()
+       {
+    XmlMainConfiguration xmlConf;
+               CPPUNIT_ASSERT (xmlConf.open ("bla/bla/bla"));
+       }
+
+       void testGetDoc ()
+       {
+    XmlMainConfiguration xmlConf;
+               CPPUNIT_ASSERT_EQUAL (xmlConf.getDoc (), (xmlDocPtr)NULL);
+       }
+
+       void testClose ()
+       {
+    XmlMainConfiguration xmlConf;
+               CPPUNIT_ASSERT (xmlConf.close ());
+       }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION (TestXmlMainConfiguration);
diff --git a/plugins/src/http_checker/http_checker.cpp 
b/plugins/src/http_checker/http_checker.cpp
index 3bc77f2..2019bea 100644
--- a/plugins/src/http_checker/http_checker.cpp
+++ b/plugins/src/http_checker/http_checker.cpp
@@ -20,6 +20,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <include/base/multicast/multicast.h>
 #include <include/protocol/http/http.h>
 #include <include/plugin/plugin.h>
+#include <include/conf/main/xml_main_configuration.h>
 #include <Python.h>
 
 #ifdef WIN32
@@ -234,7 +235,7 @@ EXPORTABLE(int) load(void* server,void* parser)
   string msg("new-http-request");
   string pythonName("python");
   Plugin* python;
-  XmlParser* configuration;
+  MainConfiguration* configuration;
   xmlDocPtr xmlDoc;
 
   if(!staticData)
@@ -262,8 +263,10 @@ EXPORTABLE(int) load(void* server,void* parser)
       return -1;
     }
 
-  configuration = serverInstance->getXmlConfiguration ();
-  xmlDoc = configuration->getDoc ();
+  configuration = serverInstance->getConfiguration ();
+
+  /* FIXME: DON'T DO THIS.  */
+  xmlDoc = ((XmlMainConfiguration*)configuration)->getDoc ();
 
   for(xmlNodePtr ptr = xmlDoc->children->next->children; ptr; ptr = ptr->next)
     {
diff --git a/plugins/src/python_http_handler/python_http_handler.cpp 
b/plugins/src/python_http_handler/python_http_handler.cpp
index 377e4d7..508e824 100644
--- a/plugins/src/python_http_handler/python_http_handler.cpp
+++ b/plugins/src/python_http_handler/python_http_handler.cpp
@@ -21,6 +21,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <include/base/multicast/multicast.h>
 #include <include/protocol/http/http.h>
 #include <include/plugin/plugin.h>
+#include <include/conf/main/xml_main_configuration.h>
 #include <Python.h>
 
 
@@ -406,8 +407,9 @@ EXPORTABLE(int) load (void* server)
        string msg("new-http-request");
        string pythonName("python");
        Plugin* python;
-       XmlParser* configuration;
+  MainConfiguration* configuration;
        xmlDocPtr xmlDoc;
+
        if(!staticData)
     {
       serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("PythonHttpHandler: 
Invalid HTTP static data"));
@@ -431,8 +433,11 @@ EXPORTABLE(int) load (void* server)
       serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("PythonHttpHandler: 
Cannot find method initModule in executors::python"));
       return -1;
     }
-       configuration = serverInstance->getXmlConfiguration();
-       xmlDoc = configuration->getDoc();
+
+  configuration = serverInstance->getConfiguration ();
+
+  /* FIXME: DON'T DO THIS.  */
+  xmlDoc = ((XmlMainConfiguration*)configuration)->getDoc ();
 
        for(xmlNodePtr ptr = xmlDoc->children->next->children; ptr; ptr = 
ptr->next)
          {
diff --git a/plugins/src/rules_checker/rules_checker.cpp 
b/plugins/src/rules_checker/rules_checker.cpp
index 954d78b..682f29d 100644
--- a/plugins/src/rules_checker/rules_checker.cpp
+++ b/plugins/src/rules_checker/rules_checker.cpp
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <include/server/server.h>
 #include <include/protocol/http/http.h>
+#include <include/conf/main/xml_main_configuration.h>
 #include "heading.h"
 
 #ifdef WIN32
@@ -98,7 +99,7 @@ EXPORTABLE(int) load (void* server)
   Server* serverInstance = (Server*)server;
   HttpStaticData* staticData =(HttpStaticData*) 
serverInstance->getGlobalData("http-static");
   string msg("new-http-request");
-  XmlParser* configuration;
+  MainConfiguration* configuration;
   xmlDocPtr xmlDoc;
   if(!staticData)
     {
@@ -109,8 +110,10 @@ EXPORTABLE(int) load (void* server)
 
   staticData->addMulticast(msg, &observer);
 
-  configuration = serverInstance->getXmlConfiguration();
-  xmlDoc = configuration->getDoc();
+  configuration = serverInstance->getConfiguration ();
+
+  /* FIXME: DON'T DO THIS.  */
+  xmlDoc = ((XmlMainConfiguration*)configuration)->getDoc ();
 
   for(xmlNodePtr ptr = xmlDoc->children->next->children; ptr; ptr = ptr->next)
     {



commit a77d3a8e5c37806253dcd582f9043229752e5647
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 21:46:55 2009 +0200

    Get the `server.max_files_cache' value by `Server::getData ()'.

diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index fd8d5b2..c9d0848 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -851,7 +851,7 @@ int Server::initialize ()
   if (data)
     maxLogFileSize=(u_long)atol(data);
 
-  data = configurationFileManager.getValue ("server.max_files_cache");
+  data = getData ("server.max_files_cache");
   if (data)
     {
       u_long maxSize = (u_long)atol(data);



commit b1421c10711c1452f3d4e868e13eea41195479f6
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 21:26:48 2009 +0200

    Remove `if' statement having the same two source branches.

diff --git a/myserver/src/myserver.cpp b/myserver/src/myserver.cpp
index c7acd0b..4170385 100644
--- a/myserver/src/myserver.cpp
+++ b/myserver/src/myserver.cpp
@@ -620,7 +620,6 @@ void  __stdcall myServerMainNT (u_long, LPTSTR*)
   try
     {
       Server::createInstance ();
-
     }
   catch(...)
     {
@@ -678,12 +677,8 @@ void __stdcall myServerCtrlHandler(u_long fdwControl)
 
     case SERVICE_CONTROL_CONTINUE:
       break;
-    default:
-      if (fdwControl >= 128 && fdwControl <= 255)
-        break;
-      else
-        break;
     }
+
   SetServiceStatus (MyServiceStatusHandle, &MyServiceStatus);
 }
 #endif



commit bd33850e68efef748d30e7e5012fd76258d1b559
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 21:14:29 2009 +0200

    Make `make check' again recursive.

diff --git a/myserver/Makefile.am b/myserver/Makefile.am
index 3891b2a..8b80a2e 100644
--- a/myserver/Makefile.am
+++ b/myserver/Makefile.am
@@ -19,6 +19,3 @@ localedir.h: Makefile
 
 all: localedir.h
 # Generate the localedir.h file before any other rule.
-
-check-recursive:
-       (cd tests; $(MAKE) check)



commit 5e54aa000139364bef420bcca875ac3b1b604f95
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 21:12:09 2009 +0200

    Use string's instead of pointers to string's to store configuration files 
name.

diff --git a/myserver/include/server/server.h b/myserver/include/server/server.h
index a671ccf..ae85ab6 100644
--- a/myserver/include/server/server.h
+++ b/myserver/include/server/server.h
@@ -229,7 +229,6 @@ private:
   string *ipAddresses;
   char serverName[HOST_NAME_MAX + 1];
   string* path;
-  string* externalPath;
   int initialize();
   int addThread(bool staticThread = false);
   ConnectionPtr addConnectionToList(Socket* s, MYSERVER_SOCKADDRIN *asock_in,
@@ -255,9 +254,12 @@ private:
 
   int purgeThreads();
   int reboot();
-  string* mainConfigurationFile;
-  string* vhostConfigurationFile;
-  string* mimeConfigurationFile;
+
+  string mainConfigurationFile;
+  string vhostConfigurationFile;
+  string mimeConfigurationFile;
+  string externalPath;
+
   PluginsManager pluginsManager;
   ProcessServerManager processServerManager;
   ConnectionsScheduler connectionsScheduler;
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 36f5f06..fd8d5b2 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -80,10 +80,6 @@ Server::Server () : connectionsScheduler (this),
   serverReady = false;
   throttlingRate = 0;
   mimeManager = 0;
-  mimeConfigurationFile = 0;
-  mainConfigurationFile = 0;
-  vhostConfigurationFile = 0;
-  externalPath = 0;
   path = 0;
   ipAddresses = 0;
   vhostList = 0;
@@ -115,26 +111,10 @@ Server::initLogManager ()
 bool Server::resetConfigurationPaths (string &mainConf, string &mimeConf,
                                     string &vhostConf, string &externPath)
 {
-  if (!mainConfigurationFile)
-    mainConfigurationFile = new string (mainConf);
-  else
-    mainConfigurationFile->assign (mainConf);
-
-  if (!mimeConfigurationFile)
-    mimeConfigurationFile = new string (mimeConf);
-  else
-    mimeConfigurationFile->assign (mimeConf);
-
-  if (!vhostConfigurationFile)
-    vhostConfigurationFile = new string (vhostConf);
-  else
-    vhostConfigurationFile->assign (vhostConf);
-
-  if (!externalPath)
-    externalPath = new string (externPath);
-  else
-    externalPath->assign (externPath);
-
+  mainConfigurationFile = mainConf;
+  mimeConfigurationFile = mimeConf;
+  vhostConfigurationFile = vhostConf;
+  externalPath = externPath;
   return true;
 }
 
@@ -166,19 +146,6 @@ Server::~Server ()
   if (vhostList)
     delete vhostList;
 
-  delete vhostConfigurationFile;
-  vhostConfigurationFile = 0;
-
-  delete mainConfigurationFile;
-  mainConfigurationFile = 0;
-
-  delete mimeConfigurationFile;
-  mimeConfigurationFile = 0;
-
-  if (externalPath)
-    delete externalPath;
-  externalPath = 0;
-
   if (xmlValidator)
     delete xmlValidator;
 
@@ -301,7 +268,7 @@ int Server::postLoad ()
 
   mimeManager = new MimeManager ();
 
-  if (int nMIMEtypes = mimeManager->loadXML(mimeConfigurationFile->c_str ()))
+  if (int nMIMEtypes = mimeManager->loadXML(mimeConfigurationFile.c_str ()))
     log (MYSERVER_LOG_MSG_INFO, _("Using %i MIME types"), nMIMEtypes);
   else
     log (MYSERVER_LOG_MSG_ERROR, _("Error while loading MIME types"));
@@ -328,7 +295,7 @@ int Server::postLoad ()
   loadPlugins ();
 
   /* Load the virtual hosts configuration from the xml file.  */
-  vhostList->loadXMLConfigurationFile (vhostConfigurationFile->c_str ());
+  vhostList->loadXMLConfigurationFile (vhostConfigurationFile.c_str ());
 
   if (path == 0)
     path = new string ();
@@ -372,7 +339,7 @@ void Server::loadPlugins ()
                               new HttpsProtocol(),
                               new FtpProtocol(),
                               new ControlProtocol(),
-                              0};
+                              NULL};
 
   for (int j = 0; protocolsSet[j]; j++)
     {
@@ -383,7 +350,7 @@ void Server::loadPlugins ()
       getProtocolsManager ()->addProtocol (protocolName, protocol);
     }
 
-  getPluginsManager ()->preLoad (this, *externalPath);
+  getPluginsManager ()->preLoad (this, externalPath);
   getPluginsManager ()->load (this);
   getPluginsManager ()->postLoad (this);
 }
@@ -399,10 +366,9 @@ void Server::mainLoop()
 
   u_long purgeThreadsCounter = 0;
 
-  mainConfTime = FilesUtility::getLastModTime (mainConfigurationFile->c_str 
());
-  hostsConfTime =
-    FilesUtility::getLastModTime (vhostConfigurationFile->c_str ());
-  mimeConfTime = FilesUtility::getLastModTime (mimeConfigurationFile->c_str 
());
+  mainConfTime = FilesUtility::getLastModTime (mainConfigurationFile.c_str ());
+  hostsConfTime = FilesUtility::getLastModTime (vhostConfigurationFile.c_str 
());
+  mimeConfTime = FilesUtility::getLastModTime (mimeConfigurationFile.c_str ());
 
   /*
    * Keep thread alive.
@@ -423,11 +389,11 @@ void Server::mainLoop()
       if (autoRebootEnabled)
         {
           time_t mainConfTimeNow =
-            FilesUtility::getLastModTime (mainConfigurationFile->c_str ());
+            FilesUtility::getLastModTime (mainConfigurationFile.c_str ());
           time_t hostsConfTimeNow =
-            FilesUtility::getLastModTime (vhostConfigurationFile->c_str ());
+            FilesUtility::getLastModTime (vhostConfigurationFile.c_str ());
           time_t mimeConfNow =
-            FilesUtility::getLastModTime (mimeConfigurationFile->c_str ());
+            FilesUtility::getLastModTime (mimeConfigurationFile.c_str ());
 
           /* If a configuration file was modified reboot the server. */
           if (((mainConfTimeNow != -1) && (hostsConfTimeNow != -1)  &&
@@ -501,7 +467,7 @@ void Server::mainLoop()
                   delete oldvhost;
 
                   /* Load the virtual hosts configuration from the xml file.  
*/
-                  if (vhostList->loadXMLConfigurationFile 
(vhostConfigurationFile->c_str ()))
+                  if (vhostList->loadXMLConfigurationFile 
(vhostConfigurationFile.c_str ()))
                     listenThreads.rollbackFastReboot ();
                   else
                     listenThreads.commitFastReboot ();
@@ -819,7 +785,7 @@ int Server::initialize ()
   maxConnections = 0;
   maxConnectionsToAccept = 0;
 
-  if (configurationFileManager.open (mainConfigurationFile->c_str ()))
+  if (configurationFileManager.open (mainConfigurationFile.c_str ()))
     return -1;
 
   readHashedData (xmlDocGetRootElement (configurationFileManager.getDoc 
())->xmlChildrenNode);
@@ -1404,7 +1370,7 @@ Protocol* Server::getProtocol (const char *protocolName)
  */
 const char* Server::getExternalPath ()
 {
-  return externalPath ? externalPath->c_str () : "";
+  return externalPath.c_str ();
 }
 
 
@@ -1540,8 +1506,7 @@ CachedFileFactory* Server::getCachedFiles ()
  */
 const char *Server::getMainConfFile ()
 {
-  return mainConfigurationFile
-    ? mainConfigurationFile->c_str () : 0;
+  return mainConfigurationFile.c_str ();
 }
 
 /*!
@@ -1549,7 +1514,7 @@ const char *Server::getMainConfFile ()
  */
 const char *Server::getVhostConfFile ()
 {
-  return vhostConfigurationFile ? vhostConfigurationFile->c_str () : NULL;
+  return vhostConfigurationFile.c_str ();
 }
 
 /*!
@@ -1557,7 +1522,7 @@ const char *Server::getVhostConfFile ()
  */
 const char *Server::getMIMEConfFile ()
 {
-  return mimeConfigurationFile ? mimeConfigurationFile->c_str () : "";
+  return mimeConfigurationFile.c_str ();
 }
 
 /*!



commit 3574c14dc0924a1f0cb14176370c26356917171e
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 20:47:34 2009 +0200

    Default configuration files are not copied automatically when a valid 
configuration files set is not found.

diff --git a/myserver/include/server/server.h b/myserver/include/server/server.h
index 4bead7b..a671ccf 100644
--- a/myserver/include/server/server.h
+++ b/myserver/include/server/server.h
@@ -241,9 +241,7 @@ private:
   int freeHashedData();
   u_long connectionTimeout;
   u_long maxLogFileSize;
-  int copyConfigurationFromDefault(const char *);
   void logWriteNTimes(string, unsigned);
-  int checkConfigurationPaths();
   bool resetConfigurationPaths(string &, string &, string &, string &);
   Mutex* connectionsMutex;
   u_long nStaticThreads;
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 383474e..36f5f06 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -139,86 +139,6 @@ bool Server::resetConfigurationPaths (string &mainConf, 
string &mimeConf,
 }
 
 /*!
-  *Check that the configuration paths are not empty, otherwise fall back to
- * the default ones.
- * Returns nonzero on error.
- */
-int Server::checkConfigurationPaths ()
-{
-  if (mainConfigurationFile->length() == 0)
-  {
-    mainConfigurationFile->assign ("myserver.xml");
-
-    if (copyConfigurationFromDefault ("myserver.xml"))
-    {
-      log (MYSERVER_LOG_MSG_ERROR, _("Error loading configuration file"));
-      return -1;
-    }
-  }
-
-  if (mimeConfigurationFile->length() == 0)
-  {
-    mimeConfigurationFile->assign ("MIMEtypes.xml");
-
-    if (copyConfigurationFromDefault ("MIMEtypes.xml"))
-    {
-      log (MYSERVER_LOG_MSG_ERROR, _("Error loading MIME configuration file"));
-      return -1;
-    }
-  }
-
-  if (vhostConfigurationFile->length() == 0)
-  {
-    vhostConfigurationFile->assign ("virtualhosts.xml");
-
-    if (copyConfigurationFromDefault ("virtualhosts.xml") != 0)
-    {
-      log (MYSERVER_LOG_MSG_ERROR, _("Error loading virtual hosts 
configuration file"));
-      return -1;
-    }
-  }
-
-  return 0;
-}
-
-/*!
- * Copy a configuration file from the default one.
- * Return nonzero on errors.
- */
-int Server::copyConfigurationFromDefault (const char *fileName)
-{
-  File inputF;
-  File outputF;
-  int ret;
-  string sSource (fileName);
-  sSource = sSource.substr (0, sSource.length () - 3);
-
-#ifdef WIN32
-  sSource.append ("default.windows.xml");
-#else
-  sSource.append ("default.xml");
-#endif
-
-  ret = inputF.openFile (sSource, File::READ
-                        | File::OPEN_IF_EXISTS);
-  if (ret)
-    return -1;
-
-  ret = outputF.openFile (fileName, File::WRITE
-                         | File::FILE_OPEN_ALWAYS);
-  if (ret)
-    return -1;
-
-  FilesUtility::copyFile (inputF, outputF);
-
-  inputF.close ();
-  outputF.close ();
-
-  return 0;
-}
-
-
-/*!
  * Load here all the libraries.
  */
 int Server::loadLibraries ()
@@ -299,10 +219,6 @@ void Server::start (string &mainConf, string &mimeConf, 
string &vhostConf,
     if (!resetConfigurationPaths (mainConf, mimeConf, vhostConf, externPath))
       return;
 
-    err = checkConfigurationPaths ();
-    if (err)
-      return;
-
     err = initialize ();
     if (err)
       return;



commit 999eb4c28da000f75405c8d59a155e394a216ffd
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Sep 29 19:55:32 2009 +0200

    Raise an error if the specified protocol is not loaded.

diff --git a/myserver/src/conf/vhost/vhost_manager.cpp 
b/myserver/src/conf/vhost/vhost_manager.cpp
index 10820be..4793e32 100644
--- a/myserver/src/conf/vhost/vhost_manager.cpp
+++ b/myserver/src/conf/vhost/vhost_manager.cpp
@@ -53,6 +53,12 @@ int VhostManager::addVHost(Vhost* vh)
                  _("Protocol not defined for vhost: %s, using HTTP by 
default"),
                                              vh->getName ());
         }
+      string protocol (vh->getProtocolName ());
+      if (Server::getInstance ()->getProtocolsManager()->getProtocol (protocol)
+          == NULL)
+        Server::getInstance()->log (MYSERVER_LOG_MSG_ERROR,
+                                _("The protocol \"%s\" is used but not 
loaded"),
+                                    protocol.c_str ());
 
       hostList.push_back (vh);
       mutex.unlock ();

-----------------------------------------------------------------------

Summary of changes:
 misc/el_control_client/myserver-control.el         |    3 +-
 myserver/Makefile.am                               |    3 -
 myserver/configure.ac                              |    2 +
 myserver/include/base/xml/xml_parser.h             |    3 +-
 myserver/include/conf/Makefile.am                  |    2 +-
 myserver/include/conf/main/Makefile.am             |    3 +
 .../url.h => conf/main/main_configuration.h}       |   39 ++--
 .../main/xml_main_configuration.h}                 |   64 +++---
 myserver/include/server/server.h                   |   17 +-
 myserver/src/base/xml/xml_parser.cpp               |  268 +++++++++-----------
 myserver/src/conf/Makefile.am                      |    2 +-
 myserver/src/conf/main/Makefile.am                 |    4 +
 .../main/main_configuration.cpp}                   |   21 ++-
 .../main/xml_main_configuration.cpp}               |    4 +-
 myserver/src/conf/vhost/vhost_manager.cpp          |    6 +
 myserver/src/myserver.cpp                          |    7 +-
 myserver/src/server/server.cpp                     |  189 +++-----------
 myserver/tests/Makefile.am                         |    3 +-
 ...est_ftp.cpp => test_xml_main_configuration.cpp} |   45 ++--
 plugins/src/http_checker/http_checker.cpp          |    9 +-
 .../python_http_handler/python_http_handler.cpp    |   11 +-
 plugins/src/rules_checker/rules_checker.cpp        |    9 +-
 22 files changed, 306 insertions(+), 408 deletions(-)
 create mode 100644 myserver/include/conf/main/Makefile.am
 copy myserver/include/{protocol/url.h => conf/main/main_configuration.h} (64%)
 copy myserver/include/{base/unix_socket/unix_socket.h => 
conf/main/xml_main_configuration.h} (51%)
 create mode 100644 myserver/src/conf/main/Makefile.am
 copy myserver/src/{log/stream/log_stream_creator.cpp => 
conf/main/main_configuration.cpp} (68%)
 copy myserver/src/{log/stream/log_stream_creator.cpp => 
conf/main/xml_main_configuration.cpp} (85%)
 copy myserver/tests/{test_ftp.cpp => test_xml_main_configuration.cpp} (52%)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]