-/*
- * Copyright (c) 1998-2007, Index Data.
+/* This file is part of the yazpp toolkit.
+ * Copyright (C) 1998-2012 Index Data and Mike Taylor
* See the file LICENSE for details.
- *
- * $Id: yaz-z-assoc.cpp,v 1.41 2007-04-12 15:00:33 adam Exp $
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <assert.h>
#include <signal.h>
return 1;
}
-int Z_Assoc::yaz_init_flag = Z_Assoc::yaz_init_func();
+int Z_Assoc::yaz_init_flag = Z_Assoc::yaz_init_func();
Z_Assoc::Z_Assoc(IPDU_Observable *the_PDU_Observable)
{
delete [] m_APDU_fname;
m_APDU_fname = 0;
- if (fname)
+ if (fname)
{
m_APDU_fname = new char[strlen(fname)+1];
strcpy (m_APDU_fname, fname);
Z_Assoc::~Z_Assoc()
{
- m_PDU_Observable->destroy();
+ m_PDU_Observable->destroy();
delete m_PDU_Observable;
odr_destroy (m_odr_print); // note: also runs fclose on m_APDU_file ..
odr_destroy (m_odr_out);
}
else
{
- close();
+ m_PDU_Observable->shutdown();
failNotify();
}
}
switch (apdu->which)
{
case Z_APDU_initRequest:
- return &apdu->u.initRequest->referenceId;
+ return &apdu->u.initRequest->referenceId;
case Z_APDU_initResponse:
return &apdu->u.initResponse->referenceId;
case Z_APDU_searchRequest:
yaz_log(YLOG_LOG, "PDU decode failed '%s' near byte %ld. Element %s",
odr_errmsg(odr_geterror(m_odr_in)),
(long) odr_offset(m_odr_in),
- element ? element : "unknown");
+ element && *element ? element : "unknown");
+ yaz_log(YLOG_LOG, "Buffer length: %d", (int) len);
+ if (len > 0)
+ {
+ WRBUF w = wrbuf_alloc();
+ wrbuf_write_escaped(w, buf, len > 1024 ? 1024 : len);
+ yaz_log(YLOG_LOG, "Buffer bytes: %s", wrbuf_cstr(w));
+ wrbuf_destroy(w);
+ }
yaz_log(YLOG_LOG, "PDU dump:");
odr_dumpBER(yaz_log_file(), buf, len);
return 0;
if (!r) // decoding failed. Get the failed element
element = odr_getelement(m_odr_out);
-
+
if (m_APDU_yazlog || !r)
{
if (!r)
void Z_Assoc::close()
{
- m_PDU_Observable->close ();
+ m_PDU_Observable->close_session();
}
int Z_Assoc::server(const char *addr)
}
}
-void Z_Assoc::set_otherInformationString (
+void Z_Assoc::set_otherInformationString(
Z_APDU *apdu,
- const char *oidname, int categoryValue,
- const char *str)
+ const Odr_oid *oid, int categoryValue, const char *str)
{
Z_OtherInformation **otherInformation;
get_otherInfoAPDU(apdu, &otherInformation);
if (!otherInformation)
return;
- set_otherInformationString(otherInformation, oidname, categoryValue, str);
-}
-
-void Z_Assoc::set_otherInformationString (
- Z_OtherInformation **otherInformation,
- const char *oidname, int categoryValue,
- const char *str)
-{
- int *oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_USERINFO, oidname,
- odr_encode());
- if (!oid)
- return ;
set_otherInformationString(otherInformation, oid, categoryValue, str);
}
+
void Z_Assoc::set_otherInformationString (
Z_OtherInformation **otherInformation,
- const int *oid, int categoryValue, const char *str)
+ const Odr_oid *oid, int categoryValue, const char *str)
{
Z_OtherInformationUnit *oi =
update_otherInformation(otherInformation, 1, oid, categoryValue, 0);
Z_OtherInformationUnit *Z_Assoc::update_otherInformation (
Z_OtherInformation **otherInformationP, int createFlag,
- const int *oid, int categoryValue, int deleteFlag)
+ const Odr_oid *oid, int categoryValue, int deleteFlag)
{
return yaz_oi_update (otherInformationP,
(createFlag ? odr_encode() : 0),
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab