From: Adam Dickmeiss Date: Thu, 12 Apr 2007 15:00:33 +0000 (+0000) Subject: Update for YAZ 3s new OID system X-Git-Tag: YAZPP.1.0.3~6 X-Git-Url: http://git.indexdata.com/?p=yazpp-moved-to-github.git;a=commitdiff_plain;h=d508100e993ab5c9a415bd1826b939875dcfe91c Update for YAZ 3s new OID system --- diff --git a/configure.ac b/configure.ac index 63d36b1..3340e8d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ -dnl YAZ++ Toolkit, Index Data 1994-2006 +dnl YAZ++ Toolkit, Index Data 1994-2007 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.15 2007-03-20 16:21:58 adam Exp $ +dnl $Id: configure.ac,v 1.16 2007-04-12 15:00:33 adam Exp $ AC_PREREQ(2.59) AC_INIT([yazpp],[1.0.3],[adam@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) @@ -13,7 +13,7 @@ AC_PROG_CXX AC_HEADER_STDC AM_PROG_LIBTOOL -YAZ_INIT(threads,2.1.50) +YAZ_INIT(threads,2.1.99) if test -z "$YAZLIB"; then AC_MSG_ERROR([YAZ development libraries missing]) fi diff --git a/include/yazpp/ir-assoc.h b/include/yazpp/ir-assoc.h index eb3d110..7e32822 100644 --- a/include/yazpp/ir-assoc.h +++ b/include/yazpp/ir-assoc.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2005, Index Data. * See the file LICENSE for details. * - * $Id: ir-assoc.h,v 1.1 2006-03-29 13:14:15 adam Exp $ + * $Id: ir-assoc.h,v 1.2 2007-04-12 15:00:33 adam Exp $ */ #include @@ -74,7 +74,7 @@ class YAZ_EXPORT IR_Assoc: public Z_Assoc { char *m_cookie; int m_num_databaseNames; char **m_databaseNames; - int m_preferredRecordSyntax; + char *m_preferredRecordSyntax; Z_ElementSetNames *m_elementSetNames; int m_lastReceived; int m_log; diff --git a/include/yazpp/z-assoc.h b/include/yazpp/z-assoc.h index 0796491..158ad9f 100644 --- a/include/yazpp/z-assoc.h +++ b/include/yazpp/z-assoc.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2005, Index Data. * See the file LICENSE for details. * - * $Id: z-assoc.h,v 1.1 2006-03-29 13:14:15 adam Exp $ + * $Id: z-assoc.h,v 1.2 2007-04-12 15:00:33 adam Exp $ */ #ifndef YAZ_Z_ASSOC_INCLUDED @@ -63,18 +63,18 @@ class YAZ_EXPORT Z_Assoc : public IPDU_Observer { void get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip); Z_OtherInformationUnit *update_otherInformation ( Z_OtherInformation **otherInformationP, int createFlag, - int *oid, int categoryValue, int deleteFlag); + const int *oid, int categoryValue, int deleteFlag); void set_otherInformationString ( Z_OtherInformation **otherInformationP, - int *oid, int categoryValue, + const int *oid, int categoryValue, const char *str); void set_otherInformationString ( Z_OtherInformation **otherInformation, - int oidval, int categoryValue, + const char *oidname, int categoryValue, const char *str); void set_otherInformationString ( Z_APDU *apdu, - int oidval, int categoryValue, + const char *oidval, int categoryValue, const char *str); Z_ReferenceId *getRefID(char* str); diff --git a/include/yazpp/z-server.h b/include/yazpp/z-server.h index c8085c7..255b24f 100644 --- a/include/yazpp/z-server.h +++ b/include/yazpp/z-server.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2000-2005, Index Data. + * Copyright (c) 2000-2007, Index Data. * See the file LICENSE for details. * - * $Id: z-server.h,v 1.1 2006-03-29 13:14:15 adam Exp $ + * $Id: z-server.h,v 1.2 2007-04-12 15:00:33 adam Exp $ */ #include @@ -14,7 +14,7 @@ class Z_Server; class YAZ_EXPORT Z_ServerUtility { public: void create_databaseRecord (ODR odr, Z_NamePlusRecord *rec, - const char *dbname, int format, + const char *dbname, const char *format, const void *buf, int len); void create_surrogateDiagnostics(ODR odr, Z_NamePlusRecord *rec, const char *dbname, int error, diff --git a/src/yaz-ir-assoc.cpp b/src/yaz-ir-assoc.cpp index 5f5d00c..31689f4 100644 --- a/src/yaz-ir-assoc.cpp +++ b/src/yaz-ir-assoc.cpp @@ -2,13 +2,14 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: yaz-ir-assoc.cpp,v 1.27 2006-03-29 13:14:15 adam Exp $ + * $Id: yaz-ir-assoc.cpp,v 1.28 2007-04-12 15:00:33 adam Exp $ */ #include #include #include +#include using namespace yazpp_1; @@ -17,7 +18,7 @@ IR_Assoc::IR_Assoc(IPDU_Observable *the_PDU_Observable) { m_num_databaseNames = 0; m_databaseNames = 0; - m_preferredRecordSyntax = VAL_NONE; + m_preferredRecordSyntax = 0; m_elementSetNames = 0; m_lastReceived = 0; m_host = 0; @@ -30,6 +31,7 @@ IR_Assoc::IR_Assoc(IPDU_Observable *the_PDU_Observable) IR_Assoc::~IR_Assoc() { + xfree(m_preferredRecordSyntax); if (m_elementSetNames) delete [] m_elementSetNames->u.generic; delete [] m_elementSetNames; @@ -89,35 +91,20 @@ void IR_Assoc::set_databaseNames(const char *dblist, const char *sep) delete [] list; } -void IR_Assoc::set_preferredRecordSyntax (int value) -{ - m_preferredRecordSyntax = value; -} - void IR_Assoc::set_preferredRecordSyntax (const char *syntax) { - m_preferredRecordSyntax = VAL_NONE; + xfree(m_preferredRecordSyntax); + m_preferredRecordSyntax = 0; if (syntax && *syntax) - m_preferredRecordSyntax = oid_getvalbyname (syntax); -} - -void IR_Assoc::get_preferredRecordSyntax (int *value) -{ - *value = m_preferredRecordSyntax; + m_preferredRecordSyntax = xstrdup(syntax); } void IR_Assoc::get_preferredRecordSyntax (const char **dst) { - struct oident ent; - ent.proto = PROTO_Z3950; - ent.oclass = CLASS_RECSYN; - ent.value = (enum oid_value) m_preferredRecordSyntax; - - int oid[OID_SIZE]; - oid_ent_to_oid (&ent, oid); - struct oident *entp = oid_getentbyoid (oid); - - *dst = entp ? entp->desc : ""; + if (m_preferredRecordSyntax) + *dst = m_preferredRecordSyntax; + else + *dst = ""; } void IR_Assoc::set_elementSetName (const char *elementSetName) @@ -201,28 +188,24 @@ int IR_Assoc::send_searchRequest(Yaz_Z_Query *query, { Z_APDU *apdu = create_Z_PDU(Z_APDU_searchRequest); Z_SearchRequest *req = apdu->u.searchRequest; - int recordSyntax; req->query = query->get_Z_Query(); if (!req->query) return -1; get_databaseNames (&req->num_databaseNames, &req->databaseNames); - int oid_syntax[OID_SIZE]; - oident prefsyn; + const char *recordSyntax; get_preferredRecordSyntax(&recordSyntax); - if (recordSyntax != VAL_NONE) + if (recordSyntax && *recordSyntax) { - prefsyn.proto = PROTO_Z3950; - prefsyn.oclass = CLASS_RECSYN; - prefsyn.value = (enum oid_value) recordSyntax; - oid_ent_to_oid(&prefsyn, oid_syntax); - req->preferredRecordSyntax = oid_syntax; + req->preferredRecordSyntax + = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, recordSyntax, + odr_encode()); } yaz_log (m_log, "send_searchRequest"); assert (req->otherInfo == 0); if (m_cookie) { - set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); + set_otherInformationString(&req->otherInfo, OID_STR_COOKIE, 1, m_cookie); assert (req->otherInfo); } @@ -250,17 +233,13 @@ int IR_Assoc::send_presentRequest(int start, req->resultSetStartPoint = &start; req->numberOfRecordsRequested = &number; - int oid_syntax[OID_SIZE]; - oident prefsyn; - int recordSyntax; + const char *recordSyntax; get_preferredRecordSyntax (&recordSyntax); - if (recordSyntax != VAL_NONE) + if (recordSyntax && *recordSyntax) { - prefsyn.proto = PROTO_Z3950; - prefsyn.oclass = CLASS_RECSYN; - prefsyn.value = (enum oid_value) recordSyntax; - oid_ent_to_oid(&prefsyn, oid_syntax); - req->preferredRecordSyntax = oid_syntax; + req->preferredRecordSyntax = + yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, recordSyntax, + odr_encode()); } Z_RecordComposition compo; Z_ElementSetNames *elementSetNames; @@ -273,7 +252,8 @@ int IR_Assoc::send_presentRequest(int start, } if (m_cookie) - set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); + set_otherInformationString(&req->otherInfo, OID_STR_COOKIE, + 1, m_cookie); if ( pRefId ) { @@ -404,9 +384,9 @@ int IR_Assoc::send_initRequest(char* pRefId) } if (m_proxy && m_host) - set_otherInformationString(&req->otherInfo, VAL_PROXY, 1, m_host); + set_otherInformationString(&req->otherInfo, OID_STR_PROXY, 1, m_host); if (m_cookie) - set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); + set_otherInformationString(&req->otherInfo, OID_STR_COOKIE, 1, m_cookie); return send_Z_PDU(apdu, 0); } @@ -435,9 +415,9 @@ int IR_Assoc::send_deleteResultSetRequest(char* pResultSetId, char* pRefId) } if (m_proxy && m_host) - set_otherInformationString(&req->otherInfo, VAL_PROXY, 1, m_host); + set_otherInformationString(&req->otherInfo, OID_STR_PROXY, 1, m_host); if (m_cookie) - set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); + set_otherInformationString(&req->otherInfo, OID_STR_COOKIE, 1, m_cookie); return send_Z_PDU(apdu, 0); } diff --git a/src/yaz-my-client.cpp b/src/yaz-my-client.cpp index f9a9462..e359be3 100644 --- a/src/yaz-my-client.cpp +++ b/src/yaz-my-client.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 1998-2004, Index Data. + * Copyright (c) 1998-2007, Index Data. * See the file LICENSE for details. * - * $Id: yaz-my-client.cpp,v 1.26 2007-04-10 12:14:04 adam Exp $ + * $Id: yaz-my-client.cpp,v 1.27 2007-04-12 15:00:33 adam Exp $ */ #include @@ -13,6 +13,7 @@ #include #include #include +#include extern "C" { #if HAVE_READLINE_READLINE_H @@ -48,10 +49,8 @@ public: void recv_namePlusRecord (Z_NamePlusRecord *zpr, int offset); void recv_record(Z_DatabaseRecord *record, int offset, const char *databaseName); - void recv_textRecord(int type, const char *buf, size_t len); + void recv_textRecord(const char *buf, size_t len); void recv_genericRecord(Z_GenericRecord *r); - void display_genericRecord(Z_GenericRecord *r, int level); - void display_variant(Z_Variant *v, int level); void connectNotify(); void failNotify(); void timeoutNotify(); @@ -114,14 +113,12 @@ void usage(char *prog) char *MyClient::get_cookie(Z_OtherInformation **otherInfo) { - int oid[OID_SIZE]; Z_OtherInformationUnit *oi; - struct oident ent; - ent.proto = PROTO_Z3950; - ent.oclass = CLASS_USERINFO; - ent.value = (oid_value) VAL_COOKIE; - if (oid_ent_to_oid (&ent, oid) && + const int *oid = + yaz_string_to_oid(yaz_oid_std(), CLASS_USERINFO, OID_STR_COOKIE); + + if (oid && (oi = update_otherInformation(otherInfo, 0, oid, 1, 1)) && oi->which == Z_OtherInfo_characterInfo) return oi->information.characterInfo; @@ -149,7 +146,6 @@ void MyClient::recv_initResponse(Z_InitResponse *initResponse) void MyClient::recv_diagrecs(Z_DiagRec **pp, int num) { int i; - oident *ent; Z_DefaultDiagFormat *r; printf("Diagnostic message(s) from database:\n"); @@ -163,11 +159,7 @@ void MyClient::recv_diagrecs(Z_DiagRec **pp, int num) } else r = p->u.defaultFormat; - if (!(ent = oid_getentbyoid(r->diagnosticSetId)) || - ent->oclass != CLASS_DIAGSET || ent->value != VAL_BIB1) - printf("Missing or unknown diagset\n"); - printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition)); -#ifdef ASN_COMPILED + printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition)); switch (r->which) { case Z_DefaultDiagFormat_v2Addinfo: @@ -177,152 +169,43 @@ void MyClient::recv_diagrecs(Z_DiagRec **pp, int num) printf (" -- v3 addinfo '%s'\n", r->u.v3Addinfo); break; } -#else - if (r->addinfo && *r->addinfo) - printf(" -- '%s'\n", r->addinfo); - else - printf("\n"); -#endif } } -void MyClient::recv_textRecord(int type, const char *buf, size_t len) +void MyClient::recv_textRecord(const char *buf, size_t len) { fwrite (buf, 1, len, stdout); fputc ('\n', stdout); } -void MyClient::display_variant(Z_Variant *v, int level) -{ - int i; - - for (i = 0; i < v->num_triples; i++) - { - printf("%*sclass=%d,type=%d", level * 4, "", *v->triples[i]->zclass, - *v->triples[i]->type); - if (v->triples[i]->which == Z_Triple_internationalString) - printf(",value=%s\n", v->triples[i]->value.internationalString); - else - printf("\n"); - } -} - -void MyClient::display_genericRecord(Z_GenericRecord *r, int level) -{ - int i; - - if (!r) - return; - for (i = 0; i < r->num_elements; i++) - { - Z_TaggedElement *t; - - printf("%*s", level * 4, ""); - t = r->elements[i]; - printf("("); - if (t->tagType) - printf("%d,", *t->tagType); - else - printf("?,"); - if (t->tagValue->which == Z_StringOrNumeric_numeric) - printf("%d) ", *t->tagValue->u.numeric); - else - printf("%s) ", t->tagValue->u.string); - if (t->content->which == Z_ElementData_subtree) - { - printf("\n"); - display_genericRecord(t->content->u.subtree, level+1); - } - else if (t->content->which == Z_ElementData_string) - printf("%s\n", t->content->u.string); - else if (t->content->which == Z_ElementData_numeric) - printf("%d\n", *t->content->u.numeric); - else if (t->content->which == Z_ElementData_oid) - { - int *ip = t->content->u.oid; - oident *oent; - - if ((oent = oid_getentbyoid(t->content->u.oid))) - printf("OID: %s\n", oent->desc); - else - { - printf("{"); - while (ip && *ip >= 0) - printf(" %d", *(ip++)); - printf(" }\n"); - } - } - else if (t->content->which == Z_ElementData_noDataRequested) - printf("[No data requested]\n"); - else if (t->content->which == Z_ElementData_elementEmpty) - printf("[Element empty]\n"); - else if (t->content->which == Z_ElementData_elementNotThere) - printf("[Element not there]\n"); - else - printf("??????\n"); - if (t->appliedVariant) - display_variant(t->appliedVariant, level+1); - if (t->metaData && t->metaData->supportedVariants) - { - int c; - - printf("%*s---- variant list\n", (level+1)*4, ""); - for (c = 0; c < t->metaData->num_supportedVariants; c++) - { - printf("%*svariant #%d\n", (level+1)*4, "", c); - display_variant(t->metaData->supportedVariants[c], level + 2); - } - } - } -} - void MyClient::recv_genericRecord(Z_GenericRecord *r) { - display_genericRecord(r, 0); + WRBUF w = wrbuf_alloc(); + yaz_display_grs1(w, r, 0); + fwrite(wrbuf_buf(w), 1, wrbuf_len(w), stdout); + wrbuf_destroy(w); } void MyClient::recv_record(Z_DatabaseRecord *record, int offset, const char *databaseName) { Z_External *r = (Z_External*) record; - oident *ent = oid_getentbyoid(r->direct_reference); - /* * Tell the user what we got. */ if (r->direct_reference) { - printf("Record type: "); - if (ent) - printf("%s\n", ent->desc); + char name_oid_str[OID_STR_MAX]; + const char *name_oid = yaz_oid_to_string_buf(r->direct_reference, 0, + name_oid_str); + printf("Record type: %s\n", name_oid ? name_oid : "unknown"); } if (r->which == Z_External_octet && record->u.octet_aligned->len) { - yaz_marc_t mt = yaz_marc_create(); - switch (ent->value) + if (yaz_oid_is_iso2709(r->direct_reference)) { - case VAL_ISO2709: - case VAL_UNIMARC: - case VAL_INTERMARC: - case VAL_USMARC: - case VAL_UKMARC: - case VAL_NORMARC: - case VAL_LIBRISMARC: - case VAL_DANMARC: - case VAL_FINMARC: - case VAL_MAB: - case VAL_CANMARC: - case VAL_SBN: - case VAL_PICAMARC: - case VAL_AUSMARC: - case VAL_IBERMARC: - case VAL_CATMARC: - case VAL_MALMARC: - case VAL_JPMARC: - case VAL_SWEMARC: - case VAL_SIGLEMARC: - case VAL_ISDSMARC: - case VAL_RUSMARC: + yaz_marc_t mt = yaz_marc_create(); + const char *result_buf; size_t result_size; yaz_marc_decode_buf(mt, (const char *) @@ -330,18 +213,18 @@ void MyClient::recv_record(Z_DatabaseRecord *record, int offset, record->u.octet_aligned->len, &result_buf, &result_size); fwrite(result_buf, 1, result_size, stdout); - break; - default: - recv_textRecord((int) ent->value, - (const char *) record->u.octet_aligned->buf, + yaz_marc_destroy(mt); + } + else + { + recv_textRecord((const char *) record->u.octet_aligned->buf, (size_t) record->u.octet_aligned->len); } - yaz_marc_destroy(mt); } - else if (ent && ent->value == VAL_SUTRS && r->which == Z_External_sutrs) - recv_textRecord((int) VAL_SUTRS, (const char *) r->u.sutrs->buf, + else if (r->which == Z_External_sutrs) + recv_textRecord((const char *) r->u.sutrs->buf, (size_t) r->u.sutrs->len); - else if (ent && ent->value == VAL_GRS1 && r->which == Z_External_grs1) + else if (r->which == Z_External_grs1) recv_genericRecord(r->u.grs1); else { @@ -366,9 +249,7 @@ void MyClient::recv_namePlusRecord (Z_NamePlusRecord *zpr, int offset) void MyClient::recv_records (Z_Records *records) { -#ifdef ASN_COMPILED Z_DiagRec dr, *dr_p = &dr; -#endif if (!records) return; int i; @@ -381,13 +262,9 @@ void MyClient::recv_records (Z_Records *records) m_setOffset += records->u.databaseOrSurDiagnostics->num_records; break; case Z_Records_NSD: -#ifdef ASN_COMPILED dr.which = Z_DiagRec_defaultFormat; dr.u.defaultFormat = records->u.nonSurrogateDiagnostic; recv_diagrecs (&dr_p, 1); -#else - recv_diagrecs (&records->u.nonSurrogateDiagnostic, 1); -#endif break; case Z_Records_multipleNSD: recv_diagrecs (records->u.multipleNonSurDiagnostics->diagRecs, diff --git a/src/yaz-my-server.cpp b/src/yaz-my-server.cpp index 2c66628..70e9fb4 100644 --- a/src/yaz-my-server.cpp +++ b/src/yaz-my-server.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-my-server.cpp,v 1.20 2006-03-29 13:14:16 adam Exp $ + * $Id: yaz-my-server.cpp,v 1.21 2007-04-12 15:00:33 adam Exp $ */ #include @@ -12,6 +12,7 @@ #include #include #include +#include using namespace yazpp_1; @@ -131,8 +132,8 @@ void MyRetrieval::sr_record (const char *resultSetName, yaz_log (YLOG_LOG, "MyServer::recv_Z_record"); const char *rec = get_record(position); if (rec) - create_databaseRecord (odr_encode(), namePlusRecord, 0, - VAL_USMARC, rec, strlen(rec)); + create_databaseRecord(odr_encode(), namePlusRecord, 0, + OID_STR_USMARC, rec, strlen(rec)); else create_surrogateDiagnostics(odr_encode(), namePlusRecord, 0, YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, 0); diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index baab950..3bd680b 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 1998-2004, Index Data. + * Copyright (c) 1998-2007, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-assoc.cpp,v 1.40 2006-10-10 13:31:49 adam Exp $ + * $Id: yaz-z-assoc.cpp,v 1.41 2007-04-12 15:00:33 adam Exp $ */ #include @@ -11,6 +11,7 @@ #include #include #include +#include using namespace yazpp_1; @@ -375,34 +376,31 @@ void Z_Assoc::get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip) void Z_Assoc::set_otherInformationString ( Z_APDU *apdu, - int oidval, int categoryValue, + const char *oidname, int categoryValue, const char *str) { Z_OtherInformation **otherInformation; get_otherInfoAPDU(apdu, &otherInformation); if (!otherInformation) return; - set_otherInformationString(otherInformation, oidval, categoryValue, str); + set_otherInformationString(otherInformation, oidname, categoryValue, str); } void Z_Assoc::set_otherInformationString ( Z_OtherInformation **otherInformation, - int oidval, int categoryValue, + const char *oidname, int categoryValue, const char *str) { - int oid[OID_SIZE]; - struct oident ent; - ent.proto = PROTO_Z3950; - ent.oclass = CLASS_USERINFO; - ent.value = (oid_value) oidval; - if (!oid_ent_to_oid (&ent, oid)) + int *oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_USERINFO, oidname, + odr_encode()); + if (!oid) return ; set_otherInformationString(otherInformation, oid, categoryValue, str); } void Z_Assoc::set_otherInformationString ( Z_OtherInformation **otherInformation, - int *oid, int categoryValue, const char *str) + const int *oid, int categoryValue, const char *str) { Z_OtherInformationUnit *oi = update_otherInformation(otherInformation, 1, oid, categoryValue, 0); @@ -413,7 +411,7 @@ void Z_Assoc::set_otherInformationString ( Z_OtherInformationUnit *Z_Assoc::update_otherInformation ( Z_OtherInformation **otherInformationP, int createFlag, - int *oid, int categoryValue, int deleteFlag) + const int *oid, int categoryValue, int deleteFlag) { return yaz_oi_update (otherInformationP, (createFlag ? odr_encode() : 0), diff --git a/src/yaz-z-query.cpp b/src/yaz-z-query.cpp index 85d496a..d5be573 100644 --- a/src/yaz-z-query.cpp +++ b/src/yaz-z-query.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2007, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-query.cpp,v 1.21 2007-03-20 07:54:11 adam Exp $ + * $Id: yaz-z-query.cpp,v 1.22 2007-04-12 15:00:33 adam Exp $ */ #include @@ -63,7 +63,7 @@ int Yaz_Z_Query::set_rpn(const char *rpn) odr_reset(odr_encode); Z_Query *query = (Z_Query*) odr_malloc(odr_encode, sizeof(*query)); query->which = Z_Query_type_1; - query->u.type_1 = p_query_rpn(odr_encode, PROTO_Z3950, rpn); + query->u.type_1 = p_query_rpn(odr_encode, rpn); if (!query->u.type_1) return -1; if (!z_Query(odr_encode, &query, 0, 0)) diff --git a/src/yaz-z-server.cpp b/src/yaz-z-server.cpp index ea59a4c..efe0ed4 100644 --- a/src/yaz-z-server.cpp +++ b/src/yaz-z-server.cpp @@ -2,11 +2,12 @@ * Copyright (c) 2000-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-server.cpp,v 1.24 2006-03-29 13:14:18 adam Exp $ + * $Id: yaz-z-server.cpp,v 1.25 2007-04-12 15:00:33 adam Exp $ */ #include #include +#include using namespace yazpp_1; @@ -112,13 +113,15 @@ void Z_Server::recv_Z_PDU (Z_APDU *apdu_request, int len) * database record. */ void Z_ServerUtility::create_databaseRecord ( - ODR odr, Z_NamePlusRecord *rec, const char *dbname, int format, + ODR odr, Z_NamePlusRecord *rec, const char *dbname, const char *format, const void *buf, int len) { + int *oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN, format, + odr); rec->databaseName = dbname ? odr_strdup (odr, dbname) : 0; rec->which = Z_NamePlusRecord_databaseRecord; - rec->u.databaseRecord = z_ext_record (odr, format, - (const char *) buf, len); + rec->u.databaseRecord = z_ext_record_oid(odr, oid, + (const char *) buf, len); } /* @@ -141,7 +144,7 @@ void Z_ServerUtility::create_surrogateDiagnostics( drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = dr; dr->diagnosticSetId = - yaz_oidval_to_z3950oid (odr, CLASS_DIAGSET, VAL_BIB1); + yaz_string_to_oid_odr(yaz_oid_std(), CLASS_DIAGSET, OID_STR_BIB1, odr); dr->condition = err; dr->which = Z_DefaultDiagFormat_v2Addinfo; @@ -164,7 +167,7 @@ Z_Records *Z_ServerUtility::create_nonSurrogateDiagnostics ( rec->which = Z_Records_NSD; rec->u.nonSurrogateDiagnostic = dr; dr->diagnosticSetId = - yaz_oidval_to_z3950oid (odr, CLASS_DIAGSET, VAL_BIB1); + yaz_string_to_oid_odr(yaz_oid_std(), CLASS_DIAGSET, OID_STR_BIB1, odr); dr->condition = err; dr->which = Z_DefaultDiagFormat_v2Addinfo; @@ -187,7 +190,7 @@ void Z_ServerUtility::create_diagnostics ( drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = dr; dr->diagnosticSetId = - yaz_oidval_to_z3950oid (odr, CLASS_DIAGSET, VAL_BIB1); + yaz_string_to_oid_odr(yaz_oid_std(), CLASS_DIAGSET, OID_STR_BIB1, odr); dr->condition = odr_intdup (odr, error); dr->which = Z_DefaultDiagFormat_v2Addinfo; dr->u.v2Addinfo = odr_strdup (odr, addinfo ? addinfo : ""); diff --git a/zlint/test-search-01.cpp b/zlint/test-search-01.cpp index 7f3adab..816a838 100644 --- a/zlint/test-search-01.cpp +++ b/zlint/test-search-01.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2004, Index Data. + * Copyright (c) 2004-2007, Index Data. * See the file LICENSE for details. * - * $Id: test-search-01.cpp,v 1.6 2005-08-11 18:53:01 adam Exp $ + * $Id: test-search-01.cpp,v 1.7 2007-04-12 15:00:33 adam Exp $ */ #include @@ -10,6 +10,7 @@ #include #include +#include static const char *try_query[] = { "@attr 1=4 petersson", @@ -131,8 +132,9 @@ Zlint_code Zlint_test_search_01::sendTest(Zlint *z) z->msg_check_for("record syntax %s", try_syntax[m_record_syntax_no]); pr->preferredRecordSyntax = - yaz_str_to_z3950oid(z->odr_encode(), CLASS_RECSYN, - try_syntax[m_record_syntax_no]); + yaz_string_to_oid_odr(yaz_oid_std(), + CLASS_RECSYN, try_syntax[m_record_syntax_no], + z->odr_encode()); z->send_Z_PDU(apdu, &len); return TEST_CONTINUE; } @@ -221,8 +223,9 @@ Zlint_code Zlint_test_search_01::recv_gdu(Zlint *z, Z_GDU *gdu) { Z_External *ext = sr->records->u.databaseOrSurDiagnostics->records[0]->u.databaseRecord; Odr_oid *expectRecordSyntax = - yaz_str_to_z3950oid(z->odr_decode(), CLASS_RECSYN, - try_syntax[m_record_syntax_no]); + yaz_string_to_oid_odr( + yaz_oid_std(), CLASS_RECSYN, + try_syntax[m_record_syntax_no], z->odr_decode()); if (oid_oidcmp(expectRecordSyntax, ext->direct_reference)) {