2 * Copyright (c) 1998-2005, Index Data.
3 * See the file LICENSE for details.
5 * $Id: gdu.cpp,v 1.4 2006-03-29 13:14:15 adam Exp $
10 using namespace yazpp_1;
12 GDU::GDU(Z_APDU *apdu)
14 ODR encode = odr_createmem(ODR_ENCODE);
15 Z_GDU *gdu = (Z_GDU *) odr_malloc(encode, sizeof(*gdu));
16 gdu->which = Z_GDU_Z3950;
23 base(gdu, odr_createmem(ODR_ENCODE));
28 base(0, odr_createmem(ODR_ENCODE));
31 GDU::GDU(const GDU &g)
33 base(g.get(), odr_createmem(ODR_ENCODE));
36 void GDU::base(Z_GDU *gdu, ODR encode)
38 m_decode = odr_createmem(ODR_DECODE);
40 if (gdu && z_GDU(encode, &gdu, 0, "encode"))
43 char *buf = odr_getbuf(encode, &len, 0);
45 odr_setbuf(m_decode, buf, len, 0);
46 z_GDU(m_decode, &m_gdu, 0, 0);
52 GDU &GDU::operator=(const GDU &g)
56 odr_destroy(m_decode);
58 base(g.get(), odr_createmem(ODR_ENCODE));
65 odr_destroy(m_decode);
68 Z_GDU *GDU::get() const
73 void GDU::move_away_gdu(ODR dst, Z_GDU **gdu)
77 NMEM nmem = odr_extract_mem(m_decode);
79 dst->mem = nmem_create();
80 nmem_transfer(dst->mem, nmem);
87 * indent-tabs-mode: nil
89 * vim: shiftwidth=4 tabstop=8 expandtab