-/* $Id: gduutil.cpp,v 1.1 2006-08-29 10:06:31 marc Exp $
+/* $Id: gduutil.cpp,v 1.2 2006-08-30 08:35:47 marc Exp $
Copyright (c) 2005-2006, Index Data.
See the LICENSE file for details
- */
+*/
#include "gduutil.hpp"
switch(zapdu.which) {
case Z_APDU_initRequest:
- os << "initRequest" << " "
- << "OK" << " ";
+ os << "initRequest" << " ";
{
Z_InitRequest *ir
= zapdu.u.initRequest;
- os
- << (ir->implementationId) << " "
+
+ Z_IdAuthentication *a = ir->idAuthentication;
+ if (a && a->which == Z_IdAuthentication_idPass )
+ os << a->u.idPass->userId
+ << ":" << a->u.idPass->groupId << " ";
+ else
+ os << "-:-" << " ";
+
+
+ os << (ir->implementationId) << " "
//<< ir->referenceId << " "
- << (ir->implementationName) << " "
- << (ir->implementationVersion) << " ";
+ << (ir->implementationName) << " "
+ << (ir->implementationVersion) << " ";
+ }
+ break;
+ case Z_APDU_initResponse:
+ os << "initResponse" << " ";
+ {
+ Z_InitResponse *ir
+ = zapdu.u.initResponse;
+ if (*(ir->result))
+ os << "OK" << " "
+ << (ir->implementationId) << " "
+ //<< ir->referenceId << " "
+ << (ir->implementationName) << " "
+ << (ir->implementationVersion) << " ";
+ else
+ os << "DIAG" << " ";
}
break;
- case Z_APDU_initResponse:
- os<< "initResponse" << " ";
- {
- Z_InitResponse *ir
- = zapdu.u.initResponse;
- if (*(ir->result))
- os
- << "OK" << " "
- << (ir->implementationId) << " "
- //<< ir->referenceId << " "
- << (ir->implementationName) << " "
- << (ir->implementationVersion) << " ";
- else
- os
- << "ERROR" << " "
- << "- - -" << " ";
-
- }
- break;
case Z_APDU_searchRequest:
os << "searchRequest" << " "
- << "OK" << " ";
+ << "--" << " ";
{
Z_SearchRequest *sr
= zapdu.u.searchRequest;
{
os << sr->databaseNames[i];
if (i+1 == sr->num_databaseNames)
- os<< " ";
+ os << " ";
else
- os<< "+";
+ os << "+";
}
WRBUF wr = wrbuf_alloc();
wrbuf_free(wr, 1);
}
break;
- case Z_APDU_searchResponse:
- os<< "searchResponse" << " ";
- {
- Z_SearchResponse *sr
- = zapdu.u.searchResponse;
- if (*(sr->searchStatus))
- os
- << "OK" << " "
- << *(sr->resultCount) << " "
- //<< sr->referenceId << " "
- << *(sr->numberOfRecordsReturned) << " "
- << *(sr->nextResultSetPosition) << " ";
- else
- os
- << "ERROR" << " "
- << "- - -" << " ";
-
- }
- //os<< wrbuf_buf(wr) << " ";
- break;
+ case Z_APDU_searchResponse:
+ os << "searchResponse" << " ";
+ {
+ Z_SearchResponse *sr
+ = zapdu.u.searchResponse;
+ if (*(sr->searchStatus))
+ os << "OK" << " "
+ << *(sr->resultCount) << " "
+ //<< sr->referenceId << " "
+ << *(sr->numberOfRecordsReturned) << " "
+ << *(sr->nextResultSetPosition) << " ";
+ else
+ os << "DIAG" << " ";
+ }
+ break;
case Z_APDU_presentRequest:
os << "presentRequest" << " "
- << "OK" << " ";
+ << "--" << " ";
{
Z_PresentRequest *pr = zapdu.u.presentRequest;
os << pr->resultSetId << " "
<< *(pr->numberOfRecordsRequested) << " ";
}
break;
- case Z_APDU_presentResponse:
- os<< "presentResponse" << " ";
- {
- Z_PresentResponse *pr
- = zapdu.u.presentResponse;
- if (!*(pr->presentStatus))
- os
- << "OK" << " "
- << "-" << " "
- //<< pr->referenceId << " "
- << *(pr->numberOfRecordsReturned) << " "
- << *(pr->nextResultSetPosition) << " ";
- else
- os
- << "ERROR" << " "
- << "-" << " "
- //<< pr->referenceId << " "
- << *(pr->numberOfRecordsReturned) << " "
- << *(pr->nextResultSetPosition) << " ";
- //<< "- - -" << " ";
- }
- break;
+ case Z_APDU_presentResponse:
+ os << "presentResponse" << " ";
+ {
+ Z_PresentResponse *pr
+ = zapdu.u.presentResponse;
+ if (!*(pr->presentStatus))
+ os << "OK" << " "
+ << "-" << " "
+ //<< pr->referenceId << " "
+ << *(pr->numberOfRecordsReturned) << " "
+ << *(pr->nextResultSetPosition) << " ";
+ else
+ os << "DIAG" << " "
+ << "-" << " "
+ //<< pr->referenceId << " "
+ << *(pr->numberOfRecordsReturned) << " "
+ << *(pr->nextResultSetPosition) << " ";
+ }
+ break;
case Z_APDU_deleteResultSetRequest:
- os << "deleteResultSetRequest" << " "
- << "OK" << " ";
+ os << "deleteResultSetRequest" << " ";
+ break;
+ case Z_APDU_deleteResultSetResponse:
+ os << "deleteResultSetResponse" << " ";
break;
- case Z_APDU_deleteResultSetResponse:
- os << "deleteResultSetResponse" << " ";
- break;
case Z_APDU_accessControlRequest:
- os << "accessControlRequest" << " "
- << "OK" << " ";
- break;
- case Z_APDU_accessControlResponse:
- os << "accessControlResponse" << " ";
- break;
- case Z_APDU_resourceControlRequest:
- os << "resourceControlRequest" << " "
- << "OK" << " ";
- break;
- case Z_APDU_resourceControlResponse:
- os << "resourceControlResponse" << " ";
- break;
+ os << "accessControlRequest" << " ";
+ break;
+ case Z_APDU_accessControlResponse:
+ os << "accessControlResponse" << " ";
+ break;
+ case Z_APDU_resourceControlRequest:
+ os << "resourceControlRequest" << " ";
+ break;
+ case Z_APDU_resourceControlResponse:
+ os << "resourceControlResponse" << " ";
+ break;
case Z_APDU_triggerResourceControlRequest:
- os << "triggerResourceControlRequest" << " "
- << "OK" << " ";
+ os << "triggerResourceControlRequest" << " ";
break;
case Z_APDU_resourceReportRequest:
- os << "resourceReportRequest" << " "
- << "OK" << " ";
+ os << "resourceReportRequest" << " ";
break;
- case Z_APDU_resourceReportResponse:
- os << "resourceReportResponse" << " ";
- break;
- case Z_APDU_scanRequest:
+ case Z_APDU_resourceReportResponse:
+ os << "resourceReportResponse" << " ";
+ break;
+ case Z_APDU_scanRequest:
os << "scanRequest" << " "
- << "OK" << " ";
+ << "--" << " ";
+ {
+ Z_ScanRequest *sr
+ = zapdu.u.scanRequest;
+
+ for (int i = 0; i < sr->num_databaseNames; i++)
+ {
+ os << sr->databaseNames[i];
+ if (i+1 == sr->num_databaseNames)
+ os << " ";
+ else
+ os << "+";
+ }
+
+ os << *(sr->numberOfTermsRequested) << " "
+ << *(sr->preferredPositionInResponse) << " "
+ << *(sr->stepSize) << " ";
+
+ WRBUF wr = wrbuf_alloc();
+ yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint, VAL_NONE);
+ os << wrbuf_buf(wr) << " ";
+ wrbuf_free(wr, 1);
+ }
+ break;
+ case Z_APDU_scanResponse:
+ os << "scanResponse" << " ";
+ {
+ Z_ScanResponse *sr
+ = zapdu.u.scanResponse;
+ if (*(sr->scanStatus))
+ os << "OK" << " "
+ << *(sr->scanStatus) << " "
+ << *(sr->numberOfEntriesReturned) << " "
+ //<< sr->referenceId << " "
+ << *(sr->positionOfTerm) << " "
+ << *(sr->stepSize) << " ";
+ else
+ os << "DIAG" << " "
+ << *(sr->scanStatus) << " "
+ << *(sr->numberOfEntriesReturned) << " "
+ //<< sr->referenceId << " "
+ << *(sr->positionOfTerm) << " "
+ << *(sr->stepSize) << " ";
+ }
break;
- case Z_APDU_scanResponse:
- os << "scanResponse" << " ";
- break;
case Z_APDU_sortRequest:
- os << "sortRequest" << " "
- << "OK" << " ";
+ os << "sortRequest" << " ";
+ break;
+ case Z_APDU_sortResponse:
+ os << "sortResponse" << " ";
break;
- case Z_APDU_sortResponse:
- os << "sortResponse" << " ";
- break;
case Z_APDU_segmentRequest:
- os << "segmentRequest" << " "
- << "OK" << " ";
+ os << "segmentRequest" << " ";
break;
case Z_APDU_extendedServicesRequest:
- os << "extendedServicesRequest" << " "
- << "OK" << " ";
+ os << "extendedServicesRequest" << " ";
+// {
+// Z_ExtendedServicesRequest *er
+// = zapdu.u.extendedServicesRequest;
+
+// os << er->packageName << " "
+// << er->userId << " "
+// << er->description << " ";
+// }
+ break;
+ case Z_APDU_extendedServicesResponse:
+ os << "extendedServicesResponse" << " ";
+// {
+// Z_ExtendedServicesResponse *er
+// = zapdu.u.extendedServicesResponse;
+
+// os << *(er->operationStatus) << " "
+// << er->num_diagnostics << " ";
+// }
break;
- case Z_APDU_extendedServicesResponse:
- os << "extendedServicesResponse" << " ";
- break;
case Z_APDU_close:
- os << "close" << " "
- << "OK" << " ";
+ os << "close" << " ";
+ {
+ Z_Close *c
+ = zapdu.u.close;
+
+ os << *(c->closeReason) << " ";
+ switch (*(c->closeReason)) {
+ case Z_Close_finished:
+ os << "finished" << " ";
+ break;
+ case Z_Close_shutdown:
+ os << "shutdown" << " ";
+ break;
+ case Z_Close_systemProblem:
+ os << "systemProblem" << " ";
+ break;
+ case Z_Close_costLimit:
+ os << "costLimit" << " ";
+ break;
+ case Z_Close_resources:
+ os << "resources" << " ";
+ break;
+ case Z_Close_securityViolation:
+ os << "securityViolation" << " ";
+ break;
+ case Z_Close_protocolError:
+ os << "protocolError" << " ";
+ break;
+ case Z_Close_lackOfActivity:
+ os << "" << " ";
+ break;
+ case Z_Close_peerAbort:
+ os << "peerAbort" << " ";
+ break;
+ case Z_Close_unspecified:
+ os << "unspecified" << " ";
+ break;
+ default:
+ os << "unknown" << " ";
+ break;
+ }
+ }
break;
case Z_APDU_duplicateDetectionRequest:
- os << "duplicateDetectionRequest" << " "
- << "OK" << " ";
+ os << "duplicateDetectionRequest" << " ";
+ break;
+ case Z_APDU_duplicateDetectionResponse:
+ os << "duplicateDetectionResponse" << " ";
break;
- case Z_APDU_duplicateDetectionResponse:
- os << "duplicateDetectionResponse" << " ";
- break;
- default:
+ default:
os << "Z_APDU "
<< "UNKNOWN" << " ";
}