2 * Copyright (c) 1995-2003, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: ber_bit.c,v 1.1 2003-10-27 12:21:30 adam Exp $
15 int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
18 const unsigned char *base;
23 if ((res = ber_declen(o->bp, &len, odr_max(o))) < 0)
25 odr_seterror(o, OPROTO, 4);
29 if (cons) /* fetch component strings */
32 while (odp_more_chunks(o, base, len))
33 if (!odr_bitstring(o, &p, 0, 0))
37 /* primitive bitstring */
40 odr_seterror(o, OOTHER, 5);
45 if (len - 1 > ODR_BITMASK_SIZE)
47 odr_seterror(o, OOTHER, 6);
52 odr_seterror(o, OOTHER, 7);
55 o->bp++; /* silently ignore the unused-bits field */
57 memcpy(p->bits + p->top + 1, o->bp, len);
62 if ((res = ber_enclen(o, p->top + 2, 5, 0)) < 0)
64 if (odr_putc(o, 0) < 0) /* no unused bits here */
68 if (odr_write(o, p->bits, p->top + 1) < 0)
74 odr_seterror(o, OOTHER, 8);