code cleanup, replaced class name Virt_db with VirtualDB
[metaproxy-moved-to-github.git] / src / util.cpp
index 2cc2759..4615347 100644 (file)
@@ -1,24 +1,41 @@
-/* $Id: util.cpp,v 1.18 2006-06-19 23:54:02 adam Exp $
+/* $Id: util.cpp,v 1.20 2006-09-29 08:42:47 marc Exp $
    Copyright (c) 2005-2006, Index Data.
 
    See the LICENSE file for details
  */
 
 #include "config.hpp"
+#include "util.hpp"
 
 #include <yaz/odr.h>
 #include <yaz/pquery.h>
 #include <yaz/otherinfo.h>
 #include <yaz/querytowrbuf.h> // for yaz_query_to_wrbuf()
-#include "util.hpp"
 
-//#include <iostream>
+#include <iostream>
 
 namespace mp = metaproxy_1;
 
 // Doxygen doesn't like mp::util, so we use this instead
 namespace mp_util = metaproxy_1::util;
 
+
+std::string mp_util::http_header_value(const Z_HTTP_Header* header, 
+                                       const std::string name)
+{
+    while (header && header->name
+           && std::string(header->name) !=  name)
+        header = header->next;
+    
+    if (header && header->name && std::string(header->name) == name
+        && header->value)
+        return std::string(header->value);
+    
+    return std::string();
+}
+    
+
+
 int mp_util::memcmp2(const void *buf1, int len1,
                      const void *buf2, int len2)
 {
@@ -191,7 +208,7 @@ void mp_util::get_init_diagnostics(
     }
 }
 
-int mp_util::get_vhost_otherinfo(
+int mp_util::get_or_remove_vhost_otherinfo(
     Z_OtherInformation **otherInformation,
     bool remove_flag,
     std::list<std::string> &vhosts)
@@ -213,6 +230,20 @@ int mp_util::get_vhost_otherinfo(
     return cat;
 }
 
+void mp_util::get_vhost_otherinfo(
+    Z_OtherInformation *otherInformation,
+    std::list<std::string> &vhosts)
+{
+    get_or_remove_vhost_otherinfo(&otherInformation, false, vhosts);
+}
+
+int mp_util::remove_vhost_otherinfo(
+    Z_OtherInformation **otherInformation,
+    std::list<std::string> &vhosts)
+{
+    return get_or_remove_vhost_otherinfo(otherInformation, true, vhosts);
+}
+
 void mp_util::set_vhost_otherinfo(
     Z_OtherInformation **otherInformation, ODR odr,
     const std::list<std::string> &vhosts)