1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2009 Index Data and Mike Taylor
3 * See the file LICENSE for details.
8 using namespace yazpp_1;
10 GDU::GDU(Z_APDU *apdu)
12 ODR encode = odr_createmem(ODR_ENCODE);
13 Z_GDU *gdu = (Z_GDU *) odr_malloc(encode, sizeof(*gdu));
14 gdu->which = Z_GDU_Z3950;
21 base(gdu, odr_createmem(ODR_ENCODE));
26 base(0, odr_createmem(ODR_ENCODE));
29 GDU::GDU(const GDU &g)
31 base(g.get(), odr_createmem(ODR_ENCODE));
34 void GDU::base(Z_GDU *gdu, ODR encode)
36 m_decode = odr_createmem(ODR_DECODE);
38 if (gdu && z_GDU(encode, &gdu, 0, "encode"))
41 char *buf = odr_getbuf(encode, &len, 0);
43 odr_setbuf(m_decode, buf, len, 0);
44 z_GDU(m_decode, &m_gdu, 0, 0);
50 GDU &GDU::operator=(const GDU &g)
54 odr_destroy(m_decode);
56 base(g.get(), odr_createmem(ODR_ENCODE));
63 odr_destroy(m_decode);
66 Z_GDU *GDU::get() const
71 void GDU::move_away_gdu(ODR dst, Z_GDU **gdu)
75 NMEM nmem = odr_extract_mem(m_decode);
77 dst->mem = nmem_create();
78 nmem_transfer(dst->mem, nmem);
85 * indent-tabs-mode: nil
87 * vim: shiftwidth=4 tabstop=8 expandtab