X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftorus.cpp;h=d60362184e0bec5d59106b325f1dd76914cb4921;hb=3173ed849a3f4d91b17e693d9c27ac38e930ef4e;hp=39f87dab5de0bba6a10e711ece155af2fbd3cdc5;hpb=67753db293cb62940e4c2db3a6e5f635cd5b78c3;p=metaproxy-moved-to-github.git diff --git a/src/torus.cpp b/src/torus.cpp index 39f87da..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,37 +148,21 @@ static WRBUF get_url(const char *uri, WRBUF username, WRBUF password, } -mp::Torus::Torus() -{ - doc = 0; -} - -mp::Torus::~Torus() +xmlDoc *mp::get_searchable(std::string url_template, const std::string &db) { - if (doc) - xmlFreeDoc(doc); -} + // http://newmk2.indexdata.com/torus2/searchable.ebsco/records/?query=udb=aberdeenUni + xmlDoc *doc = 0; + size_t found; -void mp::Torus::read_searchables(std::string url) -{ - if (url.length() == 0) - return; - - if (doc) - { - xmlFreeDoc(doc); - doc = 0; - } - + 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); + return doc; } /*