X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fgdu.cpp;h=829cfb5c9b028e3fa7bb3faf86d9f71e7a1d20c7;hb=9db3735fa68528436821b0349f5acc788f448492;hp=8df705e8136a3adead1ad6936b612c525318de9b;hpb=6b22d0543d41bec8626f3ae7ac866bcab7de44bd;p=yazpp-moved-to-github.git diff --git a/src/gdu.cpp b/src/gdu.cpp index 8df705e..829cfb5 100644 --- a/src/gdu.cpp +++ b/src/gdu.cpp @@ -1,8 +1,11 @@ /* This file is part of the yazpp toolkit. - * Copyright (C) 1998-2009 Index Data and Mike Taylor + * Copyright (C) Index Data * See the file LICENSE for details. */ +#if HAVE_CONFIG_H +#include +#endif #include using namespace yazpp_1; @@ -39,13 +42,23 @@ void GDU::base(Z_GDU *gdu, ODR encode) { int len; char *buf = odr_getbuf(encode, &len, 0); - + odr_setbuf(m_decode, buf, len, 0); - z_GDU(m_decode, &m_gdu, 0, 0); + if (!z_GDU(m_decode, &m_gdu, 0, 0)) + m_gdu = 0; } odr_destroy(encode); } +int GDU::get_size() +{ + int len = 0; + ODR encode = odr_createmem(ODR_ENCODE); + if (m_gdu && z_GDU(encode, &m_gdu, 0, "encode")) + odr_getbuf(encode, &len, 0); + odr_destroy(encode); + return len; +} GDU &GDU::operator=(const GDU &g) {