From 1063240efa2d4f03a72353936e8a7b73ee249b0d Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 10 May 2000 11:36:58 +0000 Subject: [PATCH] Added default parameters for refid to request functions. Added default parameter for result set name to search and present request. Commented out forced logging of PDU contents. Added send_deleteResultSetRequest --- include/yaz-ir-assoc.h | 10 +++--- include/yaz-z-assoc.h | 5 ++- src/yaz-ir-assoc.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++--- src/yaz-z-assoc.cpp | 26 +++++++++++++-- src/yaz-z-query.cpp | 10 ++++-- 5 files changed, 119 insertions(+), 14 deletions(-) diff --git a/include/yaz-ir-assoc.h b/include/yaz-ir-assoc.h index c1fd26d..a939e34 100644 --- a/include/yaz-ir-assoc.h +++ b/include/yaz-ir-assoc.h @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-ir-assoc.h,v 1.8 1999-12-06 13:52:45 adam Exp $ + * $Id: yaz-ir-assoc.h,v 1.9 2000-05-10 11:36:58 ian Exp $ */ #include @@ -54,9 +54,11 @@ class YAZ_EXPORT Yaz_IR_Assoc: public Yaz_Z_Assoc { const char *get_cookie(); /// Send Services - int send_initRequest(); - int send_searchRequest(Yaz_Z_Query *query); - int send_presentRequest(int start, int number); + int send_initRequest(char* pRefId=NULL); + int send_searchRequest(Yaz_Z_Query *query, char* pResultSetId = NULL, char* pRefId = NULL); + int send_presentRequest(int start, int number, char* pResultSetId = NULL, char* pRefId = NULL); + int send_deleteResultSetRequest(char* pResultSetId = NULL, char* pRefId = NULL); + /// Recv Services virtual void recv_initRequest(Z_InitRequest *initRequest); virtual void recv_initResponse(Z_InitResponse *initResponse); diff --git a/include/yaz-z-assoc.h b/include/yaz-z-assoc.h index d4d67eb..4a47d68 100644 --- a/include/yaz-z-assoc.h +++ b/include/yaz-z-assoc.h @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-z-assoc.h,v 1.5 1999-12-06 13:52:45 adam Exp $ + * $Id: yaz-z-assoc.h,v 1.6 2000-05-10 11:36:58 ian Exp $ */ #include @@ -69,6 +69,9 @@ class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer { int oidval, int categoryValue, const char *str); void set_apdu_log(const char *file); + + Z_ReferenceId* getRefID(char* str); + private: static int yaz_init_flag; static int yaz_init_func(); diff --git a/src/yaz-ir-assoc.cpp b/src/yaz-ir-assoc.cpp index 358a616..1148c50 100644 --- a/src/yaz-ir-assoc.cpp +++ b/src/yaz-ir-assoc.cpp @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ir-assoc.cpp,v $ - * Revision 1.11 1999-12-06 13:52:45 adam + * Revision 1.12 2000-05-10 11:36:58 ian + * Added default parameters for refid to request functions. + * Added default parameter for result set name to search and present request. + * Commented out forced logging of PDU contents. + * Added send_deleteResultSetRequest + * + * Revision 1.11 1999/12/06 13:52:45 adam * Modified for new location of YAZ header files. Experimental threaded * operation. * @@ -205,7 +211,9 @@ void Yaz_IR_Assoc::recv_Z_PDU(Z_APDU *apdu) } } -int Yaz_IR_Assoc::send_searchRequest(Yaz_Z_Query *query) +int Yaz_IR_Assoc::send_searchRequest(Yaz_Z_Query *query, + char* pResultSetId, + char* pRefId) { Z_APDU *apdu = create_Z_PDU(Z_APDU_searchRequest); Z_SearchRequest *req = apdu->u.searchRequest; @@ -233,10 +241,24 @@ int Yaz_IR_Assoc::send_searchRequest(Yaz_Z_Query *query) set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); assert (req->otherInfo); } + + if ( pRefId ) + { + req->referenceId = getRefID(pRefId); + } + + if ( pResultSetId ) + { + req->resultSetName = pResultSetId; + } + return send_Z_PDU(apdu); } -int Yaz_IR_Assoc::send_presentRequest(int start, int number) +int Yaz_IR_Assoc::send_presentRequest(int start, + int number, + char* pResultSetId, + char* pRefId) { Z_APDU *apdu = create_Z_PDU(Z_APDU_presentRequest); Z_PresentRequest *req = apdu->u.presentRequest; @@ -265,8 +287,20 @@ int Yaz_IR_Assoc::send_presentRequest(int start, int number) compo.which = Z_RecordComp_simple; compo.u.simple = elementSetNames; } + if (m_cookie) set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); + + if ( pRefId ) + { + req->referenceId = getRefID(pRefId); + } + + if ( pResultSetId ) + { + req->resultSetId = pResultSetId; + } + return send_Z_PDU(apdu); } @@ -358,7 +392,7 @@ void Yaz_IR_Assoc::set_lastReceived(int lastReceived) m_lastReceived = lastReceived; } -int Yaz_IR_Assoc::send_initRequest() +int Yaz_IR_Assoc::send_initRequest(char* pRefId) { Z_APDU *apdu = create_Z_PDU(Z_APDU_initRequest); Z_InitRequest *req = apdu->u.initRequest; @@ -376,6 +410,11 @@ int Yaz_IR_Assoc::send_initRequest() ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3); + if ( pRefId ) + { + req->referenceId = getRefID(pRefId); + } + if (m_proxy && m_host) set_otherInformationString(&req->otherInfo, VAL_PROXY, 1, m_host); if (m_cookie) @@ -383,3 +422,38 @@ int Yaz_IR_Assoc::send_initRequest() return send_Z_PDU(apdu); } +int Yaz_IR_Assoc::send_deleteResultSetRequest(char* pResultSetId = NULL, char* pRefId = NULL) +{ + char* ResultSetIds[1]; + + Z_APDU *apdu = create_Z_PDU(Z_APDU_deleteResultSetRequest); + Z_DeleteResultSetRequest *req = apdu->u.deleteResultSetRequest; + + + if ( pResultSetId ) + { + *req->deleteFunction = Z_DeleteResultSetRequest_list; + req->num_resultSetList = 1; + ResultSetIds[0] = pResultSetId; + req->resultSetList = ResultSetIds; + } + else + { + *req->deleteFunction = Z_DeleteResultSetRequest_all; + } + + if ( pRefId ) + { + req->referenceId = getRefID(pRefId); + } + + if (m_proxy && m_host) + set_otherInformationString(&req->otherInfo, VAL_PROXY, 1, m_host); + if (m_cookie) + set_otherInformationString(&req->otherInfo, VAL_COOKIE, 1, m_cookie); + + + return send_Z_PDU(apdu); +} + + diff --git a/src/yaz-z-assoc.cpp b/src/yaz-z-assoc.cpp index 8d46e5a..198a3f3 100644 --- a/src/yaz-z-assoc.cpp +++ b/src/yaz-z-assoc.cpp @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-z-assoc.cpp,v $ - * Revision 1.6 1999-12-06 13:52:45 adam + * Revision 1.7 2000-05-10 11:36:58 ian + * Added default parameters for refid to request functions. + * Added default parameter for result set name to search and present request. + * Commented out forced logging of PDU contents. + * Added send_deleteResultSetRequest + * + * Revision 1.6 1999/12/06 13:52:45 adam * Modified for new location of YAZ header files. Experimental threaded * operation. * @@ -111,7 +117,7 @@ Z_APDU *Yaz_Z_Assoc::decode_Z_PDU(const char *buf, int len) } else { - z_APDU(m_odr_print, &apdu, 0, "decode"); + // z_APDU(m_odr_print, &apdu, 0, "decode"); return apdu; } } @@ -123,7 +129,7 @@ int Yaz_Z_Assoc::encode_Z_PDU(Z_APDU *apdu, char **buf, int *len) logf (LOG_LOG, "yaz_Z_Assoc::encode_Z_PDU failed"); return -1; } - z_APDU(m_odr_print, &apdu, 0, "encode"); + // z_APDU(m_odr_print, &apdu, 0, "encode"); *buf = odr_getbuf (m_odr_out, len, 0); odr_reset (m_odr_out); return *len; @@ -251,3 +257,17 @@ Z_OtherInformationUnit *Yaz_Z_Assoc::update_otherInformation ( oid, categoryValue, deleteFlag); } +Z_ReferenceId* Yaz_Z_Assoc::getRefID(char* str) +{ + Z_ReferenceId* id = NULL; + + if ( str ) + { + id = (Z_ReferenceId*) odr_malloc (m_odr_out, sizeof(*id)); + id->size = id->len = strlen(str); + id->buf = (unsigned char *) str; + } + + return id; +} + diff --git a/src/yaz-z-query.cpp b/src/yaz-z-query.cpp index c06246f..e6c84f5 100644 --- a/src/yaz-z-query.cpp +++ b/src/yaz-z-query.cpp @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-z-query.cpp,v $ - * Revision 1.6 1999-12-06 13:52:45 adam + * Revision 1.7 2000-05-10 11:36:58 ian + * Added default parameters for refid to request functions. + * Added default parameter for result set name to search and present request. + * Commented out forced logging of PDU contents. + * Added send_deleteResultSetRequest + * + * Revision 1.6 1999/12/06 13:52:45 adam * Modified for new location of YAZ header files. Experimental threaded * operation. * @@ -48,7 +54,7 @@ int Yaz_Z_Query::set_rpn (const char *rpn) return -1; if (!z_Query (odr_encode, &query, 0, 0)) return -1; - z_Query(odr_print, &query, 0, 0); + // z_Query(odr_print, &query, 0, 0); buf = odr_getbuf (odr_encode, &len, 0); return len; } -- 1.7.10.4