#include <yaz/zgdu.h>
#include <yaz/srw.h>
#include <yaz/comstack.h>
-
+#include <metaproxy/util.hpp>
#include "torus.hpp"
namespace mp = metaproxy_1;
}
-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;
}
/*