1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2011 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);
52 ODR encode = odr_createmem(ODR_ENCODE);
53 if (m_gdu && z_GDU(encode, &m_gdu, 0, "encode"))
54 odr_getbuf(encode, &len, 0);
59 GDU &GDU::operator=(const GDU &g)
63 odr_destroy(m_decode);
65 base(g.get(), odr_createmem(ODR_ENCODE));
72 odr_destroy(m_decode);
75 Z_GDU *GDU::get() const
80 void GDU::move_away_gdu(ODR dst, Z_GDU **gdu)
84 NMEM nmem = odr_extract_mem(m_decode);
86 dst->mem = nmem_create();
87 nmem_transfer(dst->mem, nmem);
94 * c-file-style: "Stroustrup"
95 * indent-tabs-mode: nil
97 * vim: shiftwidth=4 tabstop=8 expandtab