1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2013 Index Data and Mike Taylor
3 * See the file LICENSE for details.
11 using namespace yazpp_1;
13 GDU::GDU(Z_APDU *apdu)
15 ODR encode = odr_createmem(ODR_ENCODE);
16 Z_GDU *gdu = (Z_GDU *) odr_malloc(encode, sizeof(*gdu));
17 gdu->which = Z_GDU_Z3950;
24 base(gdu, odr_createmem(ODR_ENCODE));
29 base(0, odr_createmem(ODR_ENCODE));
32 GDU::GDU(const GDU &g)
34 base(g.get(), odr_createmem(ODR_ENCODE));
37 void GDU::base(Z_GDU *gdu, ODR encode)
39 m_decode = odr_createmem(ODR_DECODE);
41 if (gdu && z_GDU(encode, &gdu, 0, "encode"))
44 char *buf = odr_getbuf(encode, &len, 0);
46 odr_setbuf(m_decode, buf, len, 0);
47 if (!z_GDU(m_decode, &m_gdu, 0, 0))
56 ODR encode = odr_createmem(ODR_ENCODE);
57 if (m_gdu && z_GDU(encode, &m_gdu, 0, "encode"))
58 odr_getbuf(encode, &len, 0);
63 GDU &GDU::operator=(const GDU &g)
67 odr_destroy(m_decode);
69 base(g.get(), odr_createmem(ODR_ENCODE));
76 odr_destroy(m_decode);
79 Z_GDU *GDU::get() const
84 void GDU::move_away_gdu(ODR dst, Z_GDU **gdu)
88 NMEM nmem = odr_extract_mem(m_decode);
90 dst->mem = nmem_create();
91 nmem_transfer(dst->mem, nmem);
98 * c-file-style: "Stroustrup"
99 * indent-tabs-mode: nil
101 * vim: shiftwidth=4 tabstop=8 expandtab