From MAILER-DAEMON Fri May 01 12:35:01 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1LzvhV-0003JD-MS
	for mharc-myserver-commit@gnu.org; Fri, 01 May 2009 12:35:01 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1LzvhT-0003Gk-MG
	for myserver-commit@gnu.org; Fri, 01 May 2009 12:34:59 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1LzvhS-0003FX-Rf
	for myserver-commit@gnu.org; Fri, 01 May 2009 12:34:59 -0400
Received: from [199.232.76.173] (port=48133 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1LzvhS-0003FC-KD
	for myserver-commit@gnu.org; Fri, 01 May 2009 12:34:58 -0400
Received: from savannah.gnu.org ([199.232.41.3]:55250 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1LzvhS-0004Yj-6A
	for myserver-commit@gnu.org; Fri, 01 May 2009 12:34:58 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1LzvhR-0003UY-I1
	for myserver-commit@gnu.org; Fri, 01 May 2009 16:34:57 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1LzvhR-0003UU-AU
	for myserver-commit@gnu.org; Fri, 01 May 2009 16:34:57 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1LzvhR-0003UU-AU@cvs.savannah.gnu.org>
Date: Fri, 01 May 2009 16:34:57 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3064] The `ForkServer::startForkServer ()'
 function returns after the socket is created.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 01 May 2009 16:35:00 -0000

Revision: 3064
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3064
Author:   gscrivano
Date:     2009-05-01 16:34:56 +0000 (Fri, 01 May 2009)
Log Message:
-----------
The `ForkServer::startForkServer ()' function returns after the socket is created.

Modified Paths:
--------------
    trunk/myserver/src/base/process/fork_server.cpp

Modified: trunk/myserver/src/base/process/fork_server.cpp
===================================================================
--- trunk/myserver/src/base/process/fork_server.cpp	2009-04-30 22:52:57 UTC (rev 3063)
+++ trunk/myserver/src/base/process/fork_server.cpp	2009-05-01 16:34:56 UTC (rev 3064)
@@ -363,15 +363,15 @@
 #ifndef WIN32
   FilesUtility::temporaryFileName(0, socketPath);
 
+  socket.socket ();
+  socket.bind (socketPath.c_str ());
+  socket.listen (SOMAXCONN);
+
   switch (fork ())
     {
     case -1:
       return -1;
     case 0:
-      socket.socket ();
-      socket.bind (socketPath.c_str ());
-      socket.listen (SOMAXCONN);
-
       initialized = true;
 
       forkServerLoop (&socket);
@@ -379,6 +379,7 @@
       break;
 
     default:
+      socket.close ();
       initialized = true;
       break;
     }  




From MAILER-DAEMON Sat May 02 06:54:35 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0CrZ-0004v0-BP
	for mharc-myserver-commit@gnu.org; Sat, 02 May 2009 06:54:34 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0CrW-0004ut-A6
	for myserver-commit@gnu.org; Sat, 02 May 2009 06:54:30 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0CrV-0004uh-26
	for myserver-commit@gnu.org; Sat, 02 May 2009 06:54:29 -0400
Received: from [199.232.76.173] (port=45245 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0CrU-0004ue-1m
	for myserver-commit@gnu.org; Sat, 02 May 2009 06:54:28 -0400
Received: from savannah.gnu.org ([199.232.41.3]:38341 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0CrT-0007Bt-G4
	for myserver-commit@gnu.org; Sat, 02 May 2009 06:54:27 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0CrS-0002DO-RK
	for myserver-commit@gnu.org; Sat, 02 May 2009 10:54:26 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0CrS-0002Cy-6o
	for myserver-commit@gnu.org; Sat, 02 May 2009 10:54:26 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0CrS-0002Cy-6o@cvs.savannah.gnu.org>
Date: Sat, 02 May 2009 10:54:26 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3065] Delegate the HTTP PUT/
 DELETE commands to the HTTP handlers instead of handling them in the manager
 .
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 02 May 2009 10:54:30 -0000

Revision: 3065
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3065
Author:   gscrivano
Date:     2009-05-02 10:54:25 +0000 (Sat, 02 May 2009)
Log Message:
-----------
Delegate the HTTP PUT/DELETE commands to the HTTP handlers instead of handling them in the manager.

Modified Paths:
--------------
    trunk/myserver/include/http_handler/http_file/http_file.h
    trunk/myserver/include/protocol/http/http.h
    trunk/myserver/src/http_handler/http_file/http_file.cpp
    trunk/myserver/src/protocol/http/http.cpp

Modified: trunk/myserver/include/http_handler/http_file/http_file.h
===================================================================
--- trunk/myserver/include/http_handler/http_file/http_file.h	2009-05-01 16:34:56 UTC (rev 3064)
+++ trunk/myserver/include/http_handler/http_file/http_file.h	2009-05-02 10:54:25 UTC (rev 3065)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2005, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 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
@@ -35,6 +35,12 @@
                    int execute = 0, int OnlyHeader = 0); 
   HttpFile();
   virtual ~HttpFile();
+
+protected:
+  int putFile (HttpThreadContext* td,
+               string& filename);
+  int deleteFile (HttpThreadContext* td,
+                  string& filename);
 private:
   static int appendDataToHTTPChannel(HttpThreadContext* td, 
                                      char* buffer, 

Modified: trunk/myserver/include/protocol/http/http.h
===================================================================
--- trunk/myserver/include/protocol/http/http.h	2009-05-01 16:34:56 UTC (rev 3064)
+++ trunk/myserver/include/protocol/http/http.h	2009-05-02 10:54:25 UTC (rev 3065)
@@ -129,7 +129,9 @@
   int traceHTTPRESOURCE(string& filename,
                         int yetMapped = 0);
 
-  int deleteHTTPRESOURCE(string& filename,
+  int deleteHTTPRESOURCE(string &filename,
+                         int systemrequest = 0,
+                         int onlyHeader = 0,
                          int yetMapped = 0);
 
   bool allowMethod(const char *name);

Modified: trunk/myserver/src/http_handler/http_file/http_file.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-01 16:34:56 UTC (rev 3064)
+++ trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-02 10:54:25 UTC (rev 3065)
@@ -39,6 +39,163 @@
 }
 
 /*!
+ *Main function to handle the HTTP PUT command.
+ */
+int HttpFile::putFile (HttpThreadContext* td,
+                       string& filename)
+{
+  u_long firstByte = td->request.rangeByteBegin;
+  int keepalive = 0;
+  int ret;
+
+  try
+  {
+    HttpHeaders::buildDefaultHTTPResponseHeader(&td->response);
+
+    if(td->request.isKeepAlive())
+    {
+      td->response.connection.assign("keep-alive");
+      keepalive = 1;
+    }
+
+    if(!(td->permissions & MYSERVER_PERMISSION_WRITE))
+    {
+      return td->http->sendAuth();
+    }
+
+    if(FilesUtility::fileExists(td->filenamePath.c_str()))
+    {
+      /*! If the file exists update it. */
+      File file;
+      if(file.openFile(td->filenamePath.c_str(), File::MYSERVER_OPEN_IFEXISTS |
+                       File::MYSERVER_OPEN_WRITE))
+      {
+        /*! Return an internal server error. */
+        return td->http->raiseHTTPError(500);
+      }
+      file.seek (firstByte);
+      for(;;)
+      {
+        u_long nbr = 0, nbw = 0;
+        if(td->inputData.read (td->buffer->getBuffer(),
+                               td->buffer->getRealLength(), &nbr))
+        {
+          file.close();
+          /*! Return an internal server error.  */
+          return td->http->raiseHTTPError(500);
+        }
+        if(nbr)
+        {
+          if(file.writeToFile(td->buffer->getBuffer(), nbr, &nbw))
+          {
+            file.close();
+            /*! Return an internal server error.  */
+            return td->http->raiseHTTPError(500);
+          }
+        }
+        else
+          break;
+        if(nbw != nbr)
+        {
+          file.close();
+          /*! Internal server error.  */
+          return td->http->raiseHTTPError(500);
+        }
+      }
+      file.close();
+      /*! Successful updated.  */
+      td->http->raiseHTTPError(200);
+
+      return keepalive;
+    }
+    else
+    {
+      /*!
+       *If the file doesn't exist create it.
+       */
+      File file;
+      if(file.openFile(td->filenamePath.c_str(),
+                       File::MYSERVER_CREATE_ALWAYS |
+                       File::MYSERVER_OPEN_WRITE))
+      {
+        /*! Internal server error. */
+        return td->http->raiseHTTPError(500);
+      }
+      for(;;)
+      {
+        u_long nbr = 0, nbw = 0;
+        if(td->inputData.read(td->buffer->getBuffer(),
+                                      td->buffer->getRealLength(), &nbr))
+        {
+          file.close();
+          return td->http->raiseHTTPError(500);
+        }
+        if(nbr)
+        {
+          if(file.writeToFile(td->buffer->getBuffer(), nbr, &nbw))
+          {
+            file.close();
+            return td->http->raiseHTTPError(500);
+          }
+        }
+        else
+          break;
+        if( nbw != nbr )
+        {
+          file.close();
+          return td->http->raiseHTTPError(500);
+        }
+      }
+      file.close();
+      /*! Successful created. */
+      td->http->raiseHTTPError(201);
+      return 1;
+    }
+  }
+  catch(...)
+  {
+    return td->http->raiseHTTPError(500);
+  };
+}
+
+/*!
+ *Delete the resource identified by filename.
+ */
+int HttpFile::deleteFile (HttpThreadContext* td,
+                          string& filename)
+{
+  int permissions = -1;
+  string directory;
+  string file;
+  int ret;
+  try
+  {
+    HttpHeaders::buildDefaultHTTPResponseHeader(&td->response);
+
+    if(!(td->permissions & MYSERVER_PERMISSION_DELETE))
+      return td->http->sendAuth();
+
+    if(FilesUtility::fileExists(td->filenamePath))
+    {
+      FilesUtility::deleteFile(td->filenamePath.c_str());
+
+      /*! Successful deleted.  */
+      return td->http->raiseHTTPError(202);
+    }
+    else
+    {
+      /*! No content.  */
+      return td->http->raiseHTTPError(204);
+    }
+  }
+  catch(...)
+  {
+    return td->http->raiseHTTPError(500);
+  };
+
+}
+
+/*!
  *Send a file to the client using the HTTP protocol.
  *\param td The current HTTP thread context.
  *\param s A pointer to the connection.
@@ -47,9 +204,12 @@
  *\param execute Not used.
  *\param onlyHeader Specify if send only the HTTP header.
   */
-int HttpFile::send(HttpThreadContext* td, ConnectionPtr s, 
-                   const char *filenamePath, const char* exec,
-                   int execute, int onlyHeader)
+int HttpFile::send(HttpThreadContext* td,
+                   ConnectionPtr s,
+                   const char *filenamePath,
+                   const char* exec,
+                   int execute,
+                   int onlyHeader)
 {
   /*
    *With this routine we send a file through the HTTP protocol.
@@ -80,6 +240,12 @@
   try
   {
 
+    if(!td->request.cmd.compare("PUT"))
+      return putFile (td, td->filenamePath);
+
+    if(!td->request.cmd.compare("DELETE"))
+      return deleteFile (td, td->filenamePath);
+
     if ( !(td->permissions & MYSERVER_PERMISSION_READ))
       return td->http->sendAuth ();
 

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp	2009-05-01 16:34:56 UTC (rev 3064)
+++ trunk/myserver/src/protocol/http/http.cpp	2009-05-02 10:54:25 UTC (rev 3065)
@@ -236,127 +236,12 @@
 /*!
  *Main function to handle the HTTP PUT command.
  */
-int Http::putHTTPRESOURCE(string& filename, int, int,
+int Http::putHTTPRESOURCE(string& filename,
+                          int sysReq,
+                          int onlyHeader,
                           int yetmapped)
 {
-  u_long firstByte = td->request.rangeByteBegin;
-  int permissions = -1;
-  int keepalive = 0;
-  int ret;
-
-  try
-  {
-    HttpHeaders::buildDefaultHTTPResponseHeader(&td->response);
-
-    if(td->request.isKeepAlive())
-    {
-      td->response.connection.assign("keep-alive");
-      keepalive = 1;
-    }
-
-    ret = Http::preprocessHttpRequest(filename, yetmapped, &permissions);
-
-    if(ret != 200)
-      return raiseHTTPError(ret);
-
-    if(!(permissions & MYSERVER_PERMISSION_WRITE))
-    {
-      return sendAuth();
-    }
-
-    if(FilesUtility::fileExists(td->filenamePath.c_str()))
-    {
-      /*! If the file exists update it. */
-      File file;
-      if(file.openFile(td->filenamePath.c_str(), File::MYSERVER_OPEN_IFEXISTS |
-                       File::MYSERVER_OPEN_WRITE))
-      {
-        /*! Return an internal server error. */
-        return raiseHTTPError(500);
-      }
-      file.seek (firstByte);
-      for(;;)
-      {
-        u_long nbr = 0, nbw = 0;
-        if(td->inputData.read (td->buffer->getBuffer(),
-                               td->buffer->getRealLength(), &nbr))
-        {
-          file.close();
-          /*! Return an internal server error.  */
-          return raiseHTTPError(500);
-        }
-        if(nbr)
-        {
-          if(file.writeToFile(td->buffer->getBuffer(), nbr, &nbw))
-          {
-            file.close();
-            /*! Return an internal server error.  */
-            return raiseHTTPError(500);
-          }
-        }
-        else
-          break;
-        if(nbw != nbr)
-        {
-          file.close();
-          /*! Internal server error.  */
-          return raiseHTTPError(500);
-        }
-      }
-      file.close();
-      /*! Successful updated.  */
-      raiseHTTPError(200);
-
-      return keepalive;
-    }
-    else
-    {
-      /*!
-       *If the file doesn't exist create it.
-       */
-      File file;
-      if(file.openFile(td->filenamePath.c_str(),
-                       File::MYSERVER_CREATE_ALWAYS |
-                       File::MYSERVER_OPEN_WRITE))
-      {
-        /*! Internal server error. */
-        return raiseHTTPError(500);
-      }
-      for(;;)
-      {
-        u_long nbr = 0, nbw = 0;
-        if(td->inputData.read(td->buffer->getBuffer(),
-                                      td->buffer->getRealLength(), &nbr))
-        {
-          file.close();
-          return raiseHTTPError(500);
-        }
-        if(nbr)
-        {
-          if(file.writeToFile(td->buffer->getBuffer(), nbr, &nbw))
-          {
-            file.close();
-            return raiseHTTPError(500);
-          }
-        }
-        else
-          break;
-        if( nbw != nbr )
-        {
-          file.close();
-          return raiseHTTPError(500);
-        }
-      }
-      file.close();
-      /*! Successful created. */
-      raiseHTTPError(201);
-      return 1;
-    }
-  }
-  catch(...)
-  {
-    return raiseHTTPError(500);
-  };
+  return sendHTTPResource (filename, sysReq, onlyHeader, yetmapped);
 }
 
 /*!
@@ -654,42 +539,12 @@
 /*!
  *Delete the resource identified by filename.
  */
-int Http::deleteHTTPRESOURCE(string& filename, int yetmapped)
+int Http::deleteHTTPRESOURCE(string& filename,
+                             int sysReq,
+                             int onlyHeader,
+                             int yetmapped)
 {
-  int permissions = -1;
-  string directory;
-  string file;
-  int ret;
-  try
-  {
-    HttpHeaders::buildDefaultHTTPResponseHeader(&td->response);
-
-    ret = Http::preprocessHttpRequest(filename, yetmapped, &permissions);
-
-    if(ret != 200)
-      return raiseHTTPError(ret);
-
-    if(FilesUtility::fileExists(td->filenamePath))
-    {
-      if(!(permissions & MYSERVER_PERMISSION_DELETE))
-        return 401;
-
-      FilesUtility::deleteFile(td->filenamePath.c_str());
-
-      /*! Successful deleted.  */
-      return raiseHTTPError(202);
-    }
-    else
-    {
-      /*! No content.  */
-      return raiseHTTPError(204);
-    }
-  }
-  catch(...)
-  {
-    return raiseHTTPError(500);
-  };
-
+  return sendHTTPResource (filename, sysReq, onlyHeader, yetmapped);
 }
 
 /*!
@@ -1205,7 +1060,8 @@
         }
       }
 
-      if(td->request.uri.length() > 2 && td->request.uri[1] == '~'){
+      if(td->request.uri.length() > 2 && td->request.uri[1] == '~')
+      {
         string documentRoot;
         u_long pos = 2;
         string user;
@@ -1228,23 +1084,22 @@
                                                                  MYSERVER_SERVER_CONF, 
                                                                  "public_html");
 
-	  if (strcmpi (useHomeDir, "YES"))
-	    return raiseHTTPError (404);
+          if (strcmpi (useHomeDir, "YES"))
+            return raiseHTTPError (404);
 
-    td->vhostDir.assign (documentRoot);
-    td->vhostDir.append ("/");
-    td->vhostDir.append (homeDir);
+          td->vhostDir.assign (documentRoot);
+          td->vhostDir.append ("/");
+          td->vhostDir.append (homeDir);
+
+          if(!td->request.uriEndsWithSlash && !(td->request.uri.length() - pos))
+          {
+            td->request.uri.append("/");
+            return sendHTTPRedirect(td->request.uri.c_str());
+          }
     
-    if(!td->request.uriEndsWithSlash && !(td->request.uri.length() - pos))
-      {
-        td->request.uri.append("/");
-        
-        return sendHTTPRedirect(td->request.uri.c_str());
-      }
-    
-    if(td->request.uri.length() - pos)
-      td->request.uri.assign(td->request.uri.substr(pos,
-                                                    td->request.uri.length()));
+          if(td->request.uri.length() - pos)
+            td->request.uri.assign(td->request.uri.substr(pos,
+                                                          td->request.uri.length()));
           else
             td->request.uri.assign("");
         }
@@ -1365,7 +1220,7 @@
         }
         /* DELETE REQUEST.  */
         else if(!td->request.cmd.compare("DELETE"))
-          ret = deleteHTTPRESOURCE(td->request.uri, 0);
+          ret = deleteHTTPRESOURCE(td->request.uri, 0, 1);
         /* PUT REQUEST.  */
         else if(!td->request.cmd.compare("PUT"))
           ret = putHTTPRESOURCE(td->request.uri, 0, 1);




From MAILER-DAEMON Sat May 02 11:03:45 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0Gki-0001Ft-U3
	for mharc-myserver-commit@gnu.org; Sat, 02 May 2009 11:03:44 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0Gkg-0001E2-Pm
	for myserver-commit@gnu.org; Sat, 02 May 2009 11:03:42 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0Gkf-0001C6-M8
	for myserver-commit@gnu.org; Sat, 02 May 2009 11:03:42 -0400
Received: from [199.232.76.173] (port=35444 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0Gkf-0001Br-J4
	for myserver-commit@gnu.org; Sat, 02 May 2009 11:03:41 -0400
Received: from savannah.gnu.org ([199.232.41.3]:58121 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0Gke-00078i-T7
	for myserver-commit@gnu.org; Sat, 02 May 2009 11:03:41 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0Gke-0005IJ-K6
	for myserver-commit@gnu.org; Sat, 02 May 2009 15:03:40 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0Gke-0005IE-Ah
	for myserver-commit@gnu.org; Sat, 02 May 2009 15:03:40 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0Gke-0005IE-Ah@cvs.savannah.gnu.org>
Date: Sat, 02 May 2009 15:03:40 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3066] Added new tests for the `File',
	`Socket' and `SslSocket' classes.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 02 May 2009 15:03:43 -0000

Revision: 3066
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3066
Author:   gscrivano
Date:     2009-05-02 15:03:39 +0000 (Sat, 02 May 2009)
Log Message:
-----------
Added new tests for the `File', `Socket' and `SslSocket' classes.  Thanks to Ivaylo Ilionov.

Modified Paths:
--------------
    trunk/myserver/src/base/socket/ssl_socket.cpp
    trunk/myserver/src/base/ssl/ssl.cpp
    trunk/myserver/tests/Makefile.am

Added Paths:
-----------
    trunk/myserver/tests/test_file.cpp
    trunk/myserver/tests/test_socket.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/src/base/socket/ssl_socket.cpp
===================================================================
--- trunk/myserver/src/base/socket/ssl_socket.cpp	2009-05-02 10:54:25 UTC (rev 3065)
+++ trunk/myserver/src/base/socket/ssl_socket.cpp	2009-05-02 15:03:39 UTC (rev 3066)
@@ -95,7 +95,7 @@
   {
     err = SSL_write(sslConnection,buffer,len);
   }while((err <= 0) &&
-         (SSL_get_error(sslConnection,err) == SSL_ERROR_WANT_WRITE 
+         (SSL_get_error(sslConnection,err) == SSL_ERROR_WANT_WRITE
           || SSL_get_error(sslConnection,err) == SSL_ERROR_WANT_READ));
   if(err <= 0)
     return -1;
@@ -108,14 +108,14 @@
  */
 int SslSocket::connect(MYSERVER_SOCKADDR* sa, int na)
 {
-   if ( sa == NULL || (sa->ss_family != AF_INET && sa->ss_family != AF_INET6) )
-      return 1;//Andu: TODO our error code or what?
-  if ( (sa->ss_family == AF_INET && na != sizeof(sockaddr_in)) 
+  if ( sa == NULL || (sa->ss_family != AF_INET && sa->ss_family != AF_INET6) )
+    return 1;
+  if ( (sa->ss_family == AF_INET && na != sizeof(sockaddr_in))
 #if HAVE_IPV6
-   || (sa->ss_family == AF_INET6 && na != sizeof(sockaddr_in6)) 
+       || (sa->ss_family == AF_INET6 && na != sizeof(sockaddr_in6))
 #endif
-)
-     return 1;//Andu: TODO our error code or what?
+       )
+    return 1;
 
   sslMethod = SSLv23_client_method();
   /*! Create the local context. */
@@ -218,7 +218,8 @@
   do
   {
     sslAccept = SSL_accept (sslConnection);
-  }while (SSL_get_error (sslConnection, sslAccept) == SSL_ERROR_WANT_READ);
+  }while (sslAccept != 1 &&
+          SSL_get_error (sslConnection, sslAccept) == SSL_ERROR_WANT_READ);
 
   if(sslAccept != 1 )
   {

Modified: trunk/myserver/src/base/ssl/ssl.cpp
===================================================================
--- trunk/myserver/src/base/ssl/ssl.cpp	2009-05-02 10:54:25 UTC (rev 3065)
+++ trunk/myserver/src/base/ssl/ssl.cpp	2009-05-02 15:03:39 UTC (rev 3066)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 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
@@ -47,7 +47,7 @@
   if(FilesUtility::fileExists(certificateFile.c_str()) == 0)
     return -1;
   
-  if(!SSL_CTX_use_certificate_file (context, certificateFile.c_str (),SSL_FILETYPE_PEM))
+  if(SSL_CTX_use_certificate_file (context, certificateFile.c_str (),SSL_FILETYPE_PEM) != 1)
     return -1;
 
   /*
@@ -56,11 +56,10 @@
   if(FilesUtility::fileExists(privateKeyFile) == 0)
     return -1;
 
-  if(!(SSL_CTX_use_PrivateKey_file(context, privateKeyFile.c_str(), 
-                                   SSL_FILETYPE_PEM)))
+  if(SSL_CTX_use_PrivateKey_file(context, privateKeyFile.c_str(),
+                                   SSL_FILETYPE_PEM) != 1)
     return -1;
 
-
   return 1;
 }  
 

Modified: trunk/myserver/tests/Makefile.am
===================================================================
--- trunk/myserver/tests/Makefile.am	2009-05-02 10:54:25 UTC (rev 3065)
+++ trunk/myserver/tests/Makefile.am	2009-05-02 15:03:39 UTC (rev 3066)
@@ -2,5 +2,5 @@
 #
 
 bin_PROGRAMS = tests_suite
-tests_suite_SOURCES = main.cpp test_connection.cpp test_ftp.cpp test_log_manager.cpp test_mime_manager.cpp test_mutex.cpp test_security_domain.cpp test_validator.cpp test_auth_domain.cpp test_connections_scheduler.cpp test_gzip.cpp test_log_stream_factory.cpp test_pipe.cpp test_security_manager.cpp test_validator_factory.cpp test_base64.cpp test_file_stream.cpp test_hashmap.cpp test_md5.cpp test_recursive_mutex.cpp test_semaphore.cpp test_xml.cpp test_cached_file_buffer.cpp test_file_stream_creator.cpp test_homedir.cpp test_mem_buff.cpp test_regex.cpp test_socket_stream_creator.cpp test_cached_file.cpp test_files_utility.cpp test_http_request.cpp test_http_req_security_domain.cpp test_mem_stream.cpp test_safetime.cpp test_thread.cpp test_cached_file_factory.cpp test_filter_chain.cpp test_http_response.cpp test_multicast.cpp test_security_cache.cpp test_security_token.cpp test_socket_pair.cpp test_unix_socket.cpp test_utility.cpp  test_xml_validator.cpp test_ip.cpp test_plugin_info.cpp test_fork_server.cpp
+tests_suite_SOURCES = main.cpp test_connection.cpp test_file.cpp test_ftp.cpp test_log_manager.cpp test_mime_manager.cpp test_mutex.cpp test_security_domain.cpp test_validator.cpp test_auth_domain.cpp test_connections_scheduler.cpp test_gzip.cpp test_log_stream_factory.cpp test_pipe.cpp test_security_manager.cpp test_validator_factory.cpp test_base64.cpp test_file_stream.cpp test_hashmap.cpp test_md5.cpp test_recursive_mutex.cpp test_semaphore.cpp test_xml.cpp test_cached_file_buffer.cpp test_file_stream_creator.cpp test_homedir.cpp test_mem_buff.cpp test_regex.cpp test_socket_stream_creator.cpp test_cached_file.cpp test_files_utility.cpp test_http_request.cpp test_http_req_security_domain.cpp test_mem_stream.cpp test_safetime.cpp test_thread.cpp test_cached_file_factory.cpp test_filter_chain.cpp test_http_response.cpp test_multicast.cpp test_security_cache.cpp test_security_token.cpp test_socket.cpp test_socket_pair.cpp test_ssl_socket.cpp test_unix_socket.cpp test_utility.cpp  test_xml_validator.cpp test_ip.cpp test_plugin_info.cpp test_fork_server.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)

Added: trunk/myserver/tests/test_file.cpp
===================================================================
--- trunk/myserver/tests/test_file.cpp	                        (rev 0)
+++ trunk/myserver/tests/test_file.cpp	2009-05-02 15:03:39 UTC (rev 3066)
@@ -0,0 +1,97 @@
+/*
+ MyServer
+ Copyright (C) 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
+ (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 <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+
+#include "../include/base/utility.h"
+#include "../include/base/file/file.h"
+#include "../include/base/file/files_utility.h"
+
+#include <string.h>
+#include <unistd.h>
+#include <string>
+
+using namespace std;
+
+class TestFile : public CppUnit::TestFixture
+{
+  File *tfile;
+  string fname;
+  
+  CPPUNIT_TEST_SUITE( TestFile );
+  
+  CPPUNIT_TEST( testCreateTemporaryFile );
+  CPPUNIT_TEST( testOnFile );
+  
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp ( )
+  {
+    setcwdBuffer ();/* Be sure the cwd buffer is initialized.  */
+    FilesUtility::temporaryFileName ( 0, fname );
+    tfile = new File;
+  }
+  
+  void tearDown ( )
+  {
+    delete tfile;
+  }
+  
+  void testCreateTemporaryFile ( )
+  {
+    CPPUNIT_ASSERT_EQUAL( tfile->createTemporaryFile ( fname.c_str() ), 0 );
+    
+    CPPUNIT_ASSERT_EQUAL( tfile->close ( ), 0 );
+  }
+  
+  void testOnFile ( )
+  {
+    char buf[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'm', 'y', 'W', 'o', 'r', 'l', 'd', 0 };
+    const int bufLen = sizeof (buf) / sizeof (char);
+    u_long nbw;
+    u_long nbr;
+    
+    CPPUNIT_ASSERT_EQUAL( tfile->openFile( fname.c_str(), File::MYSERVER_OPEN_WRITE | File::MYSERVER_OPEN_READ | File::MYSERVER_CREATE_ALWAYS ), 0 );
+    
+    CPPUNIT_ASSERT_EQUAL( tfile->writeToFile ( buf, bufLen, &nbw ), 0 );
+    
+    memset ( buf, 0, bufLen );
+    
+    CPPUNIT_ASSERT_EQUAL( tfile->seek ( 0 ), 0 );
+    
+    CPPUNIT_ASSERT_EQUAL( tfile->read ( buf, bufLen, &nbr ), 0 );
+    
+    CPPUNIT_ASSERT( nbr > 0 );
+    
+    CPPUNIT_ASSERT( tfile->getCreationTime ( ) != -1 );
+    
+    CPPUNIT_ASSERT( tfile->getLastAccTime ( ) != -1 );
+    
+    CPPUNIT_ASSERT( tfile->getLastModTime ( ) != -1 );
+    
+    CPPUNIT_ASSERT( tfile->getFileSize ( ) != -1 );
+    
+    CPPUNIT_ASSERT_EQUAL( tfile->close ( ), 0 );
+  }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TestFile );

Added: trunk/myserver/tests/test_socket.cpp
===================================================================
--- trunk/myserver/tests/test_socket.cpp	                        (rev 0)
+++ trunk/myserver/tests/test_socket.cpp	2009-05-02 15:03:39 UTC (rev 3066)
@@ -0,0 +1,191 @@
+/*
+ MyServer
+ Copyright (C) 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
+ (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 <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "../include/base/socket/socket.h"
+#include "../include/base/thread/thread.h"
+
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <iostream>
+
+using namespace std;
+
+void* testRecvClient ( void* );
+
+class TestSocket : public CppUnit::TestFixture
+{
+  Socket *obj;
+  ThreadID tid;
+  
+  CPPUNIT_TEST_SUITE( TestSocket );
+  
+  CPPUNIT_TEST( testGethostname );
+  CPPUNIT_TEST( testRecv );
+  CPPUNIT_TEST( testGetLocalIPsList );
+  
+  CPPUNIT_TEST_SUITE_END( );
+  
+public:
+  
+  void setUp ( )
+  {
+    CPPUNIT_ASSERT_EQUAL( Socket::startupSocketLib ( ), 0 );
+    
+    obj = new Socket;
+  }
+  
+  void tearDown ( )
+  {
+    delete obj;
+  }
+  
+  void testGethostname ( )
+  { 
+    char host[] = "localhost";
+    int len = sizeof ( host ) / sizeof ( char );
+      
+    int status = obj->gethostname ( host, len );
+  
+    CPPUNIT_ASSERT_EQUAL( status, 0 );
+  }
+  
+  void testRecv ( )
+  {
+    ThreadID tid;
+    int optvalReuseAddr = 1;
+    char host[] = "localhost";
+    int port = 6543;
+    MYSERVER_SOCKADDRIN sockIn = { 0 };
+    int status;
+    
+    ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
+    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ( "127.0.0.1" );
+    ((sockaddr_in*) (&sockIn))->sin_port = htons ( port );
+    
+    int sockInLen = sizeof ( sockaddr_in );
+    
+    CPPUNIT_ASSERT( obj->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
+    
+    CPPUNIT_ASSERT( obj->setsockopt ( SOL_SOCKET, SO_REUSEADDR, (const char*) &optvalReuseAddr, sizeof(optvalReuseAddr) ) != -1 );
+    
+    // If the port is used by another program, try a few others.
+      if ( ( status = obj->bind ( &sockIn, sockInLen ) ) != 0 )
+      while ( ++port < 28000 )
+      {
+        ((sockaddr_in*) (&sockIn))->sin_port = htons ( port );
+        
+        if ( ( status = obj->bind ( &sockIn, sockInLen ) ) == 0 )
+          break;
+      }
+    
+    CPPUNIT_ASSERT( status != -1 );
+    
+    CPPUNIT_ASSERT( obj->listen ( 1 ) != -1 );
+    
+    CPPUNIT_ASSERT_EQUAL( Thread::create ( &tid, testRecvClient, &port ), 0 );
+    
+    Socket s = obj->accept ( &sockIn, &sockInLen );
+    
+    status = int ( s.getHandle ( ) );
+    
+    if ( status < 0 )
+      CPPUNIT_ASSERT( status != -1 );
+    
+    CPPUNIT_ASSERT( s.bytesToRead ( ) >= 0 );
+    
+    int bufLen = 8;
+    char buf[bufLen];
+    memset ( buf, 0, bufLen );
+    
+    if ( ( status = s.recv ( buf, 1, 0 ) ) < 0 )
+      CPPUNIT_ASSERT( status >= 0 );
+      
+    CPPUNIT_ASSERT( s.bytesToRead ( ) > 0 );
+    
+    if ( ( status = s.recv ( buf, bufLen, 0, 2 ) ) < 0 && status != -2 )
+      CPPUNIT_ASSERT( status >= 0 || status == -2 );
+      
+    CPPUNIT_ASSERT( s.bytesToRead ( ) == 0 );
+    
+    if ( ( status = s.recv ( buf, bufLen, 0, 1 ) ) < 0 && status != -2 )
+      CPPUNIT_ASSERT( status >= 0 || status == -2 );
+    
+    // no other messages, must be -1
+    if ( ( status = s.recv ( buf, bufLen, 0 ) ) != -1)
+      CPPUNIT_ASSERT( status == -1 );
+    
+    Thread::join ( tid );
+    
+    CPPUNIT_ASSERT( obj->close ( ) != -1 );
+  }
+  
+  void testGetLocalIPsList ( )
+  {
+    int status = obj->socket ( AF_INET, SOCK_STREAM, 0 );
+
+    CPPUNIT_ASSERT( status != -1 );
+    
+    string out;
+    
+    status = obj->getLocalIPsList ( out );
+    
+    CPPUNIT_ASSERT( status != -1 );
+    
+    status = obj->close ( );
+
+    CPPUNIT_ASSERT( status != -1 );
+  }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TestSocket );
+
+void*
+testRecvClient ( void *arg )
+{
+  Socket *obj2 = new Socket;
+  
+  int optvalReuseAddr = 1;
+  char host[] = "localhost";
+  int port = *((int*)arg);
+  int status;
+  
+  CPPUNIT_ASSERT( obj2->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
+  
+  CPPUNIT_ASSERT( obj2->connect ( host, port ) != -1 );
+  
+  int bufLen = 8;
+  char buf[bufLen];
+  memset ( buf, 0, bufLen );
+  strcpy ( buf, "ehlo" );
+  
+  CPPUNIT_ASSERT( obj2->send ( buf, strlen ( buf ), 0 ) != -1 );
+  
+  sleep ( 2 );
+  
+  CPPUNIT_ASSERT( obj2->shutdown ( SD_BOTH ) != -1 );
+ 
+  CPPUNIT_ASSERT( obj2->close ( ) != -1 );
+  
+  delete obj2;
+  obj2 = NULL;
+}

Added: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	                        (rev 0)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-02 15:03:39 UTC (rev 3066)
@@ -0,0 +1,236 @@
+/*
+ MyServer
+ Copyright (C) 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
+ (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/>.
+ */
+
+#define TESTSERVERPEM "server.pem"
+#define TESTSERVERKEY "server.key"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "../include/base/socket/ssl_socket.h"
+#include "../include/base/file/file.h"
+#include "../include/base/file/files_utility.h"
+#include "../include/base/thread/thread.h"
+
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <iostream>
+
+using namespace std;
+
+
+static const char *serverKey = "-----BEGIN RSA PRIVATE KEY-----\n\
+MIIEowIBAAKCAQEA5EaaswqVe0pk+4nuhwp4S+P5Xw6f8Ba/g1kXFGP3CPhRKzEQ\n\
+q1JmkMl6t/AWVbr+wRz/JZ71JjHg+EDzaNNyHjtQQZL5A/DGXdgyRmSsgqJInAao\n\
+WB4EIbfZ+7/UalwRNyyto2sG5T2kIrFfyHDQ7oX/fuw0JjTbR8vLCPw4pQkuWm1o\n\
+JYwuh2HV2w+IEtXE1yBNDDZcy4DPRixqB8z9wN8iOHOrW9pgCaim+EB0QdrWlgae\n\
+jVsrwSZNpivN6hxXupPv+I/LBrf7xDirDRxBvgZjaQgaiMtZ2SHLV2m17x6rIKXw\n\
+wBV8xUAxTwcrCnvqXusZAx58Sow//9GCKpHsJQIDAQABAoIBAAJqIaEz56vfHKZ6\n\
+e87q3Vy9SDoyY56PAngC2OBK1q909hiME2LZGjXq2oTzs/VZMDld/Kbq3QTTVhjH\n\
+2xj6r5aLj6OwyKY7PEFYAZZq4p9ki58SThln8HH2ks+gG3eV+CYTnR7cm70iliNe\n\
+8srGwrb/vyK+xLhx4WXm8d8P0RAkGRrFJ9LlFOTFqtLcptJPmvRMzIsbA3MrLJqM\n\
+wbn/0g1bDWpfimKBbg+03++aIZbIlNDne/M1qNfWc8hcGuIhYRn+YShg7cP7PVpm\n\
+t4qVSBDLnayBQ3gqy5A+Nn1aTk9wgOJ1DEMSvCxiiujJu8V0i9HU5kjb6CbPkIqw\n\
+gve70CsCgYEA7Acm2RxMpdJBLhht4KfeVhG1CTfNkNCrCPuth/72gomrXPZ6iEQH\n\
+S6AS3bO6lI+mYqZ/QX6wy/fGToyWHb/Z4EWTxb8C4gs3gcEgF40xvMCwE+e3F1cO\n\
+zwSkYBNCjAlsFRsGMUB1onjeiax15LiCNSPhNwXNvzIVA1T9Bg/MfkMCgYEA95eG\n\
+fbaj7aGw1E1dAMZDEQFjdkzN/UQe2NTLipNVBlJcB2pLlD0BzA88tRIQKBv4neic\n\
+wdsVBygzbPtKlDJJgMn/gJjZYT9Ksyydn1aRW/Fz5E/8bV2VtSci2yNcfin69Bna\n\
+x9DRRgJCGngLwMAr75kMbMZnjUVO08ynSzAjqXcCgYEA4fkC55BhjczcHJ7E6/as\n\
+Nmkjk1y60fAGIEadYHvpVRcrWoiczcOb3Hq4NUxy0PMrUH2pjnIWIGHrmZ6dxoO8\n\
+vCzBCu0SfIpSrUbSS9ohiV5N9fC96XmvMuJ14YnvB5WpxhcmeZcGSPRB0zurb7x6\n\
+5Reh8wT6dBgl6BfBW8FafnMCgYApfxPjbgD7iuYALxcvUgtbhkgNQ8IieJBS9xdG\n\
+Gntdm+Agvgf8yFzMvqEGGAjtMALzNFFRjE5x7KLx2Qwe2m7HTxOrkfKdAeabMRcZ\n\
+5YBnUIiD84PzMIQu4GhPIhYWbyLIVqz8YFsyyJ4boZMWsx6qAZS7hmVEoCEeDmbb\n\
+iy3u8QKBgHkzr3NcKH0mu6tyQFOkf1yKVhUoEyAE2Ew9DzYkjUCj9sEayYjS/SkR\n\
+BF48eWMuYZoEFBizxmKZjiiAvvoOzCzW4oponSXR07iQWf2zwKuJvCtoWTIQ9ihP\n\
+z6v2cd8NAg3tSqmpDMXS5uNan2uaRAQQbuoUfbPuEPjrLl/qjdey\n\
+-----END RSA PRIVATE KEY-----\n";
+
+static const char *serverPem = "-----BEGIN CERTIFICATE-----\n\
+MIICuzCCAaWgAwIBAgIESfxd9DALBgkqhkiG9w0BAQUwADAeFw0wOTA1MDIxNDUx\n\
+MzRaFw0yNTAzMTMwNTI2MjJaMAAwggEfMAsGCSqGSIb3DQEBAQOCAQ4AMIIBCQKC\n\
+AQDkRpqzCpV7SmT7ie6HCnhL4/lfDp/wFr+DWRcUY/cI+FErMRCrUmaQyXq38BZV\n\
+uv7BHP8lnvUmMeD4QPNo03IeO1BBkvkD8MZd2DJGZKyCokicBqhYHgQht9n7v9Rq\n\
+XBE3LK2jawblPaQisV/IcNDuhf9+7DQmNNtHy8sI/DilCS5abWgljC6HYdXbD4gS\n\
+1cTXIE0MNlzLgM9GLGoHzP3A3yI4c6tb2mAJqKb4QHRB2taWBp6NWyvBJk2mK83q\n\
+HFe6k+/4j8sGt/vEOKsNHEG+BmNpCBqIy1nZIctXabXvHqsgpfDAFXzFQDFPBysK\n\
+e+pe6xkDHnxKjD//0YIqkewlAgMBAAGjRDBCMAwGA1UdEwEB/wQCMAAwEwYDVR0l\n\
+BAwwCgYIKwYBBQUHAwEwHQYDVR0OBBYEFMpRt0kdzKEb9G/ofZRz3TZmy7idMAsG\n\
+CSqGSIb3DQEBBQOCAQEAkKZ9kJInOz81k16vA2/Uj+ZQNrOLWJ9eoZXrmh2J+E2E\n\
+vUEnl1ZZm41PHfLYvlFS+nkE81233D2NMGUowOlu17/WZifBg2DmnXWSvMV+R1Y6\n\
+uDztAuNxEVog7QS7hXshO9jmeKJIDYwH1qNhupOyQZk3TAZouaAJ5GMZ0EzxuaqM\n\
+sUaM198sIaGDgLtSxO/FxP1xDkLPx8jqy0A+Y2IWloW7r+XoohvxSk+oS6shNmF8\n\
+FX3J22wtVUi4Ve/XftYt6RJKd764o5WTdh/Z+RUbtusXnj3ygpI/G7fTzuPUj9uF\n\
+3K2VTrZpJnbMs7+i3w/ziC/cqWRVK6Rcq3bLzTXrig==\n\
+-----END CERTIFICATE-----\n";
+
+
+
+void* testSslRecvClient ( void* ); //
+
+class TestSslSocket : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( TestSslSocket );
+  
+  CPPUNIT_TEST( testRecv );
+  
+  CPPUNIT_TEST_SUITE_END( );
+  
+public:
+  
+  void setUp ( )
+  {
+    SSL_library_init ( );
+    u_long nbw;
+    File f;
+
+    f.openFile (TESTSERVERKEY,  File::MYSERVER_OPEN_WRITE | File::MYSERVER_CREATE_ALWAYS);
+    f.writeToFile (serverKey, strlen (serverKey), &nbw);
+    f.close ();
+
+    f.openFile (TESTSERVERPEM,  File::MYSERVER_OPEN_WRITE | File::MYSERVER_CREATE_ALWAYS);
+    f.writeToFile (serverPem, strlen (serverPem), &nbw);
+    f.close ();
+  }
+  
+  void tearDown ( )
+  {
+    FilesUtility::deleteFile (TESTSERVERPEM);
+    FilesUtility::deleteFile (TESTSERVERKEY);
+  }
+  
+  void testRecv ( )
+  {
+    Socket *obj = new Socket;
+    SslSocket *sslObj = NULL;
+    SSL_CTX *ctx = NULL;;
+    ThreadID tid;
+    
+    int optvalReuseAddr = 1;
+    char host[] = "localhost";
+    int port = 6543;
+    MYSERVER_SOCKADDRIN sockIn = { 0 };
+    int status;
+    
+    ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
+    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ( "127.0.0.1" );
+    ((sockaddr_in*) (&sockIn))->sin_port = htons ( port );
+    
+    int sockInLen = sizeof ( sockaddr_in );
+    
+    CPPUNIT_ASSERT( obj->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
+    
+    CPPUNIT_ASSERT( obj->setsockopt ( SOL_SOCKET, SO_REUSEADDR,
+                                      (const char*) &optvalReuseAddr,
+                                      sizeof(optvalReuseAddr) ) != -1 );
+    
+    ctx = SSL_CTX_new ( SSLv23_server_method() );
+
+    if ( SSL_CTX_use_certificate_file ( ctx, TESTSERVERPEM, SSL_FILETYPE_PEM ) != 1 )
+    {
+      SSL_CTX_free ( ctx );
+      CPPUNIT_ASSERT (false);
+    }
+
+    if ( SSL_CTX_use_PrivateKey_file ( ctx, TESTSERVERKEY, SSL_FILETYPE_PEM ) != 1 )
+    {
+      SSL_CTX_free ( ctx );
+      CPPUNIT_ASSERT (false);
+    }
+
+    // If the port is used by another program, try a few others.
+    do
+    {
+      port++;
+      ((sockaddr_in*) (&sockIn))->sin_port = htons ( port);
+    }
+    while ((status = obj->bind (&sockIn, sockInLen)) != 0 && port < 28000);
+
+    CPPUNIT_ASSERT( status != -1 );
+
+    CPPUNIT_ASSERT( obj->listen ( 1 ) != -1 );
+
+    CPPUNIT_ASSERT_EQUAL( Thread::create ( &tid, testSslRecvClient, &port ), 0 );
+    Socket s = obj->accept ( &sockIn, &sockInLen );
+    sslObj = new SslSocket (&s);
+
+    sslObj->setSSLContext ( ctx );
+
+    int ret = sslObj->sslAccept ( );
+
+    if ( ret < 0 )
+    {
+      delete obj;
+      delete sslObj;
+      SSL_CTX_free ( ctx );
+      CPPUNIT_ASSERT (false);
+    }
+    
+    char buf[32] = {0};
+    
+    CPPUNIT_ASSERT( sslObj->recv ( buf, sizeof(buf), 0 ) != -1 );
+
+    CPPUNIT_ASSERT( sslObj->close ( ) != -1 );
+
+    CPPUNIT_ASSERT( obj->close ( ) != -1 );
+
+    SSL_CTX_free ( ctx );
+
+    delete obj;
+    delete sslObj;
+  }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TestSslSocket );
+
+void*
+testSslRecvClient ( void *arg )
+{
+  Socket *obj2 = new Socket;
+  SslSocket *sslObj2 = NULL;
+  int optvalReuseAddr = 1;
+  char host[] = "localhost";
+  int port = *((int*)arg);
+  int cstatus = 0;
+  MYSERVER_SOCKADDRIN sockIn = { 0 };
+
+  ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
+  ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ( "127.0.0.1" );
+  ((sockaddr_in*) (&sockIn))->sin_port = htons ( port );
+
+  int sockInLen = sizeof ( struct sockaddr_in );
+
+  CPPUNIT_ASSERT( obj2->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
+
+  sslObj2 = new SslSocket ( obj2 );
+
+  CPPUNIT_ASSERT( sslObj2->connect ( &sockIn, sockInLen ) != -1 );
+
+  char buf[] = "Works?\n";
+
+  CPPUNIT_ASSERT(sslObj2->rawSend ( buf, strlen(buf), 0 ) != -1 );
+
+  CPPUNIT_ASSERT( sslObj2->close ( ) != -1 );
+
+  delete obj2;
+  delete sslObj2;
+  return 0;
+}




From MAILER-DAEMON Sat May 02 14:09:21 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0JeL-0007dw-6E
	for mharc-myserver-commit@gnu.org; Sat, 02 May 2009 14:09:21 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0JeJ-0007dk-Iy
	for myserver-commit@gnu.org; Sat, 02 May 2009 14:09:19 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0JeI-0007dR-Si
	for myserver-commit@gnu.org; Sat, 02 May 2009 14:09:19 -0400
Received: from [199.232.76.173] (port=60367 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0JeI-0007dO-OL
	for myserver-commit@gnu.org; Sat, 02 May 2009 14:09:18 -0400
Received: from savannah.gnu.org ([199.232.41.3]:60912 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0JeI-0001aT-Bz
	for myserver-commit@gnu.org; Sat, 02 May 2009 14:09:18 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0JeH-0007nS-Pd
	for myserver-commit@gnu.org; Sat, 02 May 2009 18:09:18 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0JeH-0007nD-1K
	for myserver-commit@gnu.org; Sat, 02 May 2009 18:09:17 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0JeH-0007nD-1K@cvs.savannah.gnu.org>
Date: Sat, 02 May 2009 18:09:17 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3067] Added the `Url' class.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 02 May 2009 18:09:19 -0000

Revision: 3067
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3067
Author:   gscrivano
Date:     2009-05-02 18:09:16 +0000 (Sat, 02 May 2009)
Log Message:
-----------
Added the `Url' class.  It separes a "Uniform Resource Locator" string in its tokens.

Modified Paths:
--------------
    trunk/myserver/include/protocol/Makefile.am
    trunk/myserver/src/protocol/Makefile.am
    trunk/myserver/tests/Makefile.am
    trunk/myserver/tests/test_file.cpp

Added Paths:
-----------
    trunk/myserver/include/protocol/url.h
    trunk/myserver/src/protocol/url.cpp
    trunk/myserver/tests/test_url.cpp

Modified: trunk/myserver/include/protocol/Makefile.am
===================================================================
--- trunk/myserver/include/protocol/Makefile.am	2009-05-02 15:03:39 UTC (rev 3066)
+++ trunk/myserver/include/protocol/Makefile.am	2009-05-02 18:09:16 UTC (rev 3067)
@@ -1,4 +1,3 @@
 protocolincludedir=$(includedir)/myserver/include/protocol
-protocolinclude_HEADERS = protocol_buffer.h protocol.h protocols_manager.h
+protocolinclude_HEADERS = protocol_buffer.h protocol.h protocols_manager.h url.h
 SUBDIRS = control ftp http https
-

Added: trunk/myserver/include/protocol/url.h
===================================================================
--- trunk/myserver/include/protocol/url.h	                        (rev 0)
+++ trunk/myserver/include/protocol/url.h	2009-05-02 18:09:16 UTC (rev 3067)
@@ -0,0 +1,47 @@
+/* -*- 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 URL_H
+#define URL_H
+#include "stdafx.h"
+
+#include <string>
+
+using namespace std;
+
+class Url
+{
+public:
+  Url (string &, u_short port);
+  Url (const char*, u_short port);
+  string& getProtocol ();
+  u_short getPort ();
+  string& getResource ();
+  string& getHost ();
+  string& getQuery ();
+  string& getCredentials ();
+protected:
+  void parse (string &, u_short port);
+  string protocol;
+  string credentials;
+  string host;
+  string query;
+  u_short port;
+  string resource;
+};
+#endif

Modified: trunk/myserver/src/protocol/Makefile.am
===================================================================
--- trunk/myserver/src/protocol/Makefile.am	2009-05-02 15:03:39 UTC (rev 3066)
+++ trunk/myserver/src/protocol/Makefile.am	2009-05-02 18:09:16 UTC (rev 3067)
@@ -1,5 +1,5 @@
 lib_LIBRARIES = libprotocol.a
-libprotocol_a_SOURCES = protocol_buffer.cpp protocol.cpp protocols_manager.cpp
+libprotocol_a_SOURCES = protocol_buffer.cpp protocol.cpp protocols_manager.cpp url.cpp
 SUBDIRS = control ftp http https
 INCLUDES = $(all_includes)
 

Added: trunk/myserver/src/protocol/url.cpp
===================================================================
--- trunk/myserver/src/protocol/url.cpp	                        (rev 0)
+++ trunk/myserver/src/protocol/url.cpp	2009-05-02 18:09:16 UTC (rev 3067)
@@ -0,0 +1,143 @@
+/*
+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/protocol/url.h>
+
+
+/*!
+ *Build an URL object.
+ *\param url The url string.
+ *\param port the default port to use in case it is not specified.
+ */
+Url::Url (string &url, u_short port)
+{
+  parse (url, port);
+}
+
+/*!
+ *Build an URL object.
+ *\param url The url string.
+ *\param port the default port to use in case it is not specified.
+ */
+Url::Url (const char* url, u_short port)
+{
+  string urlStr (url);
+  parse (urlStr, port);
+}
+
+/*!
+ *Get the protocol part of the URL.
+ */
+string& Url::getProtocol ()
+{
+  return protocol;
+}
+
+
+/*!
+ *Get the query part of the URL.
+ */
+string& Url::getQuery ()
+{
+  return query;
+}
+
+/*!
+ *Get the credentials part of the URL.
+ */
+string& Url::getCredentials ()
+{
+  return credentials;
+}
+
+/*!
+ *Get the port part of the URL.
+ */
+u_short Url::getPort ()
+{
+  return port;
+}
+
+/*!
+ *Get the resource part of the URL.
+ */
+string& Url::getResource ()
+{
+  return resource;
+}
+
+/*!
+ *Get the host part of the URL.
+ */
+string& Url::getHost ()
+{
+  return host;
+}
+
+/*!
+ *Parse the URL.  Internal function.
+ */
+void Url::parse (string &url, u_short defPort)
+{
+  size_t portLoc;
+  size_t firstSlash;
+  size_t protoEnd = url.find ("://");
+  size_t credentialStart;
+  if (protoEnd == string::npos)
+    return;
+
+  protocol = url.substr (0, protoEnd);
+
+  portLoc = url.find (':', protoEnd + 3);
+  firstSlash = url.find ('/', portLoc == string::npos ? protoEnd + 3 :
+                                                        portLoc + 1);
+
+  credentialStart = url.find ('@', protoEnd + 3);
+  size_t offsetCredentials = credentialStart != string::npos  ? credentialStart + 1
+                                                              : protoEnd + 3;
+
+  if (credentialStart != string::npos)
+    credentials = url.substr (protoEnd + 3, offsetCredentials - protoEnd - 4);
+  else
+    credentials = "";
+
+  /* Check if the port is specified.  */
+  if (portLoc != string::npos)
+    {
+      host = url.substr (offsetCredentials, portLoc - offsetCredentials);
+      port = atoi (url.substr (portLoc + 1, firstSlash - portLoc - 1).c_str ());
+    }
+  else
+    {
+      host = url.substr (offsetCredentials, firstSlash - offsetCredentials);
+      port = defPort;
+    }
+
+  size_t queryStart = url.find ('?', firstSlash + 1);
+
+  if (queryStart == string::npos)
+    {
+      resource = url.substr (firstSlash + 1);
+      query = "";
+    }
+  else
+    {
+      resource = url.substr (firstSlash + 1, queryStart - firstSlash - 1);
+      query = url.substr (queryStart + 1);
+    }
+}

Modified: trunk/myserver/tests/Makefile.am
===================================================================
--- trunk/myserver/tests/Makefile.am	2009-05-02 15:03:39 UTC (rev 3066)
+++ trunk/myserver/tests/Makefile.am	2009-05-02 18:09:16 UTC (rev 3067)
@@ -2,5 +2,14 @@
 #
 
 bin_PROGRAMS = tests_suite
-tests_suite_SOURCES = main.cpp test_connection.cpp test_file.cpp test_ftp.cpp test_log_manager.cpp test_mime_manager.cpp test_mutex.cpp test_security_domain.cpp test_validator.cpp test_auth_domain.cpp test_connections_scheduler.cpp test_gzip.cpp test_log_stream_factory.cpp test_pipe.cpp test_security_manager.cpp test_validator_factory.cpp test_base64.cpp test_file_stream.cpp test_hashmap.cpp test_md5.cpp test_recursive_mutex.cpp test_semaphore.cpp test_xml.cpp test_cached_file_buffer.cpp test_file_stream_creator.cpp test_homedir.cpp test_mem_buff.cpp test_regex.cpp test_socket_stream_creator.cpp test_cached_file.cpp test_files_utility.cpp test_http_request.cpp test_http_req_security_domain.cpp test_mem_stream.cpp test_safetime.cpp test_thread.cpp test_cached_file_factory.cpp test_filter_chain.cpp test_http_response.cpp test_multicast.cpp test_security_cache.cpp test_security_token.cpp test_socket.cpp test_socket_pair.cpp test_ssl_socket.cpp test_unix_socket.cpp test_utility.cpp  test_xml_validator.cpp test_ip.cpp test_plugin_info.cpp test_fork_server.cpp
+tests_suite_SOURCES = main.cpp test_auth_domain.cpp test_base64.cpp test_cached_file_buffer.cpp test_cached_file.cpp \
+test_cached_file_factory.cpp test_connection.cpp test_connections_scheduler.cpp test_file.cpp test_file_stream.cpp \
+test_file_stream_creator.cpp test_files_utility.cpp test_filter_chain.cpp test_fork_server.cpp test_ftp.cpp test_gzip.cpp \
+test_hashmap.cpp test_homedir.cpp test_http_req_security_domain.cpp test_http_request.cpp test_http_response.cpp test_ip.cpp \
+test_log_manager.cpp test_log_stream_factory.cpp test_md5.cpp test_mem_buff.cpp test_mem_stream.cpp test_mime_manager.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_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
+
 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)

Modified: trunk/myserver/tests/test_file.cpp
===================================================================
--- trunk/myserver/tests/test_file.cpp	2009-05-02 15:03:39 UTC (rev 3066)
+++ trunk/myserver/tests/test_file.cpp	2009-05-02 18:09:16 UTC (rev 3067)
@@ -70,7 +70,8 @@
     u_long nbw;
     u_long nbr;
     
-    CPPUNIT_ASSERT_EQUAL( tfile->openFile( fname.c_str(), File::MYSERVER_OPEN_WRITE | File::MYSERVER_OPEN_READ | File::MYSERVER_CREATE_ALWAYS ), 0 );
+    CPPUNIT_ASSERT_EQUAL( tfile->openFile( fname.c_str(), File::MYSERVER_OPEN_WRITE | 
+                                           File::MYSERVER_OPEN_READ | File::MYSERVER_CREATE_ALWAYS ), 0 );
     
     CPPUNIT_ASSERT_EQUAL( tfile->writeToFile ( buf, bufLen, &nbw ), 0 );
     

Added: trunk/myserver/tests/test_url.cpp
===================================================================
--- trunk/myserver/tests/test_url.cpp	                        (rev 0)
+++ trunk/myserver/tests/test_url.cpp	2009-05-02 18:09:16 UTC (rev 3067)
@@ -0,0 +1,104 @@
+/*
+ MyServer
+ Copyright (C) 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
+ (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 <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <../include/protocol/url.h>
+
+#include <string.h>
+#include <unistd.h>
+#include <string>
+
+using namespace std;
+
+class TestUrl : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( TestUrl );
+  CPPUNIT_TEST( testUrl );
+  CPPUNIT_TEST( testUrlWithCredentials );
+  CPPUNIT_TEST( testUrlWithQuery );
+  CPPUNIT_TEST( testUrlWithoutPort );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp ( )
+  {
+
+  }
+
+  void tearDown ( )
+  {
+
+  }
+
+  void testUrlWithCredentials ()
+  {
+    const char *urlStr = "http://root@foo.bar:8080/what/i/want";
+    Url url (urlStr, 80);
+
+    CPPUNIT_ASSERT (!url.getCredentials ().compare ("root"));
+    CPPUNIT_ASSERT (!url.getHost ().compare ("foo.bar"));
+    CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
+    CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
+    CPPUNIT_ASSERT (!url.getQuery ().compare (""));
+    CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)8080);
+  }
+
+  void testUrlWithQuery ()
+  {
+    const char *urlStr = "http://foo.bar:8080/what/i/want?my_query";
+    Url url (urlStr, 80);
+
+    CPPUNIT_ASSERT (!url.getCredentials ().compare (""));
+    CPPUNIT_ASSERT (!url.getHost ().compare ("foo.bar"));
+    CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
+    CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
+    CPPUNIT_ASSERT (!url.getQuery ().compare ("my_query"));
+    CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)8080);
+  }
+
+  void testUrl ()
+  {
+    const char *urlStr = "http://foo.bar:8080/what/i/want";
+    Url url (urlStr, 80);
+
+    CPPUNIT_ASSERT (!url.getCredentials ().compare (""));
+    CPPUNIT_ASSERT (!url.getHost ().compare ("foo.bar"));
+    CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
+    CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
+    CPPUNIT_ASSERT (!url.getQuery ().compare (""));
+    CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)8080);
+  }
+
+  void testUrlWithoutPort ()
+  {
+    const char *urlStr = "http://foo.bar/what/i/want";
+    Url url (urlStr, 80);
+
+    CPPUNIT_ASSERT (!url.getCredentials ().compare (""));
+    CPPUNIT_ASSERT (!url.getHost ().compare ("foo.bar"));
+    CPPUNIT_ASSERT (!url.getResource ().compare ("what/i/want"));
+    CPPUNIT_ASSERT (!url.getProtocol ().compare ("http"));
+    CPPUNIT_ASSERT_EQUAL (url.getPort (), (u_short)80);
+  }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TestUrl );




From MAILER-DAEMON Sun May 03 06:55:56 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0ZMR-0007iJ-KG
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 06:55:55 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0ZMP-0007ef-8r
	for myserver-commit@gnu.org; Sun, 03 May 2009 06:55:53 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0ZMN-0007bq-T0
	for myserver-commit@gnu.org; Sun, 03 May 2009 06:55:52 -0400
Received: from [199.232.76.173] (port=56571 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0ZMN-0007bN-H2
	for myserver-commit@gnu.org; Sun, 03 May 2009 06:55:51 -0400
Received: from savannah.gnu.org ([199.232.41.3]:57058 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0ZMN-00037B-0V
	for myserver-commit@gnu.org; Sun, 03 May 2009 06:55:51 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0ZMM-0006Im-9r
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:55:50 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0ZML-0006Ie-SD
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:55:50 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0ZML-0006Ie-SD@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 10:55:49 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3068]
 The main configuration file can store structured data using a forest of
 trees .
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 10:55:53 -0000

Revision: 3068
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3068
Author:   gscrivano
Date:     2009-05-03 10:55:49 +0000 (Sun, 03 May 2009)
Log Message:
-----------
The main configuration file can store structured data using a forest of trees.

Modified Paths:
--------------
    trunk/myserver/include/conf/Makefile.am
    trunk/myserver/include/server/server.h
    trunk/myserver/src/conf/Makefile.am
    trunk/myserver/src/server/server.cpp

Added Paths:
-----------
    trunk/myserver/include/conf/nodetree.h
    trunk/myserver/include/conf/xml_conf.h
    trunk/myserver/src/conf/nodetree.cpp
    trunk/myserver/src/conf/xml_conf.cpp

Modified: trunk/myserver/include/conf/Makefile.am
===================================================================
--- trunk/myserver/include/conf/Makefile.am	2009-05-02 18:09:16 UTC (rev 3067)
+++ trunk/myserver/include/conf/Makefile.am	2009-05-03 10:55:49 UTC (rev 3068)
@@ -1,4 +1,3 @@
 confincludedir=$(includedir)/myserver/include/conf
-confinclude_HEADERS =
+confinclude_HEADERS = nodetree.h xml_conf.h
 SUBDIRS = mime security vhost
-

Added: trunk/myserver/include/conf/nodetree.h
===================================================================
--- trunk/myserver/include/conf/nodetree.h	                        (rev 0)
+++ trunk/myserver/include/conf/nodetree.h	2009-05-03 10:55:49 UTC (rev 3068)
@@ -0,0 +1,24 @@
+/* -*- 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 NODE_TREE_H
+#define NODE_TREE_H
+
+#include <src/conf/nodetree.cpp>
+
+#endif

Added: trunk/myserver/include/conf/xml_conf.h
===================================================================
--- trunk/myserver/include/conf/xml_conf.h	                        (rev 0)
+++ trunk/myserver/include/conf/xml_conf.h	2009-05-03 10:55:49 UTC (rev 3068)
@@ -0,0 +1,47 @@
+/* -*- 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_CONF_H
+#define XML_CONF_H
+
+#include <include/conf/nodetree.h>
+#include <include/base/xml/xml_parser.h>
+#include <include/base/hash_map/hash_map.h>
+
+#include <list>
+
+using namespace std;
+
+/*!
+ *Utility class for various operations on XML files.
+ */
+class XmlConf
+{
+ public:
+  static int build (xmlNodePtr root,
+                    list<NodeTree<string>*> *rootNodes,
+                    HashMap<string, NodeTree<string>*> *hashedData);
+
+ protected:
+  static void readNode (xmlNodePtr lcur,
+                        NodeTree<string> *root,
+                        list<NodeTree<string>*> *rootNodes,
+                        HashMap<string, NodeTree<string>*> *hashedData);
+};
+
+#endif

Modified: trunk/myserver/include/server/server.h
===================================================================
--- trunk/myserver/include/server/server.h	2009-05-02 18:09:16 UTC (rev 3067)
+++ trunk/myserver/include/server/server.h	2009-05-03 10:55:49 UTC (rev 3068)
@@ -42,6 +42,7 @@
 #include <include/base/multicast/multicast.h>
 #include <include/connections_scheduler/connections_scheduler.h>
 
+#include <include/conf/nodetree.h>
 
 #include <include/conf/security/security_manager.h>
 #include <include/conf/security/auth_method_factory.h>
@@ -192,7 +193,10 @@
   VhostManager *vhostList;
   MimeManager *mimeManager;
   HomeDir homeDir;
-  HashMap<string, string*> hashedData;
+
+  list<NodeTree<string>*> hashedDataTrees;
+  HashMap<string, NodeTree<string>*> hashedData;
+
   HashMap<string, void*> globalData;
   FiltersFactory filtersFactory;
   u_long uid;

Modified: trunk/myserver/src/conf/Makefile.am
===================================================================
--- trunk/myserver/src/conf/Makefile.am	2009-05-02 18:09:16 UTC (rev 3067)
+++ trunk/myserver/src/conf/Makefile.am	2009-05-03 10:55:49 UTC (rev 3068)
@@ -1,5 +1,4 @@
 lib_LIBRARIES = libconf.a
-libconf_a_SOURCES =
+libconf_a_SOURCES = nodetree.cpp xml_conf.cpp
 SUBDIRS = mime security vhost
 INCLUDES = $(all_includes)
-

Added: trunk/myserver/src/conf/nodetree.cpp
===================================================================
--- trunk/myserver/src/conf/nodetree.cpp	                        (rev 0)
+++ trunk/myserver/src/conf/nodetree.cpp	2009-05-03 10:55:49 UTC (rev 3068)
@@ -0,0 +1,90 @@
+/*
+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 <list>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+
+using namespace std;
+
+template <typename T>
+class NodeTree
+{
+public:
+  NodeTree ()
+  {
+    value = NULL;
+    children = NULL;
+  }
+
+  NodeTree (T& v)
+  {
+    value = new T (v);
+    children = NULL;
+  }
+
+  ~NodeTree ()
+  {
+    if (children)
+      {
+        typename list<NodeTree<T>* >::iterator it = children->begin ();
+        while (it != children->end ())
+          {
+            delete *it;
+            it++;
+          }
+        delete children;
+      }
+
+    if (value)
+      {
+        delete value;
+      }
+  }
+
+  void setValue (T *v)
+  {
+    value = v;
+  }
+
+  void addChild (NodeTree<T> *child)
+  {
+    if (children == NULL)
+      children = new list<NodeTree<T>*>;
+
+    children->push_back (child);
+  }
+
+  bool isLeaf ()
+  {
+    return children == NULL;
+  }
+
+  list<NodeTree<T>*> *getChildren ()
+  {
+    return children;
+  }
+
+  const T *getValue ()
+  {
+    return value;
+  }
+protected:
+  list<NodeTree<T>*> *children;
+  T *value;
+};

Added: trunk/myserver/src/conf/xml_conf.cpp
===================================================================
--- trunk/myserver/src/conf/xml_conf.cpp	                        (rev 0)
+++ trunk/myserver/src/conf/xml_conf.cpp	2009-05-03 10:55:49 UTC (rev 3068)
@@ -0,0 +1,87 @@
+/*
+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 <list>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+
+#include <include/conf/xml_conf.h>
+
+
+/*!
+ *Read a forest of trees (structured objects) from XML.
+ *
+ *\param root The XML document root.
+ *\param rootNodes All the stored top-level objects.
+ *\param hashedData Access node by a name.
+ *\return 0 on success.
+ */
+int XmlConf::build (xmlNodePtr root,
+                    list<NodeTree<string>*> *rootNodes,
+                    HashMap<string, NodeTree<string>*> *hashedData)
+{
+  readNode (root, NULL, rootNodes, hashedData);
+  return 0;
+}
+
+void XmlConf::readNode (xmlNodePtr lcur,
+                        NodeTree<string>* root,
+                        list<NodeTree<string>*> *rootNodes,
+                        HashMap<string, NodeTree<string>*> *hashedData)
+{
+  xmlAttr *attrs;
+  for(; lcur; lcur = lcur->next)
+    if (lcur->name && !xmlStrcmp (lcur->name, (const xmlChar *)"DEFINE"))
+      {
+        const char *name = NULL;
+        const char *value = NULL;
+
+        for (attrs = lcur->properties; attrs; attrs = attrs->next)
+          {
+            if (!xmlStrcmp (attrs->name, (const xmlChar *)"name") && 
+                attrs->children && attrs->children->content)
+              name = (const char*)attrs->children->content;
+            
+            if (!xmlStrcmp (attrs->name, (const xmlChar *)"value") && 
+                attrs->children && attrs->children->content)
+              value = (const char*)attrs->children->content;
+          }
+
+        string *v = value ? new string((const char*)value) : NULL;
+        NodeTree<string> *node = new NodeTree<string> ();
+        node->setValue (v);
+ 
+        if(name)
+          {
+            string key((const char*)name);
+            hashedData->put(key, node);
+          }
+
+        if (root)
+          root->addChild (node);
+
+        if (rootNodes)
+          rootNodes->push_back (node);
+
+        if (lcur->children)
+          readNode (lcur->children,
+                    node,
+                    NULL,
+                    hashedData);
+      }
+}

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp	2009-05-02 18:09:16 UTC (rev 3067)
+++ trunk/myserver/src/server/server.cpp	2009-05-03 10:55:49 UTC (rev 3068)
@@ -33,6 +33,9 @@
 #include <include/base/ssl/ssl.h>
 #include <include/base/socket/ssl_socket.h>
 
+#include <include/conf/xml_conf.h>
+
+
 extern "C"
 {
 #ifdef WIN32
@@ -1166,38 +1169,9 @@
  */
 void Server::readHashedData (xmlNodePtr lcur)
 {
-  xmlAttr *attrs;
-  for(;lcur; lcur = lcur->next)
-    {
-      
-      if (lcur->name && !xmlStrcmp(lcur->name, (const xmlChar *)"DEFINE"))
-        {
-          const char *name = NULL;
-          const char *value = NULL;
-          
-          for (attrs = lcur->properties; attrs; attrs = attrs->next)
-            {
-              if (!xmlStrcmp (attrs->name, (const xmlChar *)"name") && 
-                  attrs->children && attrs->children->content)
-                name = (const char*)attrs->children->content;
-              
-              if (!xmlStrcmp (attrs->name, (const xmlChar *)"value") && 
-                  attrs->children && attrs->children->content)
-                value = (const char*)attrs->children->content;
-            }
-          
-          if(name && value)
-            {
-              string* old;
-              string *v = new string((const char*)value);
-              string key((const char*)name);
-              old = hashedData.put(key, v);
-
-              if(old)
-                delete old;
-            }
-        }
-    }
+  XmlConf::build (lcur,
+                  &hashedDataTrees,
+                  &hashedData);
 }
 
 
@@ -1610,9 +1584,14 @@
 {
   try
   {
-    HashMap<string, string*>::Iterator it = hashedData.begin();
-    for (;it != hashedData.end(); it++)
-      delete *it;
+    list<NodeTree<string>*>::iterator it = hashedDataTrees.begin ();
+    while (it != hashedDataTrees.end ())
+      {
+        delete *it;
+        it++;
+      }
+
+    hashedDataTrees.clear ();
     hashedData.clear();
   }
   catch(...)
@@ -1627,8 +1606,9 @@
  */
 const char* Server::getHashedData(const char* name)
 {
-  string *s = hashedData.get(name);
-  return s ? s->c_str() : 0;
+  NodeTree<string> *s = hashedData.get(name);
+
+  return s ? s->getValue ()->c_str() : 0;
 }
 
 /*!




From MAILER-DAEMON Sun May 03 07:42:17 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0a5J-0007ge-DE
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 07:42:17 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0a5H-0007gP-2C
	for myserver-commit@gnu.org; Sun, 03 May 2009 07:42:15 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0a5G-0007gD-EU
	for myserver-commit@gnu.org; Sun, 03 May 2009 07:42:14 -0400
Received: from [199.232.76.173] (port=53023 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0a5G-0007gA-BF
	for myserver-commit@gnu.org; Sun, 03 May 2009 07:42:14 -0400
Received: from savannah.gnu.org ([199.232.41.3]:42632 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0a5F-0004Gh-V1
	for myserver-commit@gnu.org; Sun, 03 May 2009 07:42:14 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0a5F-0007qQ-FO
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:42:13 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0a5F-0007pz-2l
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:42:13 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0a5F-0007pz-2l@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 11:42:13 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3069] Default filenames for HTTP are stored
	using a DEFINE list.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 11:42:15 -0000

Revision: 3069
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3069
Author:   gscrivano
Date:     2009-05-03 11:42:12 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Default filenames for HTTP are stored using a DEFINE list.

Modified Paths:
--------------
    trunk/myserver/binaries/myserver.default.windows.xml
    trunk/myserver/binaries/myserver.default.xml
    trunk/myserver/documentation/directory_listing.texi
    trunk/myserver/include/protocol/http/http.h
    trunk/myserver/include/server/server.h
    trunk/myserver/src/protocol/http/http.cpp
    trunk/myserver/src/server/server.cpp

Modified: trunk/myserver/binaries/myserver.default.windows.xml
===================================================================
--- trunk/myserver/binaries/myserver.default.windows.xml	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/binaries/myserver.default.windows.xml	2009-05-03 11:42:12 UTC (rev 3069)
@@ -25,12 +25,12 @@
 	<!--DEFAULT FILENAME TO SEND IN A DIRECTORY
 			IF THE FILE ISN'T IN THE PATH THEN THE DIRECTORY
 			CONTENT IS SENT	-->
-	<DEFAULT_FILENAME>default.html</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>default.htm</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>default.php</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>index.html</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>index.htm</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>index.php</DEFAULT_FILENAME>
+  <DEFINE name="http.default_file">
+    <DEFINE value="default.html"/>
+    <DEFINE value="default.htm"/>
+    <DEFINE value="index.html"/>
+    <DEFINE value="index.htm"/>
+  </DEFINE>
 
 	<!--TIMEOUT OF EVERY CLIENTS CONNECTED TO THE SERVER.
 			IF THE CLIENT DOESN'T REQUEST ANYTHING FOR N

Modified: trunk/myserver/binaries/myserver.default.xml
===================================================================
--- trunk/myserver/binaries/myserver.default.xml	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/binaries/myserver.default.xml	2009-05-03 11:42:12 UTC (rev 3069)
@@ -25,12 +25,12 @@
 	<!--DEFAULT FILENAME TO SEND IN A DIRECTORY
 			IF THE FILE ISN'T IN THE PATH THEN THE DIRECTORY
 			CONTENT IS SENT	-->
-	<DEFAULT_FILENAME>default.html</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>default.htm</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>default.php</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>index.html</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>index.htm</DEFAULT_FILENAME>
-	<DEFAULT_FILENAME>index.php</DEFAULT_FILENAME>
+  <DEFINE name="http.default_file">
+    <DEFINE value="default.html"/>
+    <DEFINE value="default.htm"/>
+    <DEFINE value="index.html"/>
+    <DEFINE value="index.htm"/>
+  </DEFINE>
 
 	<!--TIMEOUT OF EVERY CLIENTS CONNECTED TO THE SERVER.
 			IF THE CLIENT DOESN'T REQUEST ANYTHING FOR N

Modified: trunk/myserver/documentation/directory_listing.texi
===================================================================
--- trunk/myserver/documentation/directory_listing.texi	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/documentation/directory_listing.texi	2009-05-03 11:42:12 UTC (rev 3069)
@@ -9,16 +9,19 @@
 In the @file{myserver.xml} file it is possible to set the default file
 to send instead of the directory content.
 
-Default files are defined using the @code{DEFAULT_FILENAME} element
-and they are checked in the specified order until one is found.
+Default files are defined using a list called @code{http.default_file}
+element and they are checked in the specified order until one is
+found.
 If a default file can't be found in the directory then its content is
 listed.
 
 @example
-<DEFAULT_FILENAME>default.htm</DEFAULT_FILENAME>
-<DEFAULT_FILENAME>index.htm</DEFAULT_FILENAME>
-<DEFAULT_FILENAME>default.html</DEFAULT_FILENAME>
-<DEFAULT_FILENAME>index.html</DEFAULT_FILENAME>
+<DEFINE name="http.default_file">
+        <DEFINE value="default.html"/>
+        <DEFINE value="default.htm"/>
+        <DEFINE value="index.html"/>
+        <DEFINE value="index.htm"/>
+</DEFINE>
 @end example
 
 The previous lines define the order of files that are checked by the

Modified: trunk/myserver/include/protocol/http/http.h
===================================================================
--- trunk/myserver/include/protocol/http/http.h	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/include/protocol/http/http.h	2009-05-03 11:42:12 UTC (rev 3069)
@@ -57,7 +57,6 @@
     clearMulticastRegistry();
   }
 
-  vector<string> defaultFilename;
   int cgiTimeout;
   int allowVhostMime;
 
@@ -111,7 +110,6 @@
 {
 public:
   int requestAuthorization();
-  const char *getDefaultFilenamePath(u_long ID);
 
   int sendHTTPResource(string& filename,
                        int systemrequest = 0, 

Modified: trunk/myserver/include/server/server.h
===================================================================
--- trunk/myserver/include/server/server.h	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/include/server/server.h	2009-05-03 11:42:12 UTC (rev 3069)
@@ -118,7 +118,12 @@
   const char *getAddresses();
   const char *getPath();
   u_long getNumThreads();
-  const char *getDefaultFilenamePath(u_long ID = 0);
+
+  NodeTree<string>* getNodeTree (string& key)
+  {
+    return hashedData.get (key);
+  }
+
   const char *getServerName();
   u_long getVerbosity();
   int getMaxLogFileSize();

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/src/protocol/http/http.cpp	2009-05-03 11:42:12 UTC (rev 3069)
@@ -1707,48 +1707,53 @@
 {
   int i;
   int ret;
+  string key ("http.default_file");
+  NodeTree<string> *node = Server::getInstance()->getNodeTree (key);
 
-  for(i = 0;; i++)
+  if (node)
     {
-      const char *defaultFileNamePath = getDefaultFilenamePath(i);
-      ostringstream defaultFileName;
-      defaultFileName.clear();
-      if(defaultFileNamePath)
+      list<NodeTree<string>*> *children = node->getChildren ();
+
+      for(list<NodeTree<string>*>::iterator it = children->begin ();
+          it != children->end ();
+          it++)
         {
-          defaultFileName << td->filenamePath << "/" << defaultFileNamePath;
-        }
-      else
-          break;
-      
-      if(FilesUtility::fileExists(defaultFileName.str().c_str()))
-        {
-          ostringstream nUrl;
-          
-          if(td->request.uriEndsWithSlash)
-              nUrl << defaultFileNamePath;
-          else
+          ostringstream defaultFileName;
+          const string *file = (*it)->getValue ();
+          defaultFileName.clear();
+          defaultFileName << td->filenamePath << "/" << *file;
+
+          if(FilesUtility::fileExists (defaultFileName.str ().c_str ()))
             {
-              u_long lastSlashOffset = uri.length();
-              while(lastSlashOffset && uri[lastSlashOffset] != '/')
-                --lastSlashOffset;
-              
-              nUrl << &(uri.c_str()[lastSlashOffset < uri.length() ?
-                                    lastSlashOffset + 1 : 0])
-                   << "/" << defaultFileNamePath;
-            }
-          
-          if(td->pathInfo.length())
-            nUrl << "/" << td->pathInfo;
+              ostringstream nUrl;
 
-          if(td->request.uriOpts.length())
-            nUrl << "?" << td->request.uriOpts;
+              if (td->request.uriEndsWithSlash)
+                nUrl << *file;
+              else
+                {
+                  u_long lastSlashOffset = uri.length();
+                  while (lastSlashOffset && uri[lastSlashOffset] != '/')
+                    --lastSlashOffset;
 
-          /*! Send a redirect to the new location.  */
-          if(sendHTTPRedirect(nUrl.str().c_str()))
-            ret = 1;
-          else
-            ret = 0;
-          return ret;
+                  nUrl << &(uri.c_str ()[lastSlashOffset < uri.length() ?
+                                         lastSlashOffset + 1 : 0])
+                       << "/" << *file;
+                }
+
+              if (td->pathInfo.length())
+                nUrl << "/" << td->pathInfo;
+
+              if (td->request.uriOpts.length())
+                nUrl << "?" << td->request.uriOpts;
+
+              /*! Send a redirect to the new location.  */
+              if (sendHTTPRedirect(nUrl.str().c_str()))
+                ret = 1;
+              else
+                ret = 0;
+
+              return ret;
+            }
         }
     }
 
@@ -1843,7 +1848,6 @@
 int Http::loadProtocolStatic(XmlParser* languageParser)
 {
   char *data = 0;
-  int  nDefaultFilename = 0;
   XmlParser *configurationFileManager = Server::getInstance()->getConfiguration();
   string pluginsResource(Server::getInstance()->getExternalPath());
   xmlDocPtr xmlDoc = configurationFileManager->getDoc();
@@ -1903,36 +1907,6 @@
   WinCgi::setTimeout(staticHttp.cgiTimeout);
   Isapi::setTimeout(staticHttp.cgiTimeout);
 
-  nDefaultFilename = 0;
-  staticHttp.defaultFilename.clear();
-
-
-  for(xmlNode *node = xmlDoc->children; node; node = node->next)
-  {
-
-    if(!xmlStrcmp(node->name, (const xmlChar *)"MYSERVER"))
-    {
-      for(node = node->children; node; node = node->next)
-      {
-        if(!xmlStrncmp(node->name, (const xmlChar *)"DEFAULT_FILENAME", xmlStrlen((const xmlChar *)"DEFAULT_FILENAME")))
-        {
-          staticHttp.defaultFilename.push_back((char*)node->children->content);
-          nDefaultFilename++;
-        }
-      }
-      break;
-    }
-  }
-
-  /*!
-   *Copy the right values in the buffer.
-   */
-  if(nDefaultFilename == 0)
-  {
-    staticHttp.defaultFilename.push_back("default.html");
-    nDefaultFilename++;
-  }
-
   return 1;
 }
 
@@ -1960,25 +1934,12 @@
 
   HttpDir::unLoad();
 
-  staticHttp.defaultFilename.clear();
-
   staticHttp.clear();
 
   return 1;
 }
 
 /*!
- *Returns the default filename.
- */
-const char *Http::getDefaultFilenamePath (u_long ID)
-{
-  if(staticHttp.defaultFilename.size() <= ID)
-    return 0;
-
-  return staticHttp.defaultFilename[ID].c_str();
-}
-
-/*!
  *Returns the name of the protocol. If an out buffer
  *is defined fullfill it with the name too.
  */

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp	2009-05-03 10:55:49 UTC (rev 3068)
+++ trunk/myserver/src/server/server.cpp	2009-05-03 11:42:12 UTC (rev 3069)
@@ -187,7 +187,6 @@
   return 0;
 }
 
-
 /*!
  *Copy a configuration file from the default one.
  *Return nonzero on errors.




From MAILER-DAEMON Sun May 03 08:27:25 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0amz-00039Y-II
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 08:27:25 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0amx-000391-Gp
	for myserver-commit@gnu.org; Sun, 03 May 2009 08:27:23 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0amx-00038n-7s
	for myserver-commit@gnu.org; Sun, 03 May 2009 08:27:23 -0400
Received: from [199.232.76.173] (port=40551 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0amw-00038j-Ta
	for myserver-commit@gnu.org; Sun, 03 May 2009 08:27:22 -0400
Received: from savannah.gnu.org ([199.232.41.3]:57936 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0amw-0002pr-JE
	for myserver-commit@gnu.org; Sun, 03 May 2009 08:27:22 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0amw-0001Xb-08
	for myserver-commit@gnu.org; Sun, 03 May 2009 12:27:22 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0amv-0001WW-Do
	for myserver-commit@gnu.org; Sun, 03 May 2009 12:27:21 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0amv-0001WW-Do@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 12:27:21 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3070] Added tests for `NodeTree'.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 12:27:23 -0000

Revision: 3070
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3070
Author:   gscrivano
Date:     2009-05-03 12:27:20 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Added tests for `NodeTree'.

Modified Paths:
--------------
    trunk/myserver/tests/Makefile.am

Added Paths:
-----------
    trunk/myserver/tests/test_nodetree.cpp

Modified: trunk/myserver/tests/Makefile.am
===================================================================
--- trunk/myserver/tests/Makefile.am	2009-05-03 11:42:12 UTC (rev 3069)
+++ trunk/myserver/tests/Makefile.am	2009-05-03 12:27:20 UTC (rev 3070)
@@ -10,6 +10,6 @@
 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_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_utility.cpp test_validator.cpp test_validator_factory.cpp test_xml.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)

Added: trunk/myserver/tests/test_nodetree.cpp
===================================================================
--- trunk/myserver/tests/test_nodetree.cpp	                        (rev 0)
+++ trunk/myserver/tests/test_nodetree.cpp	2009-05-03 12:27:20 UTC (rev 3070)
@@ -0,0 +1,87 @@
+/*
+ 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 <ctype.h>
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <include/conf/nodetree.h>
+
+class TestNodeTree : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( TestNodeTree );
+  CPPUNIT_TEST( testCreateDestroy );
+  CPPUNIT_TEST_SUITE_END();
+
+
+public:
+
+  void setUp()
+  {
+
+  }
+
+  void tearDown()
+  {
+
+  }
+
+  void testCreateDestroy ()
+  {
+    NodeTree<string> *c = new NodeTree<string> ();
+
+    for (int j = 0; j < 5; j++)
+      {
+        NodeTree<string> *cc = new NodeTree<string> ();
+        c->addChild (cc);
+        for (int i = 0; i < 10; i++)
+          {
+            string s = "just a string";
+            cc->addChild (new NodeTree<string> (s));
+          }
+      }
+
+    CPPUNIT_ASSERT_EQUAL (countLeafNodes (c), 50);
+
+    delete c;
+  }
+
+protected:
+  int countLeafNodes (NodeTree<string> *c)
+  {
+    int count = 0;
+    for (list<NodeTree<string>*>::iterator it = c->getChildren ()->begin ();
+         it != c->getChildren ()->end ();
+         it++)
+      {
+        NodeTree<string> *n = *it;
+        if (n->isLeaf ())
+          count++;
+        else
+          count += countLeafNodes (n);
+      }
+
+    return count;
+  }
+
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TestNodeTree );




From MAILER-DAEMON Sun May 03 10:06:50 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0cLC-0001Du-7K
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 10:06:50 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0cLA-0001DZ-9j
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:48 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0cL9-0001DN-Kq
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:47 -0400
Received: from [199.232.76.173] (port=38903 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0cL9-0001DK-D8
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:47 -0400
Received: from savannah.gnu.org ([199.232.41.3]:54528 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0cL8-0002Xz-T4
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:47 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0cL8-0001Fl-Br
	for myserver-commit@gnu.org; Sun, 03 May 2009 14:06:46 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0cL8-0001FO-0Z
	for myserver-commit@gnu.org; Sun, 03 May 2009 14:06:46 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0cL8-0001FO-0Z@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 14:06:46 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3071] All recent changes now compile under WIN32.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 14:06:48 -0000

Revision: 3071
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3071
Author:   gscrivano
Date:     2009-05-03 14:06:45 +0000 (Sun, 03 May 2009)
Log Message:
-----------
All recent changes now compile under WIN32.

Modified Paths:
--------------
    trunk/myserver/tests/test_socket.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/tests/test_socket.cpp
===================================================================
--- trunk/myserver/tests/test_socket.cpp	2009-05-03 12:27:20 UTC (rev 3070)
+++ trunk/myserver/tests/test_socket.cpp	2009-05-03 14:06:45 UTC (rev 3071)
@@ -23,14 +23,26 @@
 #include "../include/base/socket/socket.h"
 #include "../include/base/thread/thread.h"
 
+extern "C"
+{
 #include <string.h>
 #include <errno.h>
+
+#ifndef WIN32
 #include <arpa/inet.h>
+#endif
+
 #include <iostream>
+}
 
 using namespace std;
 
-void* testRecvClient ( void* );
+#ifdef WIN32
+unsigned int  __stdcall
+#else
+void *
+#endif
+testRecvClient ( void* );
 
 class TestSocket : public CppUnit::TestFixture
 {
@@ -102,7 +114,7 @@
     
     CPPUNIT_ASSERT( obj->listen ( 1 ) != -1 );
     
-    CPPUNIT_ASSERT_EQUAL( Thread::create ( &tid, testRecvClient, &port ), 0 );
+    CPPUNIT_ASSERT (!Thread::create (&tid, testRecvClient, &port ));
     
     Socket s = obj->accept ( &sockIn, &sockInLen );
     
@@ -159,7 +171,11 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestSocket );
 
-void*
+#ifdef WIN32
+unsigned int  __stdcall
+#else
+void *
+#endif
 testRecvClient ( void *arg )
 {
   Socket *obj2 = new Socket;
@@ -180,8 +196,6 @@
   
   CPPUNIT_ASSERT( obj2->send ( buf, strlen ( buf ), 0 ) != -1 );
   
-  sleep ( 2 );
-  
   CPPUNIT_ASSERT( obj2->shutdown ( SD_BOTH ) != -1 );
  
   CPPUNIT_ASSERT( obj2->close ( ) != -1 );

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-03 12:27:20 UTC (rev 3070)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-03 14:06:45 UTC (rev 3071)
@@ -28,11 +28,17 @@
 #include "../include/base/file/files_utility.h"
 #include "../include/base/thread/thread.h"
 
+extern "C"
+{
 #include <string.h>
 #include <errno.h>
+
+#ifndef WIN32
 #include <arpa/inet.h>
+#endif
+
 #include <iostream>
-
+}
 using namespace std;
 
 
@@ -83,9 +89,13 @@
 -----END CERTIFICATE-----\n";
 
 
+#ifdef WIN32
+unsigned int  __stdcall
+#else
+void *
+#endif
+testSslRecvClient ( void* ); //
 
-void* testSslRecvClient ( void* ); //
-
 class TestSslSocket : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE( TestSslSocket );
@@ -201,7 +211,11 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestSslSocket );
 
-void*
+#ifdef WIN32
+unsigned int  __stdcall
+#else
+void *
+#endif
 testSslRecvClient ( void *arg )
 {
   Socket *obj2 = new Socket;




From MAILER-DAEMON Sun May 03 10:06:54 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0cLG-0001EP-Ao
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 10:06:54 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0cLF-0001EJ-1q
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:53 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0cLE-0001E7-8U
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:52 -0400
Received: from [199.232.76.173] (port=38905 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0cLE-0001E4-3C
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:52 -0400
Received: from savannah.gnu.org ([199.232.41.3]:54530 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0cLD-0002YR-5m
	for myserver-commit@gnu.org; Sun, 03 May 2009 10:06:51 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0cLC-0001I2-Qb
	for myserver-commit@gnu.org; Sun, 03 May 2009 14:06:50 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0cLC-0001Hu-Fr
	for myserver-commit@gnu.org; Sun, 03 May 2009 14:06:50 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0cLC-0001Hu-Fr@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 14:06:50 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3072] Use `getpwnam' when it is available
 instead of parsing the `/etc/ passwd' file.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 14:06:53 -0000

Revision: 3072
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3072
Author:   gscrivano
Date:     2009-05-03 14:06:50 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Use `getpwnam' when it is available instead of parsing the `/etc/passwd' file.

Modified Paths:
--------------
    trunk/myserver/configure.in
    trunk/myserver/include/base/home_dir/home_dir.h
    trunk/myserver/src/base/home_dir/home_dir.cpp
    trunk/myserver/tests/test_homedir.cpp
    trunk/myserver/tests/test_socket.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/configure.in
===================================================================
--- trunk/myserver/configure.in	2009-05-03 14:06:45 UTC (rev 3071)
+++ trunk/myserver/configure.in	2009-05-03 14:06:50 UTC (rev 3072)
@@ -96,7 +96,9 @@
 
 AC_CHECK_FUNCS(snprintf, AC_DEFINE(SNPRINTF, 1, [Define if the snprintf function is present]) )
 
+AC_CHECK_FUNCS(getpwnam, AC_DEFINE(GETPWNAM, 1, [Define if the getpwnam function is present]) )
 
+
 case "${host}" in
     *-*-mingw32*)
      LDFLAGS="$LDFLAGS -lwsock32 -lgdi32 -lole32  -luuid -luserenv"

Modified: trunk/myserver/include/base/home_dir/home_dir.h
===================================================================
--- trunk/myserver/include/base/home_dir/home_dir.h	2009-05-03 14:06:45 UTC (rev 3071)
+++ trunk/myserver/include/base/home_dir/home_dir.h	2009-05-03 14:06:50 UTC (rev 3072)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+Copyright (C) 2006, 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
@@ -36,18 +36,18 @@
 
 	void clear();
 	int load();
-	const string *getHomeDir(string& userName);
-	void getHomeDir(string& userName, string& out);
 
-  int isLoaded(){return loaded;}
+	int getHomeDir (string& userName, string& out);
 
+  int isLoaded (){return loaded;}
+
 private:
   Mutex loadMutex;
   int loadImpl();
 
 #ifdef WIN32
   string data;
-#else
+#elif !GETPWNAM
 	HashMap<string, string*> data;
 #endif
 	time_t timestamp;

Modified: trunk/myserver/src/base/home_dir/home_dir.cpp
===================================================================
--- trunk/myserver/src/base/home_dir/home_dir.cpp	2009-05-03 14:06:45 UTC (rev 3071)
+++ trunk/myserver/src/base/home_dir/home_dir.cpp	2009-05-03 14:06:50 UTC (rev 3072)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+Copyright (C) 2006, 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
@@ -22,6 +22,7 @@
 #include <include/base/utility.h>
 #include <include/base/file/files_utility.h>
 
+
 #ifdef WIN32
 #include <userenv.h>
 #endif
@@ -30,6 +31,11 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+
+#ifdef GETPWNAM
+#include <pwd.h>
+#endif
+
 #ifndef WIN32
 #include <errno.h>
 #include <netdb.h>
@@ -55,7 +61,7 @@
 {
 #ifdef WIN32
   data.assign("");
-#else
+#elif !GETPWNAM
   data.clear();
 #endif
   timestamp = 0;
@@ -80,7 +86,7 @@
 {
 #ifdef WIN32
   data.assign("");
-#else
+#elif !GETPWNAM
   HashMap<string, string*>::Iterator i = data.begin();
   for( ; i != data.end(); i++)
   {
@@ -129,7 +135,7 @@
     }
   }
   data.assign(buf);
-#else
+#elif !GETPWNAM
   File usersFile;
   u_long size;
   char* buffer;
@@ -138,12 +144,12 @@
 
   clear();
 
-  if(usersFile.openFile("/etc/passwd", File::MYSERVER_OPEN_READ | 
-                        File::MYSERVER_OPEN_IFEXISTS))
+  if (usersFile.openFile("/etc/passwd", File::MYSERVER_OPEN_READ | 
+                         File::MYSERVER_OPEN_IFEXISTS))
     return 1;
   size = usersFile.getFileSize();
   timestamp = usersFile.getLastModTime();
-  if(size == (u_long) -1)
+  if (size == (u_long) -1)
   {
     usersFile.close();
     return 1;
@@ -151,63 +157,62 @@
 
   buffer = new char[size+1]; 
 
-  usersFile.read(buffer, size, &read);
+  usersFile.read (buffer, size, &read);
   buffer[read] = '\0';
 
- for(counter = 0; counter < read; counter++)
-   if(buffer[counter] == ':')
+ for (counter = 0; counter < read; counter++)
+   if (buffer[counter] == ':')
      buffer[counter] = '\0';
 
-
-  for(counter = 0; counter < size;)
+  for (counter = 0; counter < size;)
   {
     char *username = 0;
     char *home = 0;
     string sUsername;
     string *sHome;
     string *old;
-     
-    if(buffer[counter] == '#')
+
+    if (buffer[counter] == '#')
     {
-      while(buffer[counter++] != '\n');
+      while (buffer[counter++] != '\n');
       continue;
     }
 
      /* Username.  */
     username = &buffer[counter];
-    
-     while(buffer[counter++] != '\0');
+
+    while (buffer[counter++] != '\0');
     /* Password.  */
 
-     while(buffer[counter++] != '\0');
+    while (buffer[counter++] != '\0');
     /* User ID.  */
 
-     while(buffer[counter++] != '\0');
+    while (buffer[counter++] != '\0');
     /* Group ID.  */
 
-     while(buffer[counter++] != '\0');
+    while (buffer[counter++] != '\0');
     /* Info.  */
 
-     while(buffer[counter++] != '\0');
+    while (buffer[counter++] != '\0');
     /* Home.  */
 
     home = &buffer[counter++];
-    sUsername = string(username);
-    sHome = new string(home);
+    sUsername = string (username);
+    sHome = new string (home);
 
-    old = data.put(sUsername, sHome);
+    old = data.put (sUsername, sHome);
 
-    if(old)
+    if (old)
       delete old;
 
-    while(buffer[counter++] != '\0');
+    while (buffer[counter++] != '\0');
     /* Shell.  */
 
-    while(buffer[counter++] != '\n');
+    while (buffer[counter++] != '\n');
     /* Next tuple.  */
   }
   delete [] buffer;
-  usersFile.close();
+  usersFile.close ();
 #endif
 
   loaded = 1;
@@ -215,58 +220,54 @@
 }
 
 /*!
- *Get the home directory for a specified user.
+ *Get the home directory for a specified user and write
+ *it directly to the supplied buffer.
  *\param userName The user name.
+ *\param out The buffer where write.
+ *\return 0 on success.
  */
-const string *HomeDir::getHomeDir(string& userName)
+int HomeDir::getHomeDir(string& userName, string& out)
 {
 #ifdef WIN32
-  static string retString;
-  retString.assign(data);
-  retString.append("/");
-  retString.append(userName);
-  return &retString;
-#else
-  if(!loaded)
-    return 0;
-  /* TODO: don't check always but wait some time before.  */
-  if(FilesUtility::getLastModTime("/etc/passwd") != timestamp)
-    load();
+  out.assign (data);
+  out.append ("/");
+  out.append (userName);
+#elif GETPWNAM
+  struct passwd *p;
+  int ret = 0;
 
-  return data.get(userName);
-#endif
-}
+  loadMutex.lock ();
 
+  p = ::getpwnam (userName.c_str ());
+  if (p == NULL)
+    ret = 1;
+  else
+    out.assign (p->pw_dir);
 
-/*!
- *Get the home directory for a specified user and write
- *it directly to the supplied buffer.
- *\param userName The user name.
- *\param out The buffer where write.
- */
-void HomeDir::getHomeDir(string& userName, string& out)
-{
-#ifdef WIN32
-  out.assign(data);
-  out.append("/");
-  out.append(userName);
+  loadMutex.unlock ();
+
+  return ret;
 #else
   static u_long lastCheckTime = 0;
   string *res = 0;
-  if(!loaded)
-    return;
-  if(getTicks() - lastCheckTime > MYSERVER_SEC(1))
+
+  if (!loaded)
+    return 1;
+
+  if (getTicks () - lastCheckTime > MYSERVER_SEC (1))
   {
-    if(FilesUtility::getLastModTime("/etc/passwd") != timestamp)
-      load();
-    lastCheckTime = getTicks();
+    if(FilesUtility::getLastModTime ("/etc/passwd") != timestamp)
+      load ();
+    lastCheckTime = getTicks ();
   }
-  res = data.get(userName);
-  if(res)
+  res = data.get (userName);
+  if (res)
   {
-    out.assign(*res);
+    out.assign (*res);
   }
   else
-    out.assign("");
+    out.assign ("");
 #endif
+
+  return 0;
 }

Modified: trunk/myserver/tests/test_homedir.cpp
===================================================================
--- trunk/myserver/tests/test_homedir.cpp	2009-05-03 14:06:45 UTC (rev 3071)
+++ trunk/myserver/tests/test_homedir.cpp	2009-05-03 14:06:50 UTC (rev 3072)
@@ -57,18 +57,12 @@
      * if it doesn't handle this differently.  */
     username.assign("root");
 #endif
+    string dir;
 
-    const string *dir = homeDir->getHomeDir(username);
-    CPPUNIT_ASSERT(dir);
-    CPPUNIT_ASSERT(dir->length());
+    CPPUNIT_ASSERT_EQUAL (homeDir->getHomeDir(username, dir), 0);
 
-    string dirOut;
+    CPPUNIT_ASSERT(dir.length());
 
-    homeDir->getHomeDir(username, dirOut);
-
-    CPPUNIT_ASSERT(dirOut.length());
-
-
     homeDir->clear();
   }
 

Modified: trunk/myserver/tests/test_socket.cpp
===================================================================
--- trunk/myserver/tests/test_socket.cpp	2009-05-03 14:06:45 UTC (rev 3071)
+++ trunk/myserver/tests/test_socket.cpp	2009-05-03 14:06:50 UTC (rev 3072)
@@ -23,26 +23,14 @@
 #include "../include/base/socket/socket.h"
 #include "../include/base/thread/thread.h"
 
-extern "C"
-{
 #include <string.h>
 #include <errno.h>
-
-#ifndef WIN32
 #include <arpa/inet.h>
-#endif
-
 #include <iostream>
-}
 
 using namespace std;
 
-#ifdef WIN32
-unsigned int  __stdcall
-#else
-void *
-#endif
-testRecvClient ( void* );
+void* testRecvClient ( void* );
 
 class TestSocket : public CppUnit::TestFixture
 {
@@ -114,7 +102,7 @@
     
     CPPUNIT_ASSERT( obj->listen ( 1 ) != -1 );
     
-    CPPUNIT_ASSERT (!Thread::create (&tid, testRecvClient, &port ));
+    CPPUNIT_ASSERT_EQUAL( Thread::create ( &tid, testRecvClient, &port ), 0 );
     
     Socket s = obj->accept ( &sockIn, &sockInLen );
     
@@ -171,11 +159,7 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestSocket );
 
-#ifdef WIN32
-unsigned int  __stdcall
-#else
-void *
-#endif
+void*
 testRecvClient ( void *arg )
 {
   Socket *obj2 = new Socket;
@@ -196,6 +180,8 @@
   
   CPPUNIT_ASSERT( obj2->send ( buf, strlen ( buf ), 0 ) != -1 );
   
+  sleep ( 2 );
+  
   CPPUNIT_ASSERT( obj2->shutdown ( SD_BOTH ) != -1 );
  
   CPPUNIT_ASSERT( obj2->close ( ) != -1 );

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-03 14:06:45 UTC (rev 3071)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-03 14:06:50 UTC (rev 3072)
@@ -28,17 +28,11 @@
 #include "../include/base/file/files_utility.h"
 #include "../include/base/thread/thread.h"
 
-extern "C"
-{
 #include <string.h>
 #include <errno.h>
-
-#ifndef WIN32
 #include <arpa/inet.h>
-#endif
-
 #include <iostream>
-}
+
 using namespace std;
 
 
@@ -89,13 +83,9 @@
 -----END CERTIFICATE-----\n";
 
 
-#ifdef WIN32
-unsigned int  __stdcall
-#else
-void *
-#endif
-testSslRecvClient ( void* ); //
 
+void* testSslRecvClient ( void* ); //
+
 class TestSslSocket : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE( TestSslSocket );
@@ -211,11 +201,7 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestSslSocket );
 
-#ifdef WIN32
-unsigned int  __stdcall
-#else
-void *
-#endif
+void*
 testSslRecvClient ( void *arg )
 {
   Socket *obj2 = new Socket;




From MAILER-DAEMON Sun May 03 11:36:45 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0dkD-0000iZ-58
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 11:36:45 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0dkA-0000hb-Ub
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:43 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0dkA-0000hA-2M
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:42 -0400
Received: from [199.232.76.173] (port=50006 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0dk9-0000h4-SZ
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:41 -0400
Received: from savannah.gnu.org ([199.232.41.3]:54539 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0dk9-0003HY-Ew
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:41 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0dk8-0005Rw-RS
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:36:40 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0dk8-0005Rq-Cq
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:36:40 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0dk8-0005Rq-Cq@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 15:36:40 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3073]
 The definition of a thread entry-point is done trought the `DEFINE_THREAD'
 macro.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 15:36:43 -0000

Revision: 3073
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3073
Author:   gscrivano
Date:     2009-05-03 15:36:39 +0000 (Sun, 03 May 2009)
Log Message:
-----------
The definition of a thread entry-point is done trought the `DEFINE_THREAD' macro.

Modified Paths:
--------------
    trunk/myserver/include/base/thread/thread.h
    trunk/myserver/include/protocol/ftp/ftp.h
    trunk/myserver/include/server/clients_thread.h
    trunk/myserver/src/connections_scheduler/connections_scheduler.cpp
    trunk/myserver/src/protocol/ftp/ftp.cpp
    trunk/myserver/src/server/clients_thread.cpp
    trunk/myserver/tests/test_mutex.cpp
    trunk/myserver/tests/test_socket.cpp
    trunk/myserver/tests/test_ssl_socket.cpp
    trunk/myserver/tests/test_thread.cpp

Modified: trunk/myserver/include/base/thread/thread.h
===================================================================
--- trunk/myserver/include/base/thread/thread.h	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/include/base/thread/thread.h	2009-05-03 15:36:39 UTC (rev 3073)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 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
@@ -25,9 +25,11 @@
 
 #ifdef WIN32
 	typedef unsigned int ThreadID;
+#define DEFINE_THREAD(NAME,PARAM) unsigned int __stdcall NAME(void* PARAM)
 #endif
 #ifdef HAVE_PTHREAD
 	typedef pthread_t ThreadID;
+#define DEFINE_THREAD(NAME,PARAM) void* NAME(void* PARAM)
 #endif
 
 class Thread

Modified: trunk/myserver/include/protocol/ftp/ftp.h
===================================================================
--- trunk/myserver/include/protocol/ftp/ftp.h	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/include/protocol/ftp/ftp.h	2009-05-03 15:36:39 UTC (rev 3073)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2008 Free Software Foundation, Inc.
+Copyright (C) 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 2 of the License, or
@@ -194,19 +194,6 @@
 
 int get_ftp_reply(int nReplyCode, std::string &sReply);
 void ftp_reply(ConnectionPtr pConnection, int nReplyCode, const std::string &sCustomText = "");
-
-#ifdef WIN32
-unsigned int __stdcall SendAsciiFile(void* pParam);
-unsigned int __stdcall SendImageFile(void* pParam);
-unsigned int __stdcall ReceiveAsciiFile(void* pParam);
-unsigned int __stdcall ReceiveImageFile(void* pParam);
-#elif HAVE_PTHREAD
-void* SendAsciiFile(void* pParam);
-void* SendImageFile(void* pParam);
-void* ReceiveAsciiFile(void* pParam);
-void* ReceiveImageFile(void* pParam);
-#endif //HAVE_PTHREAD
-
 void yyerror(YYLTYPE *pLoc, Ftp *pContext, const char *msg);
 
 

Modified: trunk/myserver/include/server/clients_thread.h
===================================================================
--- trunk/myserver/include/server/clients_thread.h	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/include/server/clients_thread.h	2009-05-03 15:36:39 UTC (rev 3073)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2005, 2006, 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
@@ -35,12 +35,8 @@
 {
   friend class Server;
 
-#ifdef WIN32
-  friend  unsigned int __stdcall clients_thread(void* pParam);
-#endif
-#ifdef HAVE_PTHREAD
-  friend  void* clients_thread(void* pParam);
-#endif
+  friend DEFINE_THREAD(clients_thread, pParam);
+
 public:
   enum RETURN_CODE
   {

Modified: trunk/myserver/src/connections_scheduler/connections_scheduler.cpp
===================================================================
--- trunk/myserver/src/connections_scheduler/connections_scheduler.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/src/connections_scheduler/connections_scheduler.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -18,12 +18,7 @@
 #include <include/connections_scheduler/connections_scheduler.h>
 #include <include/server/server.h>
 
-
-#ifdef WIN32
-static unsigned int __stdcall dispatcher(void* p)
-#else
-static void* dispatcher(void* p)
-#endif
+static DEFINE_THREAD(dispatcher, p)
 {
   ConnectionsScheduler::DispatcherArg *da = (ConnectionsScheduler::DispatcherArg*)p;
 

Modified: trunk/myserver/src/protocol/ftp/ftp.cpp
===================================================================
--- trunk/myserver/src/protocol/ftp/ftp.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/src/protocol/ftp/ftp.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -40,6 +40,12 @@
 #include <arpa/inet.h>
 #endif
 
+static DEFINE_THREAD(SendAsciiFile,pParam);
+static DEFINE_THREAD(SendImageFile,pParam);
+
+static DEFINE_THREAD(ReceiveAsciiFile,pParam);
+static DEFINE_THREAD(ReceiveImageFile,pParam);
+
 //////////////////////////////////////////////////////////////////////////////
 // FtpHost class
 void SetFtpHost(FtpHost &out, const FtpHost &in)
@@ -657,11 +663,7 @@
   }
 }
 
-#ifdef WIN32
-unsigned int __stdcall SendAsciiFile(void* pParam)
-#elif HAVE_PTHREAD
-void* SendAsciiFile(void* pParam)
-#endif //HAVE_PTHREAD
+static DEFINE_THREAD(SendAsciiFile, pParam)
 {
   DataConnectionWorkerThreadData *pWt = reinterpret_cast<DataConnectionWorkerThreadData *>(pParam);
   if ( pWt == NULL )
@@ -890,11 +892,7 @@
 
 }
 
-#ifdef WIN32
-unsigned int __stdcall SendImageFile(void* pParam)
-#elif HAVE_PTHREAD
-void* SendImageFile(void* pParam)
-#endif //HAVE_PTHREAD
+static DEFINE_THREAD(SendImageFile, pParam)
 {
   DataConnectionWorkerThreadData *pWt = reinterpret_cast<DataConnectionWorkerThreadData *>(pParam);
   if ( pWt == NULL )
@@ -1071,11 +1069,7 @@
 #endif
 }
 
-#ifdef WIN32
-unsigned int __stdcall ReceiveAsciiFile(void* pParam)
-#elif HAVE_PTHREAD
-void* ReceiveAsciiFile(void* pParam)
-#endif //HAVE_PTHREAD
+static DEFINE_THREAD(ReceiveAsciiFile, pParam)
 {
   DataConnectionWorkerThreadData *pWt = reinterpret_cast<DataConnectionWorkerThreadData *>(pParam);
   if ( pWt == NULL )
@@ -1267,11 +1261,7 @@
 #endif
 }
 
-#ifdef WIN32
-unsigned int __stdcall ReceiveImageFile(void* pParam)
-#elif HAVE_PTHREAD
-void* ReceiveImageFile(void* pParam)
-#endif //HAVE_PTHREAD
+static DEFINE_THREAD(ReceiveImageFile, pParam)
 {
   DataConnectionWorkerThreadData *pWt = reinterpret_cast<DataConnectionWorkerThreadData *>(pParam);
   if ( pWt == NULL )

Modified: trunk/myserver/src/server/clients_thread.cpp
===================================================================
--- trunk/myserver/src/server/clients_thread.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/src/server/clients_thread.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -30,7 +30,8 @@
 #include <include/protocol/ftp/ftp.h>
 
 #ifndef WIN32
-extern "C" {
+extern "C" 
+{
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -117,16 +118,7 @@
  *class instance.
  *\param pParam Params to pass to the new thread.
  */
-#ifdef WIN32
-#define ClientsThread_TYPE int
-unsigned int __stdcall clients_thread(void* pParam)
-#endif
-
-#ifdef HAVE_PTHREAD
-#define ClientsThread_TYPE void*
-void* clients_thread(void* pParam)
-#endif
-
+DEFINE_THREAD(clients_thread, pParam)
 {
 #ifndef WIN32
   /* Block SigTerm, SigInt, and SigPipe in threads.  */

Modified: trunk/myserver/tests/test_mutex.cpp
===================================================================
--- trunk/myserver/tests/test_mutex.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/tests/test_mutex.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -1,6 +1,6 @@
 /*
  MyServer
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -37,12 +37,7 @@
   int max;
 };
 
-#ifdef WIN32
-unsigned int __stdcall test_mutex_incrementer(void* pParam)
-#endif
-#ifdef HAVE_PTHREAD
-void* test_mutex_incrementer(void* pParam)
-#endif
+static DEFINE_THREAD(test_mutex_incrementer, pParam)
 {
   TestMutexThreadArg *arg = (TestMutexThreadArg*) pParam;
 

Modified: trunk/myserver/tests/test_socket.cpp
===================================================================
--- trunk/myserver/tests/test_socket.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/tests/test_socket.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -30,7 +30,7 @@
 
 using namespace std;
 
-void* testRecvClient ( void* );
+static DEFINE_THREAD(testRecvClient, pParam);
 
 class TestSocket : public CppUnit::TestFixture
 {
@@ -86,8 +86,10 @@
     
     CPPUNIT_ASSERT( obj->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
     
-    CPPUNIT_ASSERT( obj->setsockopt ( SOL_SOCKET, SO_REUSEADDR, (const char*) &optvalReuseAddr, sizeof(optvalReuseAddr) ) != -1 );
-    
+    CPPUNIT_ASSERT( obj->setsockopt ( SOL_SOCKET, SO_REUSEADDR,
+                                      (const char*) &optvalReuseAddr,
+                                      sizeof(optvalReuseAddr) ) != -1 );
+
     // If the port is used by another program, try a few others.
       if ( ( status = obj->bind ( &sockIn, sockInLen ) ) != 0 )
       while ( ++port < 28000 )
@@ -97,45 +99,35 @@
         if ( ( status = obj->bind ( &sockIn, sockInLen ) ) == 0 )
           break;
       }
-    
+
     CPPUNIT_ASSERT( status != -1 );
-    
+
     CPPUNIT_ASSERT( obj->listen ( 1 ) != -1 );
-    
+
     CPPUNIT_ASSERT_EQUAL( Thread::create ( &tid, testRecvClient, &port ), 0 );
-    
+
     Socket s = obj->accept ( &sockIn, &sockInLen );
-    
+
     status = int ( s.getHandle ( ) );
-    
+
     if ( status < 0 )
       CPPUNIT_ASSERT( status != -1 );
-    
+
     CPPUNIT_ASSERT( s.bytesToRead ( ) >= 0 );
-    
+
     int bufLen = 8;
     char buf[bufLen];
     memset ( buf, 0, bufLen );
-    
-    if ( ( status = s.recv ( buf, 1, 0 ) ) < 0 )
-      CPPUNIT_ASSERT( status >= 0 );
-      
-    CPPUNIT_ASSERT( s.bytesToRead ( ) > 0 );
-    
-    if ( ( status = s.recv ( buf, bufLen, 0, 2 ) ) < 0 && status != -2 )
-      CPPUNIT_ASSERT( status >= 0 || status == -2 );
-      
-    CPPUNIT_ASSERT( s.bytesToRead ( ) == 0 );
-    
-    if ( ( status = s.recv ( buf, bufLen, 0, 1 ) ) < 0 && status != -2 )
-      CPPUNIT_ASSERT( status >= 0 || status == -2 );
-    
-    // no other messages, must be -1
-    if ( ( status = s.recv ( buf, bufLen, 0 ) ) != -1)
-      CPPUNIT_ASSERT( status == -1 );
-    
+
+    status = s.recv ( buf, bufLen, 0 );
+
+    s.send ("a", 1, 0);
+
+    CPPUNIT_ASSERT( !strcmp (buf, "ehlo"));
+    CPPUNIT_ASSERT( status >= 0 || status == -2 );
+
     Thread::join ( tid );
-    
+
     CPPUNIT_ASSERT( obj->close ( ) != -1 );
   }
   
@@ -159,33 +151,33 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestSocket );
 
-void*
-testRecvClient ( void *arg )
+static DEFINE_THREAD(testRecvClient, pParam)
 {
   Socket *obj2 = new Socket;
-  
+
   int optvalReuseAddr = 1;
   char host[] = "localhost";
-  int port = *((int*)arg);
+  int port = *((int*)pParam);
   int status;
-  
+
   CPPUNIT_ASSERT( obj2->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
-  
+
   CPPUNIT_ASSERT( obj2->connect ( host, port ) != -1 );
-  
+
   int bufLen = 8;
   char buf[bufLen];
   memset ( buf, 0, bufLen );
   strcpy ( buf, "ehlo" );
-  
+
   CPPUNIT_ASSERT( obj2->send ( buf, strlen ( buf ), 0 ) != -1 );
-  
-  sleep ( 2 );
-  
+
+  /* To sync.  */
+  CPPUNIT_ASSERT( obj2->recv ( buf, bufLen, 0 ) != -1 );
+
   CPPUNIT_ASSERT( obj2->shutdown ( SD_BOTH ) != -1 );
- 
+
   CPPUNIT_ASSERT( obj2->close ( ) != -1 );
-  
+
   delete obj2;
   obj2 = NULL;
 }

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -82,10 +82,8 @@
 3K2VTrZpJnbMs7+i3w/ziC/cqWRVK6Rcq3bLzTXrig==\n\
 -----END CERTIFICATE-----\n";
 
+static DEFINE_THREAD(testSslRecvClient, pParam);
 
-
-void* testSslRecvClient ( void* ); //
-
 class TestSslSocket : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE( TestSslSocket );
@@ -186,8 +184,12 @@
     
     char buf[32] = {0};
     
-    CPPUNIT_ASSERT( sslObj->recv ( buf, sizeof(buf), 0 ) != -1 );
+    ret = sslObj->recv ( buf, sizeof(buf), 0 );
 
+    sslObj->send ( "a", 1, 0);
+
+    CPPUNIT_ASSERT(ret != -1 );
+
     CPPUNIT_ASSERT( sslObj->close ( ) != -1 );
 
     CPPUNIT_ASSERT( obj->close ( ) != -1 );
@@ -201,14 +203,13 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( TestSslSocket );
 
-void*
-testSslRecvClient ( void *arg )
+static DEFINE_THREAD(testSslRecvClient, pParam)
 {
   Socket *obj2 = new Socket;
   SslSocket *sslObj2 = NULL;
   int optvalReuseAddr = 1;
   char host[] = "localhost";
-  int port = *((int*)arg);
+  int port = *((int*)pParam);
   int cstatus = 0;
   MYSERVER_SOCKADDRIN sockIn = { 0 };
 
@@ -226,8 +227,13 @@
 
   char buf[] = "Works?\n";
 
-  CPPUNIT_ASSERT(sslObj2->rawSend ( buf, strlen(buf), 0 ) != -1 );
+  int ret = sslObj2->send ( buf, strlen(buf), 0 );
 
+  sslObj2->recv ( buf, 1, 0 );
+
+  CPPUNIT_ASSERT(ret != -1 );
+
+
   CPPUNIT_ASSERT( sslObj2->close ( ) != -1 );
 
   delete obj2;

Modified: trunk/myserver/tests/test_thread.cpp
===================================================================
--- trunk/myserver/tests/test_thread.cpp	2009-05-03 14:06:50 UTC (rev 3072)
+++ trunk/myserver/tests/test_thread.cpp	2009-05-03 15:36:39 UTC (rev 3073)
@@ -1,6 +1,6 @@
 /*
  MyServer
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -26,15 +26,7 @@
 #include <iostream>
 using namespace std;
 
-#ifdef WIN32
-#define ClientsThread_TYPE int
-unsigned int __stdcall test_thread(void* pParam)
-#endif
-
-#ifdef HAVE_PTHREAD
-#define ClientsThread_TYPE void*
-void* test_thread(void* pParam)
-#endif
+static DEFINE_THREAD(test_thread,pParam)
 {
   int *arg = (int*) pParam;
 
@@ -43,15 +35,7 @@
   return NULL;
 }
 
-#ifdef WIN32
-#define ClientsThread_TYPE int
-unsigned int __stdcall test_terminate_thread(void* pParam)
-#endif
-
-#ifdef HAVE_PTHREAD
-#define ClientsThread_TYPE void*
-void* test_terminate_thread(void* pParam)
-#endif
+static DEFINE_THREAD(test_terminate_thread, pParam)
 {
   int *arg = (int*) pParam;
 




From MAILER-DAEMON Sun May 03 11:36:48 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0dkG-0000jo-B2
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 11:36:48 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0dkE-0000jU-TU
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:46 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0dkD-0000it-N5
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:45 -0400
Received: from [199.232.76.173] (port=50008 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0dkD-0000ip-GZ
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:45 -0400
Received: from savannah.gnu.org ([199.232.41.3]:54543 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0dkD-0003IG-5J
	for myserver-commit@gnu.org; Sun, 03 May 2009 11:36:45 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0dkC-0005T1-Kf
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:36:44 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0dkC-0005Sx-DJ
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:36:44 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0dkC-0005Sx-DJ@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 15:36:44 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3074] Fixed a problem with GNUTLS usage in a
	multi-threaded environment.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 15:36:47 -0000

Revision: 3074
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3074
Author:   gscrivano
Date:     2009-05-03 15:36:44 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Fixed a problem with GNUTLS usage in a multi-threaded environment.

Modified Paths:
--------------
    trunk/myserver/configure.in
    trunk/myserver/src/base/ssl/ssl.cpp

Modified: trunk/myserver/configure.in
===================================================================
--- trunk/myserver/configure.in	2009-05-03 15:36:39 UTC (rev 3073)
+++ trunk/myserver/configure.in	2009-05-03 15:36:44 UTC (rev 3074)
@@ -98,6 +98,7 @@
 
 AC_CHECK_FUNCS(getpwnam, AC_DEFINE(GETPWNAM, 1, [Define if the getpwnam function is present]) )
 
+AC_CHECK_LIB(gcrypt, gcry_control, AC_DEFINE(GCRY_CONTROL, 1, [Define if the gcry_control function is present]))
 
 case "${host}" in
     *-*-mingw32*)

Modified: trunk/myserver/src/base/ssl/ssl.cpp
===================================================================
--- trunk/myserver/src/base/ssl/ssl.cpp	2009-05-03 15:36:39 UTC (rev 3073)
+++ trunk/myserver/src/base/ssl/ssl.cpp	2009-05-03 15:36:44 UTC (rev 3074)
@@ -20,6 +20,19 @@
 
 #include <string.h>
 
+extern "C"
+{
+#if GCRY_CONTROL
+
+#include <errno.h>
+#include <gcrypt.h>
+GCRY_THREAD_OPTION_PTHREAD_IMPL;
+
+#endif
+
+#include <pthread.h>
+}
+
 SslContext::SslContext()
 {
   context = 0;
@@ -32,65 +45,69 @@
 /*!
  *Initialize SSL on the virtual host.
  */
-int SslContext::initialize()
+int SslContext::initialize ()
 {
   context = 0;
   method = 0;
-  method = SSLv23_server_method();
-  context = SSL_CTX_new(method);
+  method = SSLv23_server_method ();
+  context = SSL_CTX_new (method);
 
-  if(!context)
+  if (!context)
     return -1;
   /*
    *The specified file doesn't exist.
    */
-  if(FilesUtility::fileExists(certificateFile.c_str()) == 0)
+  if (FilesUtility::fileExists(certificateFile.c_str()) == 0)
     return -1;
   
-  if(SSL_CTX_use_certificate_file (context, certificateFile.c_str (),SSL_FILETYPE_PEM) != 1)
+  if (SSL_CTX_use_certificate_file (context, certificateFile.c_str (),SSL_FILETYPE_PEM) != 1)
     return -1;
 
   /*
    *The specified file doesn't exist.
    */
-  if(FilesUtility::fileExists(privateKeyFile) == 0)
+  if (FilesUtility::fileExists(privateKeyFile) == 0)
     return -1;
 
-  if(SSL_CTX_use_PrivateKey_file(context, privateKeyFile.c_str(),
-                                   SSL_FILETYPE_PEM) != 1)
+  if (SSL_CTX_use_PrivateKey_file(context, privateKeyFile.c_str(),
+                                  SSL_FILETYPE_PEM) != 1)
     return -1;
 
   return 1;
 }  
 
-int SslContext::free()
+int SslContext::free ()
 {
   int ret = 0;
-  if(context)
+  if (context)
   {
-    SSL_CTX_free(context);
+    SSL_CTX_free (context);
     ret = 1;
     context = 0;
   }
   else 
     ret = 0;
-  certificateFile.assign("");
-  privateKeyFile.assign("");
+  certificateFile.assign ("");
+  privateKeyFile.assign ("");
   return ret;
 }
 
-void initializeSSL()
+void initializeSSL ()
 {
   static bool initialized = false;
-  if(!initialized)
+
+  if (!initialized)
   {
-    SSL_load_error_strings();
-    SSL_library_init();
+#if GCRY_CONTROL
+    gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+    gnutls_global_init ();
+#endif
+
     initialized = true;
   }
 }
 
-void cleanupSSL()
+void cleanupSSL ()
 {
 
 }




From MAILER-DAEMON Sun May 03 15:31:23 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0hPH-00081T-Ib
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 15:31:23 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0hPG-00081O-Cs
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:22 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0hPF-00081C-RG
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:22 -0400
Received: from [199.232.76.173] (port=40329 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0hPF-000819-Lr
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:21 -0400
Received: from savannah.gnu.org ([199.232.41.3]:54401 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0hPE-0004Pj-Mt
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:21 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0hPA-00056H-I8
	for myserver-commit@gnu.org; Sun, 03 May 2009 19:31:16 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0hPA-00056C-5w
	for myserver-commit@gnu.org; Sun, 03 May 2009 19:31:16 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0hPA-00056C-5w@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 19:31:16 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3075]
 Complex data structures can be defined in the virtual hosts configuration
 file too .
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 19:31:23 -0000

Revision: 3075
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3075
Author:   gscrivano
Date:     2009-05-03 19:31:15 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Complex data structures can be defined in the virtual hosts configuration file too.

Modified Paths:
--------------
    trunk/myserver/include/conf/security/security_token.h
    trunk/myserver/include/conf/vhost/vhost.h
    trunk/myserver/src/conf/security/security_token.cpp
    trunk/myserver/src/conf/vhost/vhost.cpp
    trunk/myserver/src/conf/vhost/vhost_manager.cpp

Modified: trunk/myserver/include/conf/security/security_token.h
===================================================================
--- trunk/myserver/include/conf/security/security_token.h	2009-05-03 15:36:44 UTC (rev 3074)
+++ trunk/myserver/include/conf/security/security_token.h	2009-05-03 19:31:15 UTC (rev 3075)
@@ -21,7 +21,7 @@
 
 #include "stdafx.h"
 #include <include/base/hash_map/hash_map.h>
-
+#include <include/conf/nodetree.h>
 #include <string>
 
 using namespace std;
@@ -52,7 +52,9 @@
   void reset();
 
   const char* getHashedData (const char* name, int domains, const char *def = NULL);
+  NodeTree<string>* getNodeTree (string& key, int domains, NodeTree<string>* def = NULL);
 
+
   string& getUser ()
   {
     return user;

Modified: trunk/myserver/include/conf/vhost/vhost.h
===================================================================
--- trunk/myserver/include/conf/vhost/vhost.h	2009-05-03 15:36:44 UTC (rev 3074)
+++ trunk/myserver/include/conf/vhost/vhost.h	2009-05-03 19:31:15 UTC (rev 3075)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
   MyServer
-  Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+  Copyright (C) 2002, 2003, 2004, 2006, 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
@@ -35,6 +35,7 @@
 #include <include/base/ssl/ssl.h>
 #include <include/connections_scheduler/listen_threads.h>
 #include <include/conf/vhost/ip.h>
+#include <include/conf/nodetree.h>
 
 using namespace std;
 typedef int (*NULL_REFERENCECB)(class Vhost*); 
@@ -140,6 +141,12 @@
   ~Vhost();
 
   const char* getHashedData(const char* name);
+
+  NodeTree<string>* getNodeTree (string& key)
+  {
+    return hashedData.get (key);
+  }
+
   void addHost(const char *, int);
   void removeHost(const char *);
   int areAllHostAllowed();
@@ -201,7 +208,11 @@
   MimeRecord* getLocationMime (string& loc){return locationsMime.get (loc);}
 private:
   VhostProtocolData*  protocolData;
-  HashMap<string, string*> hashedData;
+
+  list<NodeTree<string>*> hashedDataTrees;
+  HashMap<string, NodeTree<string>*> hashedData;
+
+
   NULL_REFERENCECB nullReferenceCb;
   Mutex refMutex;
   LogManager* logManager;

Modified: trunk/myserver/src/conf/security/security_token.cpp
===================================================================
--- trunk/myserver/src/conf/security/security_token.cpp	2009-05-03 15:36:44 UTC (rev 3074)
+++ trunk/myserver/src/conf/security/security_token.cpp	2009-05-03 19:31:15 UTC (rev 3075)
@@ -50,11 +50,63 @@
 
 }
 
+
 /*!
  *Get the value for the variable using the specified domains.
+ *\param key Variable name.
+ *\param def Default value.
+ *\param domains Domains where to look.  They are looked in this order:
+ *\li Security configuration file.
+ *\li Virtual host configuration file.
+ *\li Global security file.
+ *\li Default value.
+ */
+NodeTree<string>* SecurityToken::getNodeTree (string& key, int domains, NodeTree<string>* def)
+{
+/*
+  if (domains & MYSERVER_SECURITY_CONF)
+  {
+    string strName (key);
+    NodeTree<string>* ret = values.get (strName);
+
+    if (ret)
+      return ret->c_str ();
+  }
+
+  if (mimeRecord && (domains & MYSERVER_MIME_CONF))
+  {
+    string strName (key);
+    NodeTree<string>* ret = mimeRecord->getNodeTree (strName);
+
+    if (ret)
+      return ret;
+  }
+*/
+  if (vhost && (domains & MYSERVER_VHOST_CONF))
+  {
+    NodeTree<string>* ret = vhost->getNodeTree (key);
+
+    if (ret)
+      return ret;
+  }
+
+  if (server && (domains & MYSERVER_SERVER_CONF))
+  {
+    NodeTree<string>* ret = server->getNodeTree (key);
+
+    if (ret)
+      return ret;
+  }
+
+  return def;
+}
+
+
+/*!
+ *Get the value for the variable using the specified domains.
  *\param name Variable name.
  *\param def Default value.
- *\param domains Domains where to look.  They are looked in this order: 
+ *\param domains Domains where to look.  They are looked in this order:
  *\li Security configuration file.
  *\li Virtual host configuration file.
  *\li Global security file.
@@ -96,6 +148,5 @@
       return ret;
   }
 
-  
   return def;
 }

Modified: trunk/myserver/src/conf/vhost/vhost.cpp
===================================================================
--- trunk/myserver/src/conf/vhost/vhost.cpp	2009-05-03 15:36:44 UTC (rev 3074)
+++ trunk/myserver/src/conf/vhost/vhost.cpp	2009-05-03 19:31:15 UTC (rev 3075)
@@ -31,6 +31,7 @@
 #include <idna.h>
 #endif
 
+
 /*!
  *vhost costructor
  */
@@ -93,11 +94,14 @@
 {
   try
     {
-      HashMap<string, string*>::Iterator it = hashedData.begin();
-      for (;it != hashedData.end(); it++)
+      list<NodeTree<string>*>::iterator it = hashedDataTrees.begin ();
+      while (it != hashedDataTrees.end ())
         {
-          delete (*it);
+          delete *it;
+          it++;
         }
+
+      hashedDataTrees.clear ();
       hashedData.clear();
     }
   catch(...)
@@ -510,18 +514,9 @@
  */
 const char* Vhost::getHashedData(const char* name)
 {
-  
-  string *s;
+  NodeTree<string> *s = hashedData.get(name);
 
-  if(!name)
-    return NULL;
-
-  s = hashedData.get(name);
-
-  if(s)
-    return s->c_str();
-
-  return NULL;
+  return s ? s->getValue ()->c_str() : 0;
 }
   
 /*!

Modified: trunk/myserver/src/conf/vhost/vhost_manager.cpp
===================================================================
--- trunk/myserver/src/conf/vhost/vhost_manager.cpp	2009-05-03 15:36:44 UTC (rev 3074)
+++ trunk/myserver/src/conf/vhost/vhost_manager.cpp	2009-05-03 19:31:15 UTC (rev 3075)
@@ -20,6 +20,8 @@
 #include <include/server/server.h>
 #include <include/base/file/files_utility.h>
 
+#include <include/conf/xml_conf.h>
+
 /*!
  *VhostManager add function.
  *\param vh The virtual host to add.
@@ -353,6 +355,10 @@
     
       while(lcur)
         {
+          XmlConf::build (lcur,
+                          &vh->hashedDataTrees,
+                          &vh->hashedData);
+
           if(!xmlStrcmp(lcur->name, (const xmlChar *)"HOST"))
             {
               int useRegex = 0;
@@ -508,23 +514,7 @@
             {
               vh->setThrottlingRate((u_long)atoi((char*)lcur->children->content));
             }
-          else if(lcur->children && lcur->children->content)
-            {
-              string *old;
-              string *s = new string((const char*)lcur->children->content);
-              if(s == 0)
-                {
-                  parser.close();
-                  clean();
-                  return -1;
-                }
-              string keyValue((const char*)lcur->name);
-              old = vh->hashedData.put(keyValue, s);
-              if(old)
-                {
-                  delete old;
-                }            
-            }
+
           lcur = lcur->next;
         }//while(lcur)
       




From MAILER-DAEMON Sun May 03 15:31:28 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0hPM-00082k-Pq
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 15:31:28 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0hPL-00082f-Gf
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:27 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0hPK-00082L-AN
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:27 -0400
Received: from [199.232.76.173] (port=40334 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0hPK-00082I-3u
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:26 -0400
Received: from savannah.gnu.org ([199.232.41.3]:54403 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0hPI-0004QM-Dj
	for myserver-commit@gnu.org; Sun, 03 May 2009 15:31:25 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0hPF-0005Ab-N9
	for myserver-commit@gnu.org; Sun, 03 May 2009 19:31:21 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0hPF-0005AK-Fr
	for myserver-commit@gnu.org; Sun, 03 May 2009 19:31:21 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0hPF-0005AK-Fr@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 19:31:21 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3076] Default file names,
 that are used instead of a directory listing, 
 can be defined differently for every virtual host.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 19:31:27 -0000

Revision: 3076
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3076
Author:   gscrivano
Date:     2009-05-03 19:31:20 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Default file names, that are used instead of a directory listing, can be defined differently for every virtual host.

Modified Paths:
--------------
    trunk/myserver/documentation/directory_listing.texi
    trunk/myserver/src/protocol/http/http.cpp

Modified: trunk/myserver/documentation/directory_listing.texi
===================================================================
--- trunk/myserver/documentation/directory_listing.texi	2009-05-03 19:31:15 UTC (rev 3075)
+++ trunk/myserver/documentation/directory_listing.texi	2009-05-03 19:31:20 UTC (rev 3076)
@@ -6,14 +6,14 @@
 
 
 @subsection Default files
-In the @file{myserver.xml} file it is possible to set the default file
-to send instead of the directory content.
+In the @file{myserver.xml} main configuration or in the
+@file{virtualhosts.xml} file, it is possible to set a list of default
+file names to use instead of the directory content.
 
-Default files are defined using a list called @code{http.default_file}
-element and they are checked in the specified order until one is
-found.
-If a default file can't be found in the directory then its content is
-listed.
+Default file names are defined using a list called
+@code{http.default_file} and they are checked in the specified order
+until one is found.  If the file can't be found in the directory then
+the directory content is listed.
 
 @example
 <DEFINE name="http.default_file">

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp	2009-05-03 19:31:15 UTC (rev 3075)
+++ trunk/myserver/src/protocol/http/http.cpp	2009-05-03 19:31:20 UTC (rev 3076)
@@ -1708,8 +1708,11 @@
   int i;
   int ret;
   string key ("http.default_file");
-  NodeTree<string> *node = Server::getInstance()->getNodeTree (key);
+  NodeTree<string> *node = td->securityToken.getNodeTree (key,
+                                                          MYSERVER_VHOST_CONF |
+                                                          MYSERVER_SERVER_CONF, NULL);
 
+
   if (node)
     {
       list<NodeTree<string>*> *children = node->getChildren ();




From MAILER-DAEMON Sun May 03 16:44:59 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M0iYV-0004Xt-T8
	for mharc-myserver-commit@gnu.org; Sun, 03 May 2009 16:44:59 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M0iYU-0004WG-5q
	for myserver-commit@gnu.org; Sun, 03 May 2009 16:44:58 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M0iYT-0004VR-JR
	for myserver-commit@gnu.org; Sun, 03 May 2009 16:44:57 -0400
Received: from [199.232.76.173] (port=51651 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M0iYT-0004V1-9x
	for myserver-commit@gnu.org; Sun, 03 May 2009 16:44:57 -0400
Received: from savannah.gnu.org ([199.232.41.3]:58546 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M0iYS-0007oO-GQ
	for myserver-commit@gnu.org; Sun, 03 May 2009 16:44:56 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M0iYR-0002AM-MR
	for myserver-commit@gnu.org; Sun, 03 May 2009 20:44:55 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M0iYR-0002AF-EF
	for myserver-commit@gnu.org; Sun, 03 May 2009 20:44:55 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M0iYR-0002AF-EF@cvs.savannah.gnu.org>
Date: Sun, 03 May 2009 20:44:55 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3077] Removed unused .xsd files.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 03 May 2009 20:44:58 -0000

Revision: 3077
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3077
Author:   gscrivano
Date:     2009-05-03 20:44:54 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Removed unused .xsd files.

Removed Paths:
-------------
    trunk/myserver/binaries/MIMEtypes.xsd
    trunk/myserver/binaries/virtualhosts.xsd

Deleted: trunk/myserver/binaries/MIMEtypes.xsd
===================================================================
--- trunk/myserver/binaries/MIMEtypes.xsd	2009-05-03 19:31:20 UTC (rev 3076)
+++ trunk/myserver/binaries/MIMEtypes.xsd	2009-05-03 20:44:54 UTC (rev 3077)
@@ -1,62 +0,0 @@
-<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="MyServer" xmlns="MyServer" elementFormDefault="qualified">
-    
-    <!-- MIMETYPES NODE -->
-    <xs:element name="MIMETYPES">
-        
-        <!-- MIMETYPE NODE -->
-        <!-- add defaultAction="DENY" / ALLOW -->
-        <xs:element name="MIMETYPE">
-            <xs:complexType>
-                <xs:sequence>
-                  
-                    <xs:element name="EXT" type="xs:string" />
-                    <xs:element name="MIME" type="xs:string" />
-                    
-                    <xs:element name="CMD">
-                        <xs:simpleType>
-                            <xs:restriction base="xs:string">
-                                <xs:enumeration value="SEND" />
-                                <xs:enumeration value="RUNCGI" />
-                                <xs:enumeration value="RUNFASTCGI" />
-                                <xs:enumeration value="EXECUTEFASTCGI" />
-                                <xs:enumeration value="RUNSCGI" />
-                                <xs:enumeration value="EXECUTESCGI" />
-                                <xs:enumeration value="RUNMSCGI" />
-                                <xs:enumeration value="EXECUTE" />
-                                <xs:enumeration value="SENDLINK" />
-                                <xs:enumeration value="EXECUTEWINCGI" />
-                                <xs:enumeration value="RUNISAPI" />
-                                <xs:enumeration value="EXECUTEISAPI" />
-                            </xs:restriction>
-                        </xs:simpleType>
-                    </xs:element>
-
-                    <xs:element name="MANAGER" type="xs:string" />
-                    
-                    <xs:element name="ACTION" type="xs:string">
-                        <xs:simpleType>
-                            <xs:restriction base="xs:string">
-                                <xs:enumeration value="ALLOW" />
-                                <xs:enumeration value="DENY" />
-                            </xs:restriction>
-                        </xs:simpleType>
-                    </xs:element>
-                    
-                    <xs:element name="FILTER">
-                        <xs:simpleType>
-                            <xs:restriction base="xs:string">
-                                <xs:enumeration value="gzip" />
-                            </xs:restriction>
-                        </xs:simpleType>
-                    </xs:element>
-                                      
-                </xs:sequence>
-            
-            </xs:complexType>
-        </xs:element>
-
-      </xs:element>
-      
-      
-</xs:schema>
\ No newline at end of file

Deleted: trunk/myserver/binaries/virtualhosts.xsd
===================================================================
--- trunk/myserver/binaries/virtualhosts.xsd	2009-05-03 19:31:20 UTC (rev 3076)
+++ trunk/myserver/binaries/virtualhosts.xsd	2009-05-03 20:44:54 UTC (rev 3077)
@@ -1,53 +0,0 @@
-<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="MyServer" xmlns="MyServer" elementFormDefault="qualified">
-
-  
-    <!-- VHOSTS NODE -->
-    <xs:element name="VHOSTS">
-        
-        <!-- VHOST NODE -->
-        <xs:element name="VHOST">
-            <xs:complexType>
-                <xs:sequence>
-                    <xs:element name="NAME" type="xs:string" />
-                    <xs:element name="PORT" type="xs:integer" />
-                    <xs:element name="PROTOCOL" type="xs:string" />
-                    <xs:element name="DOCROOT" type="xs:string" />
-                    <xs:element name="SYSFOLDER" type="xs:string" />
-	    
-                    <xs:element name="ACCESSLOG" type="xs:string" />
-                    <!-- add type="combined" -->
-                    <!-- add cycle="yes" cycle_gzip="no" -->
-                    <xs:element name="ACCESSLOG" type="xs:string" />
-                    <xs:element name="WARNINGLOG" type="xs:string" />
-
-                    <!-- add useRegex="YES" -->
-                    <!-- add IPv6 regex -->
-                    <xs:element name="IP">
-                        <xs:simpleType>
-                            <xs:restriction base="xs:string">
-                                <xs:pattern value="\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" />
-                            </xs:restriction>
-                        </xs:simpleType>
-                    </xs:element>
-
-                    <xs:element name="HOST" type="xs:string" />
-                    <xs:element name="ALLOW_CGI" type="xs:string" />
-                    <xs:element name="ALLOW_FASTCGI" type="xs:string" />
-                    <xs:element name="ALLOW_SCGI" type="xs:string" />
-                    <xs:element name="ALLOW_ISAPI" type="xs:string" />
-                    <xs:element name="ALLOW_MSCGI" type="xs:string" />
-                    <xs:element name="ALLOW_WINCGI" type="xs:string" />
-                    <xs:element name="ALLOW_SEND_LINK" type="xs:string" />
-                    <xs:element name="ALLOW_EXTERNAL_COMMANDS" type="xs:string" />
-                    <xs:element name="ALLOW_SEND_FILE" type="xs:string" />
-	    
-                    <xs:element name="FOLLOW_LINKS" type="xs.string" />
-                </xs:sequence>
-            </xs:complexType>
-        </xs:element>
-
-      </xs:element>
-      
-      
-</xs:schema>




From MAILER-DAEMON Mon May 04 14:34:20 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M12zb-0007s5-Uu
	for mharc-myserver-commit@gnu.org; Mon, 04 May 2009 14:34:20 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M12zZ-0007ra-PK
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:17 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M12zX-0007rO-Ac
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:16 -0400
Received: from [199.232.76.173] (port=40448 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M12zX-0007rL-5k
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:15 -0400
Received: from savannah.gnu.org ([199.232.41.3]:43860 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M12zW-00011S-RN
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:14 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M12zV-00014e-RX
	for myserver-commit@gnu.org; Mon, 04 May 2009 18:34:14 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M12zV-00013u-3B
	for myserver-commit@gnu.org; Mon, 04 May 2009 18:34:13 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M12zV-00013u-3B@cvs.savannah.gnu.org>
Date: Mon, 04 May 2009 18:34:13 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3078] Now a node can store attributes.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 04 May 2009 18:34:18 -0000

Revision: 3078
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3078
Author:   gscrivano
Date:     2009-05-04 18:34:12 +0000 (Mon, 04 May 2009)
Log Message:
-----------
Now a node can store attributes.

Modified Paths:
--------------
    trunk/myserver/src/conf/nodetree.cpp
    trunk/myserver/src/conf/xml_conf.cpp
    trunk/myserver/tests/test_nodetree.cpp

Modified: trunk/myserver/src/conf/nodetree.cpp
===================================================================
--- trunk/myserver/src/conf/nodetree.cpp	2009-05-03 20:44:54 UTC (rev 3077)
+++ trunk/myserver/src/conf/nodetree.cpp	2009-05-04 18:34:12 UTC (rev 3078)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <string>
+#include <map>
 
 using namespace std;
 
@@ -30,12 +31,14 @@
   {
     value = NULL;
     children = NULL;
+    attrs = NULL;
   }
 
   NodeTree (T& v)
   {
     value = new T (v);
     children = NULL;
+    attrs = NULL;
   }
 
   ~NodeTree ()
@@ -52,9 +55,10 @@
       }
 
     if (value)
-      {
-        delete value;
-      }
+      delete value;
+
+    if (attrs)
+      delete attrs;
   }
 
   void setValue (T *v)
@@ -70,6 +74,29 @@
     children->push_back (child);
   }
 
+  void addAttr (string &name, T value)
+  {
+    if (attrs == NULL)
+      attrs = new list<pair<string, T> > ();
+
+    attrs->push_back (pair<string, T> (name, value));
+  }
+
+  T* getAttr (string &name)
+  {
+    if (attrs == NULL)
+      return NULL;
+    for (typename list<pair<string, T> >::iterator it = attrs->begin ();
+         it != attrs->end ();
+         it++)
+      {
+        if ((*it).first.compare (name) == 0)
+          return &((*it).second);
+      }
+
+    return NULL;
+  }
+
   bool isLeaf ()
   {
     return children == NULL;
@@ -86,5 +113,6 @@
   }
 protected:
   list<NodeTree<T>*> *children;
+  list<pair<string, T> > *attrs;
   T *value;
 };

Modified: trunk/myserver/src/conf/xml_conf.cpp
===================================================================
--- trunk/myserver/src/conf/xml_conf.cpp	2009-05-03 20:44:54 UTC (rev 3077)
+++ trunk/myserver/src/conf/xml_conf.cpp	2009-05-04 18:34:12 UTC (rev 3078)
@@ -48,6 +48,7 @@
   for(; lcur; lcur = lcur->next)
     if (lcur->name && !xmlStrcmp (lcur->name, (const xmlChar *)"DEFINE"))
       {
+        NodeTree<string> *node = new NodeTree<string> ();
         const char *name = NULL;
         const char *value = NULL;
 
@@ -56,14 +57,19 @@
             if (!xmlStrcmp (attrs->name, (const xmlChar *)"name") && 
                 attrs->children && attrs->children->content)
               name = (const char*)attrs->children->content;
-            
-            if (!xmlStrcmp (attrs->name, (const xmlChar *)"value") && 
+            else if (!xmlStrcmp (attrs->name, (const xmlChar *)"value") && 
                 attrs->children && attrs->children->content)
               value = (const char*)attrs->children->content;
+            else
+              {
+                string attr ((const char*)attrs->name);
+                string valueAttr ((const char*)attrs->children->content);
+                node->addAttr (attr, valueAttr);
+              }
           }
 
         string *v = value ? new string((const char*)value) : NULL;
-        NodeTree<string> *node = new NodeTree<string> ();
+
         node->setValue (v);
  
         if(name)

Modified: trunk/myserver/tests/test_nodetree.cpp
===================================================================
--- trunk/myserver/tests/test_nodetree.cpp	2009-05-03 20:44:54 UTC (rev 3077)
+++ trunk/myserver/tests/test_nodetree.cpp	2009-05-04 18:34:12 UTC (rev 3078)
@@ -28,39 +28,55 @@
 {
   CPPUNIT_TEST_SUITE( TestNodeTree );
   CPPUNIT_TEST( testCreateDestroy );
+  CPPUNIT_TEST( testAttributes );
   CPPUNIT_TEST_SUITE_END();
 
 
 public:
 
+  NodeTree<string> *node;
+
   void setUp()
   {
-
+    node = new NodeTree<string> ();
   }
 
   void tearDown()
   {
+    delete node;
+  }
 
+  void testAttributes ()
+  {
+    string name ("my_attrib");
+    string value ("foo.bar");
+    string *value2;
+
+    value2 = node->getAttr (name);
+    CPPUNIT_ASSERT_EQUAL (value2, (string*)NULL);
+
+    node->addAttr (name, value);
+
+    value2 = node->getAttr (name);
+    CPPUNIT_ASSERT (value2);
+
+    CPPUNIT_ASSERT_EQUAL (value2->compare (value), 0);
   }
 
   void testCreateDestroy ()
   {
-    NodeTree<string> *c = new NodeTree<string> ();
-
     for (int j = 0; j < 5; j++)
       {
-        NodeTree<string> *cc = new NodeTree<string> ();
-        c->addChild (cc);
+        NodeTree<string> *child = new NodeTree<string> ();
+        node->addChild (child);
         for (int i = 0; i < 10; i++)
           {
             string s = "just a string";
-            cc->addChild (new NodeTree<string> (s));
+            child->addChild (new NodeTree<string> (s));
           }
       }
 
-    CPPUNIT_ASSERT_EQUAL (countLeafNodes (c), 50);
-
-    delete c;
+    CPPUNIT_ASSERT_EQUAL (countLeafNodes (node), 50);
   }
 
 protected:




From MAILER-DAEMON Mon May 04 14:34:22 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M12ze-0007tt-4a
	for mharc-myserver-commit@gnu.org; Mon, 04 May 2009 14:34:22 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M12zc-0007sA-3p
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:20 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M12za-0007ri-LP
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:19 -0400
Received: from [199.232.76.173] (port=40449 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M12za-0007rf-HC
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:18 -0400
Received: from savannah.gnu.org ([199.232.41.3]:43862 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M12za-00011g-45
	for myserver-commit@gnu.org; Mon, 04 May 2009 14:34:18 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M12zZ-00017S-Do
	for myserver-commit@gnu.org; Mon, 04 May 2009 18:34:17 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M12zZ-00017N-4P
	for myserver-commit@gnu.org; Mon, 04 May 2009 18:34:17 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M12zZ-00017N-4P@cvs.savannah.gnu.org>
Date: Mon, 04 May 2009 18:34:17 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3079] Processes servers list are saved using a
 `NodeTree' structure inside the main configuration file.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 04 May 2009 18:34:20 -0000

Revision: 3079
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3079
Author:   gscrivano
Date:     2009-05-04 18:34:16 +0000 (Mon, 04 May 2009)
Log Message:
-----------
Processes servers list are saved using a `NodeTree' structure inside the main configuration file.

Modified Paths:
--------------
    trunk/myserver/documentation/process_security.texi
    trunk/myserver/src/base/process/process_server_manager.cpp

Modified: trunk/myserver/documentation/process_security.texi
===================================================================
--- trunk/myserver/documentation/process_security.texi	2009-05-04 18:34:12 UTC (rev 3078)
+++ trunk/myserver/documentation/process_security.texi	2009-05-04 18:34:16 UTC (rev 3079)
@@ -67,25 +67,22 @@
 FastCGI/SCGI configuration inside MIME types by its name.
 
 @example
-<PROCESS_SERVER>
-        <NAME>/opt/bin/fastcgi_server</NAME>
-        <DOMAIN>fastcgi</DOMAIN>
-        <HOST>localhost</HOST>
-        <PORT>2010</PORT>
-        <LOCAL>yes</LOCAL>
-        <UID>1000</UID>
-        <GID>1000</GID>
-</PROCESS_SERVER>
+<!-- Inside myserver.xml.  -->
+<DEFINE name="process_servers.list">
+  <DEFINE server="/opt/bin/fastcgi_server" domain="fastcgi"
+          host="localhost" port="2010" local="yes" uid="1000"
+          gid="1000"/>
+</DEFINE>
 @end example
 
 In the previous example the FastCGI server
 @code{/opt/bin/fastcgi_server} is created.  The @code{domain} must be
 "fastcgi" or "scgi", depending on the specific protocol to use.
-@code{LOCAL} specifies if the server is handled by myserver or it is
+@code{local} specifies if the server is handled by myserver or it is
 already running; in the former case, myserver will simply access and
 use it.
-If the server is not local then the @code{name} is a simple label that
-can be used by a MIME type trought @code{param} to access it.
+If the server is not local then the @code{server} is a simple label
+that can be used by a MIME type trought @code{param} to access it.
 
 It is possible to specify a different uid/gid for the local server
 process and don't maintain the original myserver process privileges.
@@ -96,14 +93,9 @@
 registers it on the @code{fcgi} extension:
 
 @example
-<!-- Inside myserver.xml.  -->
-<PROCESS_SERVER>
-        <NAME>a_remote_server</NAME>
-        <DOMAIN>fastcgi</DOMAIN>
-        <HOST>foo</HOST>
-        <PORT>2010</PORT>
-        <LOCAL>NO</LOCAL>
-</PROCESS_SERVER>
+<DEFINE name="process_servers.list">
+  <DEFINE server="a_remote_server" domain="fastcgi" host="foo" port="2010" local="no"/>
+</DEFINE>
 
 <!-- Inside MIMEtypes.xml.  -->
 <MIME mime="text/html" handler="RUNFASTCGI" param="a_remote_server">

Modified: trunk/myserver/src/base/process/process_server_manager.cpp
===================================================================
--- trunk/myserver/src/base/process/process_server_manager.cpp	2009-05-04 18:34:12 UTC (rev 3078)
+++ trunk/myserver/src/base/process/process_server_manager.cpp	2009-05-04 18:34:16 UTC (rev 3079)
@@ -42,87 +42,95 @@
 /*!
  *Load the class.
  */
-void ProcessServerManager::load()
+void ProcessServerManager::load ()
 {
-  XmlParser* conf = ::Server::getInstance()->getConfiguration();
-  xmlNodePtr node =  xmlDocGetRootElement(conf->getDoc())->xmlChildrenNode;
-  for(;node; node = node->next)
-  {
-    string domain;
-    string host;
-    string name;
-    string port;
-    string local;
-    bool localBool = true;
-    int uid = 0;
-    int gid = 0;
-    xmlNodePtr node2;
-    if (strcmpi((const char*)node->name, "PROCESS_SERVER"))
-      continue;
-    node2 = node->children;
-    for (;node2; node2 = node2->next)
+ 
+  string key ("process_servers.list");
+  NodeTree<string> *node = ::Server::getInstance()->getNodeTree (key);
+
+  if (node == NULL)
+    return;
+
+  string serverKey ("server");
+  string domainKey ("domain");
+  string hostKey ("host");
+  string portKey ("port");
+  string localKey ("local");
+  string uidKey ("uid");
+  string gidKey ("gid");
+
+  list<NodeTree<string>*> *children = node->getChildren ();
+
+  for(list<NodeTree<string>*>::iterator it = children->begin ();
+      it != children->end ();
+      it++)
     {
-      if (!node2->children || !node2->children->content)
-        continue;
-      
-      if (!strcmpi ((const char*)node2->name, "NAME"))
-        name.assign ((const char*) node2->children->content);
+      string domain;
+      string host;
+      string name;
+      string port;
+      string local;
+      bool localBool = true;
+      int uid = 0;
+      int gid = 0;
 
-      if (!strcmpi ((const char*)node2->name, "HOST"))
-        host.assign ((const char*) node2->children->content);
+      NodeTree<string>* n = *it;
 
-      if (!strcmpi ((const char*)node2->name, "DOMAIN"))
-        domain.assign ((const char*) node2->children->content);
+      if (n->getAttr (serverKey))
+        name.assign (*n->getAttr (serverKey));
 
-      if (!strcmpi ((const char*)node2->name, "PORT"))
-        port.assign ((const char*) node2->children->content);
+      if (n->getAttr (domainKey))
+        domain.assign (*n->getAttr (domainKey));
 
-      if (!strcmpi ((const char*)node2->name, "LOCAL"))
-        local.assign ((const char*) node2->children->content);
+      if (n->getAttr (hostKey))
+        host.assign (*n->getAttr (hostKey));
 
-      if (!strcmpi ((const char*)node2->name, "UID"))
-        uid = atoi ((const char*) node2->children->content);
+      if (n->getAttr (portKey))
+        port.assign (*n->getAttr (portKey));
 
-      if (!strcmpi ((const char*)node2->name, "GID"))
-        gid = atoi ((const char*) node2->children->content);
-    }
-    
-    if (!local.compare("YES") || !local.compare("yes"))
-      localBool = true;
-    else
-      localBool = false;
+      if (n->getAttr (localKey))
+        local.assign (*n->getAttr (localKey));
 
-    if (name.size () && domain.size ())
-    {
-      u_short portN = 0;
+      if (n->getAttr (uidKey))
+        uid = atoi (n->getAttr (uidKey)->c_str ());
 
-      if(port.size ())
-        portN = atoi (port.c_str());
+      if (n->getAttr (gidKey))
+        gid = atoi (n->getAttr (gidKey)->c_str ());
 
-      if (localBool)
-        runAndAddServer (domain.c_str(), name.c_str(), uid, gid, portN);
+      if (!local.compare("YES") || !local.compare("yes"))
+        localBool = true;
       else
-      {
-        if (portN)
-          addRemoteServer (domain.c_str(), name.c_str(), host.c_str(), portN);
-        else
+        localBool = false;
+
+      if (name.size () && domain.size ())
         {
-          ostringstream msg;
-          msg << "Error: incomplete remote PROCESS_SERVER block, " 
-              << domain  << ":" << name << " needs a port";
-          ::Server::getInstance ()->logWriteln(msg.str().c_str(), MYSERVER_LOG_MSG_ERROR);
+          u_short portN = 0;
+
+          if(port.size ())
+            portN = atoi (port.c_str());
+
+          if (localBool)
+            runAndAddServer (domain.c_str(), name.c_str(), uid, gid, portN);
+          else
+            {
+              if (portN)
+                addRemoteServer (domain.c_str(), name.c_str(), host.c_str(), portN);
+              else
+                {
+                  ostringstream msg;
+                  msg << "Error: incomplete remote PROCESS_SERVER block, "
+                      << domain  << ":" << name << " needs a port";
+                  ::Server::getInstance ()->logWriteln (msg.str ().c_str (), MYSERVER_LOG_MSG_ERROR);
+                }
+            }
         }
-      }
-
+      else
+        {
+          const char *msg = "Error: incomplete PROCESS_SERVER block";
+          ::Server::getInstance ()->logWriteln (msg, MYSERVER_LOG_MSG_ERROR);
+        }
     }
-    else
-    {
-      const char *msg = "Error: incomplete PROCESS_SERVER block";
-      ::Server::getInstance ()->logWriteln(msg, MYSERVER_LOG_MSG_ERROR);
-    }
 
-  }
-
 }
 
 /*!




From MAILER-DAEMON Mon May 04 16:37:03 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M14uN-0006oE-Gr
	for mharc-myserver-commit@gnu.org; Mon, 04 May 2009 16:37:03 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M14uM-0006o5-NE
	for myserver-commit@gnu.org; Mon, 04 May 2009 16:37:02 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M14uL-0006nk-C3
	for myserver-commit@gnu.org; Mon, 04 May 2009 16:37:02 -0400
Received: from [199.232.76.173] (port=57555 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M14uL-0006nb-6Y
	for myserver-commit@gnu.org; Mon, 04 May 2009 16:37:01 -0400
Received: from savannah.gnu.org ([199.232.41.3]:44508 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M14uK-0004bP-Ps
	for myserver-commit@gnu.org; Mon, 04 May 2009 16:37:00 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M14uK-0006C6-0j
	for myserver-commit@gnu.org; Mon, 04 May 2009 20:37:00 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M14uJ-0006Bj-IZ
	for myserver-commit@gnu.org; Mon, 04 May 2009 20:36:59 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M14uJ-0006Bj-IZ@cvs.savannah.gnu.org>
Date: Mon, 04 May 2009 20:36:59 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3080] Simple ip-hashing based load balancing for
 SCGI/FastCGI servers, 
 a set of equivalent servers is kept referred by the same name.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 04 May 2009 20:37:02 -0000

Revision: 3080
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3080
Author:   gscrivano
Date:     2009-05-04 20:36:59 +0000 (Mon, 04 May 2009)
Log Message:
-----------
Simple ip-hashing based load balancing for SCGI/FastCGI servers, a set of equivalent servers is kept referred by the same name.

Modified Paths:
--------------
    trunk/myserver/include/base/process/process_server_manager.h
    trunk/myserver/src/base/process/process_server_manager.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/http_handler/scgi/scgi.cpp

Modified: trunk/myserver/include/base/process/process_server_manager.h
===================================================================
--- trunk/myserver/include/base/process/process_server_manager.h	2009-05-04 18:34:16 UTC (rev 3079)
+++ trunk/myserver/include/base/process/process_server_manager.h	2009-05-04 20:36:59 UTC (rev 3080)
@@ -29,6 +29,7 @@
 #include <include/base/hash_map/hash_map.h>
 #include <string>
 
+#include <vector>
 using namespace std;
 
 class ProcessServerManager
@@ -66,7 +67,7 @@
 	struct ServerDomain
 	{
 		string domainName;
-		HashMap<string, Server*> servers;
+		HashMap<string, vector<Server*>* > servers;
 		void (*clear)(Server*);
 		ServerDomain()
 		{
@@ -77,13 +78,12 @@
 	ServerDomain* createDomain(const char* name);
 	ServerDomain* getDomain(const char* name);
 	void clear();
-	Server* getServer(const char* domain, const char* name);
+	Server* getServer(const char* domain, const char* name, int seed = 0);
 	ProcessServerManager();
 	~ProcessServerManager();
 	int connect(Socket* sock, Server* server);
 	void setMaxServers(int max){maxServers = max;}
 	int getMaxServers(){return maxServers;}
-	void removeServer(const char* domain, const char* name);
 	void removeDomain(const char* domain);
 	int domainServers(const char* domain);
 	void load();

Modified: trunk/myserver/src/base/process/process_server_manager.cpp
===================================================================
--- trunk/myserver/src/base/process/process_server_manager.cpp	2009-05-04 18:34:16 UTC (rev 3079)
+++ trunk/myserver/src/base/process/process_server_manager.cpp	2009-05-04 20:36:59 UTC (rev 3080)
@@ -152,7 +152,7 @@
  *\param name The domain name.
  */
 ProcessServerManager::ServerDomain* 
-ProcessServerManager::createDomain(const char* name)
+ProcessServerManager::createDomain (const char* name)
 {
   ServerDomain* ret;
 
@@ -182,23 +182,31 @@
 
   it = domains.begin();
 
-  for(;it != domains.end(); it++)
-  {
-    ServerDomain *sd = *it;
-    HashMap<string, Server*>::Iterator server = sd->servers.begin();
-
-    for(;server != sd->servers.end(); server++)
+  for (;it != domains.end(); it++)
     {
-      if((*it)->clear)
-      {
-        (*it)->clear(*server);
-      }
-      if((*server)->isLocal)
-        nServers--;
-      (*server)->terminate();
-      delete (*server);
-    }
-    delete (*it);
+      ServerDomain *sd = *it;
+      HashMap<string, vector<Server*>*>::Iterator server = sd->servers.begin();
+
+      for (; server != sd->servers.end (); server++)
+        {
+          for (vector<Server*>::iterator it = (*server)->begin ();
+               it != (*server)->end ();
+               it++)
+            {
+              Server *s = *it;
+
+              if(s->isLocal)
+                nServers--;
+
+              if (sd->clear)
+                sd->clear(s);
+
+              s->terminate();
+              delete s;
+            }
+          delete (*server);
+        }
+      delete (*it);
   }
   domains.clear();
   mutex.unlock();
@@ -208,16 +216,22 @@
  *Get a server is running by its domain and name.
  *\param domain The domain name.
  *\param name The server name name.
+ *\param seed Random seed to use for choosing a server.
  */
 ProcessServerManager::Server* 
-ProcessServerManager::getServer(const char* domain, const char* name)
+ProcessServerManager::getServer(const char* domain, const char* name, int seed)
 {
   ServerDomain* sd;
   Server* s;
+
   mutex.lock();
   sd = domains.get(domain);
+
   if(sd)
-    s = sd->servers.get(name);
+    {
+      vector<Server*> *slist = sd->servers.get (name);
+      s = slist->at (seed % slist->size ());
+    }
   else
     s = 0;
   
@@ -251,19 +265,21 @@
 void ProcessServerManager::addServer(ProcessServerManager::Server* server, 
                                      const char* domain, const char* name)
 {
-  ServerDomain* sd = createDomain(domain);
-  Server* old;
-  string str(name);
+  ServerDomain *sd = createDomain (domain);
+  Server *old;
+  string strName (name);
 
   mutex.lock();
+  vector<Server*>* slist = sd->servers.get (strName);
 
-  old = sd->servers.put(str, server);
+  if (slist == NULL)
+    {
+      slist = new vector<Server*> ();
+      sd->servers.put (strName, slist);
+    }
 
-  if(old)
-  {
-    old->terminate();
-    delete old;
-  }
+  slist->push_back (server);
+
   mutex.unlock();
 }
 
@@ -275,16 +291,16 @@
  *\param port The port number to use for the connection.
  */
 ProcessServerManager::Server* 
-ProcessServerManager::addRemoteServer(const char* domain, const char* name, 
-                                      const char* host, u_short port)
+ProcessServerManager::addRemoteServer (const char* domain, const char* name,
+                                       const char* host, u_short port)
 {
   Server* server = new Server;
-  server->path.assign(name);
-  server->host.assign(host);
+  server->path.assign (name);
+  server->host.assign (host);
   server->port = port;
   server->isLocal = false;
 
-  addServer(server, domain, name);
+  addServer (server, domain, name);
   return server;
 }
 
@@ -292,62 +308,40 @@
  *Remove a domain by its name.
  *\param domain The domain name.
  */
-void ProcessServerManager::removeDomain(const char* domain)
+void ProcessServerManager::removeDomain (const char* domain)
 {
   ServerDomain *sd;
   HashMap<string, Server*>::Iterator server;
 
   mutex.lock();
 
-  sd = getDomain(domain);
-  if(sd)
-  {
-    server = sd->servers.begin();
-    
-    for(;server != sd->servers.end(); server++)
+  sd = getDomain (domain);
+
+  if (sd)
     {
-      if(sd->clear)
-      {
-        sd->clear(*server);
-      }
-      if((*server)->isLocal)
-        nServers--;
-      (*server)->terminate();
-      delete (*server);
-    }
-    delete sd;
-  }
+      HashMap<string, vector<Server*>*>::Iterator server = sd->servers.begin ();
 
-  mutex.unlock();
-}
+      for (; server != sd->servers.end (); server++)
+        {
+          for (vector<Server*>::iterator it = (*server)->begin ();
+               it != (*server)->end ();
+               it++)
+            {
+              Server *s = *it;
 
-/*!
- *Remove a server by its domain and name.
- *\param domain The server domain.
- *\param name The server name.
- */
-void ProcessServerManager::removeServer(const char* domain, const char* name)
-{
-  ServerDomain* sd;
-  Server* server;
-  mutex.lock();
-  sd = domains.get(domain);
-  if(sd)
-    server = sd->servers.remove(name);
-  else
-    server = 0;
-  
-  if(server)
-  {
-    if(server->isLocal)
-    {
-      if(sd->clear)
-        sd->clear(server);
-      server->terminate();
-      nServers--;
+              if(s->isLocal)
+                nServers--;
+
+              if (sd->clear)
+                sd->clear(s);
+
+              s->terminate ();
+              delete s;
+            }
+          delete (*server);
+        }
+      delete sd;
     }
-    delete server;
-  }
 
   mutex.unlock();
 }

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-04 18:34:16 UTC (rev 3079)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-04 20:36:59 UTC (rev 3080)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 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
@@ -512,8 +512,17 @@
 FastCgiServer* FastCgi::runFcgiServer(FcgiContext* context, 
                                       const char* path)
 {
-  FastCgiServer* server =  processServerManager->getServer(SERVERS_DOMAIN, 
-                                                          path);
+  /* This method needs a better home (and maybe better code).
+   * Compute a simple hash from the IP address.  */
+  const char *ip = context->td->connection->getIpAddr();
+  int seed = 13;
+  for (const char *c = ip; c; c++)
+    seed = *c * 21 + seed;
+
+  FastCgiServer* server = processServerManager->getServer(SERVERS_DOMAIN,
+                                                          path,
+                                                          seed);
+
   if(server)
     return server;
 

Modified: trunk/myserver/src/http_handler/scgi/scgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-04 18:34:16 UTC (rev 3079)
+++ trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-04 20:36:59 UTC (rev 3080)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 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
@@ -538,8 +538,16 @@
 ScgiServer* Scgi::runScgiServer(ScgiContext* context, 
                                 const char* path)
 {
+  /* This method needs a better home (and maybe better code).
+   * Compute a simple hash from the IP address.  */
+  const char *ip = context->td->connection->getIpAddr();
+  int seed = 13;
+  for (const char *c = ip; c; c++)
+    seed = *c * 21 + seed;
+
   ScgiServer* server =  processServerManager->getServer(SERVERS_DOMAIN, 
-                                                        path);
+                                                        path,
+                                                        seed);
   if(server)
     return server;
 




From MAILER-DAEMON Tue May 05 14:30:04 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M1PP2-0002hu-18
	for mharc-myserver-commit@gnu.org; Tue, 05 May 2009 14:30:04 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M1PP0-0002ho-KC
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:02 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M1POz-0002hT-FT
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:02 -0400
Received: from [199.232.76.173] (port=33654 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M1POz-0002hQ-AC
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:01 -0400
Received: from savannah.gnu.org ([199.232.41.3]:35304 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M1POy-0001iG-Ro
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:01 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M1POy-0000fg-8Q
	for myserver-commit@gnu.org; Tue, 05 May 2009 18:30:00 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M1POx-0000fG-U7
	for myserver-commit@gnu.org; Tue, 05 May 2009 18:30:00 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M1POx-0000fG-U7@cvs.savannah.gnu.org>
Date: Tue, 05 May 2009 18:29:59 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3081] Do not use XML data to store data but
	access it trought `NodeTree'.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 05 May 2009 18:30:02 -0000

Revision: 3081
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3081
Author:   gscrivano
Date:     2009-05-05 18:29:59 +0000 (Tue, 05 May 2009)
Log Message:
-----------
Do not use XML data to store data but access it trought `NodeTree'.

Modified Paths:
--------------
    trunk/myserver/include/http_handler/fastcgi/fastcgi.h
    trunk/myserver/include/http_handler/http_dir/http_dir.h
    trunk/myserver/include/http_handler/http_file/http_file.h
    trunk/myserver/include/http_handler/isapi/isapi.h
    trunk/myserver/include/http_handler/mscgi/mscgi.h
    trunk/myserver/include/http_handler/scgi/scgi.h
    trunk/myserver/include/protocol/http/http_data_handler.h
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/http_handler/http_dir/http_dir.cpp
    trunk/myserver/src/http_handler/http_file/http_file.cpp
    trunk/myserver/src/http_handler/isapi/isapi.cpp
    trunk/myserver/src/http_handler/mscgi/mscgi.cpp
    trunk/myserver/src/http_handler/scgi/scgi.cpp
    trunk/myserver/src/plugin/plugins_manager.cpp
    trunk/myserver/src/protocol/http/http.cpp
    trunk/myserver/src/protocol/http/http_data_handler.cpp

Modified: trunk/myserver/include/http_handler/fastcgi/fastcgi.h
===================================================================
--- trunk/myserver/include/http_handler/fastcgi/fastcgi.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/http_handler/fastcgi/fastcgi.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -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
@@ -163,7 +163,7 @@
   static int getTimeout ();
   static void setTimeout (int);
 	FastCgi ();
-	static int load (XmlParser*);
+	static int load ();
 	virtual int send (HttpThreadContext* td, ConnectionPtr connection,
                    const char* scriptpath, const char *cgipath, 
                    int execute = 0, int onlyHeader = 0);

Modified: trunk/myserver/include/http_handler/http_dir/http_dir.h
===================================================================
--- trunk/myserver/include/http_handler/http_dir/http_dir.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/http_handler/http_dir/http_dir.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 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
@@ -37,8 +37,8 @@
     off_t size;
   };
 
-  static int load(XmlParser*);
-  static int unLoad();
+  static int load ();
+  static int unLoad ();
   virtual int send(HttpThreadContext*, ConnectionPtr s, 
                    const char *filenamePath, const char* cgi,
                    int execute = 0, int OnlyHeader = 0); 

Modified: trunk/myserver/include/http_handler/http_file/http_file.h
===================================================================
--- trunk/myserver/include/http_handler/http_file/http_file.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/http_handler/http_file/http_file.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -28,9 +28,9 @@
 class HttpFile  : public HttpDataHandler
 {
 public:
-  static int load(XmlParser*);
-  static int unLoad();
-  virtual int send(HttpThreadContext*, ConnectionPtr s, 
+  static int load ();
+  static int unLoad ();
+  virtual int send (HttpThreadContext*, ConnectionPtr s, 
                    const char *filenamePath, const char* cgi,
                    int execute = 0, int OnlyHeader = 0); 
   HttpFile();

Modified: trunk/myserver/include/http_handler/isapi/isapi.h
===================================================================
--- trunk/myserver/include/http_handler/isapi/isapi.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/http_handler/isapi/isapi.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 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
@@ -149,7 +149,7 @@
 #endif  
   Isapi();
   static Mutex *isapiMutex;
-  static int load(XmlParser*);
+  static int load ();
   static int unLoad();
   static void setTimeout(u_long);
   static u_long getTimeout();

Modified: trunk/myserver/include/http_handler/mscgi/mscgi.h
===================================================================
--- trunk/myserver/include/http_handler/mscgi/mscgi.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/http_handler/mscgi/mscgi.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 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
@@ -56,7 +56,7 @@
 	/*!
    *Functions to Load and free the MSCGI library.
    */
-	static int load(XmlParser*);
+	static int load();
 	static int unLoad();
 	/*!
 	*Use this to send a MSCGI file through the HTTP protocol.

Modified: trunk/myserver/include/http_handler/scgi/scgi.h
===================================================================
--- trunk/myserver/include/http_handler/scgi/scgi.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/http_handler/scgi/scgi.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -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
@@ -55,7 +55,7 @@
   static int getTimeout();
   static void setTimeout(int);
   Scgi();
-  static int load(XmlParser*);
+  static int load();
   int send(HttpThreadContext* td, ConnectionPtr connection,
            const char* scriptpath, const char *cgipath = 0,
            int execute = 0, int onlyHeader = 0);

Modified: trunk/myserver/include/protocol/http/http_data_handler.h
===================================================================
--- trunk/myserver/include/protocol/http/http_data_handler.h	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/include/protocol/http/http_data_handler.h	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 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
@@ -18,10 +18,10 @@
 
 #ifndef HTTP_DATA_HANDLER_H
 #define HTTP_DATA_HANDLER_H
+
 #include "stdafx.h"
 #include <include/protocol/protocol.h>
 #include "include/protocol/http/http_headers.h"
-#include <include/base/xml/xml_parser.h>
 #include <include/filter/filters_chain.h>
 
 /*!
@@ -30,8 +30,8 @@
 class HttpDataHandler
 {
 public:
-  static int load(XmlParser* );
-  static int unLoad();
+  static int load ();
+  static int unLoad ();
 
 	virtual int send(HttpThreadContext*, ConnectionPtr s,
                    const char* exec, const char* cmdLine = 0,

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -456,7 +456,7 @@
 /*!
  *Initialize the FastCGI protocol implementation
  */
-int FastCgi::load(XmlParser* /*confFile*/)
+int FastCgi::load()
 {
   if(initialized)
     return 1;

Modified: trunk/myserver/src/http_handler/http_dir/http_dir.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_dir/http_dir.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/http_handler/http_dir/http_dir.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -93,7 +93,7 @@
 /*!
  *Load the static elements.
  */
-int HttpDir::load(XmlParser* /*confFile*/)
+int HttpDir::load ()
 {
   return 0;
 }
@@ -101,7 +101,7 @@
 /*!
  *Unload the static elements.
  */
-int HttpDir::unLoad()
+int HttpDir::unLoad ()
 {
   return 0;
 }

Modified: trunk/myserver/src/http_handler/http_file/http_file.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -729,7 +729,7 @@
  *Load the static elements.
  *\param confFile Not used.
  */
-int HttpFile::load(XmlParser* confFile)
+int HttpFile::load ()
 {
   return 0;
 }

Modified: trunk/myserver/src/http_handler/isapi/isapi.cpp
===================================================================
--- trunk/myserver/src/http_handler/isapi/isapi.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/http_handler/isapi/isapi.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1009,7 +1009,7 @@
 /*!
 *Initialize the ISAPI engine under WIN32.
 */
-int Isapi::load(XmlParser*/* confFile*/)
+int Isapi::load ()
 {
 #ifdef WIN32
   u_long nThreads = Server::getInstance()->getMaxThreads()/2;

Modified: trunk/myserver/src/http_handler/mscgi/mscgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/mscgi/mscgi.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/http_handler/mscgi/mscgi.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -233,7 +233,7 @@
  *Map the library in the application address space.
  *\param confFile The xml parser with configuration.
  */
-int MsCgi::load(XmlParser* confFile)
+int MsCgi::load()
 {
   return 1;
 }

Modified: trunk/myserver/src/http_handler/scgi/scgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -482,7 +482,7 @@
 /*!
  *Initialize the SCGI protocol implementation
  */
-int Scgi::load(XmlParser* /*confFile*/)
+int Scgi::load ()
 {
   if(initialized)
     return 1;

Modified: trunk/myserver/src/plugin/plugins_manager.cpp
===================================================================
--- trunk/myserver/src/plugin/plugins_manager.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/plugin/plugins_manager.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -20,7 +20,7 @@
 #include <include/base/xml/xml_parser.h>
 #include <include/base/find_data/find_data.h>
 #include <include/server/server.h>
-
+#include <include/base/string/stringutils.h>
 #include <string>
 using namespace std;
 
@@ -58,65 +58,63 @@
  *\param languageFile The language file to use to get errors and warnings 
  *messages.
  */
-int PluginsManager::loadOptions(Server *server, XmlParser* languageFile)
+int PluginsManager::loadOptions (Server *server, XmlParser* languageFile)
 {
-  xmlDocPtr xmlDoc;
   int ret = 0;
-  XmlParser* configuration;
-  
-  configuration = server->getConfiguration();
-  
-  xmlDoc = configuration->getDoc();
-  
+  string key ("plugins");
 
-  for(xmlNode *root = xmlDoc->children; root; root = root->next)
-    if(!xmlStrcmp(root->name, (const xmlChar *)"MYSERVER"))
-      for(xmlNode *node = root->children; node; node = node->next)
-        {
-          string namespaceName;
-          string pluginName;
+  NodeTree<string>* node = server->getNodeTree (key);
+
+  if (node == NULL)
+    return 0;
+
+  list<NodeTree<string>*> *children = node->getChildren ();
+
+  if (children == NULL)
+    return 0;
+
+  string namespaceKey ("namespace");
+  string pluginKey ("plugin");
+  string globalKey ("global");
+  string enabledKey ("enabled");
+
+  for(list<NodeTree<string>*>::iterator it = children->begin ();
+      it != children->end ();
+      it++)
+    {
+      NodeTree<string>* node = *it;
+
+      string plugin;
+      string namespaceName;
 		  bool global = false;
 		  bool enabled = false;
-          
-          if(!xmlStrcmp(node->name, (const xmlChar *)"PLUGIN"))
-          {
-            xmlAttrPtr properties = node->properties;
-            
-            while(properties)
-            {
-              if(!xmlStrcmp(properties->name, (const xmlChar *)"name"))
-              {
-                if(properties->children && properties->children->content)
-                  pluginName.assign((char*)properties->children->content);
-              }
-              properties = properties->next;
-            }
-            
-            for(xmlNode *internal = node->children; internal; internal = internal->next)  
-            {
-              if(!xmlStrcmp(internal->name, (const xmlChar *)"ENABLED"))
-                enabled = strcmpi("NO", (const char*)internal->children->content) ? true : false;
-              else if(!xmlStrcmp(internal->name, (const xmlChar *)"GLOBAL"))
-                global = strcmpi("YES", (const char*)internal->children->content) ? false : true;
-            }
 
-            if(!pluginName.length())
-            {
-              string error;
-              error.assign("PLUGINS MANAGER: Warning: invalid plugin name in PLUGIN block");
-              server->logWriteln(error.c_str(), MYSERVER_LOG_MSG_ERROR);
-              ret = -1;  
-            }
-            else
-            {
-                addPluginInfo(pluginName, new PluginInfo(pluginName,enabled,global));
-            }
+      if (node->getAttr (namespaceKey))
+        namespaceName.assign (*node->getAttr (namespaceKey));
 
-          }
+      if (node->getAttr (pluginKey))
+        plugin.assign (*node->getAttr (pluginKey));
+
+      if (node->getAttr (globalKey))
+        global = stringcmpi (*node->getAttr (globalKey), "YES") == 0;
+
+      if (node->getAttr (enabledKey))
+        enabled = stringcmpi (*node->getAttr (enabledKey), "YES") == 0;
+
+      if (!plugin.length ())
+        {
+          string error;
+          error.assign ("PLUGINS MANAGER: Warning: invalid plugin name in PLUGIN block");
+          server->logWriteln (error.c_str (), MYSERVER_LOG_MSG_ERROR);
+          ret = -1;  
         }
+      else
+        {
+          addPluginInfo (plugin, new PluginInfo (plugin, enabled, global));
+        }
+    }
 
   return ret;
-  
 }
 
 

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/protocol/http/http.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1850,10 +1850,8 @@
  */
 int Http::loadProtocolStatic(XmlParser* languageParser)
 {
-  char *data = 0;
-  XmlParser *configurationFileManager = Server::getInstance()->getConfiguration();
+  const char *data = NULL;
   string pluginsResource(Server::getInstance()->getExternalPath());
-  xmlDocPtr xmlDoc = configurationFileManager->getDoc();
 
   /*
    *Store defaults value.
@@ -1867,19 +1865,19 @@
   HttpErrors::load ();
 
   /* Initialize ISAPI.  */
-  Isapi::load (configurationFileManager);
+  Isapi::load ();
 
   /* Initialize FastCGI.  */
-  FastCgi::load (configurationFileManager);
+  FastCgi::load ();
 
   /* Initialize SCGI.  */
-  Scgi::load (configurationFileManager);
+  Scgi::load ();
 
   /* Load the MSCGI library.  */
-  MsCgi::load (configurationFileManager);
+  MsCgi::load ();
 
-  HttpFile::load (configurationFileManager);
-  HttpDir::load (configurationFileManager);
+  HttpFile::load ();
+  HttpDir::load ();
 
   staticHttp.dynManagerList.addHttpManager ("SEND", staticHttp.httpFile);
   staticHttp.dynManagerList.addHttpManager ("DIR", staticHttp.httpDir);
@@ -1890,7 +1888,7 @@
   staticHttp.dynManagerList.addHttpManager ("FASTCGI", staticHttp.fastcgi);
   staticHttp.dynManagerList.addHttpManager ("ISAPI", staticHttp.isapi);
 
-  data = configurationFileManager->getValue("vhost.allow_mime");
+  data = Server::getInstance ()->getHashedData ("vhost.allow_mime");
   if(data)
   {
 
@@ -1899,16 +1897,16 @@
     else
       staticHttp.allowVhostMime = 0;
   }
-  data = configurationFileManager->getValue("cgi.timeout");
+  data = Server::getInstance ()->getHashedData ("cgi.timeout");
   if(data)
   {
-    staticHttp.cgiTimeout = MYSERVER_SEC(atoi(data));
+    staticHttp.cgiTimeout = MYSERVER_SEC (atoi (data));
   }
 
-  Cgi::setTimeout(staticHttp.cgiTimeout);
-  Scgi::setTimeout(staticHttp.cgiTimeout);
-  WinCgi::setTimeout(staticHttp.cgiTimeout);
-  Isapi::setTimeout(staticHttp.cgiTimeout);
+  Cgi::setTimeout (staticHttp.cgiTimeout);
+  Scgi::setTimeout (staticHttp.cgiTimeout);
+  WinCgi::setTimeout (staticHttp.cgiTimeout);
+  Isapi::setTimeout (staticHttp.cgiTimeout);
 
   return 1;
 }

Modified: trunk/myserver/src/protocol/http/http_data_handler.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http_data_handler.cpp	2009-05-04 20:36:59 UTC (rev 3080)
+++ trunk/myserver/src/protocol/http/http_data_handler.cpp	2009-05-05 18:29:59 UTC (rev 3081)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 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
@@ -47,7 +47,7 @@
 /*!
  *Load the static elements.
  */
-int HttpDataHandler::load(XmlParser* /*confFile*/)
+int HttpDataHandler::load ()
 {
   return 0;
 }




From MAILER-DAEMON Tue May 05 14:30:46 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M1PPi-00030G-NC
	for mharc-myserver-commit@gnu.org; Tue, 05 May 2009 14:30:46 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M1PPh-0002z2-1F
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:45 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M1PPg-0002yb-5n
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:44 -0400
Received: from [199.232.76.173] (port=36655 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M1PPf-0002yV-UX
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:44 -0400
Received: from savannah.gnu.org ([199.232.41.3]:35345 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M1PPf-0001qC-GG
	for myserver-commit@gnu.org; Tue, 05 May 2009 14:30:43 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M1PPW-00013E-3Q
	for myserver-commit@gnu.org; Tue, 05 May 2009 18:30:36 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M1PPE-0000sD-Rs
	for myserver-commit@gnu.org; Tue, 05 May 2009 18:30:30 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M1PPE-0000sD-Rs@cvs.savannah.gnu.org>
Date: Tue, 05 May 2009 18:30:17 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3082] The main configuration file is closed
	after it is parsed.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 05 May 2009 18:30:45 -0000

Revision: 3082
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3082
Author:   gscrivano
Date:     2009-05-05 18:30:06 +0000 (Tue, 05 May 2009)
Log Message:
-----------
The main configuration file is closed after it is parsed.

Modified Paths:
--------------
    trunk/myserver/include/server/server.h
    trunk/myserver/src/server/server.cpp

Modified: trunk/myserver/include/server/server.h
===================================================================
--- trunk/myserver/include/server/server.h	2009-05-05 18:29:59 UTC (rev 3081)
+++ trunk/myserver/include/server/server.h	2009-05-05 18:30:06 UTC (rev 3082)
@@ -141,7 +141,6 @@
   u_long getBuffersize2();
   u_long getThrottlingRate();
   int waitNewConnection(u_long tid, u_long timeout);
-  XmlParser *getConfiguration(){return &configurationFileManager;}
   ListenThreads *getListenThreads(){return &listenThreads;}
 
   void *getEnvString(){return envString;}
@@ -208,7 +207,6 @@
   u_long gid;
   int currentThreadID;
   ProtocolsManager protocols;
-  XmlParser configurationFileManager;
   XmlParser languageParser;
 
   bool autoRebootEnabled;

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp	2009-05-05 18:29:59 UTC (rev 3081)
+++ trunk/myserver/src/server/server.cpp	2009-05-05 18:30:06 UTC (rev 3082)
@@ -938,8 +938,6 @@
 
   filtersFactory.free();
 
-  configurationFileManager.close();
-
   getPluginsManager()->unLoad(this, &languageParser);
 
   delete connectionsMutex;
@@ -975,6 +973,8 @@
 int Server::initialize ()
 {
   const char *data;
+  XmlParser configurationFileManager;
+
 #ifdef WIN32
   envString = GetEnvironmentStrings ();
 #endif
@@ -1000,6 +1000,9 @@
 
   readHashedData (xmlDocGetRootElement(configurationFileManager.getDoc ())->xmlChildrenNode);
 
+  configurationFileManager.close();
+
+
   /*
    * Process console colors information.
    */




From MAILER-DAEMON Thu May 07 16:42:12 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M2AQ0-0002xC-CR
	for mharc-myserver-commit@gnu.org; Thu, 07 May 2009 16:42:12 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M2APy-0002vA-Hk
	for myserver-commit@gnu.org; Thu, 07 May 2009 16:42:10 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M2APx-0002tb-A3
	for myserver-commit@gnu.org; Thu, 07 May 2009 16:42:09 -0400
Received: from [199.232.76.173] (port=38422 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M2APx-0002tJ-0X
	for myserver-commit@gnu.org; Thu, 07 May 2009 16:42:09 -0400
Received: from savannah.gnu.org ([199.232.41.3]:47612 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M2APw-0002bS-Lr
	for myserver-commit@gnu.org; Thu, 07 May 2009 16:42:08 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M2APw-0007Wq-1N
	for myserver-commit@gnu.org; Thu, 07 May 2009 20:42:08 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M2APv-0007Wm-Kz
	for myserver-commit@gnu.org; Thu, 07 May 2009 20:42:07 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M2APv-0007Wm-Kz@cvs.savannah.gnu.org>
Date: Thu, 07 May 2009 20:42:07 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3083] Changed name for some lists stored in the
	main configuration file.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 07 May 2009 20:42:11 -0000

Revision: 3083
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3083
Author:   gscrivano
Date:     2009-05-07 20:42:07 +0000 (Thu, 07 May 2009)
Log Message:
-----------
Changed name for some lists stored in the main configuration file.

Modified Paths:
--------------
    trunk/myserver/documentation/process_security.texi
    trunk/myserver/src/base/process/process_server_manager.cpp
    trunk/myserver/src/plugin/plugins_manager.cpp

Modified: trunk/myserver/documentation/process_security.texi
===================================================================
--- trunk/myserver/documentation/process_security.texi	2009-05-05 18:30:06 UTC (rev 3082)
+++ trunk/myserver/documentation/process_security.texi	2009-05-07 20:42:07 UTC (rev 3083)
@@ -68,7 +68,7 @@
 
 @example
 <!-- Inside myserver.xml.  -->
-<DEFINE name="process_servers.list">
+<DEFINE name="server.process_servers">
   <DEFINE server="/opt/bin/fastcgi_server" domain="fastcgi"
           host="localhost" port="2010" local="yes" uid="1000"
           gid="1000"/>

Modified: trunk/myserver/src/base/process/process_server_manager.cpp
===================================================================
--- trunk/myserver/src/base/process/process_server_manager.cpp	2009-05-05 18:30:06 UTC (rev 3082)
+++ trunk/myserver/src/base/process/process_server_manager.cpp	2009-05-07 20:42:07 UTC (rev 3083)
@@ -45,7 +45,7 @@
 void ProcessServerManager::load ()
 {
  
-  string key ("process_servers.list");
+  string key ("server.process_servers");
   NodeTree<string> *node = ::Server::getInstance()->getNodeTree (key);
 
   if (node == NULL)

Modified: trunk/myserver/src/plugin/plugins_manager.cpp
===================================================================
--- trunk/myserver/src/plugin/plugins_manager.cpp	2009-05-05 18:30:06 UTC (rev 3082)
+++ trunk/myserver/src/plugin/plugins_manager.cpp	2009-05-07 20:42:07 UTC (rev 3083)
@@ -61,7 +61,7 @@
 int PluginsManager::loadOptions (Server *server, XmlParser* languageFile)
 {
   int ret = 0;
-  string key ("plugins");
+  string key ("server.plugins");
 
   NodeTree<string>* node = server->getNodeTree (key);
 




From MAILER-DAEMON Thu May 14 15:11:12 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M4gKl-0007Qh-Tg
	for mharc-myserver-commit@gnu.org; Thu, 14 May 2009 15:11:11 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M4gKk-0007QY-6H
	for myserver-commit@gnu.org; Thu, 14 May 2009 15:11:10 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M4gKj-0007QB-9u
	for myserver-commit@gnu.org; Thu, 14 May 2009 15:11:09 -0400
Received: from [199.232.76.173] (port=48445 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M4gKj-0007Q7-4t
	for myserver-commit@gnu.org; Thu, 14 May 2009 15:11:09 -0400
Received: from savannah.gnu.org ([199.232.41.3]:53106 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M4gKi-0008Sy-2D
	for myserver-commit@gnu.org; Thu, 14 May 2009 15:11:08 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M4gKh-0005z3-8p
	for myserver-commit@gnu.org; Thu, 14 May 2009 19:11:07 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M4gKh-0005yz-0V
	for myserver-commit@gnu.org; Thu, 14 May 2009 19:11:07 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M4gKh-0005yz-0V@cvs.savannah.gnu.org>
Date: Thu, 14 May 2009 19:11:07 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3084] Do not fail if the OS version is not
	recognized.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 14 May 2009 19:11:10 -0000

Revision: 3084
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3084
Author:   gscrivano
Date:     2009-05-14 19:11:06 +0000 (Thu, 14 May 2009)
Log Message:
-----------
Do not fail if the OS version is not recognized.

Modified Paths:
--------------
    trunk/myserver/src/base/utility.cpp
    trunk/myserver/tests/test_utility.cpp

Modified: trunk/myserver/src/base/utility.cpp
===================================================================
--- trunk/myserver/src/base/utility.cpp	2009-05-07 20:42:07 UTC (rev 3083)
+++ trunk/myserver/src/base/utility.cpp	2009-05-14 19:11:06 UTC (rev 3084)
@@ -51,7 +51,7 @@
 
 /*!
  *Returns the version of the operating system.
- *Return 0 on fails.
+ *Return 0 if it is not recognized.
  */
 int getOSVersion()
 {

Modified: trunk/myserver/tests/test_utility.cpp
===================================================================
--- trunk/myserver/tests/test_utility.cpp	2009-05-07 20:42:07 UTC (rev 3083)
+++ trunk/myserver/tests/test_utility.cpp	2009-05-14 19:11:06 UTC (rev 3084)
@@ -59,7 +59,7 @@
 
   void testGetOsVersion()
   {
-    CPPUNIT_ASSERT(getOSVersion() > 0);
+    CPPUNIT_ASSERT(getOSVersion() >= 0);
   }
 
 




From MAILER-DAEMON Sun May 17 14:28:28 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M5l64-0008GW-Mv
	for mharc-myserver-commit@gnu.org; Sun, 17 May 2009 14:28:28 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M5l62-0008D5-4f
	for myserver-commit@gnu.org; Sun, 17 May 2009 14:28:26 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M5l5z-00088Q-Ra
	for myserver-commit@gnu.org; Sun, 17 May 2009 14:28:25 -0400
Received: from [199.232.76.173] (port=56740 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M5l5z-00088E-Ng
	for myserver-commit@gnu.org; Sun, 17 May 2009 14:28:23 -0400
Received: from savannah.gnu.org ([199.232.41.3]:34696 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M5l5z-0003Nj-8v
	for myserver-commit@gnu.org; Sun, 17 May 2009 14:28:23 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M5l5y-0004za-Ox
	for myserver-commit@gnu.org; Sun, 17 May 2009 18:28:22 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M5l5y-0004zW-Fa
	for myserver-commit@gnu.org; Sun, 17 May 2009 18:28:22 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M5l5y-0004zW-Fa@cvs.savannah.gnu.org>
Date: Sun, 17 May 2009 18:28:22 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3085] Check if headers are available before
	inclusion.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 17 May 2009 18:28:26 -0000

Revision: 3085
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3085
Author:   gscrivano
Date:     2009-05-17 18:28:22 +0000 (Sun, 17 May 2009)
Log Message:
-----------
Check if headers are available before inclusion.  It solves a compiling issue under Windows.

Modified Paths:
--------------
    trunk/myserver/src/base/ssl/ssl.cpp
    trunk/myserver/tests/test_socket.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/src/base/ssl/ssl.cpp
===================================================================
--- trunk/myserver/src/base/ssl/ssl.cpp	2009-05-14 19:11:06 UTC (rev 3084)
+++ trunk/myserver/src/base/ssl/ssl.cpp	2009-05-17 18:28:22 UTC (rev 3085)
@@ -30,7 +30,9 @@
 
 #endif
 
+#ifdef HAVE_PTHREAD
 #include <pthread.h>
+#endif
 }
 
 SslContext::SslContext()

Modified: trunk/myserver/tests/test_socket.cpp
===================================================================
--- trunk/myserver/tests/test_socket.cpp	2009-05-14 19:11:06 UTC (rev 3084)
+++ trunk/myserver/tests/test_socket.cpp	2009-05-17 18:28:22 UTC (rev 3085)
@@ -23,10 +23,15 @@
 #include "../include/base/socket/socket.h"
 #include "../include/base/thread/thread.h"
 
+extern "C"
+{
 #include <string.h>
+#ifndef WIN32
 #include <errno.h>
 #include <arpa/inet.h>
+#endif
 #include <iostream>
+}
 
 using namespace std;
 

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-14 19:11:06 UTC (rev 3084)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-17 18:28:22 UTC (rev 3085)
@@ -28,11 +28,15 @@
 #include "../include/base/file/files_utility.h"
 #include "../include/base/thread/thread.h"
 
+extern "C"
+{
 #include <string.h>
+#ifndef WIN32
 #include <errno.h>
 #include <arpa/inet.h>
+#endif
 #include <iostream>
-
+}
 using namespace std;
 
 




From MAILER-DAEMON Sun May 17 15:04:40 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M5lf6-0008OU-4u
	for mharc-myserver-commit@gnu.org; Sun, 17 May 2009 15:04:40 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M5lf4-0008ON-Pe
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:04:38 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M5lf4-0008O7-8w
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:04:38 -0400
Received: from [199.232.76.173] (port=46234 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M5lf4-0008O4-2D
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:04:38 -0400
Received: from savannah.gnu.org ([199.232.41.3]:53214 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M5lf3-0004Zs-Db
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:04:37 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M5lf2-00086t-OS
	for myserver-commit@gnu.org; Sun, 17 May 2009 19:04:36 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M5lf2-00086p-HV
	for myserver-commit@gnu.org; Sun, 17 May 2009 19:04:36 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M5lf2-00086p-HV@cvs.savannah.gnu.org>
Date: Sun, 17 May 2009 19:04:36 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3086] Do not assume that `Socket::gethostname'
	returns "localhost".
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 17 May 2009 19:04:39 -0000

Revision: 3086
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3086
Author:   gscrivano
Date:     2009-05-17 19:04:36 +0000 (Sun, 17 May 2009)
Log Message:
-----------
Do not assume that `Socket::gethostname' returns "localhost".

Modified Paths:
--------------
    trunk/myserver/tests/test_socket.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/tests/test_socket.cpp
===================================================================
--- trunk/myserver/tests/test_socket.cpp	2009-05-17 18:28:22 UTC (rev 3085)
+++ trunk/myserver/tests/test_socket.cpp	2009-05-17 19:04:36 UTC (rev 3086)
@@ -30,8 +30,8 @@
 #include <errno.h>
 #include <arpa/inet.h>
 #endif
+}
 #include <iostream>
-}
 
 using namespace std;
 
@@ -66,9 +66,15 @@
   
   void testGethostname ( )
   { 
-    char host[] = "localhost";
-    int len = sizeof ( host ) / sizeof ( char );
-      
+    int len;
+#ifdef HOST_NAME_MAX
+    len = HOST_NAME_MAX;
+    char host[HOST_NAME_MAX];
+#else
+    len = 255;
+    char host[255];
+#endif
+
     int status = obj->gethostname ( host, len );
   
     CPPUNIT_ASSERT_EQUAL( status, 0 );

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-17 18:28:22 UTC (rev 3085)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-17 19:04:36 UTC (rev 3086)
@@ -35,8 +35,9 @@
 #include <errno.h>
 #include <arpa/inet.h>
 #endif
+}
+
 #include <iostream>
-}
 using namespace std;
 
 




From MAILER-DAEMON Sun May 17 15:34:04 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M5m7Y-0001W1-8e
	for mharc-myserver-commit@gnu.org; Sun, 17 May 2009 15:34:04 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M5m7W-0001V9-Vo
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:34:03 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M5m7V-0001Tv-Vn
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:34:02 -0400
Received: from [199.232.76.173] (port=54669 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M5m7V-0001Sg-S4
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:34:01 -0400
Received: from savannah.gnu.org ([199.232.41.3]:37135 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M5m7U-0002uA-LO
	for myserver-commit@gnu.org; Sun, 17 May 2009 15:34:00 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M5m7T-0002ca-PE
	for myserver-commit@gnu.org; Sun, 17 May 2009 19:33:59 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M5m7T-0002cV-CF
	for myserver-commit@gnu.org; Sun, 17 May 2009 19:33:59 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M5m7T-0002cV-CF@cvs.savannah.gnu.org>
Date: Sun, 17 May 2009 19:33:59 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3087] Properly initialize GNUTLS even in the
 case `GCRY_CONTROL' is not defined.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 17 May 2009 19:34:03 -0000

Revision: 3087
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3087
Author:   gscrivano
Date:     2009-05-17 19:33:58 +0000 (Sun, 17 May 2009)
Log Message:
-----------
Properly initialize GNUTLS even in the case `GCRY_CONTROL' is not defined.

Modified Paths:
--------------
    trunk/myserver/src/base/ssl/ssl.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/src/base/ssl/ssl.cpp
===================================================================
--- trunk/myserver/src/base/ssl/ssl.cpp	2009-05-17 19:04:36 UTC (rev 3086)
+++ trunk/myserver/src/base/ssl/ssl.cpp	2009-05-17 19:33:58 UTC (rev 3087)
@@ -23,11 +23,9 @@
 extern "C"
 {
 #if GCRY_CONTROL
-
 #include <errno.h>
 #include <gcrypt.h>
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
-
 #endif
 
 #ifdef HAVE_PTHREAD
@@ -102,8 +100,8 @@
   {
 #if GCRY_CONTROL
     gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-    gnutls_global_init ();
 #endif
+    gnutls_global_init ();
 
     initialized = true;
   }

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-17 19:04:36 UTC (rev 3086)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-17 19:33:58 UTC (rev 3087)
@@ -101,7 +101,7 @@
   
   void setUp ( )
   {
-    SSL_library_init ( );
+    initializeSSL ();
     u_long nbw;
     File f;
 




From MAILER-DAEMON Wed May 20 14:12:10 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M6qGw-0003Gu-BG
	for mharc-myserver-commit@gnu.org; Wed, 20 May 2009 14:12:10 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M6qGt-0003GO-S0
	for myserver-commit@gnu.org; Wed, 20 May 2009 14:12:07 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M6qGt-0003GC-Cw
	for myserver-commit@gnu.org; Wed, 20 May 2009 14:12:07 -0400
Received: from [199.232.76.173] (port=37180 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M6qGt-0003G9-9b
	for myserver-commit@gnu.org; Wed, 20 May 2009 14:12:07 -0400
Received: from savannah.gnu.org ([199.232.41.3]:59284 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M6qGt-00027G-21
	for myserver-commit@gnu.org; Wed, 20 May 2009 14:12:07 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M6qGs-0006e4-Fx
	for myserver-commit@gnu.org; Wed, 20 May 2009 18:12:06 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M6qGs-0006e0-3T
	for myserver-commit@gnu.org; Wed, 20 May 2009 18:12:06 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M6qGs-0006e0-3T@cvs.savannah.gnu.org>
Date: Wed, 20 May 2009 18:12:06 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3088] Store the protocol prefix in the
	`Protocol' class.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 20 May 2009 18:12:08 -0000

Revision: 3088
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3088
Author:   gscrivano
Date:     2009-05-20 18:12:05 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Store the protocol prefix in the `Protocol' class.

Modified Paths:
--------------
    trunk/myserver/include/protocol/http/http.h
    trunk/myserver/include/protocol/protocol.h
    trunk/myserver/src/protocol/control/control_protocol.cpp
    trunk/myserver/src/protocol/ftp/ftp.cpp
    trunk/myserver/src/protocol/protocol.cpp

Modified: trunk/myserver/include/protocol/http/http.h
===================================================================
--- trunk/myserver/include/protocol/http/http.h	2009-05-17 19:33:58 UTC (rev 3087)
+++ trunk/myserver/include/protocol/http/http.h	2009-05-20 18:12:05 UTC (rev 3088)
@@ -205,7 +205,6 @@
   void clean();
   void computeDigest(char*, char*);
   u_long checkDigest();
-  string protocolPrefix;
 };
 
 

Modified: trunk/myserver/include/protocol/protocol.h
===================================================================
--- trunk/myserver/include/protocol/protocol.h	2009-05-17 19:33:58 UTC (rev 3087)
+++ trunk/myserver/include/protocol/protocol.h	2009-05-20 18:12:05 UTC (rev 3088)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 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
@@ -33,15 +33,18 @@
 {
 public:
 	Protocol();
-  virtual ~Protocol();
-	virtual char* registerName(char*,int len);
-	virtual int controlConnection(ConnectionPtr a, char *b1, char *b2,
-                                int bs1, int bs2, u_long nbtr, u_long id);
-	virtual int loadProtocol(XmlParser*);
-	virtual int unLoadProtocol(XmlParser*);
+  virtual ~Protocol ();
+	virtual char* registerName (char*,int len);
+	virtual int controlConnection (ConnectionPtr a, char *b1, char *b2,
+                                 int bs1, int bs2, u_long nbtr, u_long id);
+	virtual int loadProtocol (XmlParser*);
+	virtual int unLoadProtocol (XmlParser*);
 
-  virtual int getProtocolOptions(){return protocolOptions;}
+  virtual int getProtocolOptions (){return protocolOptions;}
+
+  virtual string &getProtocolPrefix (){return protocolPrefix;}
 protected:
+  string protocolPrefix;
 	int protocolOptions;
 };
 #endif

Modified: trunk/myserver/src/protocol/control/control_protocol.cpp
===================================================================
--- trunk/myserver/src/protocol/control/control_protocol.cpp	2009-05-17 19:33:58 UTC (rev 3087)
+++ trunk/myserver/src/protocol/control/control_protocol.cpp	2009-05-20 18:12:05 UTC (rev 3088)
@@ -81,6 +81,7 @@
 ControlProtocol::ControlProtocol() 
 {
   protocolOptions = PROTOCOL_USES_SSL;
+  protocolPrefix.assign ("control://");
 }
 
 /*!

Modified: trunk/myserver/src/protocol/ftp/ftp.cpp
===================================================================
--- trunk/myserver/src/protocol/ftp/ftp.cpp	2009-05-17 19:33:58 UTC (rev 3087)
+++ trunk/myserver/src/protocol/ftp/ftp.cpp	2009-05-20 18:12:05 UTC (rev 3088)
@@ -310,6 +310,7 @@
 {
   m_nPassivePort = Ftp::FIRST_PASV_PORT;
   protocolOptions = PROTOCOL_FAST_CHECK | PROTOCOL_DENY_DELETE;
+  protocolPrefix.assign("ftp://");
 }
 
 Ftp::~Ftp()

Modified: trunk/myserver/src/protocol/protocol.cpp
===================================================================
--- trunk/myserver/src/protocol/protocol.cpp	2009-05-17 19:33:58 UTC (rev 3087)
+++ trunk/myserver/src/protocol/protocol.cpp	2009-05-20 18:12:05 UTC (rev 3088)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 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
@@ -68,6 +68,7 @@
 Protocol::Protocol()
 {
   protocolOptions = 0;
+  protocolPrefix.assign ("");
 }
 
 /*!




From MAILER-DAEMON Fri May 22 16:21:17 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7bEz-0006ue-FM
	for mharc-myserver-commit@gnu.org; Fri, 22 May 2009 16:21:17 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7bEy-0006uZ-Mz
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:16 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7bEy-0006uL-6Q
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:16 -0400
Received: from [199.232.76.173] (port=46682 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7bEx-0006uI-V3
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:16 -0400
Received: from savannah.gnu.org ([199.232.41.3]:35538 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7bEx-0000oN-KU
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:15 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7bEv-00046P-HS
	for myserver-commit@gnu.org; Fri, 22 May 2009 20:21:14 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7bEt-00046F-6g
	for myserver-commit@gnu.org; Fri, 22 May 2009 20:21:11 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7bEt-00046F-6g@cvs.savannah.gnu.org>
Date: Fri, 22 May 2009 20:21:11 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3089] Code refactoring: `FilesUtility::copyFile
 (const char*, const char*, 
 int)' calls internally `FilesUtility::copyFile (File&, File&)'.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 22 May 2009 20:21:16 -0000

Revision: 3089
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3089
Author:   gscrivano
Date:     2009-05-22 20:21:08 +0000 (Fri, 22 May 2009)
Log Message:
-----------
Code refactoring: `FilesUtility::copyFile (const char*, const char*, int)' calls internally `FilesUtility::copyFile (File&, File&)'.

Modified Paths:
--------------
    trunk/myserver/include/base/file/files_utility.h
    trunk/myserver/src/base/file/files_utility.cpp

Modified: trunk/myserver/include/base/file/files_utility.h
===================================================================
--- trunk/myserver/include/base/file/files_utility.h	2009-05-20 18:12:05 UTC (rev 3088)
+++ trunk/myserver/include/base/file/files_utility.h	2009-05-22 20:21:08 UTC (rev 3089)
@@ -77,7 +77,7 @@
     {return renameFile(before.c_str(), after.c_str());}
 
   static int copyFile(const char*, const char*, int overwrite);
-  static int copyFile(File, File);
+  static int copyFile(File&, File&);
   static int copyFile(string const &src, string const &dest, int overwrite)
   {return copyFile(src.c_str(), dest.c_str(), overwrite);}
 

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp	2009-05-20 18:12:05 UTC (rev 3088)
+++ trunk/myserver/src/base/file/files_utility.cpp	2009-05-22 20:21:08 UTC (rev 3089)
@@ -154,54 +154,31 @@
  *\param dest The destination file name.
  *\param overwrite Overwrite the dest file if already exists?
  */
-int FilesUtility::copyFile(const char* src, const char* dest, int overwrite)
+int FilesUtility::copyFile (const char* src, const char* dest, int overwrite)
 {
 #ifdef WIN32
-  return CopyFile(src, dest, overwrite ? FALSE : TRUE) ? 0 : 1;
+  return CopyFile (src, dest, overwrite ? FALSE : TRUE) ? 0 : 1;
 #else
-  int srcFile = open(src, O_RDONLY);
-  int destFile;
+  File srcFile;
+  File destFile;
   char buffer[4096];
   size_t dim;
 
-  if(srcFile == -1)
+  if (srcFile.openFile (src, File::MYSERVER_OPEN_READ))
     return -1;
 
-  if(overwrite)
-    destFile = open(dest, O_WRONLY);
-  else
-    destFile = open(dest, O_WRONLY | O_CREAT);
-
-  if(destFile == -1)
-  {
-    close(srcFile);
-    return -1;
-  }
-
-  do
-  {
-    dim = read(srcFile, buffer, 4096);
-
-    if(dim == (size_t)-1)
+  if (destFile.openFile (dest, File::MYSERVER_OPEN_WRITE | (overwrite ? File::MYSERVER_CREATE_ALWAYS : 0)))
     {
-      close(srcFile);
-      close(destFile);
+      srcFile.close ();
       return -1;
     }
 
-    if(dim && (write(destFile, buffer, dim) != -1))
-    {
-      close(srcFile);
-      close(destFile);
-      return -1;
-    }
+  int ret = copyFile (srcFile, destFile);
 
-  }while(dim);
+  srcFile.close ();
+  destFile.close ();
 
-  close(srcFile);
-  close(destFile);
-
-  return 0;
+  return ret;
 #endif
 }
 
@@ -210,23 +187,22 @@
  *\param src The source File.
  *\param dest The destination File.
  */
-int FilesUtility::copyFile(File src, File dest)
+int FilesUtility::copyFile (File& src, File& dest)
 {
   char buffer[4096];
   u_long nbr, nbw;
   int ret;
 
-
   for (;;) 
   {
-    ret = src.read(buffer, 4096, &nbr);
+    ret = src.read (buffer, 4096, &nbr);
     if (ret)
       return -1;
     
     if (!nbr)
       break;
     
-    ret = dest.writeToFile(buffer, nbr, &nbw);
+    ret = dest.writeToFile (buffer, nbr, &nbw);
     if (ret)
       return -1;
   }




From MAILER-DAEMON Fri May 22 16:21:29 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7bFB-0006vd-K7
	for mharc-myserver-commit@gnu.org; Fri, 22 May 2009 16:21:29 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7bFA-0006vQ-2b
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:28 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7bF9-0006vE-H1
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:27 -0400
Received: from [199.232.76.173] (port=46686 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7bF9-0006vB-Dd
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:27 -0400
Received: from savannah.gnu.org ([199.232.41.3]:35544 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7bF9-0000qT-56
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:27 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7bF8-00048D-4Q
	for myserver-commit@gnu.org; Fri, 22 May 2009 20:21:26 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7bF7-00047j-0r
	for myserver-commit@gnu.org; Fri, 22 May 2009 20:21:25 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7bF7-00047j-0r@cvs.savannah.gnu.org>
Date: Fri, 22 May 2009 20:21:25 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3090] Added `File::getSeek ()' function.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 22 May 2009 20:21:28 -0000

Revision: 3090
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3090
Author:   gscrivano
Date:     2009-05-22 20:21:23 +0000 (Fri, 22 May 2009)
Log Message:
-----------
Added `File::getSeek ()' function.

Modified Paths:
--------------
    trunk/myserver/include/base/file/file.h
    trunk/myserver/src/base/file/file.cpp
    trunk/myserver/tests/test_file.cpp

Modified: trunk/myserver/include/base/file/file.h
===================================================================
--- trunk/myserver/include/base/file/file.h	2009-05-22 20:21:08 UTC (rev 3089)
+++ trunk/myserver/include/base/file/file.h	2009-05-22 20:21:23 UTC (rev 3090)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 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
@@ -31,40 +31,41 @@
 class File : public Stream
 {
 public:
-	static const u_long MYSERVER_OPEN_READ;
-	static const u_long MYSERVER_OPEN_WRITE;
-	static const u_long MYSERVER_OPEN_TEMPORARY;
-	static const u_long MYSERVER_OPEN_HIDDEN;
-	static const u_long MYSERVER_OPEN_ALWAYS;
-	static const u_long MYSERVER_OPEN_IFEXISTS;
-	static const u_long MYSERVER_OPEN_APPEND;
-	static const u_long MYSERVER_CREATE_ALWAYS;
-	static const u_long MYSERVER_NO_INHERIT;
+  static const u_long MYSERVER_OPEN_READ;
+  static const u_long MYSERVER_OPEN_WRITE;
+  static const u_long MYSERVER_OPEN_TEMPORARY;
+  static const u_long MYSERVER_OPEN_HIDDEN;
+  static const u_long MYSERVER_OPEN_ALWAYS;
+  static const u_long MYSERVER_OPEN_IFEXISTS;
+  static const u_long MYSERVER_OPEN_APPEND;
+  static const u_long MYSERVER_CREATE_ALWAYS;
+  static const u_long MYSERVER_NO_INHERIT;
 
-	File();
+  File();
   File(char *,int);
-	virtual FileHandle getHandle();
-	virtual int setHandle(FileHandle);
-	virtual int writeToFile(const char* ,u_long ,u_long* );
-	virtual int createTemporaryFile(const char* );
+  virtual FileHandle getHandle();
+  virtual int setHandle(FileHandle);
+  virtual int writeToFile(const char* ,u_long ,u_long* );
+  virtual int createTemporaryFile(const char* );
 
-	virtual int openFile(const char*, u_long );
+  virtual int openFile(const char*, u_long );
   virtual int openFile(string const &file, u_long opt)
     {return openFile(file.c_str(), opt);}
 
-	virtual u_long getFileSize();
-	virtual int seek (u_long);
+  virtual u_long getFileSize();
+  virtual int seek (u_long);
+  virtual u_long getSeek ();
 
-	virtual time_t getLastModTime();
-	virtual time_t getCreationTime();
-	virtual time_t getLastAccTime();
-	virtual const char *getFilename();
-	virtual int setFilename(const char*);
+  virtual time_t getLastModTime();
+  virtual time_t getCreationTime();
+  virtual time_t getLastAccTime();
+  virtual const char *getFilename();
+  virtual int setFilename(const char*);
   virtual int setFilename(string const &name)
     {return setFilename(name.c_str());}
 
-	virtual int operator =(File);
-	virtual int close();
+  virtual int operator =(File);
+  virtual int close();
 
   /*! Inherithed from Stream. */
   virtual int read(char* buffer, u_long len, u_long *nbr);
@@ -73,7 +74,7 @@
   virtual int fastCopyToSocket (Socket *dest, u_long offset, 
                                 MemBuf *buf, u_long *nbw);
 protected:
-	FileHandle handle;
-	string filename;
+  FileHandle handle;
+  string filename;
 };
 #endif

Modified: trunk/myserver/src/base/file/file.cpp
===================================================================
--- trunk/myserver/src/base/file/file.cpp	2009-05-22 20:21:08 UTC (rev 3089)
+++ trunk/myserver/src/base/file/file.cpp	2009-05-22 20:21:23 UTC (rev 3090)
@@ -406,6 +406,20 @@
 }
 
 /*!
+ * Get the current file pointer position.
+ *
+ *\return The current file pointer position.
+ */
+u_long File::getSeek ()
+{
+#ifdef WIN32
+  return SetFilePointer ((HANDLE)handle, 0, NULL, FILE_CURRENT);
+#else
+  return lseek (handle, 0, SEEK_CUR);
+#endif
+}
+
+/*!
  *Get the time of the last modifify did to the file.
  */
 time_t File::getLastModTime()

Modified: trunk/myserver/tests/test_file.cpp
===================================================================
--- trunk/myserver/tests/test_file.cpp	2009-05-22 20:21:08 UTC (rev 3089)
+++ trunk/myserver/tests/test_file.cpp	2009-05-22 20:21:23 UTC (rev 3090)
@@ -36,63 +36,69 @@
   File *tfile;
   string fname;
   
-  CPPUNIT_TEST_SUITE( TestFile );
+  CPPUNIT_TEST_SUITE ( TestFile );
   
-  CPPUNIT_TEST( testCreateTemporaryFile );
-  CPPUNIT_TEST( testOnFile );
+  CPPUNIT_TEST ( testCreateTemporaryFile );
+  CPPUNIT_TEST ( testOnFile );
   
-  CPPUNIT_TEST_SUITE_END();
+  CPPUNIT_TEST_SUITE_END ();
 
 public:
-  void setUp ( )
+  void setUp ()
   {
     setcwdBuffer ();/* Be sure the cwd buffer is initialized.  */
-    FilesUtility::temporaryFileName ( 0, fname );
+    FilesUtility::temporaryFileName (0, fname);
     tfile = new File;
   }
   
-  void tearDown ( )
+  void tearDown ()
   {
     delete tfile;
   }
   
-  void testCreateTemporaryFile ( )
+  void testCreateTemporaryFile ()
   {
-    CPPUNIT_ASSERT_EQUAL( tfile->createTemporaryFile ( fname.c_str() ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->createTemporaryFile (fname.c_str()), 0);
     
-    CPPUNIT_ASSERT_EQUAL( tfile->close ( ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->close (), 0);
   }
   
-  void testOnFile ( )
+  void testOnFile ()
   {
     char buf[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'm', 'y', 'W', 'o', 'r', 'l', 'd', 0 };
     const int bufLen = sizeof (buf) / sizeof (char);
     u_long nbw;
     u_long nbr;
     
-    CPPUNIT_ASSERT_EQUAL( tfile->openFile( fname.c_str(), File::MYSERVER_OPEN_WRITE | 
-                                           File::MYSERVER_OPEN_READ | File::MYSERVER_CREATE_ALWAYS ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->openFile( fname.c_str (), File::MYSERVER_OPEN_WRITE | 
+                                           File::MYSERVER_OPEN_READ | 
+                                           File::MYSERVER_CREATE_ALWAYS ), 0);
     
-    CPPUNIT_ASSERT_EQUAL( tfile->writeToFile ( buf, bufLen, &nbw ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->writeToFile ( buf, bufLen, &nbw ), 0);
     
-    memset ( buf, 0, bufLen );
+    memset (buf, 0, bufLen);
     
-    CPPUNIT_ASSERT_EQUAL( tfile->seek ( 0 ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->seek (0), 0);
     
-    CPPUNIT_ASSERT_EQUAL( tfile->read ( buf, bufLen, &nbr ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->read (buf, bufLen, &nbr), 0);
     
-    CPPUNIT_ASSERT( nbr > 0 );
+    CPPUNIT_ASSERT (nbr > 0);
     
-    CPPUNIT_ASSERT( tfile->getCreationTime ( ) != -1 );
+    CPPUNIT_ASSERT (tfile->getCreationTime () != -1);
     
-    CPPUNIT_ASSERT( tfile->getLastAccTime ( ) != -1 );
+    CPPUNIT_ASSERT (tfile->getLastAccTime () != -1);
     
-    CPPUNIT_ASSERT( tfile->getLastModTime ( ) != -1 );
+    CPPUNIT_ASSERT (tfile->getLastModTime () != -1);
     
-    CPPUNIT_ASSERT( tfile->getFileSize ( ) != -1 );
+    CPPUNIT_ASSERT (tfile->getFileSize () != -1);
+
+    CPPUNIT_ASSERT_EQUAL (tfile->seek (1), 0);
+
+    CPPUNIT_ASSERT_EQUAL (tfile->getSeek (), 1ul);
+
     
-    CPPUNIT_ASSERT_EQUAL( tfile->close ( ), 0 );
+    CPPUNIT_ASSERT_EQUAL (tfile->close (), 0);
   }
 };
 
-CPPUNIT_TEST_SUITE_REGISTRATION( TestFile );
+CPPUNIT_TEST_SUITE_REGISTRATION (TestFile);




From MAILER-DAEMON Fri May 22 16:21:38 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7bFK-0006wo-OA
	for mharc-myserver-commit@gnu.org; Fri, 22 May 2009 16:21:38 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7bFJ-0006wV-62
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:37 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7bFI-0006wJ-LT
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:36 -0400
Received: from [199.232.76.173] (port=46690 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7bFI-0006wG-Hq
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:36 -0400
Received: from savannah.gnu.org ([199.232.41.3]:35548 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7bFG-0000sA-CQ
	for myserver-commit@gnu.org; Fri, 22 May 2009 16:21:35 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7bFF-00048g-Im
	for myserver-commit@gnu.org; Fri, 22 May 2009 20:21:33 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7bFE-00048c-6d
	for myserver-commit@gnu.org; Fri, 22 May 2009 20:21:32 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7bFE-00048c-6d@cvs.savannah.gnu.org>
Date: Fri, 22 May 2009 20:21:32 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3091] While copying a file,
 use the `posix_fallocate () system call if it is available.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 22 May 2009 20:21:37 -0000

Revision: 3091
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3091
Author:   gscrivano
Date:     2009-05-22 20:21:30 +0000 (Fri, 22 May 2009)
Log Message:
-----------
While copying a file, use the `posix_fallocate () system call if it is available.

Modified Paths:
--------------
    trunk/myserver/configure.in
    trunk/myserver/src/base/file/files_utility.cpp

Modified: trunk/myserver/configure.in
===================================================================
--- trunk/myserver/configure.in	2009-05-22 20:21:23 UTC (rev 3090)
+++ trunk/myserver/configure.in	2009-05-22 20:21:30 UTC (rev 3091)
@@ -94,6 +94,8 @@
 
 AC_CHECK_FUNCS(pipe, AC_DEFINE(PIPE, 1, [Define if the pipe function is present]) )
 
+AC_CHECK_FUNCS(posix_fallocate, AC_DEFINE(POSIX_FALLOCATE, 1, [Define if the posix_fallocate function is present]) )
+
 AC_CHECK_FUNCS(snprintf, AC_DEFINE(SNPRINTF, 1, [Define if the snprintf function is present]) )
 
 AC_CHECK_FUNCS(getpwnam, AC_DEFINE(GETPWNAM, 1, [Define if the getpwnam function is present]) )

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp	2009-05-22 20:21:23 UTC (rev 3090)
+++ trunk/myserver/src/base/file/files_utility.cpp	2009-05-22 20:21:30 UTC (rev 3091)
@@ -193,6 +193,12 @@
   u_long nbr, nbw;
   int ret;
 
+#ifdef HAVE_POSIX_FALLOCATE
+  if (posix_fallocate (dest.getHandle (), dest.getSeek (),
+                       src.getFileSize () - src.getSeek ()))
+    return -1;
+#endif
+
   for (;;) 
   {
     ret = src.read (buffer, 4096, &nbr);




From MAILER-DAEMON Fri May 22 18:00:27 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7cmx-0006re-NQ
	for mharc-myserver-commit@gnu.org; Fri, 22 May 2009 18:00:27 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7cmu-0006qn-8k
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:24 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7cmq-0006qA-9b
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:22 -0400
Received: from [199.232.76.173] (port=41243 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7cmq-0006q7-3k
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:20 -0400
Received: from savannah.gnu.org ([199.232.41.3]:56372 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7cmp-0004ZJ-GY
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:19 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7cmi-0004sr-3o
	for myserver-commit@gnu.org; Fri, 22 May 2009 22:00:13 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7cmc-0004pG-94
	for myserver-commit@gnu.org; Fri, 22 May 2009 22:00:08 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7cmc-0004pG-94@cvs.savannah.gnu.org>
Date: Fri, 22 May 2009 22:00:06 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3092] A maximum file size can be defined for
	security files.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 22 May 2009 22:00:26 -0000

Revision: 3092
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3092
Author:   gscrivano
Date:     2009-05-22 22:00:04 +0000 (Fri, 22 May 2009)
Log Message:
-----------
A maximum file size can be defined for security files.

Modified Paths:
--------------
    trunk/myserver/documentation/security.texi
    trunk/myserver/include/conf/security/security_cache.h
    trunk/myserver/src/conf/security/security_cache.cpp
    trunk/myserver/src/conf/security/xml_validator.cpp

Modified: trunk/myserver/documentation/security.texi
===================================================================
--- trunk/myserver/documentation/security.texi	2009-05-22 20:21:30 UTC (rev 3091)
+++ trunk/myserver/documentation/security.texi	2009-05-22 22:00:04 UTC (rev 3092)
@@ -38,6 +38,14 @@
 The anonymous user is matched inside MyServer with the ``Guest''
 username and an empty password.
 
+The name for the security file can be changed trought the
+@code{security.filename} variable.
+The maximum allowed size for a security file can be limited by the
+@code{security.max_size} variable, by default there is no limit.
+Both @code{security.filename} and @code{security.max_size} can be
+defined in the global configuration file or differently for every
+virtual host.
+
 @section Security file user authentication
 The information used for the first phase of logging is a simple list
 of USER elements.  Any permission is configured by an attribute, if

Modified: trunk/myserver/include/conf/security/security_cache.h
===================================================================
--- trunk/myserver/include/conf/security/security_cache.h	2009-05-22 20:21:30 UTC (rev 3091)
+++ trunk/myserver/include/conf/security/security_cache.h	2009-05-22 22:00:04 UTC (rev 3092)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006, 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
@@ -40,7 +40,8 @@
   void setMaxNodes (int);
   int getMaxNodes ();
 
-  XmlParser* getParser (const string &dir, const string &sys, bool useXpath = true, const char* secName = ".security.xml");
+  XmlParser* getParser (const string &dir, const string &sys, bool useXpath = true,
+                        const char* secName = ".security.xml", u_long maxSize = 0);
 	int getSecurityFile (const string &file, const string &sys, string &out, const char* secName = ".security.xml");
 
   /////////OLD NASTY AND DISGUSTING.  TEMPORARY SOLUTION TO DON'T BREAK APIs////////////////////////////////////

Modified: trunk/myserver/src/conf/security/security_cache.cpp
===================================================================
--- trunk/myserver/src/conf/security/security_cache.cpp	2009-05-22 20:21:30 UTC (rev 3091)
+++ trunk/myserver/src/conf/security/security_cache.cpp	2009-05-22 22:00:04 UTC (rev 3092)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006, 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
@@ -164,11 +164,13 @@
  *\param sys The system directory.
  *\param useXpath Specify if XPath will be used on the file.
  *\param secFileName The security file name.
+ *\param maxSize The maximum file size allowed for the security file.
  */
 XmlParser* SecurityCache::getParser (const string &dir, 
                                      const string &sys, 
                                      bool useXpath,
-                                     const char* secFileName)
+                                     const char* secFileName,
+                                     u_long maxSize)
 {
   XmlParser* parser;
   string file;
@@ -186,10 +188,26 @@
     time_t fileModTime;
     /*! If the file was modified reload it. */
     fileModTime = FilesUtility::getLastModTime (file.c_str ());
+
     if ((fileModTime != static_cast<time_t>(-1))  && 
        (parser->getLastModTime () != fileModTime))
     {
       parser->close ();
+
+      /* FIXME:  Don't open the file twice, once to check
+       * and the second time to parse.  */
+      if (maxSize)
+        {
+          File parserFile;
+          if (parserFile.openFile (file.c_str (), File::MYSERVER_OPEN_READ))
+            return NULL;
+
+          if (parserFile.getFileSize () > maxSize)
+            return NULL;
+
+          parserFile.close ();
+        }
+
       if(parser->open (file.c_str (), useXpath) == -1)
       {
         dictionary.remove (file.c_str ());

Modified: trunk/myserver/src/conf/security/xml_validator.cpp
===================================================================
--- trunk/myserver/src/conf/security/xml_validator.cpp	2009-05-22 20:21:30 UTC (rev 3091)
+++ trunk/myserver/src/conf/security/xml_validator.cpp	2009-05-22 22:00:04 UTC (rev 3092)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2008 Free Software Foundation, Inc.
+Copyright (C) 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
@@ -68,8 +68,10 @@
   if (!cache)
     return NULL;
 
-  secName = st->getHashedData ("SECURITY_FILE_NAME", MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, ".security.xml");
+  secName = st->getHashedData ("security.filename", MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, ".security.xml");
 
+  u_long maxSize = atol (st->getHashedData ("security.max_size", MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, "0"));
+
   return cache->getParser (*(st->getDirectory ()), *(st->getSysDirectory ()), false, secName);
 }
 




From MAILER-DAEMON Fri May 22 18:00:50 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7cnJ-0006ux-S7
	for mharc-myserver-commit@gnu.org; Fri, 22 May 2009 18:00:49 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7cnI-0006ug-Lw
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:48 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7cnI-0006uR-2C
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:48 -0400
Received: from [199.232.76.173] (port=41252 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7cnH-0006uO-On
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:47 -0400
Received: from savannah.gnu.org ([199.232.41.3]:56414 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7cnH-0004e1-4C
	for myserver-commit@gnu.org; Fri, 22 May 2009 18:00:47 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7cnF-0004xq-G8
	for myserver-commit@gnu.org; Fri, 22 May 2009 22:00:46 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7cmz-0004x6-9M
	for myserver-commit@gnu.org; Fri, 22 May 2009 22:00:34 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7cmz-0004x6-9M@cvs.savannah.gnu.org>
Date: Fri, 22 May 2009 22:00:29 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3093] Refactoring: file open modes now have a
	shorter name.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 22 May 2009 22:00:48 -0000

Revision: 3093
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3093
Author:   gscrivano
Date:     2009-05-22 22:00:24 +0000 (Fri, 22 May 2009)
Log Message:
-----------
Refactoring: file open modes now have a shorter name.

Modified Paths:
--------------
    trunk/myserver/include/base/file/file.h
    trunk/myserver/src/base/file/file.cpp
    trunk/myserver/src/base/file/files_utility.cpp
    trunk/myserver/src/base/files_cache/cached_file_buffer.cpp
    trunk/myserver/src/base/files_cache/cached_file_factory.cpp
    trunk/myserver/src/base/home_dir/home_dir.cpp
    trunk/myserver/src/conf/security/security_cache.cpp
    trunk/myserver/src/http_handler/cgi/cgi.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/http_handler/http_file/http_file.cpp
    trunk/myserver/src/http_handler/scgi/scgi.cpp
    trunk/myserver/src/http_handler/wincgi/wincgi.cpp
    trunk/myserver/src/log/stream/file_stream.cpp
    trunk/myserver/src/protocol/control/control_protocol.cpp
    trunk/myserver/src/protocol/ftp/ftp.cpp
    trunk/myserver/src/protocol/http/http_data_read.cpp
    trunk/myserver/src/server/server.cpp
    trunk/myserver/tests/test_file.cpp
    trunk/myserver/tests/test_ssl_socket.cpp

Modified: trunk/myserver/include/base/file/file.h
===================================================================
--- trunk/myserver/include/base/file/file.h	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/include/base/file/file.h	2009-05-22 22:00:24 UTC (rev 3093)
@@ -31,15 +31,15 @@
 class File : public Stream
 {
 public:
-  static const u_long MYSERVER_OPEN_READ;
-  static const u_long MYSERVER_OPEN_WRITE;
-  static const u_long MYSERVER_OPEN_TEMPORARY;
-  static const u_long MYSERVER_OPEN_HIDDEN;
-  static const u_long MYSERVER_OPEN_ALWAYS;
-  static const u_long MYSERVER_OPEN_IFEXISTS;
-  static const u_long MYSERVER_OPEN_APPEND;
-  static const u_long MYSERVER_CREATE_ALWAYS;
-  static const u_long MYSERVER_NO_INHERIT;
+  static const u_long READ;
+  static const u_long WRITE;
+  static const u_long TEMPORARY;
+  static const u_long HIDDEN;
+  static const u_long OPEN_ALWAYS;
+  static const u_long OPEN_IF_EXISTS;
+  static const u_long APPEND;
+  static const u_long CREATE_ALWAYS;
+  static const u_long NO_INHERIT;
 
   File();
   File(char *,int);

Modified: trunk/myserver/src/base/file/file.cpp
===================================================================
--- trunk/myserver/src/base/file/file.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/base/file/file.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -54,15 +54,15 @@
 
 using namespace std;
 
-const u_long File::MYSERVER_OPEN_READ = (1<<0);
-const u_long File::MYSERVER_OPEN_WRITE = (1<<1);
-const u_long File::MYSERVER_OPEN_TEMPORARY = (1<<2);
-const u_long File::MYSERVER_OPEN_HIDDEN = (1<<3);
-const u_long File::MYSERVER_OPEN_ALWAYS = (1<<4);
-const u_long File::MYSERVER_OPEN_IFEXISTS = (1<<5);
-const u_long File::MYSERVER_OPEN_APPEND = (1<<6);
-const u_long File::MYSERVER_CREATE_ALWAYS = (1<<7);
-const u_long File::MYSERVER_NO_INHERIT = (1<<8);
+const u_long File::READ = (1<<0);
+const u_long File::WRITE = (1<<1);
+const u_long File::TEMPORARY = (1<<2);
+const u_long File::HIDDEN = (1<<3);
+const u_long File::OPEN_ALWAYS = (1<<4);
+const u_long File::OPEN_IF_EXISTS = (1<<5);
+const u_long File::APPEND = (1<<6);
+const u_long File::CREATE_ALWAYS = (1<<7);
+const u_long File::NO_INHERIT = (1<<8);
 
 
 /*!
@@ -127,30 +127,30 @@
   u_long attributeFlag = 0;
   SECURITY_ATTRIBUTES sa = {0};
   sa.nLength = sizeof(sa);
-  if(opt & File::MYSERVER_NO_INHERIT)
+  if(opt & File::NO_INHERIT)
     sa.bInheritHandle = FALSE;
   else
     sa.bInheritHandle = TRUE;
   sa.lpSecurityDescriptor = NULL;
 
-  if(opt & File::MYSERVER_OPEN_ALWAYS)
+  if(opt & File::OPEN_ALWAYS)
     creationFlag|=OPEN_ALWAYS;
-  if(opt & File::MYSERVER_OPEN_IFEXISTS)
+  if(opt & File::OPEN_IF_EXISTS)
     creationFlag|=OPEN_EXISTING;
-  if(opt & File::MYSERVER_CREATE_ALWAYS)
+  if(opt & File::CREATE_ALWAYS)
     creationFlag|=CREATE_ALWAYS;
 
-  if(opt & File::MYSERVER_OPEN_READ)
+  if(opt & File::READ)
     openFlag|=GENERIC_READ;
-  if(opt & File::MYSERVER_OPEN_WRITE)
+  if(opt & File::WRITE)
     openFlag|=GENERIC_WRITE;
 
-  if(opt & File::MYSERVER_OPEN_TEMPORARY)
+  if(opt & File::TEMPORARY)
   {
     openFlag |= FILE_ATTRIBUTE_TEMPORARY; 
     attributeFlag |= FILE_FLAG_DELETE_ON_CLOSE;
   }
-  if(opt & File::MYSERVER_OPEN_HIDDEN)
+  if(opt & File::HIDDEN)
     openFlag|= FILE_ATTRIBUTE_HIDDEN;
 
   if(attributeFlag == 0)
@@ -168,7 +168,7 @@
   }
   else/*! Open the file. */
   {
-    if(opt & File::MYSERVER_OPEN_APPEND)
+    if(opt & File::APPEND)
       ret = seek (getFileSize ());
     else
       ret = seek (0);
@@ -182,15 +182,15 @@
 #else
   struct stat F_Stats;
   int F_Flags;
-  if(opt & File::MYSERVER_OPEN_READ && opt & File::MYSERVER_OPEN_WRITE)
+  if(opt & File::READ && opt & File::WRITE)
     F_Flags = O_RDWR;
-  else if(opt & File::MYSERVER_OPEN_READ)
+  else if(opt & File::READ)
     F_Flags = O_RDONLY;
-  else if(opt & File::MYSERVER_OPEN_WRITE)
+  else if(opt & File::WRITE)
     F_Flags = O_WRONLY;
     
     
-  if(opt & File::MYSERVER_OPEN_IFEXISTS)
+  if(opt & File::OPEN_IF_EXISTS)
   {
     ret = stat(filename.c_str(), &F_Stats);
     if(ret  < 0)
@@ -206,7 +206,7 @@
     }
     handle= (FileHandle)ret;
   }
-  else if(opt & File::MYSERVER_OPEN_APPEND)
+  else if(opt & File::APPEND)
   {
     ret = stat(filename.c_str(), &F_Stats);
     if(ret < 0)
@@ -221,7 +221,7 @@
     else
       handle = (FileHandle)ret;
   }
-  else if(opt & File::MYSERVER_CREATE_ALWAYS)
+  else if(opt & File::CREATE_ALWAYS)
   {
     stat(filename.c_str(), &F_Stats);
     if(ret)
@@ -236,7 +236,7 @@
     else
       handle=(FileHandle)ret;
   }
-  else if(opt & File::MYSERVER_OPEN_ALWAYS)
+  else if(opt & File::OPEN_ALWAYS)
   {
     ret = stat(filename.c_str(), &F_Stats);
 
@@ -254,7 +254,7 @@
        handle = (FileHandle)ret;
   }
   
-  if(opt & File::MYSERVER_OPEN_TEMPORARY)
+  if(opt & File::TEMPORARY)
     unlink(filename.c_str()); // Remove File on close
   
   if((long)handle < 0)
@@ -335,11 +335,11 @@
   if(FilesUtility::fileExists(filename))
     FilesUtility::deleteFile(filename);
 
-  return openFile(filename, File::MYSERVER_OPEN_READ | 
-                  File::MYSERVER_OPEN_WRITE| 
-                  File::MYSERVER_CREATE_ALWAYS | 
-                  File::MYSERVER_OPEN_TEMPORARY |
-                  File::MYSERVER_NO_INHERIT);
+  return openFile(filename, File::READ | 
+                  File::WRITE| 
+                  File::CREATE_ALWAYS | 
+                  File::TEMPORARY |
+                  File::NO_INHERIT);
 }
 
 /*!

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/base/file/files_utility.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -164,10 +164,10 @@
   char buffer[4096];
   size_t dim;
 
-  if (srcFile.openFile (src, File::MYSERVER_OPEN_READ))
+  if (srcFile.openFile (src, File::READ))
     return -1;
 
-  if (destFile.openFile (dest, File::MYSERVER_OPEN_WRITE | (overwrite ? File::MYSERVER_CREATE_ALWAYS : 0)))
+  if (destFile.openFile (dest, File::WRITE | (overwrite ? File::CREATE_ALWAYS : 0)))
     {
       srcFile.close ();
       return -1;

Modified: trunk/myserver/src/base/files_cache/cached_file_buffer.cpp
===================================================================
--- trunk/myserver/src/base/files_cache/cached_file_buffer.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/base/files_cache/cached_file_buffer.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -56,8 +56,8 @@
   refCounter = 0;
   this->filename.assign(filename);
 
-  file.openFile(filename, File::MYSERVER_OPEN_IFEXISTS | 
-                File::MYSERVER_OPEN_READ);
+  file.openFile(filename, File::OPEN_IF_EXISTS | 
+                File::READ);
 
   fileSize = file.getFileSize();
   buffer = new char[fileSize];

Modified: trunk/myserver/src/base/files_cache/cached_file_factory.cpp
===================================================================
--- trunk/myserver/src/base/files_cache/cached_file_factory.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/base/files_cache/cached_file_factory.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -173,8 +173,8 @@
       mutex.unlock();
       
       file = new File();
-      if(file->openFile(filename, File::MYSERVER_OPEN_IFEXISTS | 
-                        File::MYSERVER_OPEN_READ))
+      if(file->openFile(filename, File::OPEN_IF_EXISTS | 
+                        File::READ))
       {
         delete file;
         return 0;
@@ -187,8 +187,8 @@
   {
     u_long fileSize;
     File *file = new File();
-    if(file->openFile(filename, File::MYSERVER_OPEN_IFEXISTS | 
-                      File::MYSERVER_OPEN_READ))
+    if(file->openFile(filename, File::OPEN_IF_EXISTS | 
+                      File::READ))
     {
       mutex.unlock();
       delete file;

Modified: trunk/myserver/src/base/home_dir/home_dir.cpp
===================================================================
--- trunk/myserver/src/base/home_dir/home_dir.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/base/home_dir/home_dir.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -144,8 +144,8 @@
 
   clear();
 
-  if (usersFile.openFile("/etc/passwd", File::MYSERVER_OPEN_READ | 
-                         File::MYSERVER_OPEN_IFEXISTS))
+  if (usersFile.openFile("/etc/passwd", File::READ | 
+                         File::OPEN_IF_EXISTS))
     return 1;
   size = usersFile.getFileSize();
   timestamp = usersFile.getLastModTime();

Modified: trunk/myserver/src/conf/security/security_cache.cpp
===================================================================
--- trunk/myserver/src/conf/security/security_cache.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/conf/security/security_cache.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -199,7 +199,7 @@
       if (maxSize)
         {
           File parserFile;
-          if (parserFile.openFile (file.c_str (), File::MYSERVER_OPEN_READ))
+          if (parserFile.openFile (file.c_str (), File::READ))
             return NULL;
 
           if (parserFile.getFileSize () > maxSize)

Modified: trunk/myserver/src/http_handler/cgi/cgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/cgi/cgi.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/http_handler/cgi/cgi.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -234,7 +234,7 @@
 
   /*! Open the stdin file for the new CGI process. */
   if(stdInFile.openFile(td->inputDataPath, 
-                        File::MYSERVER_OPEN_READ | File::MYSERVER_OPEN_ALWAYS))
+                        File::READ | File::OPEN_ALWAYS))
   {
     td->connection->host->warningsLogWrite("Cgi: Cannot open CGI stdin file.");
     stdOutFile.close();

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -193,9 +193,9 @@
   }
 
   td->inputData.close();
-  if(td->inputData.openFile(td->inputDataPath, File::MYSERVER_OPEN_READ | 
-                            File::MYSERVER_OPEN_ALWAYS |
-                            File::MYSERVER_NO_INHERIT))
+  if(td->inputData.openFile(td->inputDataPath, File::READ | 
+                            File::OPEN_ALWAYS |
+                            File::NO_INHERIT))
   {
     td->buffer->setLength(0);
     if(Server::getInstance()->getVerbosity() > 2)

Modified: trunk/myserver/src/http_handler/http_file/http_file.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -67,8 +67,8 @@
     {
       /*! If the file exists update it. */
       File file;
-      if(file.openFile(td->filenamePath.c_str(), File::MYSERVER_OPEN_IFEXISTS |
-                       File::MYSERVER_OPEN_WRITE))
+      if(file.openFile(td->filenamePath.c_str(), File::OPEN_IF_EXISTS |
+                       File::WRITE))
       {
         /*! Return an internal server error. */
         return td->http->raiseHTTPError(500);
@@ -115,8 +115,8 @@
        */
       File file;
       if(file.openFile(td->filenamePath.c_str(),
-                       File::MYSERVER_CREATE_ALWAYS |
-                       File::MYSERVER_OPEN_WRITE))
+                       File::CREATE_ALWAYS |
+                       File::WRITE))
       {
         /*! Internal server error. */
         return td->http->raiseHTTPError(500);

Modified: trunk/myserver/src/http_handler/scgi/scgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -184,9 +184,9 @@
     return td->http->raiseHTTPError(500);
   }
   td->inputData.close();
-  if(td->inputData.openFile(td->inputDataPath, File::MYSERVER_OPEN_READ | 
-                            File::MYSERVER_OPEN_ALWAYS |
-                            File::MYSERVER_NO_INHERIT))
+  if(td->inputData.openFile(td->inputDataPath, File::READ | 
+                            File::OPEN_ALWAYS |
+                            File::NO_INHERIT))
   {
     td->buffer->setLength(0);
     if(Server::getInstance()->getVerbosity() > 2)

Modified: trunk/myserver/src/http_handler/wincgi/wincgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/wincgi/wincgi.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/http_handler/wincgi/wincgi.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -143,7 +143,7 @@
    *The WinCGI protocol uses a .ini file to send data to the new process.
    */
   ret=DataFileHandle.openFile(dataFilePath,
-                     File::MYSERVER_CREATE_ALWAYS|File::MYSERVER_OPEN_WRITE);
+                     File::CREATE_ALWAYS|File::WRITE);
   if ( ret ) 
   {
     td->connection->host->warningsLogWrite("WinCGI: Error creating .ini");
@@ -287,7 +287,7 @@
    */
   if(!FilesUtility::fileExists(outFilePath))
   {
-    ret = OutFileHandle.openFile(outFilePath, File::MYSERVER_CREATE_ALWAYS);
+    ret = OutFileHandle.openFile(outFilePath, File::CREATE_ALWAYS);
     if (ret)
     {
       td->connection->host->warningsLogWrite(
@@ -318,8 +318,8 @@
     return td->http->raiseHTTPError(500);
   }
 
-  ret=OutFileHandle.openFile(outFilePath, File::MYSERVER_OPEN_ALWAYS|
-                             File::MYSERVER_OPEN_READ);
+  ret=OutFileHandle.openFile(outFilePath, File::OPEN_ALWAYS|
+                             File::READ);
   if (ret)
   {
     ostringstream msg;

Modified: trunk/myserver/src/log/stream/file_stream.cpp
===================================================================
--- trunk/myserver/src/log/stream/file_stream.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/log/stream/file_stream.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -1,6 +1,6 @@
 /*
   MyServer
-  Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+  Copyright (C) 2006, 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
@@ -18,11 +18,11 @@
 #include <include/log/stream/file_stream.h>
 
 int const FileStream::defaultFileMask = 
-  File::MYSERVER_OPEN_APPEND | 
-  File::MYSERVER_OPEN_ALWAYS |
-  File::MYSERVER_OPEN_WRITE | 
-  File::MYSERVER_OPEN_READ | 
-  File::MYSERVER_NO_INHERIT;
+  File::APPEND | 
+  File::OPEN_ALWAYS |
+  File::WRITE | 
+  File::READ | 
+  File::NO_INHERIT;
 
 FileStream::FileStream (FiltersFactory* ff, u_long cycle, Stream* out,
                         FiltersChain* fc) : 
@@ -62,9 +62,9 @@
         }
      
       if (newFile.openFile (newFileName,
-                            File::MYSERVER_OPEN_WRITE |
-                            File::MYSERVER_NO_INHERIT |
-                            File::MYSERVER_CREATE_ALWAYS))
+                            File::WRITE |
+                            File::NO_INHERIT |
+                            File::CREATE_ALWAYS))
         {
           cerr << "could not open " << newFileName << endl;
           delete [] buffer;

Modified: trunk/myserver/src/protocol/control/control_protocol.cpp
===================================================================
--- trunk/myserver/src/protocol/control/control_protocol.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/protocol/control/control_protocol.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -842,7 +842,7 @@
     filename = fn;    
   }
   
-  ret = localfile.openFile(filename, File::MYSERVER_OPEN_READ | File::MYSERVER_OPEN_IFEXISTS);
+  ret = localfile.openFile(filename, File::READ | File::OPEN_IF_EXISTS);
 
   /* An internal server error happens.  */
   if(ret)
@@ -933,7 +933,7 @@
     return CONTROL_INTERNAL;
   }
 
-  ret = localfile.openFile(filename, File::MYSERVER_OPEN_WRITE | File::MYSERVER_OPEN_ALWAYS);
+  ret = localfile.openFile(filename, File::WRITE | File::OPEN_ALWAYS);
 
   /* An internal server error happens.  */
   if(ret)

Modified: trunk/myserver/src/protocol/ftp/ftp.cpp
===================================================================
--- trunk/myserver/src/protocol/ftp/ftp.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/protocol/ftp/ftp.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -1159,9 +1159,9 @@
   {
     u_long flags = 0;
     if ( pWt->m_bAppend )
-      flags = File::MYSERVER_OPEN_APPEND | File::MYSERVER_OPEN_WRITE;
+      flags = File::APPEND | File::WRITE;
     else
-      flags = File::MYSERVER_CREATE_ALWAYS | File::MYSERVER_OPEN_WRITE;
+      flags = File::CREATE_ALWAYS | File::WRITE;
     if ( file.openFile(pWt->m_sFilePath.c_str(), flags) )
     {
       ftp_reply(pConnection, 451);
@@ -1352,9 +1352,9 @@
   {
     u_long flags = 0;
     if ( pWt->m_bAppend )
-      flags = File::MYSERVER_OPEN_APPEND | File::MYSERVER_OPEN_WRITE;
+      flags = File::APPEND | File::WRITE;
     else
-      flags = File::MYSERVER_CREATE_ALWAYS | File::MYSERVER_OPEN_WRITE;
+      flags = File::CREATE_ALWAYS | File::WRITE;
     if ( file.openFile(pWt->m_sFilePath.c_str(), flags) )
     {
       ftp_reply(pConnection, 451);

Modified: trunk/myserver/src/protocol/http/http_data_read.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http_data_read.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/protocol/http/http_data_read.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -310,9 +310,9 @@
    *Create the file that contains the posted data.
    *This data is the stdin file in the CGI.
    */
-  if(td->inputData.openFile(td->inputDataPath, File::MYSERVER_CREATE_ALWAYS |
-                            File::MYSERVER_OPEN_READ |
-                            File::MYSERVER_OPEN_WRITE))
+  if(td->inputData.openFile(td->inputDataPath, File::CREATE_ALWAYS |
+                            File::READ |
+                            File::WRITE))
   {
     *httpRetCode = 500;
     return 1;

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/src/server/server.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -205,13 +205,13 @@
   sSource.append ("default.xml");
 #endif
 
-  ret = inputF.openFile (sSource, File::MYSERVER_OPEN_READ
-                        | File::MYSERVER_OPEN_IFEXISTS);
+  ret = inputF.openFile (sSource, File::READ
+                        | File::OPEN_IF_EXISTS);
   if (ret)
     return -1;
 
-  ret = outputF.openFile (fileName, File::MYSERVER_OPEN_WRITE
-                         | File::MYSERVER_OPEN_ALWAYS);
+  ret = outputF.openFile (fileName, File::WRITE
+                         | File::OPEN_ALWAYS);
   if (ret)
     return -1;
 

Modified: trunk/myserver/tests/test_file.cpp
===================================================================
--- trunk/myserver/tests/test_file.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/tests/test_file.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -70,9 +70,9 @@
     u_long nbw;
     u_long nbr;
     
-    CPPUNIT_ASSERT_EQUAL (tfile->openFile( fname.c_str (), File::MYSERVER_OPEN_WRITE | 
-                                           File::MYSERVER_OPEN_READ | 
-                                           File::MYSERVER_CREATE_ALWAYS ), 0);
+    CPPUNIT_ASSERT_EQUAL (tfile->openFile( fname.c_str (), File::WRITE | 
+                                           File::READ | 
+                                           File::CREATE_ALWAYS ), 0);
     
     CPPUNIT_ASSERT_EQUAL (tfile->writeToFile ( buf, bufLen, &nbw ), 0);
     

Modified: trunk/myserver/tests/test_ssl_socket.cpp
===================================================================
--- trunk/myserver/tests/test_ssl_socket.cpp	2009-05-22 22:00:04 UTC (rev 3092)
+++ trunk/myserver/tests/test_ssl_socket.cpp	2009-05-22 22:00:24 UTC (rev 3093)
@@ -105,11 +105,11 @@
     u_long nbw;
     File f;
 
-    f.openFile (TESTSERVERKEY,  File::MYSERVER_OPEN_WRITE | File::MYSERVER_CREATE_ALWAYS);
+    f.openFile (TESTSERVERKEY,  File::WRITE | File::CREATE_ALWAYS);
     f.writeToFile (serverKey, strlen (serverKey), &nbw);
     f.close ();
 
-    f.openFile (TESTSERVERPEM,  File::MYSERVER_OPEN_WRITE | File::MYSERVER_CREATE_ALWAYS);
+    f.openFile (TESTSERVERPEM,  File::WRITE | File::CREATE_ALWAYS);
     f.writeToFile (serverPem, strlen (serverPem), &nbw);
     f.close ();
   }




From MAILER-DAEMON Sat May 23 17:12:18 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7yVt-0002DW-S9
	for mharc-myserver-commit@gnu.org; Sat, 23 May 2009 17:12:17 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7yVs-0002DE-2j
	for myserver-commit@gnu.org; Sat, 23 May 2009 17:12:16 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7yVr-0002Cv-H1
	for myserver-commit@gnu.org; Sat, 23 May 2009 17:12:15 -0400
Received: from [199.232.76.173] (port=54837 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7yVr-0002Cr-6p
	for myserver-commit@gnu.org; Sat, 23 May 2009 17:12:15 -0400
Received: from savannah.gnu.org ([199.232.41.3]:45299 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7yVq-0007te-N8
	for myserver-commit@gnu.org; Sat, 23 May 2009 17:12:14 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7yVp-00032s-Oj
	for myserver-commit@gnu.org; Sat, 23 May 2009 21:12:13 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7yVp-00032o-E5
	for myserver-commit@gnu.org; Sat, 23 May 2009 21:12:13 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7yVp-00032o-E5@cvs.savannah.gnu.org>
Date: Sat, 23 May 2009 21:12:13 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3094] Added basic Proxy features.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 23 May 2009 21:12:16 -0000

Revision: 3094
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3094
Author:   gscrivano
Date:     2009-05-23 21:12:13 +0000 (Sat, 23 May 2009)
Log Message:
-----------
Added basic Proxy features.

Modified Paths:
--------------
    trunk/myserver/configure.in
    trunk/myserver/documentation/mime_types.texi
    trunk/myserver/include/http_handler/Makefile.am
    trunk/myserver/include/protocol/http/http.h
    trunk/myserver/src/http_handler/Makefile.am
    trunk/myserver/src/protocol/http/http.cpp

Added Paths:
-----------
    trunk/myserver/include/http_handler/proxy/
    trunk/myserver/include/http_handler/proxy/Makefile.am
    trunk/myserver/include/http_handler/proxy/proxy.h
    trunk/myserver/src/http_handler/proxy/
    trunk/myserver/src/http_handler/proxy/Makefile.am
    trunk/myserver/src/http_handler/proxy/proxy.cpp

Modified: trunk/myserver/configure.in
===================================================================
--- trunk/myserver/configure.in	2009-05-22 22:00:24 UTC (rev 3093)
+++ trunk/myserver/configure.in	2009-05-23 21:12:13 UTC (rev 3094)
@@ -350,6 +350,7 @@
     include/http_handler/mscgi/Makefile
     include/http_handler/fastcgi/Makefile
     include/http_handler/http_file/Makefile
+    include/http_handler/proxy/Makefile
     include/http_handler/scgi/Makefile
     include/http_handler/isapi/Makefile
     include/http_handler/http_dir/Makefile
@@ -402,6 +403,7 @@
     src/http_handler/fastcgi/Makefile
     src/http_handler/http_file/Makefile
     src/http_handler/scgi/Makefile
+    src/http_handler/proxy/Makefile
     src/http_handler/isapi/Makefile
     src/http_handler/http_dir/Makefile
     src/base/Makefile

Modified: trunk/myserver/documentation/mime_types.texi
===================================================================
--- trunk/myserver/documentation/mime_types.texi	2009-05-22 22:00:24 UTC (rev 3093)
+++ trunk/myserver/documentation/mime_types.texi	2009-05-23 21:12:13 UTC (rev 3094)
@@ -12,13 +12,13 @@
 
 @example
 <MIME mime="text/html" handler="SEND" param="">
-<EXTENSION value="html"/>
-<FILTER value="gzip"/>
+      <EXTENSION value="html"/>
+      <FILTER value="gzip"/>
 </MIME>
 
 <MIME mime="text/html" handler="CGI" param="/usr/bin/perl" selfExecuted="NO">
-<EXTENSION value="pl"/>
-<DEFINE name="http.error.file.404" value="404.html"/>
+      <EXTENSION value="pl"/>
+      <DEFINE name="http.error.file.404" value="404.html"/>
 </MIME>
 @end example
 
@@ -107,6 +107,10 @@
 This protocol is obsoleted by ISAPI.  As CGI it needs a new process
 for every request and it uses files to communicate with the web
 server.  It is very inefficient.
+@item PROXY
+The HTTP request is forwarded to the HTTP server specified in the
+@code{param}.  This is not a real proxy, there is not caching and
+message is forwarded as it is without any change.
 @end enumerate
 
 It is possible to match the file name against a regular expression

Modified: trunk/myserver/include/http_handler/Makefile.am
===================================================================
--- trunk/myserver/include/http_handler/Makefile.am	2009-05-22 22:00:24 UTC (rev 3093)
+++ trunk/myserver/include/http_handler/Makefile.am	2009-05-23 21:12:13 UTC (rev 3094)
@@ -1,4 +1,4 @@
 http_handlerincludedir=$(includedir)/myserver/include/http_handler
 http_handlerinclude_HEADERS =
-SUBDIRS = cgi fastcgi http_dir http_file isapi mscgi scgi wincgi
+SUBDIRS = cgi fastcgi http_dir http_file isapi mscgi proxy scgi wincgi
 

Added: trunk/myserver/include/http_handler/proxy/Makefile.am
===================================================================
--- trunk/myserver/include/http_handler/proxy/Makefile.am	                        (rev 0)
+++ trunk/myserver/include/http_handler/proxy/Makefile.am	2009-05-23 21:12:13 UTC (rev 3094)
@@ -0,0 +1,3 @@
+proxyincludedir=$(includedir)/myserver/include/http_handler/proxy
+proxyinclude_HEADERS = proxy.h
+SUBDIRS =

Added: trunk/myserver/include/http_handler/proxy/proxy.h
===================================================================
--- trunk/myserver/include/http_handler/proxy/proxy.h	                        (rev 0)
+++ trunk/myserver/include/http_handler/proxy/proxy.h	2009-05-23 21:12:13 UTC (rev 3094)
@@ -0,0 +1,43 @@
+/* -*- 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 PROXY_H
+#define PROXY_H
+
+#include <include/protocol/http/http_response.h>
+#include <include/protocol/http/http_request.h>
+#include <include/protocol/http/http_headers.h>
+#include <include/protocol/http/http_data_handler.h>
+
+class FiltersChain;
+
+class Proxy : public HttpDataHandler
+{
+public:
+  static void setTimeout (int);
+  static int getTimeout ();
+
+	virtual int send (HttpThreadContext*, ConnectionPtr s,
+                   const char* scriptpath, const char* exec = 0,
+                   int execute = 0, int onlyHeader = 0);
+protected:
+  int flushToClient (HttpThreadContext* td, Socket& client,
+                     FiltersChain &out, int onlyHeader);
+  static int timeout;
+};
+#endif

Modified: trunk/myserver/include/protocol/http/http.h
===================================================================
--- trunk/myserver/include/protocol/http/http.h	2009-05-22 22:00:24 UTC (rev 3093)
+++ trunk/myserver/include/protocol/http/http.h	2009-05-23 21:12:13 UTC (rev 3094)
@@ -67,6 +67,7 @@
   HttpDataHandler *scgi;
   HttpDataHandler *fastcgi;
   HttpDataHandler *httpFile;
+  HttpDataHandler *proxy;
   HttpDataHandler *httpDir;
 
 

Modified: trunk/myserver/src/http_handler/Makefile.am
===================================================================
--- trunk/myserver/src/http_handler/Makefile.am	2009-05-22 22:00:24 UTC (rev 3093)
+++ trunk/myserver/src/http_handler/Makefile.am	2009-05-23 21:12:13 UTC (rev 3094)
@@ -1,5 +1,5 @@
 lib_LIBRARIES = libhttp_handler.a
 libhttp_handler_a_SOURCES =
-SUBDIRS = cgi fastcgi http_dir http_file isapi mscgi scgi wincgi
+SUBDIRS = cgi fastcgi http_dir http_file isapi mscgi proxy scgi wincgi
 INCLUDES = $(all_includes)
 

Added: trunk/myserver/src/http_handler/proxy/Makefile.am
===================================================================
--- trunk/myserver/src/http_handler/proxy/Makefile.am	                        (rev 0)
+++ trunk/myserver/src/http_handler/proxy/Makefile.am	2009-05-23 21:12:13 UTC (rev 3094)
@@ -0,0 +1,5 @@
+lib_LIBRARIES = libproxy.a
+libproxy_a_SOURCES = proxy.cpp
+SUBDIRS =
+INCLUDES = $(all_includes)
+

Added: trunk/myserver/src/http_handler/proxy/proxy.cpp
===================================================================
--- trunk/myserver/src/http_handler/proxy/proxy.cpp	                        (rev 0)
+++ trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-23 21:12:13 UTC (rev 3094)
@@ -0,0 +1,235 @@
+/*
+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 "stdafx.h"
+#include <include/http_handler/proxy/proxy.h>
+
+#include <include/protocol/http/http_thread_context.h>
+#include <include/protocol/http/http.h>
+#include <include/protocol/url.h>
+#include <include/base/socket/socket.h>
+#include <include/protocol/http/http_request.h>
+#include <include/protocol/http/http_data_handler.h>
+#include <include/protocol/http/http_headers.h>
+#include <include/filter/filters_chain.h>
+
+#include <sstream>
+
+int Proxy::timeout = MYSERVER_SEC (10);
+
+/*
+ *Forward the HTTP requesto to another server.
+ *
+ *\param td The HTTP thread context.
+ *\param s A pointer to the connection structure.
+ *\param scriptpath Not used.
+ *\param exec The remote server Url.
+ *\param execute Not used.
+ *\param onlyHeader Specify if send only the HTTP header.
+ */
+int Proxy::send (HttpThreadContext *td, ConnectionPtr s,
+                 const char* scriptpath,
+                 const char* exec,
+                 int execute,
+                 int onlyHeader)
+{
+  Url destUrl (exec, 80);
+  Socket sock;
+  FiltersChain chain;
+  HttpRequestHeader req;
+  u_long nbw;
+
+  for (HashMap<string, HttpRequestHeader::Entry*>::Iterator it = td->request.begin ();
+       it != td->request.end ();
+       it++)
+    {
+      HttpRequestHeader::Entry *e = *it;
+      req.setValue (e->name->c_str (), e->value->c_str ());
+    }
+
+  if (destUrl.getProtocol ().compare ("HTTP"))
+    {
+      ostringstream msg;
+      msg << "Proxy: " << destUrl.getProtocol () << " is not known.";
+      td->connection->host->warningsLogWrite (msg.str ().c_str ());
+      return 0;
+    }
+
+  /*Use HTTP/1.0 until we accept chunks from clients.  */
+  req.ver.assign ("HTTP/1.0");
+  req.cmd.assign ("GET");
+  req.uri.assign ("/");
+  req.uri.append (destUrl.getResource ());
+  req.uri.append (td->pathInfo);
+  req.setValue ("Connection", "Close");
+
+  ostringstream host;
+  host << destUrl.getHost ();
+  if (destUrl.getPort () != 80 )
+    host << ":" << destUrl.getPort ();
+
+  req.setValue ("Host", host.str ().c_str ());
+
+	HttpHeaders::buildHTTPRequestHeader (td->secondaryBuffer->getBuffer (),
+                                       &req);
+
+  if (sock.connect (destUrl.getHost ().c_str (), destUrl.getPort ()))
+    return td->http->raiseHTTPError (500);
+
+  if (td->request.uriOptsPtr &&
+      td->inputData.fastCopyToSocket (&sock, 0, td->secondaryBuffer, &nbw))
+    {
+      sock.close ();
+      return td->http->raiseHTTPError (500);
+    }
+
+  if (sock.write (td->secondaryBuffer->getBuffer (),
+                  strlen (td->secondaryBuffer->getBuffer ()), &nbw))
+    {
+      sock.close ();
+      return td->http->raiseHTTPError (500);
+    }
+
+  chain.setProtocol(td->http);
+  chain.setProtocolData(td);
+  chain.setStream(td->connection->socket);
+
+  if(td->mime && Server::getInstance()->getFiltersFactory()->chain(&chain,
+                                                                   td->mime->filters,
+                                                                   td->connection->socket,
+                                                                   &nbw,
+                                                                   1))
+    {
+      sock.close ();
+      return td->http->raiseHTTPError (500);
+    }
+
+  int ret = flushToClient (td, sock, chain, onlyHeader);
+
+
+  chain.clearAllFilters();
+  sock.close ();
+
+  return ret;
+}
+
+/*!
+ *Flush the server reply to the client.
+ */
+int Proxy::flushToClient (HttpThreadContext* td, Socket& client,
+                          FiltersChain &out, int onlyHeader)
+{
+  u_long read = 0;
+  u_long headerLength;
+  int ret;
+  u_long nbw;
+  bool useChunks = false;
+  bool keepalive = false;
+
+  do
+    {
+      ret = client.recv (td->secondaryBuffer->getBuffer () + read,
+                         td->secondaryBuffer->getRealLength () - read,
+                         0,
+                         timeout);
+
+      if (ret == 0)
+        return td->http->raiseHTTPError (500);
+
+      read += ret;
+
+      ret = HttpHeaders::buildHTTPResponseHeaderStruct (td->secondaryBuffer->getBuffer (),
+                                                        &td->response,
+                                                        &headerLength);
+    }
+  while (ret == -1);
+
+  checkDataChunks (td, &keepalive, &useChunks);
+
+
+  HttpHeaders::buildHTTPResponseHeader (td->buffer->getBuffer (),
+                                        &td->response);
+
+  if (out.getStream ()->write (td->buffer->getBuffer (),
+                               strlen (td->buffer->getBuffer ()),
+                               &nbw))
+    return 0;
+
+  if (onlyHeader)
+    return keepalive;
+
+  if (read - headerLength)
+    {
+      if (HttpDataHandler::appendDataToHTTPChannel(td,
+                                                   td->secondaryBuffer->getBuffer() +
+                                                     headerLength,
+                                                   read - headerLength,
+                                                   &(td->outputData),
+                                                   &out,
+                                                   td->appendOutputs,
+                                                   useChunks))
+        return 0;
+
+      td->sentData += read - headerLength;
+    }
+
+  while (ret = client.recv (td->secondaryBuffer->getBuffer (),
+                            td->secondaryBuffer->getRealLength (),
+                            0,
+                            timeout))
+    {
+
+      if (ret == -1)
+        break;
+
+      if (HttpDataHandler::appendDataToHTTPChannel(td,
+                                                   td->secondaryBuffer->getBuffer(),
+                                                   ret,
+                                                   &(td->outputData),
+                                                   &out,
+                                                   td->appendOutputs,
+                                                   useChunks))
+        return 0;
+
+      td->sentData += ret;
+    }
+
+
+  if(useChunks && out.write ("0\r\n\r\n", 5, &nbw))
+    {
+      return 0;
+    }
+
+  return keepalive;
+}
+
+/*!
+ *Set the CGI timeout for the new processes.
+ *\param nt The new timeout value.
+ */
+void Proxy::setTimeout(int nt)
+{
+   timeout = nt;
+}
+
+/*!
+ *Get the timeout value for HTTP requests.
+ */
+int Proxy::getTimeout()
+{
+  return timeout;
+}

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp	2009-05-22 22:00:24 UTC (rev 3093)
+++ trunk/myserver/src/protocol/http/http.cpp	2009-05-23 21:12:13 UTC (rev 3094)
@@ -39,6 +39,7 @@
 #include <include/http_handler/mscgi/mscgi.h>
 #include <include/http_handler/isapi/isapi.h>
 #include <include/http_handler/http_file/http_file.h>
+#include <include/http_handler/proxy/proxy.h>
 #include <include/http_handler/http_dir/http_dir.h>
 #include <include/protocol/http/http_data_read.h>
 
@@ -82,10 +83,12 @@
   fastcgi = new FastCgi();
   httpFile = new HttpFile();
   httpDir = new HttpDir();
+  proxy = new Proxy ();
 }
 
 HttpStaticData::~HttpStaticData ()
 {
+  delete proxy;
   delete mscgi;
   delete wincgi;
   delete isapi;
@@ -1887,6 +1890,7 @@
   staticHttp.dynManagerList.addHttpManager ("WINCGI", staticHttp.wincgi);
   staticHttp.dynManagerList.addHttpManager ("FASTCGI", staticHttp.fastcgi);
   staticHttp.dynManagerList.addHttpManager ("ISAPI", staticHttp.isapi);
+  staticHttp.dynManagerList.addHttpManager ("PROXY", staticHttp.proxy);
 
   data = Server::getInstance ()->getHashedData ("vhost.allow_mime");
   if(data)
@@ -1907,6 +1911,7 @@
   Scgi::setTimeout (staticHttp.cgiTimeout);
   WinCgi::setTimeout (staticHttp.cgiTimeout);
   Isapi::setTimeout (staticHttp.cgiTimeout);
+  Proxy::setTimeout (staticHttp.cgiTimeout);
 
   return 1;
 }




From MAILER-DAEMON Sat May 23 18:31:51 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M7zkt-00049x-Ko
	for mharc-myserver-commit@gnu.org; Sat, 23 May 2009 18:31:51 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M7zks-00049N-Gx
	for myserver-commit@gnu.org; Sat, 23 May 2009 18:31:50 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M7zkr-00048Y-KG
	for myserver-commit@gnu.org; Sat, 23 May 2009 18:31:50 -0400
Received: from [199.232.76.173] (port=41395 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M7zkr-00048S-Gw
	for myserver-commit@gnu.org; Sat, 23 May 2009 18:31:49 -0400
Received: from savannah.gnu.org ([199.232.41.3]:50121 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M7zkq-000609-VC
	for myserver-commit@gnu.org; Sat, 23 May 2009 18:31:49 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M7zkq-00020U-Ac
	for myserver-commit@gnu.org; Sat, 23 May 2009 22:31:48 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M7zkp-00020Q-Pf
	for myserver-commit@gnu.org; Sat, 23 May 2009 22:31:48 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M7zkp-00020Q-Pf@cvs.savannah.gnu.org>
Date: Sat, 23 May 2009 22:31:47 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3095] Code refactoring,
 `HttpFile::appendDataToHTTPChannel ()'
 was moved to the `HttpDataHandler' class.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 23 May 2009 22:31:50 -0000

Revision: 3095
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3095
Author:   gscrivano
Date:     2009-05-23 22:31:47 +0000 (Sat, 23 May 2009)
Log Message:
-----------
Code refactoring, `HttpFile::appendDataToHTTPChannel ()' was moved to the `HttpDataHandler' class.

Modified Paths:
--------------
    trunk/myserver/include/http_handler/http_file/http_file.h
    trunk/myserver/include/protocol/http/http_data_handler.h
    trunk/myserver/src/http_handler/cgi/cgi.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/http_handler/http_dir/http_dir.cpp
    trunk/myserver/src/http_handler/http_file/http_file.cpp
    trunk/myserver/src/http_handler/isapi/isapi.cpp
    trunk/myserver/src/http_handler/mscgi/mscgi.cpp
    trunk/myserver/src/http_handler/scgi/scgi.cpp
    trunk/myserver/src/http_handler/wincgi/wincgi.cpp
    trunk/myserver/src/protocol/http/http_data_handler.cpp

Modified: trunk/myserver/include/http_handler/http_file/http_file.h
===================================================================
--- trunk/myserver/include/http_handler/http_file/http_file.h	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/include/http_handler/http_file/http_file.h	2009-05-23 22:31:47 UTC (rev 3095)
@@ -23,7 +23,6 @@
 #include <include/protocol/protocol.h>
 #include <include/protocol/http/http_headers.h>
 #include <include/protocol/http/http_data_handler.h>
-#include <include/filter/memory_stream.h>
 
 class HttpFile  : public HttpDataHandler
 {
@@ -41,16 +40,6 @@
                string& filename);
   int deleteFile (HttpThreadContext* td,
                   string& filename);
-private:
-  static int appendDataToHTTPChannel(HttpThreadContext* td, 
-                                     char* buffer, 
-                                     u_long size,
-                                     File* appendFile, 
-                                     FiltersChain* chain,
-                                     bool append, 
-                                     bool useChunks,
-                                     u_long realBufferSize,
-                                     MemoryStream *tmpStream);
 };
 
 

Modified: trunk/myserver/include/protocol/http/http_data_handler.h
===================================================================
--- trunk/myserver/include/protocol/http/http_data_handler.h	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/include/protocol/http/http_data_handler.h	2009-05-23 22:31:47 UTC (rev 3095)
@@ -23,7 +23,9 @@
 #include <include/protocol/protocol.h>
 #include "include/protocol/http/http_headers.h"
 #include <include/filter/filters_chain.h>
+#include <include/filter/memory_stream.h>
 
+
 /*!
  *Base class to handle HTTP data.
  */
@@ -41,10 +43,22 @@
   virtual ~HttpDataHandler();
 
 	static void checkDataChunks(HttpThreadContext*, bool*, bool*);
+
+  static int appendDataToHTTPChannel (HttpThreadContext* td,
+                                      char* buffer,
+                                      u_long size,
+                                      File* appendFile,
+                                      FiltersChain* chain,
+                                      bool append,
+                                      bool useChunks,
+                                      u_long realBufferSize,
+                                      MemoryStream *tmpStream);
+
 	static int appendDataToHTTPChannel(HttpThreadContext* td, 
-                                     char* buffer, u_long size,
+                                     char* buffer,
+                                     u_long size,
                                      File* appendFile, 
-                                     Stream* chain,
+                                     FiltersChain* chain,
                                      bool append, 
                                      bool useChunks);
 

Modified: trunk/myserver/src/http_handler/cgi/cgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/cgi/cgi.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/cgi/cgi.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -420,7 +420,7 @@
   
   
     /* Send the last null chunk if needed.  */
-    if(useChunks && chain.write("0\r\n\r\n", 5, &nbw2))
+    if(useChunks && chain.getStream ()->write("0\r\n\r\n", 5, &nbw2))
     {
       return 0;       
     }
@@ -555,8 +555,9 @@
 
       td->buffer->setLength((u_int)strlen(td->buffer->getBuffer()));
 
-      if (chain.write(td->buffer->getBuffer(),
-                      static_cast<int>(td->buffer->getLength()), &nbw))
+      if (chain.getStream ()->write(td->buffer->getBuffer(),
+                                    static_cast<int> (td->buffer->getLength()),
+                                    &nbw))
       {
         *ret = 0;
         return 1;

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -328,7 +328,7 @@
   /* Send the last null chunk if needed.  */
   if(con.useChunks && 
      (td->response.getStatusType () == HttpResponseHeader::SUCCESSFUL))
-    chain.write("0\r\n\r\n", 5, &nbw);
+    chain.getStream ()->write("0\r\n\r\n", 5, &nbw);
 
   chain.clearAllFilters();
   con.sock.close();

Modified: trunk/myserver/src/http_handler/http_dir/http_dir.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_dir/http_dir.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/http_dir/http_dir.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -311,7 +311,8 @@
   bool sortReverse = false;
   string linkPrefix;
   const char *formatString = td->securityToken.getHashedData ("http.dir.format", 
-                                                              MYSERVER_SECURITY_CONF | MYSERVER_VHOST_CONF |
+                                                              MYSERVER_SECURITY_CONF |
+                                                              MYSERVER_VHOST_CONF |
                                                               MYSERVER_SERVER_CONF, "%f%t%s");
 
 
@@ -633,7 +634,7 @@
 
   if(!td->appendOutputs && useChunks)
   {
-    if(chain.write("0\r\n\r\n", 5, &nbw))
+    if(chain.getStream ()->write ("0\r\n\r\n", 5, &nbw))
       return 1;
   }
 

Modified: trunk/myserver/src/http_handler/http_file/http_file.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -22,6 +22,7 @@
 #include <include/filter/gzip/gzip.h>
 #include <include/server/server.h>
 #include <include/filter/filters_chain.h>
+#include <include/filter/memory_stream.h>
 
 #include <sstream>
 #include <algorithm>
@@ -394,10 +395,10 @@
     if(td->mime)
     {
       if(td->mime && 
-         Server::getInstance()->getFiltersFactory()->chain(&chain, 
-                                                           td->mime->filters, 
-                                                           &memStream, 
-                                                           &nbw))
+         Server::getInstance()->getFiltersFactory()->chain (&chain,
+                                                            td->mime->filters,
+                                                            &memStream,
+                                                            &nbw))
       {
         file->close();
         delete file;
@@ -421,7 +422,7 @@
         chain.clearAllFilters();
         return 0;
       }
-      if(chain.addFilter(gzipFilter, &nbw))
+      if(chain.addFilter (gzipFilter, &nbw))
       {
         delete gzipFilter;
         file->close();
@@ -567,7 +568,7 @@
                                                     td->buffer->getBuffer(), 
                                                     nbr,
                                                     &(td->outputData), 
-                                                    chain.getStream(),
+                                                    &chain,
                                                     td->appendOutputs, 
                                                     useChunks))
         {
@@ -607,14 +608,14 @@
         bytesToSend -= nbr;
 
 
-        ret = appendDataToHTTPChannel(td, td->buffer->getBuffer(),
-                                      nbr,
-                                      &(td->outputData), 
-                                      &chain,
-                                      td->appendOutputs, 
-                                      useChunks,
-                                      td->buffer->getRealLength(),
-                                      &memStream);
+        ret = appendDataToHTTPChannel (td, td->buffer->getBuffer (),
+                                       nbr,
+                                       &(td->outputData),
+                                       &chain,
+                                       td->appendOutputs,
+                                       useChunks,
+                                       td->buffer->getRealLength (),
+                                       &memStream);
         if(ret)
           break;     
           
@@ -660,7 +661,7 @@
                                                          td->buffer->getBuffer(), 
                                                          nbr,
                                                          &(td->outputData), 
-                                                         chain.getStream(),
+                                                         &chain,
                                                          td->appendOutputs, 
                                                          useChunks);
           if(ret)
@@ -670,7 +671,7 @@
                                                          0,
                                                          0,
                                                          &(td->outputData), 
-                                                         chain.getStream(),
+                                                         &chain,
                                                          td->appendOutputs, 
                                                          useChunks);
         
@@ -685,34 +686,34 @@
     file->close();
     delete file;
   }
-  catch(bad_alloc &ba)
+  catch (bad_alloc &ba)
   {
-    file->close();
+    file->close ();
     delete file;
-    s->host->warningsLogWrite("HttpFile: Error allocating memory");
-    chain.clearAllFilters();
-    return td->http->raiseHTTPError(500);
+    s->host->warningsLogWrite ("HttpFile: Error allocating memory");
+    chain.clearAllFilters ();
+    return td->http->raiseHTTPError (500);
   }
-  catch(...)
+  catch (...)
   {
-    file->close();
+    file->close ();
     delete file;
-    s->host->warningsLogWrite("HttpFile: Internal error");
+    s->host->warningsLogWrite ("HttpFile: Internal error");
     chain.clearAllFilters();
-    return td->http->raiseHTTPError(500);
+    return td->http->raiseHTTPError (500);
   };
  
   /* For logging activity.  */
   td->sentData += dataSent;
 
-  chain.clearAllFilters();
+  chain.clearAllFilters ();
   return !ret;
 }
 
 /*!
  *Constructor for the class.
  */
-HttpFile::HttpFile()
+HttpFile::HttpFile ()
 {
 
 }
@@ -720,7 +721,7 @@
 /*!
  *Destroy the object.
  */
-HttpFile::~HttpFile()
+HttpFile::~HttpFile ()
 {
 
 }
@@ -737,67 +738,7 @@
 /*!
  *Unload the static elements.
  */
-int HttpFile::unLoad()
+int HttpFile::unLoad ()
 {
   return 0;
 }
-
-/*!
- *Custom version for the appendDataToHTTPChannel function, this is
- *slower that the HttpDataHandler one but the internal buffer is
- *needed by the filters chain.
- *\param td The HTTP thread context.
- *\param buffer Data to send.
- *\param size Size of the buffer.
- *\param appendFile The file where append if in append mode.
- *\param chain Where send data if not append.
- *\param append Append to the file?
- *\param useChunks Can we use HTTP chunks to send data?
- *\param realBufferSize The real dimension of the buffer that can be
- *used by this method.
- *\param tmpStream A support on memory read/write stream used
- *internally by the function.
- */
-int HttpFile::appendDataToHTTPChannel(HttpThreadContext* td, 
-                                      char* buffer, 
-                                      u_long size,
-                                      File* appendFile, 
-                                      FiltersChain* chain,
-                                      bool append, 
-                                      bool useChunks,
-                                      u_long realBufferSize,
-                                      MemoryStream *tmpStream)
-{
-  u_long nbr, nbw;
-  Stream *oldStream = chain->getStream();
-
-  /* 
-   *This function can't append directly to the chain because we can't
-   *know in advance the data chunk size.  Therefore we replace the
-   *final stream with a memory buffer and write there the final data
-   *chunk content, finally we read from it and send directly on the
-   *original stream.
-   */
-  chain->setStream(tmpStream);
-  
-  if(chain->write(buffer, size, &nbw))
-    return 1;
-
-  if(tmpStream->read(buffer, realBufferSize, &nbr))
-    return 1;
-  
-  chain->setStream(oldStream);
-  
-  /*
-   *Use of chain->getStream() is needed to write directly on the
-   *final stream.
-   */
-  return HttpDataHandler::appendDataToHTTPChannel(td, 
-                                                  buffer, 
-                                                  nbr, 
-                                                  appendFile, 
-                                                  chain->getStream(), 
-                                                  append, 
-                                                  useChunks);
-  
-}

Modified: trunk/myserver/src/http_handler/isapi/isapi.cpp
===================================================================
--- trunk/myserver/src/http_handler/isapi/isapi.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/isapi/isapi.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -311,9 +311,9 @@
         /*! With keep-alive connections use chunks.*/
         if(keepalive && (!ConnInfo->td->appendOutputs))
         {
-          sprintf(chunkSize,"%x\r\n",len);
-          if(ConnInfo->chain.write(chunkSize, 
-                                   (int)strlen(chunkSize), &nbw))      
+          sprintf(chunkSize, "%x\r\n", len);
+          if(ConnInfo->chain.getStream ()->write(chunkSize,
+                                                 (int)strlen(chunkSize), &nbw))
             return 0;
         }
         
@@ -326,16 +326,16 @@
         }
         else
         {
-          if(ConnInfo->chain.write((char*)(buffer + headerSize), 
-                                   len, &nbw))
+          if(ConnInfo->chain.write ((char*)(buffer + headerSize),
+                                    len, &nbw))
             return 0;
           ConnInfo->dataSent += nbw;
         }
 
-        /*! Send the chunk tailer.*/
+        /*! Send the chunk footer.  */
         if(keepalive && (!ConnInfo->td->appendOutputs))
         {
-          if(ConnInfo->chain.write("\r\n", 2, &nbw))          
+          if (ConnInfo->chain.getStream ()->write ("\r\n", 2, &nbw))
             return 0;
         }
       }
@@ -349,13 +349,13 @@
   {
     if(keepalive  && (!ConnInfo->td->appendOutputs))
     {
-      sprintf(chunkSize,"%x\r\n",*lpdwBytes);
-      nbw = ConnInfo->connection->socket->send(chunkSize, 
-                                               (int)strlen(chunkSize), 0);
+      sprintf (chunkSize, "%x\r\n", *lpdwBytes);
+      nbw = ConnInfo->connection->socket->send (chunkSize, 
+                                                (int)strlen(chunkSize), 0);
       if((nbw == (u_long)-1) || (!nbw))
         return 0;
     }
-    
+
     if(ConnInfo->td->appendOutputs)
     {
       if(ConnInfo->td->outputData.writeToFile((char*)Buffer,*lpdwBytes, &nbw))
@@ -371,7 +371,7 @@
 
     if(keepalive  && (!ConnInfo->td->appendOutputs))
     {
-      nbw = ConnInfo->connection->socket->send("\r\n",2, 0);
+      nbw = ConnInfo->connection->socket->send("\r\n", 2, 0);
       if((nbw == (u_long)-1) || (!nbw))
         return 0;
     }
@@ -946,7 +946,7 @@
   }
 
   Ret = HttpExtensionProc(&ExtCtrlBlk);
-  if (Ret == HSE_STATUS_PENDING) 
+  if (Ret == HSE_STATUS_PENDING)
   {
     WaitForSingleObject(connTable[connIndex].ISAPIDoneEvent, timeout);
   }
@@ -956,7 +956,7 @@
     HttpRequestHeader::Entry *connection = connTable[connIndex].td->request.other.get("Connection");
 
     if(connection && !stringcmpi(connection->value->c_str(), "keep-alive"))
-      Ret = connTable[connIndex].chain.write("0\r\n\r\n", 5, &nbw);
+      Ret = connTable[connIndex].chain.getStream ()->write("0\r\n\r\n", 5, &nbw);
   }
   
   switch(Ret) 

Modified: trunk/myserver/src/http_handler/mscgi/mscgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/mscgi/mscgi.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/mscgi/mscgi.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -154,7 +154,7 @@
 
   if(!td->appendOutputs && data.useChunks && !data.error)
   {
-    if(chain.write("0\r\n\r\n", 5, &nbw))
+    if(chain.getStream ()->write("0\r\n\r\n", 5, &nbw))
       return 0;
   }
 
@@ -193,7 +193,7 @@
                                               (char*) data,
                                               len,
                                               &(mcd->td->outputData), 
-                                              mcd->filtersChain->getStream(),
+                                              mcd->filtersChain,
                                               mcd->td->appendOutputs, 
                                               mcd->useChunks))
     return 1;

Modified: trunk/myserver/src/http_handler/scgi/scgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -338,7 +338,7 @@
     
     if(!td->appendOutputs && useChunks)
     {
-      if(chain->write("0\r\n\r\n", 5, &nbw))
+      if(chain->getStream ()->write("0\r\n\r\n", 5, &nbw))
         return -1;
     }
   }

Modified: trunk/myserver/src/http_handler/wincgi/wincgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/wincgi/wincgi.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/http_handler/wincgi/wincgi.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -375,9 +375,9 @@
      */
     HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
                                           &td->response);
-    if(chain.write((const char*)td->buffer->getBuffer(),
-                          (int)strlen((const char*)td->buffer->getBuffer()), 
-                   &nbw2))
+    if(chain.getStream ()->write((const char*)td->buffer->getBuffer(),
+                                 (int)strlen((const char*)td->buffer->getBuffer()), 
+                                 &nbw2))
     {
       OutFileHandle.close();
       FilesUtility::deleteFile(outFilePath);

Modified: trunk/myserver/src/protocol/http/http_data_handler.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http_data_handler.cpp	2009-05-23 21:12:13 UTC (rev 3094)
+++ trunk/myserver/src/protocol/http/http_data_handler.cpp	2009-05-23 22:31:47 UTC (rev 3095)
@@ -61,7 +61,74 @@
 }
 
 /*!
- *Send data over the HTTP channel.
+ *Send data over the HTTP channel.  This method considers modifier filters.
+ *in the filters chain.
+ *\param td The HTTP thread context.
+ *\param buffer Data to send.
+ *\param size Size of the buffer.
+ *\param appendFile The file where append if in append mode.
+ *\param chain Where send data if not append.
+ *\param append Append to the file?
+ *\param useChunks Can we use HTTP chunks to send data?
+ *\param realBufferSize The real dimension of the buffer that can be
+ *used by this method.
+ *\param tmpStream A support on memory read/write stream used
+ *internally by the function.
+ */
+int HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext* td,
+                                              char* buffer,
+                                              u_long size,
+                                              File* appendFile,
+                                              FiltersChain* chain,
+                                              bool append,
+                                              bool useChunks,
+                                              u_long realBufferSize,
+                                              MemoryStream *tmpStream)
+{
+  u_long nbr, nbw;
+  Stream *oldStream = chain->getStream ();
+
+  if (!chain->hasModifiersFilters ())
+    return appendDataToHTTPChannel (td,
+                                    buffer,
+                                    size,
+                                    appendFile,
+                                    chain,
+                                    append,
+                                    useChunks);
+
+  /*
+   *This function can't append directly to the chain because we can't
+   *know in advance the data chunk size.  Therefore we replace the
+   *final stream with a memory buffer and write there the final data
+   *chunk content, finally we read from it and send directly to the
+   *original stream.
+   */
+  chain->setStream (tmpStream);
+
+  if (chain->write (buffer, size, &nbw))
+    return 1;
+
+  if (tmpStream->read (buffer, realBufferSize, &nbr))
+    return 1;
+
+  chain->setStream (oldStream);
+
+  /*
+   *Use of chain->getStream() is needed to write directly on the
+   *final stream.
+   */
+  return appendDataToHTTPChannel (td,
+                                  buffer,
+                                  nbr,
+                                  appendFile,
+                                  chain,
+                                  append,
+                                  useChunks);
+}
+
+/*!
+ *Send raw data over the HTTP channel.  It doesn't consider modifier filters.
  *Return zero on success.
  *\param td The HTTP thread context.
  *\param buffer Data to send.
@@ -71,45 +138,45 @@
  *\param append Append to the file?
  *\param useChunks Can we use HTTP chunks to send data?
  */
-int HttpDataHandler::appendDataToHTTPChannel(HttpThreadContext* td, 
-                                             char* buffer, u_long size,
-                                             File* appendFile, 
-                                             Stream* chain,
-                                             bool append, 
-                                             bool useChunks)
+int HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext* td,
+                                              char* buffer,
+                                              u_long size,
+                                              File* appendFile,
+                                              FiltersChain* chain,
+                                              bool append,
+                                              bool useChunks)
 {
   u_long nbw;
+
+  if (chain->hasModifiersFilters ())
+    return 1;
+
   if(append)
-  {
     return appendFile->writeToFile(buffer, size, &nbw);
-  }
   else
-  {
-    if(useChunks)
-      {
-      ostringstream chunkHeader;
-      u_long flushNbw = 0;
-      chunkHeader << hex << size << "\r\n"; 
+    {
+      if(useChunks)
+        {
+          ostringstream chunkHeader;
+          u_long flushNbw = 0;
+          chunkHeader << hex << size << "\r\n";
 
-      if(chain->flush(&flushNbw))
-        return 1;
+          if(chain->flush(&flushNbw))
+            return 1;
 
-      if(chain->write(chunkHeader.str().c_str(), 
-                                   chunkHeader.str().length(), &nbw))
+          if(chain->getStream ()->write(chunkHeader.str().c_str(),
+                                        chunkHeader.str().length(), &nbw))
+            return 1;
+        }
+
+      if(size && chain->write(buffer, size, &nbw))
         return 1;
-    }
 
-    if(size)
-      if(chain->write(buffer, size, &nbw))
+      if(useChunks && chain->getStream ()->write("\r\n", 2, &nbw))
         return 1;
 
-    if(useChunks)
-
-    if(chain->write("\r\n", 2, &nbw))
-      return 1;
-
-    return 0;
-  }
+      return 0;
+    }
   return 1;
 }
 




From MAILER-DAEMON Sun May 24 09:01:06 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M8DK2-0007tB-Gy
	for mharc-myserver-commit@gnu.org; Sun, 24 May 2009 09:01:03 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M8DJw-0007qO-V2
	for myserver-commit@gnu.org; Sun, 24 May 2009 09:00:57 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M8DJu-0007ob-3u
	for myserver-commit@gnu.org; Sun, 24 May 2009 09:00:54 -0400
Received: from [199.232.76.173] (port=33581 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M8DJt-0007oQ-6O
	for myserver-commit@gnu.org; Sun, 24 May 2009 09:00:53 -0400
Received: from savannah.gnu.org ([199.232.41.3]:36357 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M8Bmw-0008V0-Jn
	for myserver-commit@gnu.org; Sun, 24 May 2009 07:22:46 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M8Bmv-0001QW-Vl
	for myserver-commit@gnu.org; Sun, 24 May 2009 11:22:46 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M8Bmv-0001QS-In
	for myserver-commit@gnu.org; Sun, 24 May 2009 11:22:45 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M8Bmv-0001QS-In@cvs.savannah.gnu.org>
Date: Sun, 24 May 2009 11:22:45 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3097] The HTTP Proxy is now HTTP/1.1 compliant.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 24 May 2009 13:00:58 -0000

Revision: 3097
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3097
Author:   gscrivano
Date:     2009-05-24 11:22:44 +0000 (Sun, 24 May 2009)
Log Message:
-----------
The HTTP Proxy is now HTTP/1.1 compliant.

Modified Paths:
--------------
    trunk/myserver/AUTHORS
    trunk/myserver/include/http_handler/proxy/proxy.h
    trunk/myserver/include/protocol/http/http_data_read.h
    trunk/myserver/src/http_handler/proxy/proxy.cpp
    trunk/myserver/src/protocol/http/http_data_read.cpp

Modified: trunk/myserver/AUTHORS
===================================================================
--- trunk/myserver/AUTHORS	2009-05-24 08:18:18 UTC (rev 3096)
+++ trunk/myserver/AUTHORS	2009-05-24 11:22:44 UTC (rev 3097)
@@ -1,7 +1,8 @@
 People who contributed significantly to GNU MyServer:
 ==================================================
+
 Georgy Berdyshev <codingmaster@gmail.com>
-Hacked everywhere in the code.
+Long term contributor.
 
 Russ Bohnhoff <rustypaint@gmail.com>
 Original port to POSIX.
@@ -10,6 +11,7 @@
 Alexandru Iancu <alexandru.iancu@gmail.com>
 Implemented the IPv6 protocol.
 Implemented the FTP protocol.
+Many improvements all around.
 
 Daniele Perrone <dperrone@it.gnu.org>
 Redesign of the plugins management system.

Modified: trunk/myserver/include/http_handler/proxy/proxy.h
===================================================================
--- trunk/myserver/include/http_handler/proxy/proxy.h	2009-05-24 08:18:18 UTC (rev 3096)
+++ trunk/myserver/include/http_handler/proxy/proxy.h	2009-05-24 11:22:44 UTC (rev 3097)
@@ -25,6 +25,7 @@
 #include <include/protocol/http/http_data_handler.h>
 
 class FiltersChain;
+class Socket;
 
 class Proxy : public HttpDataHandler
 {
@@ -38,6 +39,16 @@
 protected:
   int flushToClient (HttpThreadContext* td, Socket& client,
                      FiltersChain &out, int onlyHeader);
+  int readPayLoad (HttpThreadContext* td,
+                   HttpResponseHeader* res,
+                   FiltersChain *out,
+                   Socket *client,
+                   const char *initBuffer,
+                   u_long initBufferSize,
+                   int timeout,
+                   bool useChunks = false,
+                   bool keepalive = false);
+
   static int timeout;
 };
 #endif

Modified: trunk/myserver/include/protocol/http/http_data_read.h
===================================================================
--- trunk/myserver/include/protocol/http/http_data_read.h	2009-05-24 08:18:18 UTC (rev 3096)
+++ trunk/myserver/include/protocol/http/http_data_read.h	2009-05-24 11:22:44 UTC (rev 3097)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002-2008 Free Software Foundation, Inc.
+Copyright (C) 2002-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
@@ -43,7 +43,7 @@
 public:
   static int readPostData(HttpThreadContext* td, int* ret);
 
-  static int readContiguousPrimitivePostData(char* inBuffer,
+  static int readContiguousPrimitivePostData(const char* inBuffer,
                                              u_long *inBufferPos,
                                              u_long inBufferSize,
                                              Socket *inSocket,
@@ -51,7 +51,7 @@
                                              u_long outBufferSize,
                                              u_long* nbr,
                                              u_long timeout);
-  static int readChunkedPostData(char* inBuffer,
+  static int readChunkedPostData(const char* inBuffer,
                                  u_long *inBufferPos,
                                  u_long inBufferSize,
                                  Socket *inSocket,
@@ -59,7 +59,8 @@
                                  u_long outBufferSize,
                                  u_long* nbr,
                                  u_long timeout,
-                                 File* out);
+                                 Stream* out,
+                                 long maxChunks);
   
 };
 

Modified: trunk/myserver/src/http_handler/proxy/proxy.cpp
===================================================================
--- trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-24 08:18:18 UTC (rev 3096)
+++ trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-24 11:22:44 UTC (rev 3097)
@@ -23,6 +23,8 @@
 #include <include/protocol/url.h>
 #include <include/base/socket/socket.h>
 #include <include/protocol/http/http_request.h>
+#include <include/protocol/http/http_response.h>
+#include <include/protocol/http/http_data_read.h>
 #include <include/protocol/http/http_data_handler.h>
 #include <include/protocol/http/http_headers.h>
 #include <include/filter/filters_chain.h>
@@ -61,17 +63,16 @@
       req.setValue (e->name->c_str (), e->value->c_str ());
     }
 
-  if (destUrl.getProtocol ().compare ("HTTP"))
+  if (destUrl.getProtocol ().compare ("http") && destUrl.getProtocol ().compare ("HTTP"))
     {
       ostringstream msg;
-      msg << "Proxy: " << destUrl.getProtocol () << " is not known.";
+      msg << "Proxy: " << destUrl.getProtocol () << " is not a known protocol.";
       td->connection->host->warningsLogWrite (msg.str ().c_str ());
       return 0;
     }
 
-  /*Use HTTP/1.0 until we accept chunks from clients.  */
-  req.ver.assign ("HTTP/1.0");
-  req.cmd.assign ("GET");
+  req.ver.assign ("HTTP/1.1");
+  req.cmd.assign (td->request.cmd);
   req.uri.assign ("/");
   req.uri.append (destUrl.getResource ());
   req.uri.append (td->pathInfo);
@@ -120,9 +121,9 @@
 
   int ret = flushToClient (td, sock, chain, onlyHeader);
 
-
   chain.clearAllFilters();
   sock.close ();
+  req.free ();
 
   return ret;
 }
@@ -160,7 +161,12 @@
 
   checkDataChunks (td, &keepalive, &useChunks);
 
+  td->response.setValue ("Via", Server::getInstance()->getServerName());
 
+  if (useChunks)
+    td->response.setValue ("Transfer-Encoding", "chunked");
+
+
   HttpHeaders::buildHTTPResponseHeader (td->buffer->getBuffer (),
                                         &td->response);
 
@@ -172,49 +178,21 @@
   if (onlyHeader)
     return keepalive;
 
-  if (read - headerLength)
-    {
-      if (HttpDataHandler::appendDataToHTTPChannel(td,
-                                                   td->secondaryBuffer->getBuffer() +
-                                                     headerLength,
-                                                   read - headerLength,
-                                                   &(td->outputData),
-                                                   &out,
-                                                   td->appendOutputs,
-                                                   useChunks))
-        return 0;
 
-      td->sentData += read - headerLength;
-    }
+  ret = readPayLoad (td,
+                     &td->response,
+                     &out,
+                     &client,
+                     td->secondaryBuffer->getBuffer() + headerLength,
+                     read - headerLength,
+                     timeout,
+                     useChunks,
+                     keepalive);
 
-  while (ret = client.recv (td->secondaryBuffer->getBuffer (),
-                            td->secondaryBuffer->getRealLength (),
-                            0,
-                            timeout))
-    {
+  if (ret != -1)
+    td->sentData += ret;
 
-      if (ret == -1)
-        break;
-
-      if (HttpDataHandler::appendDataToHTTPChannel(td,
-                                                   td->secondaryBuffer->getBuffer(),
-                                                   ret,
-                                                   &(td->outputData),
-                                                   &out,
-                                                   td->appendOutputs,
-                                                   useChunks))
-        return 0;
-
-      td->sentData += ret;
-    }
-
-
-  if(useChunks && out.write ("0\r\n\r\n", 5, &nbw))
-    {
-      return 0;
-    }
-
-  return keepalive;
+  return ret == -1 ? 0 : keepalive;
 }
 
 /*!
@@ -233,3 +211,134 @@
 {
   return timeout;
 }
+
+
+/*!
+ *Forward the message payload to the client.
+ *
+ *\param td The current HTTP thread context.
+ *\param res Response obtained by the server.
+ *\param out The client chain.
+ *\param initBuffer Initial read data.
+ *\param initBufferSize Size of initial data.
+ *\param timeout Connection timeout.
+ *\param useChunks Use chunked transfer encoding
+ *with the client.
+ *\param keepalive The connection is keep-alive.
+ *
+ *\return -1 on error.
+ *\return Otherwise the number of bytes transmitted.
+ */
+int Proxy::readPayLoad (HttpThreadContext* td,
+                        HttpResponseHeader* res,
+                        FiltersChain *out,
+                        Socket *client,
+                        const char *initBuffer,
+                        u_long initBufferSize,
+                        int timeout,
+                        bool useChunks,
+                        bool keepalive)
+{
+  u_long contentLength = -1;
+
+  u_long nbr = 0, nbw = 0, length = 0, inPos = 0;
+  u_long bufferDataSize = 0;
+  u_long written = 0;
+
+  HttpResponseHeader::Entry *encoding = res->other.get ("Transfer-Encoding");
+
+  /* Only the chunked transfer encoding is supported.  */
+  if(encoding && !encoding->value->compare("chunked"))
+    return -1;
+
+  if (res->contentLength.length ())
+    {
+      contentLength = atol (res->contentLength.c_str ());
+      if (contentLength < 0)
+        return -1;
+    }
+
+  length = contentLength;
+
+  bufferDataSize = (td->nBytesToRead < td->buffer->getRealLength() - 1
+                    ? td->nBytesToRead
+                    : td->buffer->getRealLength() - 1 ) - td->nHeaderChars;
+
+  /* If it is specified a transfer encoding read data using it.  */
+  if(encoding)
+  {
+    if(!encoding->value->compare("chunked"))
+    {
+      for (;;)
+        {
+          if (HttpDataRead::readChunkedPostData (initBuffer,
+                                                 &inPos,
+                                                 initBufferSize,
+                                                 client,
+                                                 td->buffer->getBuffer(),
+                                                 td->buffer->getRealLength() - 1,
+                                                 &nbr,
+                                                 timeout,
+                                                 NULL,
+                                                 1))
+            return -1;
+
+          if (nbr == 0)
+            break;
+
+          if (HttpDataHandler::appendDataToHTTPChannel (td,
+                                                        td->buffer->getBuffer(),
+                                                        nbr,
+                                                        &(td->outputData),
+                                                        out,
+                                                        td->appendOutputs,
+                                                        useChunks))
+            return -1;
+
+          written += nbr;
+        }
+    }
+  }
+  /* If it is not specified an encoding, read the data as it is.  */
+  else for(;;)
+  {
+
+    if(HttpDataRead::readContiguousPrimitivePostData (initBuffer,
+                                                      &inPos,
+                                                      initBufferSize,
+                                                      client,
+                                                      td->buffer->getBuffer(),
+                                                      td->buffer->getRealLength() - 1,
+                                                      &nbr,
+                                                      timeout))
+    {
+      return -1;
+    }
+
+    if(nbr <= length)
+      length -= nbr;
+    else
+    {
+      return -1;
+    }
+
+    if (nbr && HttpDataHandler::appendDataToHTTPChannel (td,
+                                                         td->buffer->getBuffer (),
+                                                         nbr,
+                                                         &(td->outputData),
+                                                         out,
+                                                         td->appendOutputs,
+                                                         useChunks))
+      return -1;
+
+    written += nbr;
+
+    if(!length)
+      break;
+  }
+
+  if(useChunks && out->getStream ()->write ("0\r\n\r\n", 5, &nbw))
+    return -1;
+
+  return written;
+}

Modified: trunk/myserver/src/protocol/http/http_data_read.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http_data_read.cpp	2009-05-24 08:18:18 UTC (rev 3096)
+++ trunk/myserver/src/protocol/http/http_data_read.cpp	2009-05-24 11:22:44 UTC (rev 3097)
@@ -58,7 +58,7 @@
  *\param timeout Timeout value to use on the socket.
  *\return Return 0 on success.
  */
-int HttpDataRead::readContiguousPrimitivePostData(char* inBuffer,
+int HttpDataRead::readContiguousPrimitivePostData(const char* inBuffer,
                                                   u_long *inBufferPos,
                                                   u_long inBufferSize,
                                                   Socket *inSocket,
@@ -111,12 +111,13 @@
  *\param outBufferSize outBuffer size.
  *\param outNbr Number of bytes read.
  *\param timeout Timeout value to use on the socket.
- *\param out Output file.
+ *\param out Output file, may be  a NULL pointer.
+ *\param maxChunks The maximum number of chunks to read.
  *\return Return 0 on success.
  *\return -1 on internal error.
  *\return Any other value is the HTTP error code.
  */
-int HttpDataRead::readChunkedPostData(char* inBuffer,
+int HttpDataRead::readChunkedPostData(const char* inBuffer,
                                       u_long *inBufferPos,
                                       u_long inBufferSize,
                                       Socket *inSocket,
@@ -124,12 +125,13 @@
                                       u_long outBufferSize,
                                       u_long* outNbr,
                                       u_long timeout,
-                                      File* out)
+                                      Stream* out,
+                                      long maxChunks)
 {
   u_long nbr;
   *outNbr = 0;
 
-  for(;;)
+  for (int n = 0; maxChunks == 0 || n < maxChunks; n++)
   {
     u_long chunkNbr;
     u_long dataToRead;
@@ -203,10 +205,8 @@
 
       chunkNbr += nbr;
 
-      if(out->writeToFile(outBuffer, nbr, &nbw))
-      {
+      if (out && out->write (outBuffer, nbr, &nbw))
         return -1;
-      }
 
       if(nbw != nbr)
         return -1;
@@ -337,7 +337,8 @@
                                     td->secondaryBuffer->getRealLength() - 1,
                                     &nbr,
                                     timeout,
-                                    &(td->inputData));
+                                    &(td->inputData),
+                                    0);
 
       if(ret == -1)
       {




From MAILER-DAEMON Sun May 24 09:01:25 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M8DKP-00083L-70
	for mharc-myserver-commit@gnu.org; Sun, 24 May 2009 09:01:25 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M8DK8-0007vI-2b
	for myserver-commit@gnu.org; Sun, 24 May 2009 09:01:08 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M8DK3-0007t2-7T
	for myserver-commit@gnu.org; Sun, 24 May 2009 09:01:03 -0400
Received: from [199.232.76.173] (port=33581 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M8DK1-0007oQ-Io
	for myserver-commit@gnu.org; Sun, 24 May 2009 09:01:01 -0400
Received: from savannah.gnu.org ([199.232.41.3]:56712 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M88uS-0006Op-3c
	for myserver-commit@gnu.org; Sun, 24 May 2009 04:18:20 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M88uR-000105-8p
	for myserver-commit@gnu.org; Sun, 24 May 2009 08:18:19 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M88uQ-000101-RA
	for myserver-commit@gnu.org; Sun, 24 May 2009 08:18:19 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M88uQ-000101-RA@cvs.savannah.gnu.org>
Date: Sun, 24 May 2009 08:18:18 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3096] Keep minor contributors in the THANKS file.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 24 May 2009 13:01:13 -0000

Revision: 3096
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3096
Author:   gscrivano
Date:     2009-05-24 08:18:18 +0000 (Sun, 24 May 2009)
Log Message:
-----------
Keep minor contributors in the THANKS file.

Modified Paths:
--------------
    trunk/myserver/AUTHORS

Added Paths:
-----------
    trunk/myserver/THANKS

Modified: trunk/myserver/AUTHORS
===================================================================
--- trunk/myserver/AUTHORS	2009-05-23 22:31:47 UTC (rev 3095)
+++ trunk/myserver/AUTHORS	2009-05-24 08:18:18 UTC (rev 3096)
@@ -1,12 +1,21 @@
-GNU MyServer
-
-People who contributed with code or documentation:
+People who contributed significantly to GNU MyServer:
 ==================================================
-Renato Nunes Bastos <rnbastos@yahoo.com>
 Georgy Berdyshev <codingmaster@gmail.com>
+Hacked everywhere in the code.
+
 Russ Bohnhoff <rustypaint@gmail.com>
+Original port to POSIX.
+Developed the first GUI control program.
+
 Alexandru Iancu <alexandru.iancu@gmail.com>
+Implemented the IPv6 protocol.
+Implemented the FTP protocol.
+
 Daniele Perrone <dperrone@it.gnu.org>
+Redesign of the plugins management system.
+
 Francesco Pipita <francesco.pipita@gmail.com>
-Debarshi Ray <rishi@gnu.org>
+Redesign of the logging system.
+
 Giuseppe Scrivano <gscrivano@gnu.org>
+Original author.

Added: trunk/myserver/THANKS
===================================================================
--- trunk/myserver/THANKS	                        (rev 0)
+++ trunk/myserver/THANKS	2009-05-24 08:18:18 UTC (rev 3096)
@@ -0,0 +1,8 @@
+These people have contributed to the GNU MyServer.  Some have reported problems, others
+have contributed improvements to the documentation, actual code, and even
+complete programs.  If your name has been left out, if you'd rather not be listed,
+or if you'd prefer a different address be used, please send a note to
+the bug mailing list.
+
+Renato Nunes Bastos                 <rnbastos@yahoo.com>
+Debarshi Ray                        <rishi@gnu.org>




From MAILER-DAEMON Sun May 24 14:42:32 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M8IeW-00041g-GA
	for mharc-myserver-commit@gnu.org; Sun, 24 May 2009 14:42:32 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M8IeU-0003xx-Rl
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:30 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M8IeT-0003xA-Oo
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:30 -0400
Received: from [199.232.76.173] (port=50648 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M8IeT-0003x7-Kt
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:29 -0400
Received: from savannah.gnu.org ([199.232.41.3]:44946 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M8IeT-0002P7-0K
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:29 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M8IeR-0001J5-7u
	for myserver-commit@gnu.org; Sun, 24 May 2009 18:42:27 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M8IeQ-0001J1-Re
	for myserver-commit@gnu.org; Sun, 24 May 2009 18:42:27 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M8IeQ-0001J1-Re@cvs.savannah.gnu.org>
Date: Sun, 24 May 2009 18:42:26 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3098] Use the `Host' value used by the client
	for the `Via' header.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 24 May 2009 18:42:31 -0000

Revision: 3098
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3098
Author:   gscrivano
Date:     2009-05-24 18:42:26 +0000 (Sun, 24 May 2009)
Log Message:
-----------
Use the `Host' value used by the client for the `Via' header.  Keep old `Via' values that may be present in the header.

Modified Paths:
--------------
    trunk/myserver/src/http_handler/proxy/proxy.cpp

Modified: trunk/myserver/src/http_handler/proxy/proxy.cpp
===================================================================
--- trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-24 11:22:44 UTC (rev 3097)
+++ trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-24 18:42:26 UTC (rev 3098)
@@ -161,8 +161,19 @@
 
   checkDataChunks (td, &keepalive, &useChunks);
 
-  td->response.setValue ("Via", Server::getInstance()->getServerName());
+  string *tmp = td->request.getValue ("Host", NULL);
+  const char *via = tmp ? tmp->c_str () : td->connection->getLocalIpAddr ();
 
+  tmp = td->response.getValue ("Via", NULL);
+  if (tmp)
+    {
+      tmp->append (", ");
+      tmp->append (via);
+      td->response.setValue ("Via", tmp->c_str ());
+    }
+  else
+    td->response.setValue ("Via", via);
+
   if (useChunks)
     td->response.setValue ("Transfer-Encoding", "chunked");
 




From MAILER-DAEMON Sun May 24 14:42:39 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1M8Ied-00045A-OB
	for mharc-myserver-commit@gnu.org; Sun, 24 May 2009 14:42:39 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1M8Iec-000453-7q
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:38 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1M8IeZ-00044r-Vo
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:36 -0400
Received: from [199.232.76.173] (port=50651 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1M8IeZ-00044o-Ot
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:35 -0400
Received: from savannah.gnu.org ([199.232.41.3]:44948 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <gscrivano@gnu.org>) id 1M8IeY-0002Rn-SQ
	for myserver-commit@gnu.org; Sun, 24 May 2009 14:42:35 -0400
Received: from cvs.savannah.gnu.org ([199.232.41.69])
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gscrivano@gnu.org>) id 1M8IeY-0001Jn-AM
	for myserver-commit@gnu.org; Sun, 24 May 2009 18:42:34 +0000
Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <gscrivano@savannah.gnu.org>) id 1M8IeY-0001Jj-0K
	for myserver-commit@gnu.org; Sun, 24 May 2009 18:42:34 +0000
MIME-Version: 1.0
X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/
Errors-To: gscrivano
To: myserver-commit@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Giuseppe Scrivano <gscrivano@gnu.org>
Message-Id: <E1M8IeY-0001Jj-0K@cvs.savannah.gnu.org>
Date: Sun, 24 May 2009 18:42:34 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [myserver-commit] [3099] Fixed different bugs and added some
	optimizations.
X-BeenThere: myserver-commit@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: myserver-commit.gnu.org
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/myserver-commit>
List-Post: <mailto:myserver-commit@gnu.org>
List-Help: <mailto:myserver-commit-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/myserver-commit>,
	<mailto:myserver-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 24 May 2009 18:42:38 -0000

Revision: 3099
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3099
Author:   gscrivano
Date:     2009-05-24 18:42:33 +0000 (Sun, 24 May 2009)
Log Message:
-----------
Fixed different bugs and added some optimizations.

Modified Paths:
--------------
    trunk/myserver/include/http_handler/proxy/proxy.h
    trunk/myserver/include/protocol/http/http_headers.h
    trunk/myserver/src/http_handler/cgi/cgi.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/http_handler/http_file/http_file.cpp
    trunk/myserver/src/http_handler/isapi/isapi.cpp
    trunk/myserver/src/http_handler/mscgi/mscgi.cpp
    trunk/myserver/src/http_handler/proxy/proxy.cpp
    trunk/myserver/src/http_handler/scgi/scgi.cpp
    trunk/myserver/src/http_handler/wincgi/wincgi.cpp
    trunk/myserver/src/protocol/http/http.cpp
    trunk/myserver/src/protocol/http/http_data_read.cpp
    trunk/myserver/src/protocol/http/http_headers.cpp

Modified: trunk/myserver/include/http_handler/proxy/proxy.h
===================================================================
--- trunk/myserver/include/http_handler/proxy/proxy.h	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/include/http_handler/proxy/proxy.h	2009-05-24 18:42:33 UTC (rev 3099)
@@ -47,7 +47,8 @@
                    u_long initBufferSize,
                    int timeout,
                    bool useChunks = false,
-                   bool keepalive = false);
+                   bool keepalive = false,
+                   string *serverTransferEncoding = NULL);
 
   static int timeout;
 };

Modified: trunk/myserver/include/protocol/http/http_headers.h
===================================================================
--- trunk/myserver/include/protocol/http/http_headers.h	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/include/protocol/http/http_headers.h	2009-05-24 18:42:33 UTC (rev 3099)
@@ -66,8 +66,8 @@
 	static void buildDefaultHTTPResponseHeader (HttpResponseHeader*);
 	static void buildDefaultHTTPRequestHeader (HttpRequestHeader*);
 
-	static void buildHTTPResponseHeader (char *, HttpResponseHeader*);
-	static void buildHTTPRequestHeader (char *, HttpRequestHeader*);
+	static u_long buildHTTPResponseHeader (char*, HttpResponseHeader*);
+	static u_long buildHTTPRequestHeader (char*, HttpRequestHeader*);
 
 protected:
   static int readReqAuthLine (HttpRequestHeader *request, 

Modified: trunk/myserver/src/http_handler/cgi/cgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/cgi/cgi.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/cgi/cgi.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -550,10 +550,10 @@
         return 1;
       }
 
-      HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
-                                           &td->response);
+      u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
+                                                           &td->response);
 
-      td->buffer->setLength((u_int)strlen(td->buffer->getBuffer()));
+      td->buffer->setLength(hdrLen);
 
       if (chain.getStream ()->write(td->buffer->getBuffer(),
                                     static_cast<int> (td->buffer->getLength()),

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -800,11 +800,11 @@
       return 0;
     }
 
-    HttpHeaders::buildHTTPResponseHeader(con->td->secondaryBuffer->getBuffer(),
-                                         &con->td->response);
+    u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(con->td->secondaryBuffer->getBuffer(),
+                                                         &con->td->response);
 
     if(con->td->connection->socket->send(con->td->secondaryBuffer->getBuffer(),
-                                         static_cast<int>(strlen(con->td->secondaryBuffer->getBuffer())),
+                                         hdrLen,
                                          0) == SOCKET_ERROR )
     {
       *responseCompleted = true;

Modified: trunk/myserver/src/http_handler/http_file/http_file.cpp
===================================================================
--- trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/http_file/http_file.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -486,10 +486,11 @@
       }
     }
  
-    HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(), 
-                                         &td->response);
+    u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(), 
+                                                         &td->response);
 
-    td->buffer->setLength((u_long)strlen(td->buffer->getBuffer()));
+    td->buffer->setLength(hdrLen);
+
     if(!td->appendOutputs)
     {
       /* Send the HTTP header.  */

Modified: trunk/myserver/src/http_handler/isapi/isapi.cpp
===================================================================
--- trunk/myserver/src/http_handler/isapi/isapi.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/isapi/isapi.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -290,12 +290,11 @@
         else
           ConnInfo->td->response.connection.assign("Close");
         
-        HttpHeaders::buildHTTPResponseHeader(
-                 (char*)ConnInfo->td->secondaryBuffer->getBuffer(),&(ConnInfo->td->response));
+        u_long hdrLen = HttpHeaders::buildHTTPResponseHeader ((char*)ConnInfo->td->secondaryBuffer->getBuffer(),
+                                                              &(ConnInfo->td->response));
   
         if(ConnInfo->connection->socket->send(
-                     (char*)ConnInfo->td->secondaryBuffer->getBuffer(),
-                     (int)strlen((char*)ConnInfo->td->secondaryBuffer->getBuffer()), 0)==-1)
+                     (char*)ConnInfo->td->secondaryBuffer->getBuffer(), hdrLen, 0)==-1)
           return 0;
       }
       /*! Save the headerSent status. */

Modified: trunk/myserver/src/http_handler/mscgi/mscgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/mscgi/mscgi.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/mscgi/mscgi.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -220,8 +220,8 @@
     char *buffer = td->secondaryBuffer->getBuffer();
     ConnectionPtr s = td->connection;
 
-    HttpHeaders::buildHTTPResponseHeader(buffer, &(td->response));
-    if(s->socket->send(buffer, (int)strlen(buffer), 0) == SOCKET_ERROR)
+    u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(buffer, &(td->response));
+    if(s->socket->send(buffer, hdrLen, 0) == SOCKET_ERROR)
       return 1;
   }
 

Modified: trunk/myserver/src/http_handler/proxy/proxy.cpp
===================================================================
--- trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/proxy/proxy.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -85,8 +85,8 @@
 
   req.setValue ("Host", host.str ().c_str ());
 
-	HttpHeaders::buildHTTPRequestHeader (td->secondaryBuffer->getBuffer (),
-                                       &req);
+	u_long hdrLen = HttpHeaders::buildHTTPRequestHeader (td->secondaryBuffer->getBuffer (),
+                                                       &req);
 
   if (sock.connect (destUrl.getHost ().c_str (), destUrl.getPort ()))
     return td->http->raiseHTTPError (500);
@@ -98,8 +98,7 @@
       return td->http->raiseHTTPError (500);
     }
 
-  if (sock.write (td->secondaryBuffer->getBuffer (),
-                  strlen (td->secondaryBuffer->getBuffer ()), &nbw))
+  if (sock.write (td->secondaryBuffer->getBuffer (), hdrLen, &nbw))
     {
       sock.close ();
       return td->http->raiseHTTPError (500);
@@ -174,15 +173,25 @@
   else
     td->response.setValue ("Via", via);
 
+  string transferEncoding;
+  bool hasTransferEncoding = false;
+  tmp = td->response.getValue ("Transfer-Encoding", NULL);
+  if (tmp)
+    {
+      hasTransferEncoding = false;
+      transferEncoding.assign (*tmp);
+    }
+  
+
   if (useChunks)
     td->response.setValue ("Transfer-Encoding", "chunked");
 
 
-  HttpHeaders::buildHTTPResponseHeader (td->buffer->getBuffer (),
-                                        &td->response);
+  u_long hdrLen = HttpHeaders::buildHTTPResponseHeader (td->buffer->getBuffer (),
+                                                        &td->response);
 
   if (out.getStream ()->write (td->buffer->getBuffer (),
-                               strlen (td->buffer->getBuffer ()),
+                               hdrLen,
                                &nbw))
     return 0;
 
@@ -198,7 +207,8 @@
                      read - headerLength,
                      timeout,
                      useChunks,
-                     keepalive);
+                     keepalive,
+                     hasTransferEncoding ? &transferEncoding : NULL);
 
   if (ret != -1)
     td->sentData += ret;
@@ -236,6 +246,8 @@
  *\param useChunks Use chunked transfer encoding
  *with the client.
  *\param keepalive The connection is keep-alive.
+ *\param serverTransferEncoding Transfer-Encoding
+ *used by the server.
  *
  *\return -1 on error.
  *\return Otherwise the number of bytes transmitted.
@@ -248,18 +260,18 @@
                         u_long initBufferSize,
                         int timeout,
                         bool useChunks,
-                        bool keepalive)
+                        bool keepalive,
+                        string *serverTransferEncoding)
 {
-  u_long contentLength = -1;
+  u_long contentLength = 0;
 
   u_long nbr = 0, nbw = 0, length = 0, inPos = 0;
   u_long bufferDataSize = 0;
   u_long written = 0;
 
-  HttpResponseHeader::Entry *encoding = res->other.get ("Transfer-Encoding");
 
   /* Only the chunked transfer encoding is supported.  */
-  if(encoding && !encoding->value->compare("chunked"))
+  if(serverTransferEncoding && serverTransferEncoding->compare("chunked"))
     return -1;
 
   if (res->contentLength.length ())
@@ -276,9 +288,9 @@
                     : td->buffer->getRealLength() - 1 ) - td->nHeaderChars;
 
   /* If it is specified a transfer encoding read data using it.  */
-  if(encoding)
+  if(serverTransferEncoding)
   {
-    if(!encoding->value->compare("chunked"))
+    if(!serverTransferEncoding->compare("chunked"))
     {
       for (;;)
         {
@@ -294,7 +306,7 @@
                                                  1))
             return -1;
 
-          if (nbr == 0)
+          if (!nbr)
             break;
 
           if (HttpDataHandler::appendDataToHTTPChannel (td,
@@ -314,24 +326,31 @@
   else for(;;)
   {
 
+    u_long len = td->buffer->getRealLength() - 1;
+
+    if (contentLength && length < len)
+      len = length;
+
+    if (len == 0)
+      break;
+
     if(HttpDataRead::readContiguousPrimitivePostData (initBuffer,
                                                       &inPos,
                                                       initBufferSize,
                                                       client,
                                                       td->buffer->getBuffer(),
-                                                      td->buffer->getRealLength() - 1,
+                                                      len,
                                                       &nbr,
                                                       timeout))
     {
       return -1;
     }
 
-    if(nbr <= length)
+    if (contentLength == 0 && nbr == 0)
+      break;
+
+    if (length)
       length -= nbr;
-    else
-    {
-      return -1;
-    }
 
     if (nbr && HttpDataHandler::appendDataToHTTPChannel (td,
                                                          td->buffer->getBuffer (),
@@ -344,7 +363,7 @@
 
     written += nbr;
 
-    if(!length)
+    if(contentLength && length == 0)
       break;
   }
 

Modified: trunk/myserver/src/http_handler/scgi/scgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/scgi/scgi.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -295,11 +295,10 @@
                                                  &td->response, 
                                                  &(td->nBytesToRead));
     }
-    HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
-                                         &td->response);
+    u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
+                                                         &td->response);
     
-    if(chain->write(td->buffer->getBuffer(), strlen(td->buffer->getBuffer()),
-                    &nbw))
+    if(chain->write(td->buffer->getBuffer(), hdrLen, &nbw))
       return -1;
   }
 

Modified: trunk/myserver/src/http_handler/wincgi/wincgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/wincgi/wincgi.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/http_handler/wincgi/wincgi.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -373,10 +373,10 @@
     /*!
      *Send the header if it is not appending.
      */
-    HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
-                                          &td->response);
+    u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
+                                                         &td->response);
     if(chain.getStream ()->write((const char*)td->buffer->getBuffer(),
-                                 (int)strlen((const char*)td->buffer->getBuffer()), 
+                                 hdrLen,
                                  &nbw2))
     {
       OutFileHandle.close();
@@ -411,9 +411,10 @@
       chain.clearAllFilters();
       return 1;
     }
-    
+
     td->outputData.writeToFile((char*)(buffer + headerSize),
-                               nBytesRead - headerSize,&nbw2);
+                               nBytesRead - headerSize,
+                               &nbw2);
     nbw += nbw2;
   }
 

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/protocol/http/http.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -1530,11 +1530,10 @@
         td->response.contentLength.assign(size.str());
       }
     }
-    HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
-                                         &td->response);
-    if(td->connection->socket->send(td->buffer->getBuffer(),
-                                   (u_long)strlen(td->buffer->getBuffer()), 0)
-       == -1)
+    u_long hdrLen = HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
+                                                         &td->response);
+
+    if(td->connection->socket->send(td->buffer->getBuffer(), hdrLen, 0) == -1)
       return 0;
 
     if(errorBodyLength && (td->connection->socket->send(errorBodyMessage.str().c_str(),

Modified: trunk/myserver/src/protocol/http/http_data_read.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http_data_read.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/protocol/http/http_data_read.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -68,7 +68,6 @@
                                                   u_long timeout)
 {
   int ret;
-  u_long nbtrSocket = 0;
   *nbr = 0;
   if(inBufferSize - *inBufferPos)
   {
@@ -83,13 +82,8 @@
   if(outBufferSize == *nbr)
     return 0;
 
-  nbtrSocket = inSocket->bytesToRead();
+  ret = inSocket->recv(outBuffer + *nbr,  outBufferSize - *nbr, 0, timeout);
 
-  if(!nbtrSocket)
-    return 0;
-
-  ret = inSocket->recv(outBuffer + *nbr,  min(nbtrSocket, outBufferSize - *nbr), 0, timeout);
-
   if(ret == -1)
     return -1;
 
@@ -211,7 +205,10 @@
       if(nbw != nbr)
         return -1;
 
-      *outNbr += nbw;
+      if (out)
+        *outNbr += nbw;
+      else
+        *outNbr += nbr;
 
       /* Read final chunk \r\n.  */
       if(readContiguousPrimitivePostData(inBuffer,
@@ -243,7 +240,7 @@
  */
 int HttpDataRead::readPostData(HttpThreadContext* td, int* httpRetCode)
 {
-  int contentLength = -1;
+  int contentLength = 0;
 
   u_long nbw = 0;
   u_long bufferDataSize = 0;

Modified: trunk/myserver/src/protocol/http/http_headers.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http_headers.cpp	2009-05-24 18:42:26 UTC (rev 3098)
+++ trunk/myserver/src/protocol/http/http_headers.cpp	2009-05-24 18:42:33 UTC (rev 3099)
@@ -41,9 +41,11 @@
  *Builds an HTTP header string starting from an HttpResponseHeader structure.
  *\param str The buffer where write the HTTP header.
  *\param response the HttpResponseHeader where the HTTP data is.
+ *
+ *\return The number of bytes written to STR.
  */
-void HttpHeaders::buildHTTPResponseHeader(char *str, 
-                                          HttpResponseHeader* response)
+u_long HttpHeaders::buildHTTPResponseHeader (char *str, 
+                                             HttpResponseHeader* response)
 {
   /*
    *Here we build the HTTP response header.
@@ -51,234 +53,248 @@
    *Every directive ends with a \r\n sequence.
    */
   char *pos = str;
-  const int MAX = MYSERVER_KB(8);
-  if(response->httpStatus != 200)
+  const int MAX = MYSERVER_KB (8);
+  if (response->httpStatus != 200)
   {
-    if(response->errorType.length() == 0)
+    if (response->errorType.length () == 0)
     {
-      HttpErrors::getErrorMessage(response->httpStatus, response->errorType);
+      HttpErrors::getErrorMessage (response->httpStatus, response->errorType);
     }
-    pos += sprintf(str, "%s %i %s\r\nStatus: %s\r\n", response->ver.c_str(),
-            response->httpStatus, response->errorType.c_str(), 
-            response->errorType.c_str() );
+    pos += sprintf (str, "%s %i %s\r\nStatus: %s\r\n", response->ver.c_str (),
+                    response->httpStatus, response->errorType.c_str (), 
+                    response->errorType.c_str () );
   }
   else
-    pos += sprintf(str,"%s 200 OK\r\n",response->ver.c_str());
+    pos += sprintf (str,"%s 200 OK\r\n",response->ver.c_str ());
   
-  if(response->serverName.length())
-  {
-    pos += myserver_strlcpy(pos, "Server: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->serverName.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
+  if (response->serverName.length ())
+    {
+      pos += myserver_strlcpy (pos, "Server: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, response->serverName.c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+    }
   else
-  {
-    pos += myserver_strlcpy(pos, "Server: GNU MyServer ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, MYSERVER_VERSION,  MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
+    {
+      pos += myserver_strlcpy (pos, "Server: GNU MyServer ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, MYSERVER_VERSION,  MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+    }
 
-  if(response->lastModified.length())
-  {
-    pos += myserver_strlcpy(pos,"Last-Modified: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->lastModified.c_str(), 
-                            MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos,"\r\n", MAX-(long)(pos-str));
-  }
-  if(response->connection.length())
-  {
-    pos += myserver_strlcpy(pos,"Connection: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->connection.c_str(), 
-                            MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
+  if (response->lastModified.length ())
+    {
+      pos += myserver_strlcpy (pos,"Last-Modified: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, response->lastModified.c_str (), 
+                               MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos,"\r\n", MAX-(long)(pos-str));
+    }
+
+  if (response->connection.length ())
+    {
+      pos += myserver_strlcpy (pos,"Connection: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, response->connection.c_str (), 
+                             MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+    }
   else
-  {
-    pos += myserver_strlcpy(pos, "Connection: Close\r\n", MAX-(long)(pos-str));
-  }
-  if(response->contentLength.length())
-  {
-    /*
-    *Do not specify the Content-Length field if it is used
-    *the chunked Transfer-Encoding.
-    */
-    HttpResponseHeader::Entry *e = response->other.get("Transfer-Encoding");
+    {
+      pos += myserver_strlcpy (pos, "Connection: Close\r\n", MAX-(long)(pos-str));
+    }
 
-    if(!e || (e && e->value->find("chunked",0) == string::npos ))
+  if (response->contentLength.length ())
     {
-      pos += myserver_strlcpy(pos, "Content-Length: ", MAX-(long)(pos-str));
-      pos += myserver_strlcpy(pos, response->contentLength.c_str(), MAX-(long)(pos-str));
-      pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+      /*
+       *Do not specify the Content-Length field if it is used
+       *the chunked Transfer-Encoding.
+       */
+      HttpResponseHeader::Entry *e = response->other.get ("Transfer-Encoding");
+
+      if (!e || (e && e->value->find ("chunked", 0) == string::npos ))
+        {
+          pos += myserver_strlcpy (pos, "Content-Length: ", MAX-(long)(pos-str));
+          pos += myserver_strlcpy (pos, response->contentLength.c_str (), MAX-(long)(pos-str));
+          pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+        }
     }
-  }
-  if(response->cookie.length())
-  {
-    string cookie;
-    const char *token = response->cookie.c_str();
-    int max = response->cookie.length();
-    while(token)
+
+  if (response->cookie.length ())
     {
-      int len = getCharInString(token, "\n", max);
-      if(len == -1 || *token=='\n')
+      string cookie;
+      const char *token = response->cookie.c_str ();
+      int max = response->cookie.length ();
+      while (token)
+        {
+          int len = getCharInString (token, "\n", max);
+          if (len == -1 || *token=='\n')
         break;
-      cookie.assign("Set-Cookie: ");
-      cookie.append(token, len);
-      cookie.append("\r\n");  
-      pos += myserver_strlcpy(pos, cookie.c_str(), MAX-(long)(pos-str));  
-      token+=len+1;
+          cookie.assign ("Set-Cookie: ");
+          cookie.append (token, len);
+          cookie.append ("\r\n");  
+          pos += myserver_strlcpy (pos, cookie.c_str (), MAX-(long)(pos-str));  
+          token += len + 1;
+        }
     }
-  }
-  if(response->mimeVer.length())
-  {
-    pos += myserver_strlcpy(pos, "MIME-Version: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->mimeVer.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
-  if(response->contentType.length())
-  {
-    pos += myserver_strlcpy(pos, "Content-Type: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->contentType.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
-  if(response->date.length())
-  {
-    pos += myserver_strlcpy(pos, "Date: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->date.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
-  if(response->dateExp.length())
-  {
-    pos += myserver_strlcpy(pos, "Expires: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->dateExp.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
-  if(response->auth.length())
-  {
-    pos += myserver_strlcpy(pos, "WWW-Authenticate: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, response->auth.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
-  }
-  
-  if(response->location.length())
-  {
-    pos += myserver_strlcpy(pos, "Location: ", MAX - (long)(pos - str));
-    pos += myserver_strlcpy(pos, response->location.c_str(), 
-                            MAX - (long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX - (long)(pos - str));
-  }
 
-  if(response->other.size())
-  {
-    HashMap<string, HttpResponseHeader::Entry*>::Iterator it = 
-      response->other.begin();
-    for(; it != response->other.end(); it++)
+  if (response->mimeVer.length ())
     {
-      HttpResponseHeader::Entry *e = *it;
-      if(e)
+      pos += myserver_strlcpy (pos, "MIME-Version: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, response->mimeVer.c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+    }
+
+  if (response->contentType.length ())
+    {
+      pos += myserver_strlcpy (pos, "Content-Type: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, response->contentType.c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+    }
+
+  if (response->date.length ())
+    {
+      pos += myserver_strlcpy(pos, "Date: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy(pos, response->date.c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+    }
+
+  if (response->dateExp.length ())
+    {
+      pos += myserver_strlcpy (pos, "Expires: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, response->dateExp.c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+    }
+
+  if (response->auth.length ())
+    {
+      pos += myserver_strlcpy(pos, "WWW-Authenticate: ", MAX-(long)(pos-str));
+      pos += myserver_strlcpy(pos, response->auth.c_str (), MAX-(long)(pos-str));
+      pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+    }
+
+  if (response->location.length ())
+    {
+      pos += myserver_strlcpy (pos, "Location: ", MAX - (long)(pos - str));
+      pos += myserver_strlcpy (pos, response->location.c_str (), 
+                               MAX - (long)(pos-str));
+      pos += myserver_strlcpy (pos, "\r\n", MAX - (long)(pos - str));
+    }
+
+  if (response->other.size ())
+    {
+      HashMap<string, HttpResponseHeader::Entry*>::Iterator it = 
+        response->other.begin();
+    for (; it != response->other.end(); it++)
       {
-        pos += myserver_strlcpy(pos, e->name->c_str(), MAX-(long)(pos-str));
-        pos += myserver_strlcpy(pos, ": ", MAX-(long)(pos-str));
-        pos += myserver_strlcpy(pos, e->value->c_str(), MAX-(long)(pos-str));
-        pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+        HttpResponseHeader::Entry *e = *it;
+        if (e)
+          {
+            pos += myserver_strlcpy (pos, e->name->c_str (), MAX-(long)(pos-str));
+            pos += myserver_strlcpy (pos, ": ", MAX-(long)(pos-str));
+            pos += myserver_strlcpy (pos, e->value->c_str (), MAX-(long)(pos-str));
+            pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
+          }
       }
-      
     }
-  }
 
   /*
    *MyServer supports the bytes range.
    */
-  pos += myserver_strlcpy(pos, "Accept-Ranges: bytes\r\n", MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, "Accept-Ranges: bytes\r\n", MAX-(long)(pos-str));
   
   /*
    *The HTTP header ends with a \r\n sequence.
    */
-  pos += myserver_strlcpy(pos, "\r\n\0\0\0\0\0", MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, "\r\n\0\0\0", MAX-(long)(pos-str));
+
+  return (pos - str);
 }
 
 /*!
  *Builds an HTTP header string starting from an HttpRequestHeader structure.
  *\param str The buffer where write the HTTP header.
  *\param request the HttpRequestHeader where the HTTP data is.
+ *
+ *\return The number of bytes written to STR.
  */
-void HttpHeaders::buildHTTPRequestHeader(char * str,HttpRequestHeader* request)
+u_long HttpHeaders::buildHTTPRequestHeader (char * str,HttpRequestHeader* request)
 {
   char *pos = str;
   const int MAX = MYSERVER_KB(8);
 
   /* First line.  */
-  pos += myserver_strlcpy(pos, request->cmd.c_str(), MAX-(long)(pos-str));
-  pos += myserver_strlcpy(pos, " ", MAX-(long)(pos-str));
-  pos += myserver_strlcpy(pos, request->uri.c_str(), MAX-(long)(pos-str));
-  pos += myserver_strlcpy(pos, " ", MAX-(long)(pos-str));
-  if(request->uriOpts.length() > 0)
+  pos += myserver_strlcpy (pos, request->cmd.c_str (), MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, " ", MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, request->uri.c_str (), MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, " ", MAX-(long)(pos-str));
+
+  if (request->uriOpts.length () > 0)
   {
-    pos += myserver_strlcpy(pos, "?", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, request->uriOpts.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, " ", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "?", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, request->uriOpts.c_str (), MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, " ", MAX-(long)(pos-str));
 
   }
-  pos += myserver_strlcpy(pos, request->ver.c_str(), MAX-(long)(pos-str));
-  pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+
+  pos += myserver_strlcpy (pos, request->ver.c_str (), MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
   
   /* Authorization.  */
-  if(request->auth.length() > 0)
+  if (request->auth.length () > 0)
   {
-    pos += myserver_strlcpy(pos, "Authorization: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, request->auth.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "Authorization: ", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, request->auth.c_str (), MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
   }
 
   /* Content-Length.  */
-  if(request->contentLength.length() > 0)
+  if (request->contentLength.length () > 0)
   {
-    pos += myserver_strlcpy(pos, "Content-Length: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, request->contentLength.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "Content-Length: ", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, request->contentLength.c_str (), MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
   }
 
   /* Range.  */
-  if(request->rangeType.length() > 0)
+  if (request->rangeType.length () > 0)
   {
     char buffer[12];
-    pos += myserver_strlcpy(pos, "Range: ", MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, request->rangeType.c_str(), MAX-(long)(pos-str));
-    pos += myserver_strlcpy(pos, " ", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "Range: ", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, request->rangeType.c_str (), MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, " ", MAX-(long)(pos-str));
 
-    if(request->rangeByteBegin != (u_long)-1)
+    if (request->rangeByteBegin != (u_long)-1)
     {
       sprintf(buffer, "%lu", request->rangeByteBegin);
-      pos += myserver_strlcpy(pos, buffer, MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, buffer, MAX-(long)(pos-str));
     }
 
-    pos += myserver_strlcpy(pos, "-", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "-", MAX-(long)(pos-str));
 
-    if(request->rangeByteEnd != (u_long)-1)
+    if (request->rangeByteEnd != (u_long)-1)
     {
       sprintf(buffer, "%lu", request->rangeByteEnd);
-      pos += myserver_strlcpy(pos, buffer, MAX-(long)(pos-str));
+      pos += myserver_strlcpy (pos, buffer, MAX-(long)(pos-str));
     }
 
-    pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+    pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
   }
 
-  if(request->other.size())
+  if (request->other.size())
   {
     HashMap<string, HttpRequestHeader::Entry*>::Iterator it = 
       request->other.begin();
     for(; it != request->other.end(); it++)
     {
       HttpRequestHeader::Entry *e = *it;
-      if(e)
+      if (e)
       {
-        pos += myserver_strlcpy(pos, e->name->c_str(), MAX-(long)(pos-str));
-        pos += myserver_strlcpy(pos, ": ", MAX-(long)(pos-str));
-        pos += myserver_strlcpy(pos, e->value->c_str(), MAX-(long)(pos-str));
-        pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+        pos += myserver_strlcpy (pos, e->name->c_str (), MAX-(long)(pos-str));
+        pos += myserver_strlcpy (pos, ": ", MAX-(long)(pos-str));
+        pos += myserver_strlcpy (pos, e->value->c_str (), MAX-(long)(pos-str));
+        pos += myserver_strlcpy (pos, "\r\n", MAX-(long)(pos-str));
       }
     }
   }
-  pos += myserver_strlcpy(pos, "\r\n", MAX-(long)(pos-str));
+  pos += myserver_strlcpy (pos, "\r\n\0\0\0", MAX-(long)(pos-str));
+  return (pos - str);
 }
 
 
@@ -356,16 +372,16 @@
   u_long nLinechars = 0;
   u_long nLines = 0;
 
-  if(res == 0)
+  if (res == 0)
     return 0;
   /*
    *Count the number of lines in the header.
    */
   for(i = 0; res[i]; i++)
   {
-    if(res[i]=='\n')
+    if (res[i]=='\n')
     {
-      if((res[i+2] == '\n') || (res[i+1] == '\0') || (res[i+1] == '\n'))
+      if ((res[i+2] == '\n') || (res[i+1] == '\0') || (res[i+1] == '\n'))
         break;
       nLines++;
     }
@@ -375,7 +391,7 @@
        *If a line contains more than 4160 characters we consider the 
        *header invalid.
        */
-      if(nLinechars >= 4160)
+      if (nLinechars >= 4160)
           return 0;
         nLinechars++;
     }
@@ -454,14 +470,14 @@
   validRequest = validHTTPRequest(input, inputSize, &nLines, &maxTotchars);
 
   /* Invalid header.  */
-  if(validRequest!=200)
+  if (validRequest!=200)
   {
     /* Incomplete header.  */
-    if(validRequest==-1)
+    if (validRequest==-1)
       return -1;
     /* Keep trace of first line for logging. */
     tokenOff = getEndLine(input, HTTP_REQUEST_URI_DIM);
-    if(tokenOff > 0)
+    if (tokenOff > 0)
       request->uri.assign( input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
     else
       request->uri.assign(input, HTTP_REQUEST_URI_DIM );
@@ -471,11 +487,11 @@
   /* Get the first token, this is the HTTP command.*/
   tokenOff = getCharInString(token, cmdSeps, HTTP_REQUEST_CMD_DIM);
   
-  if(tokenOff == -1)
+  if (tokenOff == -1)
   {
     /* Keep trace of first line for logging.  */
     tokenOff = getEndLine(token, HTTP_REQUEST_URI_DIM);
-    if(tokenOff > 0)
+    if (tokenOff > 0)
       request->uri.assign(input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
     else
       request->uri.assign(input, HTTP_REQUEST_URI_DIM );
@@ -483,22 +499,22 @@
   
   do
   {
-    if(tokenOff== -1 )
+    if (tokenOff== -1 )
       return 400;
     
     /* Copy the HTTP field(this is the command if we are on the first line).  */
-    myserver_strlcpy(command, token, min(commandSize, tokenOff + 1) );
+    myserver_strlcpy (command, token, min(commandSize, tokenOff + 1) );
   
     token += tokenOff;
     
-    if(*token == ':')
+    if (*token == ':')
       token++;
     while(*token == ' ')
       token++;
     nLineControlled++;
     lineControlled = 0;
 
-    if(nLineControlled == 1)
+    if (nLineControlled == 1)
     {
       int containOpts = 0;
       u_long lenToken = tokenOff;
@@ -513,23 +529,23 @@
       tokenOff = getEndLine(token, 
                             HTTP_REQUEST_VER_DIM + HTTP_REQUEST_URI_DIM+10);
       lenToken = tokenOff;
-      if(tokenOff == -1)
+      if (tokenOff == -1)
       {
         request->ver.clear();
         request->cmd.clear();
         tokenOff = getEndLine(input, HTTP_REQUEST_URI_DIM);
-        if(tokenOff > 0)
+        if (tokenOff > 0)
           request->uri.assign(input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
         else
           request->uri.assign(input, HTTP_REQUEST_URI_DIM );
         return 400;
       }
-      if(tokenOff > maxUri)
+      if (tokenOff > maxUri)
       {
         request->ver.clear();
         request->cmd.clear();
         tokenOff = getEndLine(input, HTTP_REQUEST_URI_DIM);
-        if(tokenOff > 0)
+        if (tokenOff > 0)
           request->uri.assign(input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
         else
           request->uri.assign(input, HTTP_REQUEST_URI_DIM );
@@ -540,12 +556,12 @@
         max--;
       for(i=0; ((int)i < max) && (i < HTTP_REQUEST_URI_DIM); i++)
       {
-        if(token[i] == '?')
+        if (token[i] == '?')
         {
           containOpts = 1;
           break;
         }
-        else if(token[i] == ' ')
+        else if (token[i] == ' ')
         {
           break;
         }
@@ -555,14 +571,14 @@
        *If a uri was specified store it. If it wasn't specified 
        *return an invalid header value.
        */
-      if(i)
+      if (i)
         request->uri.assign(token, i);
       else
       {
         request->ver.clear();
         request->cmd.clear();
         tokenOff = getEndLine(input, HTTP_REQUEST_URI_DIM);
-        if(tokenOff > 0)
+        if (tokenOff > 0)
           request->uri.assign(input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
         else
           request->uri.assign(input, HTTP_REQUEST_URI_DIM );
@@ -570,7 +586,7 @@
       }  
 
       /* If the uri contains some query data determine how long it is. */
-      if(containOpts)
+      if (containOpts)
       {
         j = getEndLine(&token[i], HTTP_REQUEST_URI_DIM);
         for(j = 0; ((int)(i+j+1)<max) && (j<HTTP_REQUEST_URI_OPTS_DIM-1);j++)
@@ -592,7 +608,7 @@
        */
       for(j = 0; j < 10; j++)
       {
-        if(token[i]==' ')
+        if (token[i]==' ')
           i++;
         else 
           break;
@@ -601,12 +617,12 @@
        *If there are more than 10 black spaces store the entire line 
        *for logging then return an invalid header value.
        */
-      if(j == 10)
+      if (j == 10)
       {
         request->ver.clear();
         request->cmd.clear();
         tokenOff = getEndLine(input, HTTP_REQUEST_URI_DIM);
-        if(tokenOff > 0)
+        if (tokenOff > 0)
           request->uri.assign(input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
         else
           request->uri.assign(input, HTTP_REQUEST_URI_DIM );
@@ -620,19 +636,19 @@
         i++;
 
       /* Save the HTTP version. */
-      if(i-j)
+      if (i-j)
         request->ver.assign(&token[j], i-j);
 
       /*
        *If the version is not specified or it is too long store 
        *some information for logging then return an invalid header value. 
        */
-      if((!j) || ( (i-j) == HTTP_REQUEST_VER_DIM ))
+      if ((!j) || ( (i-j) == HTTP_REQUEST_VER_DIM ))
       {
         request->ver.clear();
         request->cmd.clear();   
         tokenOff = getEndLine(input, HTTP_REQUEST_URI_DIM);
-        if(tokenOff > 0)
+        if (tokenOff > 0)
           request->uri.assign(input, min(HTTP_REQUEST_URI_DIM, tokenOff) );
         else
           request->uri.assign(input, HTTP_REQUEST_URI_DIM );
@@ -640,7 +656,7 @@
       }
       
       /* Store if the requested uri terminates with a slash character. */
-      request->uriEndsWithSlash = request->uri[(request->uri.length())-1]=='/';
+      request->uriEndsWithSlash = request->uri[(request->uri.length ())-1]=='/';
 
       /*
        *Do not maintain any slash character if the uri has them at 
@@ -651,7 +667,7 @@
 
     }else
     /* Authorization.  */
-    if(!strcmpi(command,"Authorization"))
+    if (!strcmpi(command,"Authorization"))
     {
       int ret = readReqAuthLine (request, connection, token, &tokenOff);
       if (ret)
@@ -659,32 +675,32 @@
       lineControlled = 1;
     }else
     /* Content-Length.  */
-    if(!strcmpi(command, (char*)"Content-Length"))
+    if (!strcmpi(command, (char*)"Content-Length"))
     {
       tokenOff = getEndLine(token, HTTP_REQUEST_CONTENT_LENGTH_DIM);
-      if(tokenOff==-1)
+      if (tokenOff==-1)
         return 400;
       lineControlled = 1;
       request->contentLength.assign(token,tokenOff);
     }else
     /* Range.  */
-    if(!strcmpi(command, (char*)"Range"))
+    if (!strcmpi(command, (char*)"Range"))
     {
       int ret = readReqRangeLine (request, connection, token, &tokenOff);
       if (ret)
         return ret;
       lineControlled = 1;
     }else
-    if(!lineControlled)
+    if (!lineControlled)
     {
       tokenOff = getEndLine(token, maxTotchars);
-      if(tokenOff==-1)
+      if (tokenOff==-1)
         return 400;
       
       {
         string cmdStr(command);
         HttpRequestHeader::Entry *old = request->other.get(cmdStr);
-        if(old)
+        if (old)
         {
           old->value->append(", ");
           old->value->append(token, 
@@ -695,7 +711,7 @@
         else
         {
           HttpRequestHeader::Entry *e = new HttpRequestHeader::Entry(); 
-          if(e)
+          if (e)
           {
             e->name->assign(command, HTTP_RESPONSE_OTHER_DIM);
             e->value->assign(token, 
@@ -737,7 +753,7 @@
   rangeByteEnd[0] = '\0';
 
   int tokenOff = getEndLine(token, HTTP_REQUEST_RANGE_TYPE_DIM + 30);
-  if(tokenOff ==-1)
+  if (tokenOff ==-1)
     return 400;
   
   *lenOut = tokenOff;
@@ -769,19 +785,19 @@
     }
   while((*(++localToken) != '\r' )&&(i<12));
 
-  for(i=0;i < static_cast<int>(request->rangeType.length()); i++)
-    if(request->rangeType[i] == '=')
+  for(i=0;i < static_cast<int>(request->rangeType.length ()); i++)
+    if (request->rangeType[i] == '=')
       request->rangeType[i] = '\0';
   
-  for(i = 0; i < static_cast<int>(strlen(rangeByteBegin)); i++)
-    if(rangeByteBegin[i] == '=')
+  for(i = 0; i < static_cast<int>(strlen (rangeByteBegin)); i++)
+    if (rangeByteBegin[i] == '=')
       rangeByteBegin[i] = '\0';
   
-  for(i = 0; i < static_cast<int>(strlen(rangeByteEnd)); i++)
-    if(rangeByteEnd[i]== '=')
+  for(i = 0; i < static_cast<int>(strlen (rangeByteEnd)); i++)
+    if (rangeByteEnd[i]== '=')
       rangeByteEnd[i]='\0';
       
-  if(rangeByteBegin[0] == 0)
+  if (rangeByteBegin[0] == 0)
     {
       request->rangeByteBegin=0;
     }      
@@ -789,14 +805,14 @@
     {
       request->rangeByteBegin = (u_long)atol(rangeByteBegin); 
     }
-  if(rangeByteEnd[0] == '\r')
+  if (rangeByteEnd[0] == '\r')
     {
       request->rangeByteEnd = 0;
     }
   else
     {
       request->rangeByteEnd = (u_long)atol(rangeByteEnd);
-      if(request->rangeByteEnd < request->rangeByteBegin)
+      if (request->rangeByteEnd < request->rangeByteBegin)
         return 400;
     }
 
@@ -820,14 +836,14 @@
     token++;
   int tokenOff = getCharInString(token, " ", HTTP_REQUEST_AUTH_DIM);
   
-  if(tokenOff==-1)
+  if (tokenOff==-1)
     return 400;
 
   request->auth.assign(token, tokenOff);
   connection->setLogin("");
   connection->setPassword("");
 
-  if(!request->auth.compare("Basic"))
+  if (!request->auth.compare("Basic"))
     {
       u_long i;
       const char *base64 = &token[6];
@@ -839,7 +855,7 @@
       char password[32]; 
       CBase64Utils base64Utils;
     
-      if(len == -1)
+      if (len == -1)
         return 400;    
       
       login[0] = password[0] = '\0';
@@ -873,7 +889,7 @@
       delete lsecondaryBufferOr;
       *lenOut = tokenOff = getEndLine(token, 100);
     }
-  else if(!request->auth.compare("Digest"))
+  else if (!request->auth.compare("Digest"))
     {
       char *digestBuff;
       char *digestToken;
@@ -895,100 +911,100 @@
       memcpy(digestBuff, token, tokenOff);
       digestBuff[tokenOff]='\0';
       digestToken = strtok( digestBuff, "=" );
-      if(!digestToken)
+      if (!digestToken)
         return 400;
       do
         {
           StrTrim(digestToken, (char*)" ");
-          if(!strcmpi(digestToken, (char*)"nonce"))
+          if (!strcmpi(digestToken, (char*)"nonce"))
             {
               digestToken = strtok( NULL, (char*)"," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestNonce,digestToken,48+1);
+                  myserver_strlcpy (request->digestNonce,digestToken,48+1);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"opaque"))
+          else if (!strcmpi(digestToken, (char*)"opaque"))
             {
               digestToken = strtok( NULL, (char*)"," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestOpaque,digestToken,48+1);
+                  myserver_strlcpy (request->digestOpaque,digestToken,48+1);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"uri"))
+          else if (!strcmpi(digestToken, (char*)"uri"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestUri,digestToken,1024+1);
+                  myserver_strlcpy (request->digestUri,digestToken,1024+1);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"method"))
+          else if (!strcmpi(digestToken, (char*)"method"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestMethod,digestToken,16+1);
+                  myserver_strlcpy (request->digestMethod,digestToken,16+1);
                 }
             }  
-          else if(!strcmpi(digestToken, (char*)"qop"))
+          else if (!strcmpi(digestToken, (char*)"qop"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken,(char*)"\" ");
-                  myserver_strlcpy(request->digestQop,digestToken,16+1);
+                  myserver_strlcpy (request->digestQop,digestToken,16+1);
                 }
             }          
-          else if(!strcmpi(digestToken, (char*)"realm"))
+          else if (!strcmpi(digestToken, (char*)"realm"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestRealm,digestToken,48+1);
+                  myserver_strlcpy (request->digestRealm,digestToken,48+1);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"cnonce"))
+          else if (!strcmpi(digestToken, (char*)"cnonce"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)" \"");
-                  myserver_strlcpy(request->digestCnonce, digestToken, 48+1);
+                  myserver_strlcpy (request->digestCnonce, digestToken, 48+1);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"username"))
+          else if (!strcmpi(digestToken, (char*)"username"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestUsername, digestToken, 48+1);
+                  myserver_strlcpy (request->digestUsername, digestToken, 48+1);
                   connection->setLogin(digestToken);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"response"))
+          else if (!strcmpi(digestToken, (char*)"response"))
             {
               digestToken = strtok( NULL, "\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestResponse,digestToken,48+1);
+                  myserver_strlcpy (request->digestResponse,digestToken,48+1);
                 }
             }
-          else if(!strcmpi(digestToken, (char*)"nc"))
+          else if (!strcmpi(digestToken, (char*)"nc"))
             {
               digestToken = strtok( NULL, (char*)"\r\n," );
-              if(digestToken)
+              if (digestToken)
                 {
                   StrTrim(digestToken, (char*)"\" ");
-                  myserver_strlcpy(request->digestNc,digestToken,10+1);
+                  myserver_strlcpy (request->digestNc,digestToken,10+1);
                 }
             }
           else 
@@ -1040,14 +1056,14 @@
   int nLineControlled = 0;
 
   /* Control if the HTTP header is a valid header.  */
-  if(input[0] == 0)
+  if (input[0] == 0)
     return 0;
   validResponse = validHTTPResponse(input,&nLines, &maxTotchars);
 
-  if(validResponse)
+  if (validResponse)
   {
     newInput = new char[maxTotchars + 1];
-    if(!newInput)
+    if (!newInput)
       return 0;
     /*
      * FIXME: 
@@ -1063,7 +1079,7 @@
   token = (char*) input;
   
   /* Check if is specified the first line containing the HTTP status.  */
-  if((input[0] == 'H') && (input[1] == 'T') && (input[2] == 'T')
+  if ((input[0] == 'H') && (input[1] == 'T') && (input[2] == 'T')
      &&(input[3] == 'P') && (input[4] == '/'))
   {
     containStatusLine = 1;
@@ -1073,7 +1089,7 @@
     token = strtok( token, ": ,\t\n\r" );
   do
   {
-    if(!token)
+    if (!token)
       break;
     /*
      *Reset the flag lineControlled.
@@ -1083,26 +1099,26 @@
     /*
      *Copy the HTTP command.
      */
-    myserver_strlcpy(command, token, 96);
+    myserver_strlcpy (command, token, 96);
     
     nLineControlled++;
-    if((nLineControlled == 1) && containStatusLine)
+    if ((nLineControlled == 1) && containStatusLine)
     {
       lineControlled = 1;
       /* Copy the HTTP version.  */
       response->ver.assign(command);
     
       token = strtok( NULL, " ,\t\n\r" );
-      if(token)
+      if (token)
         response->httpStatus = atoi(token);
       
       token = strtok( NULL, "\r\n\0" );
-      if(token)
+      if (token)
         response->errorType.assign(token);
 
     }else
     /* Server.  */
-    if(!strcmpi(command,"Server"))
+    if (!strcmpi(command,"Server"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1110,11 +1126,11 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
         response->serverName.assign(token);
     }else
     /* Location  */
-    if(!strcmpi(command,"Location"))
+    if (!strcmpi(command,"Location"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1122,11 +1138,11 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
         response->location.assign(token);
     }else
     /* Last-Modified.  */
-    if(!strcmpi(command,"Last-Modified"))
+    if (!strcmpi(command,"Last-Modified"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1134,11 +1150,11 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
         response->lastModified.assign(token);
     }else
     /* Status.  */
-    if(!strcmpi(command,"Status"))
+    if (!strcmpi(command,"Status"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1147,12 +1163,12 @@
         token++;
 
       /*! If the response status is different from 200 don't modify it. */
-      if(response->httpStatus == 200)
-        if(token)
+      if (response->httpStatus == 200)
+        if (token)
           response->httpStatus = atoi(token);
     }else
     /* Date.  */
-    if(!strcmpi(command,"Date"))
+    if (!strcmpi(command,"Date"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1160,11 +1176,11 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
         response->date.assign(token);
     }else
     /* Content-Type.  */
-    if(!strcmpi(command,"Content-Type"))
+    if (!strcmpi(command,"Content-Type"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1172,11 +1188,11 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
         response->contentType.assign(token);
     }else
     /* MIME-Version.  */
-    if(!strcmpi(command,"MIME-Version"))
+    if (!strcmpi(command,"MIME-Version"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1184,11 +1200,11 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
         response->mimeVer.assign(token);
     }else
     /* Set-Cookie.  */
-    if(!strcmpi(command,"Set-Cookie"))
+    if (!strcmpi(command,"Set-Cookie"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1196,7 +1212,7 @@
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
       {
         /* Divide multiple cookies.  */
         response->cookie.append(token );
@@ -1204,7 +1220,7 @@
       }
     }else
     /* Content-Length.  */
-    if(!strcmpi(command,"Content-Length"))
+    if (!strcmpi(command,"Content-Length"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
@@ -1215,42 +1231,42 @@
       response->contentLength.assign(token);
     }else
     /* Connection.  */
-    if(!strcmpi(command,"Connection"))
+    if (!strcmpi(command,"Connection"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
 
-      if(token)
+      if (token)
         response->connection.assign(token);
     }else
     /* Expires.  */
-    if(!strcmpi(command,"Expires"))
+    if (!strcmpi(command,"Expires"))
     {
       token = strtok( NULL, "\r\n\0" );
       lineControlled = 1;
-      if(token)
+      if (token)
         response->dateExp.assign(token);
     }
     /*
      *If the line is not controlled arrive with the token
      *at the end of the line.
      */
-    if( (!lineControlled) &&  ((!containStatusLine) || (nLineControlled != 1)))
+    if ( (!lineControlled) &&  ((!containStatusLine) || (nLineControlled != 1)))
     {
       token = strtok(NULL, "\r\n");
 
       while(token && *token == ' ')
         token++;
 
-      if(token)
+      if (token)
       {
         HttpResponseHeader::Entry *e;
-        if(strlen(command) > HTTP_RESPONSE_OTHER_DIM || 
-           strlen(token) > HTTP_RESPONSE_OTHER_DIM)
+        if (strlen (command) > HTTP_RESPONSE_OTHER_DIM || 
+           strlen (token) > HTTP_RESPONSE_OTHER_DIM)
           return 0;
 
         e = new HttpResponseHeader::Entry(); 
-        if(e)
+        if (e)
         {
           e->name->assign(command);
           e->value->assign(token);
@@ -1258,7 +1274,7 @@
             HttpResponseHeader::Entry *old = 0;
             string cmdString(command);
             old = response->other.put(cmdString, e);
-            if(old)
+            if (old)
               delete old;
           }
         }
@@ -1294,16 +1310,16 @@
   nLinechars = 0;
   u_long nLines = 0;
   
-  if(req == 0)
+  if (req == 0)
     return 400;
   
   for(;i < MYSERVER_KB(8); i++)
   {
-    if(req[i] == '\n')
+    if (req[i] == '\n')
     {
-      if(req[i + 2] == '\n')
+      if (req[i + 2] == '\n')
       {
-        if((i + 3) > size)
+        if ((i + 3) > size)
           return 400;
         break;
       }
@@ -1311,20 +1327,20 @@
        *If the lines number is greater than 25 we consider 
        *the header invalid.
       */
-      if(nLines >= 25)
+      if (nLines >= 25)
         return 400;
       nLinechars = 0;
       nLines++;
     }
-    else if(req[i]=='\0')
+    else if (req[i]=='\0')
       return -1;
 
     /*
     *If a line contains more than 2048 characters then the header is considered invalid.
     */
-    if(nLinechars >= 2048)
+    if (nLinechars >= 2048)
     {
-      if(nLines == 0)
+      if (nLines == 0)
         return 414;
       return 400;
     }




