-/* $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.21 2007-05-09 21:23:09 adam Exp $
+ Copyright (c) 2005-2007, Index Data.
- See the LICENSE file for details
-*/
+This file is part of Metaproxy.
+
+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
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Metaproxy; see the file LICENSE. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
#include "gduutil.hpp"
#include "util.hpp"
#include <yaz/wrbuf.h>
+#include <yaz/oid_db.h>
#include <yaz/querytowrbuf.h>
#include <iostream>
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)
{
= 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
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:
{
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";
}
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:
os << " " << *(pr->numberOfRecordsRequested);
else
os << " -";
- //if (pr->preferredRecordSyntax)
- // os << " " << *(pr->preferredRecordSyntax);
- //else
- // os << " -";
- //elements
- //if (pr->)
- // os << " " << *(pr->);
- //else
- // os << " -";
+ if (pr->preferredRecordSyntax)
+ {
+ 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
+ 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:
if (sr->termListAndStartPoint)
{
WRBUF wr = wrbuf_alloc();
- yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint, VAL_NONE);
- os << wrbuf_buf(wr);
- wrbuf_free(wr, 1);
+ yaz_scan_to_wrbuf(wr, sr->termListAndStartPoint,
+ sr->attributeSet);
+ os << wrbuf_cstr(wr);
+ wrbuf_destroy(wr);
}
else
os << " -";