+std::string mp_util::uri_decode(std::string s)
+{
+ char *x = (char *) xmalloc(1 + s.length());
+ yaz_decode_uri_component(x, s.c_str(), s.length());
+ std::string result(x);
+ xfree(x);
+ return result;
+}
+
+mp::wrbuf::wrbuf()
+{
+ m_wrbuf = wrbuf_alloc();
+}
+
+mp::wrbuf::~wrbuf()
+{
+ wrbuf_destroy(m_wrbuf);
+}
+
+mp::wrbuf::operator WRBUF() const
+{
+ return m_wrbuf;
+}
+
+size_t mp::wrbuf::len()
+{
+ return wrbuf_len(m_wrbuf);
+}
+
+const char *mp::wrbuf::buf()
+{
+ return wrbuf_buf(m_wrbuf);
+}
+
+const char *mp::wrbuf::c_str()
+{
+ return wrbuf_cstr(m_wrbuf);
+}
+
+const char *mp::wrbuf::c_str_null()
+{
+ return wrbuf_cstr_null(m_wrbuf);
+}
+
+bool mp::util::match_ip(const std::string &pattern, const std::string &value)
+{
+ std::vector<std::string> globitems;
+ // split may produce empty strings as results - in particular
+ // the empty pattern produces one empty string (vector size 1)
+ boost::split(globitems, pattern, boost::is_any_of(" "));
+ bool ret_value = true; // for now (if only empty values)
+ std::vector<std::string>::const_iterator it = globitems.begin();
+ for (; it != globitems.end(); it++)
+ {
+ const char *c_str = (*it).c_str();
+ if (*c_str)
+ {
+ ret_value = false; // at least one non-empty value
+ if (yaz_match_glob(c_str, value.c_str()))
+ return true;
+ }
+ }
+ return ret_value;
+}
+