X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fgdu.cpp;h=467ded2b2aa7b97d7968b9ee505c58746f163491;hb=805b4fdf7b70b0e9b298064f24ceff0c1d38e05b;hp=1f660eae4e1b2e154debe190fb0a3d18b02838f7;hpb=b03c09ff93152fb9387281ad5431e6b4d44f16cd;p=yazpp-moved-to-github.git diff --git a/src/gdu.cpp b/src/gdu.cpp index 1f660ea..467ded2 100644 --- a/src/gdu.cpp +++ b/src/gdu.cpp @@ -1,11 +1,12 @@ -/* - * Copyright (c) 1998-2005, Index Data. +/* This file is part of the yazpp toolkit. + * Copyright (C) 1998-2013 Index Data and Mike Taylor * See the file LICENSE for details. - * - * $Id: gdu.cpp,v 1.3 2005-10-13 09:56:38 adam Exp $ */ -#include +#if HAVE_CONFIG_H +#include +#endif +#include using namespace yazpp_1; @@ -41,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) { @@ -84,6 +95,7 @@ void GDU::move_away_gdu(ODR dst, Z_GDU **gdu) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab