myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [3075] Complex data structures can be defined in the v


From: Giuseppe Scrivano
Subject: [myserver-commit] [3075] Complex data structures can be defined in the virtual hosts configuration file too .
Date: Sun, 03 May 2009 19:31:16 +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)
       





reply via email to

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