-/* $Id: filter_backend_test.cpp,v 1.23 2007-03-08 09:38:31 adam Exp $
+/* $Id: filter_backend_test.cpp,v 1.24 2007-04-13 09:57:51 adam Exp $
Copyright (c) 2005-2007, Index Data.
See the LICENSE file for details
#include <yaz/log.h>
#include <yaz/otherinfo.h>
#include <yaz/diagbib1.h>
+#include <yaz/oid_db.h>
namespace mp = metaproxy_1;
namespace yf = mp::filter;
int start, int number, int &error_code, std::string &addinfo,
int *number_returned, int *next_position)
{
- oident *prefformat;
- oid_value form;
const char *element_set_name = "F"; // default to use
if (number + start - 1 > result_set_size || start < 1)
return 0;
}
- if (!(prefformat = oid_getentbyoid(preferredRecordSyntax)))
- form = VAL_NONE;
- else
- form = prefformat->value;
- switch(form)
+ const char *name_oid = OID_STR_USMARC; // default if syntax is given
+ if (preferredRecordSyntax)
{
- case VAL_NONE:
- form = VAL_USMARC;
- break;
- case VAL_USMARC:
- case VAL_TEXT_XML:
- break;
- default:
- error_code = YAZ_BIB1_RECORD_SYNTAX_UNSUPP;
- return 0;
+ name_oid =
+ yaz_oid_to_string(yaz_oid_std(), preferredRecordSyntax, 0);
+ if (name_oid && !strcmp(name_oid, OID_STR_USMARC))
+ ;
+ else if (name_oid && !strcmp(name_oid, OID_STR_XML))
+ ;
+ else
+ {
+ error_code = YAZ_BIB1_RECORD_SYNTAX_UNSUPP;
+ return 0;
+ }
}
// no element set, "B" and "F" are supported
}
element_set_name = esn->u.generic;
}
- if (!strcmp(element_set_name, "B") && form == VAL_USMARC)
+ if (!strcmp(element_set_name, "B")
+ && !strcmp(name_oid, OID_STR_USMARC))
; // Brief
- else if (!strcmp(element_set_name, "F") && form == VAL_USMARC)
+ else if (!strcmp(element_set_name, "F")
+ && !strcmp(name_oid, OID_STR_USMARC))
; // Full
- else if (!strncmp(element_set_name, "FF", 2) && form == VAL_TEXT_XML)
+ else if (!strncmp(element_set_name, "FF", 2)
+ && !strcmp(name_oid, OID_STR_XML))
; // Huge XML test record
else
{
memcpy(tmp_rec, "<a>", 3);
memcpy(tmp_rec + sz - 4, "</a>", 4);
- npr->u.databaseRecord = z_ext_record(odr, VAL_TEXT_XML, tmp_rec, sz);
+ npr->u.databaseRecord = z_ext_record_xml(odr, tmp_rec, sz);
xfree(tmp_rec);
}
else
char offset_str[30];
sprintf(offset_str, "test__%09d_", i+start);
memcpy(tmp_rec+186, offset_str, strlen(offset_str));
- npr->u.databaseRecord = z_ext_record(odr, VAL_USMARC,
- tmp_rec, strlen(tmp_rec));
+ npr->u.databaseRecord = z_ext_record_usmarc(
+ odr, tmp_rec, strlen(tmp_rec));
}
}
-/* $Id: filter_record_transform.cpp,v 1.9 2007-03-20 07:57:54 adam Exp $
+/* $Id: filter_record_transform.cpp,v 1.10 2007-04-13 09:57:51 adam Exp $
Copyright (c) 2005-2007, Index Data.
See the LICENSE file for details
else if (ret_code == 2)
{
char oidbuf[OID_STR_MAX];
- oid_to_dotstring(input_syntax, oidbuf);
+ oid_oid_to_dotstring(input_syntax, oidbuf);
details = odr_strdup(odr_en, oidbuf);
apdu = odr_en.create_presentResponse(
return;
}
-
-
// now re-coding the z3950 backend present request
- // z3950'fy record syntax
- if (backend_syntax) // TODO: this seems not to work - why ??
- pr_req->preferredRecordSyntax = backend_syntax;
+ if (backend_syntax)
+ pr_req->preferredRecordSyntax = odr_oiddup(odr_en, backend_syntax);
else
- pr_req->preferredRecordSyntax
- = yaz_oidval_to_z3950oid(odr_en, CLASS_RECSYN, VAL_NONE);
+ pr_req->preferredRecordSyntax = 0;
// z3950'fy record schema
output_record);
if (ret_trans == 0)
{
- struct oident *ident = oid_getentbyoid(match_syntax);
npr->u.databaseRecord =
- z_ext_record(odr_en, ident->value,
+ z_ext_record_oid(odr_en, match_syntax,
wrbuf_buf(output_record),
wrbuf_len(output_record));
}
-/* $Id: filter_sru_to_z3950.cpp,v 1.32 2007-03-20 07:20:16 adam Exp $
+/* $Id: filter_sru_to_z3950.cpp,v 1.33 2007-04-13 09:57:51 adam Exp $
Copyright (c) 2005-2007, Index Data.
See the LICENSE file for details
#include <yaz/z-core.h>
#include <yaz/srw.h>
#include <yaz/pquery.h>
+#include <yaz/oid_db.h>
#include <boost/thread/mutex.hpp>
record_packing = Z_SRW_recordPacking_string;
// RecordSyntax will always be XML
- (apdu->u.presentRequest->preferredRecordSyntax)
- = yaz_oidval_to_z3950oid (odr_en, CLASS_RECSYN, VAL_TEXT_XML);
+ apdu->u.presentRequest->preferredRecordSyntax
+ = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, OID_STR_XML,
+ odr_en);
// z3950'fy record schema
if (sr_req->recordSchema)
else
{
Z_External *r = npr->u.databaseRecord;
- oident *ent = oid_getentbyoid(r->direct_reference);
- if (r->which == Z_External_octet
- && ent->value == VAL_TEXT_XML)
+ const int *xml_oid = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_RECSYN,
+ OID_STR_XML);
+ if (xml_oid && r->direct_reference
+ && !oid_oidcmp(r->direct_reference, xml_oid))
{
sru_res->records[i].recordSchema = "dc";
sru_res->records[i].recordData_buf
-/* $Id: gduutil.cpp,v 1.19 2007-04-10 11:28:51 marc Exp $
+/* $Id: gduutil.cpp,v 1.20 2007-04-13 09:57:51 adam Exp $
Copyright (c) 2005-2007, Index Data.
See the LICENSE file for details
#include "util.hpp"
#include <yaz/wrbuf.h>
+#include <yaz/oid_db.h>
#include <yaz/querytowrbuf.h>
#include <iostream>
else
os << " -";
if (pr->preferredRecordSyntax)
- //os << " " << pr->preferredRecordSyntax;
- os << " " <<(oid_getentbyoid(pr->preferredRecordSyntax))->desc;
+ {
+ char oid_name_str[OID_STR_MAX];
+ const char *oid_name = yaz_oid_to_string_buf(
+ pr->preferredRecordSyntax, 0, oid_name_str);
+
+ os << " " << oid_name;
+ }
else
os << " -";
const char * msg = 0;
if (sr->termListAndStartPoint)
{
WRBUF wr = wrbuf_alloc();
- yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint, VAL_NONE);
+ yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint,
+ sr->attributeSet);
os << wrbuf_cstr(wr);
wrbuf_destroy(wr);
}
-/* $Id: test_filter_z3950_client.cpp,v 1.10 2007-01-25 14:05:54 adam Exp $
+/* $Id: test_filter_z3950_client.cpp,v 1.11 2007-04-13 09:57:51 adam Exp $
Copyright (c) 2005-2007, Index Data.
See the LICENSE file for details
#include <yaz/zgdu.h>
#include <yaz/otherinfo.h>
+#include <yaz/oid_db.h>
using namespace boost::unit_test;
namespace mp = metaproxy_1;
const char *vhost = "localhost:9999";
if (vhost)
- yaz_oi_set_string_oidval(&apdu->u.initRequest->otherInfo,
- odr, VAL_PROXY, 1, vhost);
+ {
+ const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_USERINFO,
+ OID_STR_PROXY);
+ yaz_oi_set_string_oid(&apdu->u.initRequest->otherInfo,
+ odr, oid_proxy, 1, vhost);
+ }
BOOST_CHECK(apdu);
pack.request() = apdu;
-/* $Id: util.cpp,v 1.26 2007-03-20 07:57:54 adam Exp $
+/* $Id: util.cpp,v 1.27 2007-04-13 09:57:51 adam Exp $
Copyright (c) 2005-2007, Index Data.
See the LICENSE file for details
#include <yaz/odr.h>
#include <yaz/pquery.h>
#include <yaz/otherinfo.h>
-#include <yaz/querytowrbuf.h> // for yaz_query_to_wrbuf()
+#include <yaz/querytowrbuf.h>
+#include <yaz/oid_db.h>
#include <iostream>
std::list<std::string> &vhosts)
{
int cat;
+ const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_USERINFO,
+ OID_STR_PROXY);
for (cat = 1; ; cat++)
{
// check virtual host
const char *vhost =
- yaz_oi_get_string_oidval(otherInformation,
- VAL_PROXY,
- cat /* categoryValue */,
- remove_flag /* delete flag */);
+ yaz_oi_get_string_oid(otherInformation,
+ oid_proxy,
+ cat /* categoryValue */,
+ remove_flag /* delete flag */);
if (!vhost)
break;
vhosts.push_back(std::string(vhost));
{
int cat;
std::list<std::string>::const_iterator it = vhosts.begin();
+
+ const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_USERINFO,
+ OID_STR_PROXY);
+
for (cat = 1; it != vhosts.end() ; cat++, it++)
{
- yaz_oi_set_string_oidval(otherInformation, odr,
- VAL_PROXY, cat, it->c_str());
+ yaz_oi_set_string_oid(otherInformation, odr,
+ oid_proxy, cat, it->c_str());
}
}
Z_OtherInformation **otherInformation, ODR odr,
const std::string vhost, const int cat)
{
- yaz_oi_set_string_oidval(otherInformation, odr,
- VAL_PROXY, cat, vhost.c_str());
+ const int *oid_proxy = yaz_string_to_oid(yaz_oid_std(),
+ CLASS_USERINFO,
+ OID_STR_PROXY);
+
+ yaz_oi_set_string_oid(otherInformation, odr,
+ oid_proxy, cat, vhost.c_str());
}
void mp_util::split_zurl(std::string zurl, std::string &host,
- std::list<std::string> &db)
+ std::list<std::string> &db)
{
const char *zurl_cstr = zurl.c_str();
const char *sep = strchr(zurl_cstr, '/');