X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=8360dbe9b31a998d84b6a59a562ccee52140d82c;hb=3109185a2036377894be1dd303d899a305b44281;hp=59ccc362e28a0ca1369187feca1db9825ac4d237;hpb=c6e5ad789740135af3558298f6e2014ae99ee7dd;p=yazpp-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 59ccc36..8360dbe 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-proxy.cpp,v $ - * Revision 1.3 1999-04-09 11:46:57 adam + * Revision 1.4 1999-04-20 10:30:05 adam + * Implemented various stuff for client and proxy. Updated calls + * to ODR to reflect new name parameter. + * + * Revision 1.3 1999/04/09 11:46:57 adam * Added object Yaz_Z_Assoc. Much more functional client. * * Revision 1.2 1999/01/28 13:08:46 adam @@ -26,7 +30,6 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable) : Yaz_Z_Assoc(the_PDU_Observable) { m_PDU_Observable = the_PDU_Observable; - m_maps = 0; m_client = 0; } @@ -40,6 +43,36 @@ IYaz_PDU_Observer *Yaz_Proxy::clone(IYaz_PDU_Observable return new Yaz_Proxy(the_PDU_Observable); } +char *Yaz_Proxy::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) && + (oi = update_otherInformation(otherInfo, 0, oid, 1)) && + oi->which == Z_OtherInfo_characterInfo) + return oi->information.characterInfo; + return 0; +} + +char *Yaz_Proxy::get_proxy(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_PROXY; + if (oid_ent_to_oid (&ent, oid) && + (oi = update_otherInformation(otherInfo, 0, oid, 1)) && + oi->which == Z_OtherInfo_characterInfo) + return oi->information.characterInfo; + return 0; +} + void Yaz_Proxy::recv_Z_PDU(Z_APDU *apdu) { if (apdu->which == Z_APDU_initRequest) @@ -48,7 +81,12 @@ void Yaz_Proxy::recv_Z_PDU(Z_APDU *apdu) logf (LOG_LOG, "got InitRequest"); m_client = new Yaz_ProxyClient(m_PDU_Observable->clone()); m_client->m_server = this; - m_client->client("localhost:8888"); + + char *proxy_host = get_cookie(&apdu->u.initRequest->otherInfo); + if (proxy_host) + m_client->client(proxy_host); + else + m_client->client("localhost:8888"); } assert (m_client); logf (LOG_LOG, "sending PDU"); @@ -78,7 +116,8 @@ IYaz_PDU_Observer *Yaz_ProxyClient::clone(IYaz_PDU_Observable Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable) : Yaz_Z_Assoc (the_PDU_Observable) { - + m_cookie = 0; + m_next = 0; } void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu)