X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Futil.cpp;fp=src%2Futil.cpp;h=c18895dbab054ce3fbc86cb008ca886e14413e33;hb=4a46c6ad125dde75e1e35a09f8388f43eab5bb39;hp=f23c00c5ad2c0c749b2098b65c39bae45408099e;hpb=86b2928564b2701c34518f48244b830cc4647d7f;p=metaproxy-moved-to-github.git diff --git a/src/util.cpp b/src/util.cpp index f23c00c..c18895d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include + +#include #include @@ -737,6 +740,25 @@ 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 globitems; + boost::split(globitems, pattern, boost::is_any_of(" ")); + std::vector::const_iterator it = globitems.begin(); + bool ret_value = true; // for now (if only empty values) + 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; +} + /* * Local variables: * c-basic-offset: 4