X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Ftorus.cpp;h=d60362184e0bec5d59106b325f1dd76914cb4921;hb=8eff7fecccca024ff59c9c305592fe8e3c5cab36;hp=924781a7d752db934d759327df47225937f2a005;hpb=c6105f042dd7591d8566fa590eb92476b2435bb5;p=metaproxy-moved-to-github.git diff --git a/src/torus.cpp b/src/torus.cpp index 924781a..d603621 100644 --- a/src/torus.cpp +++ b/src/torus.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include - +#include #include "torus.hpp" namespace mp = metaproxy_1; @@ -148,40 +148,20 @@ static WRBUF get_url(const char *uri, WRBUF username, WRBUF password, } -mp::Torus::Torus() -{ - doc = 0; -} - -mp::Torus::~Torus() -{ - if (doc) - xmlFreeDoc(doc); -} - -void mp::Torus::read_searchables(std::string url) +xmlDoc *mp::get_searchable(std::string url_template, const std::string &db) { - if (doc) - { - xmlFreeDoc(doc); - doc = 0; - } - if (url.length() == 0) - return; + // http://newmk2.indexdata.com/torus2/searchable.ebsco/records/?query=udb=aberdeenUni + xmlDoc *doc = 0; + size_t found; + found = url_template.find("%db"); + if (found != std::string::npos) + url_template.replace(found, found+3, mp::util::uri_encode(db)); int code; - WRBUF w = get_url(url.c_str(), 0, 0, &code); + WRBUF w = get_url(url_template.c_str(), 0, 0, &code); if (code == 200) - { doc = xmlParseMemory(wrbuf_buf(w), wrbuf_len(w)); - if (doc) - yaz_log(YLOG_LOG, "xmlParseMemory OK"); - } wrbuf_destroy(w); -} - -xmlDoc *mp::Torus::get_doc() -{ return doc; }