2 * Copyright (C) 1995-2007, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: odr_bit.c,v 1.7 2007-03-19 21:08:13 adam Exp $
10 * \brief Implements ODR BITSTRING codec
21 * Top level bitstring string en/decoder.
22 * Returns 1 on success, 0 on error.
24 int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name)
30 if (o->op->t_class < 0)
32 o->op->t_class = ODR_UNIVERSAL;
33 o->op->t_tag = ODR_BITSTRING;
35 res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
39 return odr_missing(o, opt, name);
40 if (o->direction == ODR_PRINT)
43 odr_printf(o, "BITSTRING(len=%d)\n",(*p)->top + 1);
46 if (o->direction == ODR_DECODE)
48 *p = (Odr_bitmask *)odr_malloc(o, sizeof(Odr_bitmask));
49 memset((*p)->bits, 0, ODR_BITMASK_SIZE);
53 /* ignoring the cons helps with at least one target.
54 * http://bugzilla.indexdata.dk/cgi-bin/bugzilla/show_bug.cgi?id=24
56 return ber_bitstring(o, *p, 0);
58 return ber_bitstring(o, *p, cons);
64 * indent-tabs-mode: nil
66 * vim: shiftwidth=4 tabstop=8 expandtab