X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fber_int.c;h=e445bc94fea17784cb4a54f609cc1752a5688fb9;hp=7b1aba81cc30502b34b3ef314b68c01f12618864;hb=95d8bd04e10519a635972a24176270ef4dbe8d2c;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9 diff --git a/src/ber_int.c b/src/ber_int.c index 7b1aba8..e445bc9 100644 --- a/src/ber_int.c +++ b/src/ber_int.c @@ -1,20 +1,31 @@ /* - * Copyright (c) 1995-2003, Index Data + * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * - * $Id: ber_int.c,v 1.1 2003-10-27 12:21:30 adam Exp $ + * $Id: ber_int.c,v 1.6 2005-08-11 14:21:55 adam Exp $ */ + +/** + * \file ber_int.c + * \brief Implements BER INTEGER encoding and decoding. + * + * This source file implements BER encoding and decoding of + * the INTEGER type. + */ + #if HAVE_CONFIG_H #include #endif #include +#if HAVE_SYS_TYPES_H +#include +#endif + #ifdef WIN32 #include #else -#include #include #endif @@ -29,20 +40,22 @@ int ber_integer(ODR o, int *val) switch (o->direction) { - case ODR_DECODE: - if ((res = ber_decinteger(o->bp, val, odr_max(o))) <= 0) - { - odr_seterror(o, OPROTO, 50); - return 0; - } - o->bp += res; - return 1; - case ODR_ENCODE: - if ((res = ber_encinteger(o, *val)) < 0) - return 0; - return 1; - case ODR_PRINT: return 1; - default: odr_seterror(o, OOTHER, 51); return 0; + case ODR_DECODE: + if ((res = ber_decinteger(o->bp, val, odr_max(o))) <= 0) + { + odr_seterror(o, OPROTO, 50); + return 0; + } + o->bp += res; + return 1; + case ODR_ENCODE: + if ((res = ber_encinteger(o, *val)) < 0) + return 0; + return 1; + case ODR_PRINT: + return 1; + default: + odr_seterror(o, OOTHER, 51); return 0; } } @@ -64,9 +77,6 @@ int ber_encinteger(ODR o, int val) return -1; if (odr_write(o, (unsigned char*) tmp.c + a, len) < 0) return -1; -#ifdef ODR_DEBUG - fprintf(stderr, "[val=%d]", val); -#endif return 0; } @@ -98,8 +108,13 @@ int ber_decinteger(const unsigned char *buf, int *val, int max) *val = ntohl(tmp.i); b += len; -#ifdef ODR_DEBUG - fprintf(stderr, "[val=%d]", *val); -#endif return b - buf; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +