X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fgduutil.cpp;h=eb7e18c51907cb5b5b5ca8b0fb1b76798d0d7c2f;hb=2f8cb1e1bda27debbd84f233453d33c8ff0700fc;hp=373918ffdcbcf6563e743421b34256c4473403e3;hpb=a1c8801960987ba4255f15a6fb1fdcb0a126e8f6;p=metaproxy-moved-to-github.git diff --git a/src/gduutil.cpp b/src/gduutil.cpp index 373918f..eb7e18c 100644 --- a/src/gduutil.cpp +++ b/src/gduutil.cpp @@ -1,5 +1,5 @@ -/* $Id: gduutil.cpp,v 1.13 2006-09-26 13:15:33 marc Exp $ - Copyright (c) 2005-2006, Index Data. +/* $Id: gduutil.cpp,v 1.19 2007-04-10 11:28:51 marc Exp $ + Copyright (c) 2005-2007, Index Data. See the LICENSE file for details */ @@ -16,7 +16,10 @@ namespace mp = metaproxy_1; // Doxygen doesn't like mp::gdu, so we use this instead -namespace mp_gdu = metaproxy_1::gdu; +namespace mp_util = metaproxy_1::util; + + + std::ostream& std::operator<<(std::ostream& os, Z_GDU& zgdu) { @@ -126,7 +129,8 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) = zapdu.u.initRequest; Z_IdAuthentication *a = ir->idAuthentication; - if (a && a->which == Z_IdAuthentication_idPass ) + if (a && a->which == Z_IdAuthentication_idPass + && a->u.idPass->userId) os << a->u.idPass->userId << " "; //<< ":" << a->u.idPass->groupId << " "; else @@ -141,10 +145,13 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) else os << "-" << " " ; - os << (ir->implementationId) << " " - //<< ir->referenceId << " " - << (ir->implementationName) << " " - << (ir->implementationVersion); + if (ir->implementationId) + os << (ir->implementationId) << " "; + //<< ir->referenceId << " " + if (ir->implementationName) + os<< (ir->implementationName) << " "; + if (ir->implementationVersion) + os << (ir->implementationVersion) << " "; } break; case Z_APDU_initResponse: @@ -152,12 +159,16 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) { Z_InitResponse *ir = zapdu.u.initResponse; - if (ir->result && *(ir->result)) - os << "OK" << " " - << (ir->implementationId) << " " + if (ir->result && *(ir->result)){ + os << "OK" << " "; + if (ir->implementationId) + os << (ir->implementationId) << " "; //<< ir->referenceId << " " - << (ir->implementationName) << " " - << (ir->implementationVersion) << " "; + if (ir->implementationName) + os<< (ir->implementationName) << " "; + if (ir->implementationVersion) + os << (ir->implementationVersion) << " "; + } else os << "DIAG"; } @@ -179,8 +190,8 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) WRBUF wr = wrbuf_alloc(); yaz_query_to_wrbuf(wr, sr->query); - os << wrbuf_buf(wr); - wrbuf_free(wr, 1); + os << wrbuf_cstr(wr); + wrbuf_destroy(wr); } break; case Z_APDU_searchResponse: @@ -229,15 +240,17 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) os << " " << *(pr->numberOfRecordsRequested); else os << " -"; - //if (pr->preferredRecordSyntax) - // os << " " << *(pr->preferredRecordSyntax); - //else - // os << " -"; - //elements - //if (pr->) - // os << " " << *(pr->); - //else - // os << " -"; + if (pr->preferredRecordSyntax) + //os << " " << pr->preferredRecordSyntax; + os << " " <<(oid_getentbyoid(pr->preferredRecordSyntax))->desc; + else + os << " -"; + const char * msg = 0; + if (pr->recordComposition + && (msg = mp_util::record_composition_to_esn(pr->recordComposition))) + os << " " << msg; + else + os << " -"; } break; case Z_APDU_presentResponse: @@ -331,8 +344,8 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) { WRBUF wr = wrbuf_alloc(); yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint, VAL_NONE); - os << wrbuf_buf(wr); - wrbuf_free(wr, 1); + os << wrbuf_cstr(wr); + wrbuf_destroy(wr); } else os << " -";