X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fgduutil.cpp;h=b39fd28ae87afd60b894c5367b6136224d72ea38;hb=586d78659d671683f33ec55f4a7d32b28e345ccd;hp=c2ebef799dd8221bbe11df0916c6c9e20784b4e6;hpb=64671485649150d7793c1f303950a08eeb959323;p=metaproxy-moved-to-github.git diff --git a/src/gduutil.cpp b/src/gduutil.cpp index c2ebef7..b39fd28 100644 --- a/src/gduutil.cpp +++ b/src/gduutil.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2012 Index Data + Copyright (C) Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -58,14 +58,14 @@ std::ostream& std::operator<<(std::ostream& os, Z_GDU& zgdu) std::ostream& std::operator<<(std::ostream& os, Z_HTTP_Request& httpreq) { os << httpreq.method << " "; - os << httpreq.path; + os << httpreq.path; return os; } std::ostream& std::operator<<(std::ostream& os, Z_HTTP_Response& httpres) { os << httpres.code << " "; - os << httpres.content_len; + os << httpres.content_len; return os; } @@ -80,16 +80,29 @@ std::ostream& std::operator<<(std::ostream& os, Z_Records & rs) os << *(rs.u.nonSurrogateDiagnostic); break; case Z_Records_multipleNSD: - os << "Z_Records_multipleNSD"; - //os << *(rs.u.multipleNonSurDiagnostics); + os << *(rs.u.multipleNonSurDiagnostics); break; default: os << "Z_Records" ; } - + return os; } +std::ostream& std::operator<<(std::ostream& os, Z_DiagRecs& dr) +{ + if (dr.num_diagRecs >= 1) + { + os << *dr.diagRecs[0]; + } + else + { + os << "multipleNSD"; + } + return os; +} + + std::ostream& std::operator<<(std::ostream& os, Z_DiagRec& dr) { switch (dr.which) @@ -104,7 +117,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_DiagRec& dr) default: os << "Z_DiagRec" ; } - + return os; } @@ -128,7 +141,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_DefaultDiagFormat& ddf) default: os << "-"; } - + return os; } @@ -161,9 +174,9 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) case Z_APDU_initRequest: os << " " << "initRequest"; - + { - Z_InitRequest *ir + Z_InitRequest *ir = zapdu.u.initRequest; Z_IdAuthentication *a = ir->idAuthentication; @@ -173,17 +186,17 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) dump_opt_string(os, a->u.open); else dump_opt_string(os, 0); - + os << " "; std::list vhosts; mp::util::get_vhost_otherinfo(ir->otherInfo, vhosts); if (vhosts.size()){ - copy(vhosts.begin(), vhosts.end(), + copy(vhosts.begin(), vhosts.end(), ostream_iterator(os, " ")); } else os << "-" ; - + dump_opt_string(os, ir->implementationId); dump_opt_string(os, ir->implementationName); dump_opt_string(os, ir->implementationVersion); @@ -192,7 +205,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) case Z_APDU_initResponse: os << " " << "initResponse "; { - Z_InitResponse *ir + Z_InitResponse *ir = zapdu.u.initResponse; if (ir->result && *(ir->result)) { @@ -209,10 +222,10 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) break; case Z_APDU_searchRequest: os << " " << "searchRequest" << " "; - { - Z_SearchRequest *sr + { + Z_SearchRequest *sr = zapdu.u.searchRequest; - + for (int i = 0; i < sr->num_databaseNames; i++) { os << sr->databaseNames[i]; @@ -272,7 +285,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) 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 @@ -286,7 +299,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) case Z_APDU_presentResponse: os << " " << "presentResponse" << " "; { - Z_PresentResponse *pr + Z_PresentResponse *pr = zapdu.u.presentResponse; if (!pr->presentStatus) os << "Unknown"; @@ -348,9 +361,9 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) break; case Z_APDU_scanRequest: os << " " << "scanRequest" << " "; - { + { Z_ScanRequest *sr = zapdu.u.scanRequest; - + if (sr) { for (int i = 0; i < sr->num_databaseNames; i++) @@ -367,7 +380,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) if (sr->termListAndStartPoint) { mp::wrbuf wr; - yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint, + yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint, sr->attributeSet); os << wrbuf_cstr(wr); } @@ -430,8 +443,8 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) break; case Z_APDU_extendedServicesRequest: os << " " << "extendedServicesRequest"; - { - Z_ExtendedServicesRequest *er + { + Z_ExtendedServicesRequest *er = zapdu.u.extendedServicesRequest; if (er) { @@ -455,18 +468,18 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) } else os << " -"; - - + + if (er->userId) os << " " << er->userId ; else os << " -"; - + if (er->packageName) os << " " << er->packageName; else os << " -"; - + if (er->description) os << " " << er->description; else @@ -476,8 +489,8 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) break; case Z_APDU_extendedServicesResponse: os << " " << "extendedServicesResponse"; - { - Z_ExtendedServicesResponse *er + { + Z_ExtendedServicesResponse *er = zapdu.u.extendedServicesResponse; if (er) { @@ -509,7 +522,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) break; case Z_APDU_close: os << " " << "close" << " "; - { + { Z_Close *c = zapdu.u.close; if (c) { @@ -553,7 +566,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) os << "unknown"; } } - + if (c->diagnosticInformation) os << " " << c->diagnosticInformation; } @@ -565,7 +578,7 @@ std::ostream& std::operator<<(std::ostream& os, Z_APDU& zapdu) case Z_APDU_duplicateDetectionResponse: os << " " << "duplicateDetectionResponse"; break; - default: + default: os << " " << "Z_APDU " << "UNKNOWN"; }