2 * Copyright (c) 1995-2002, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: ber_bit.c,v 1.13 2002-07-25 12:51:08 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)) < 0)
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 */
45 if (len - 1 > ODR_BITMASK_SIZE)
50 o->bp++; /* silently ignore the unused-bits field */
52 memcpy(p->bits + p->top + 1, o->bp, len);
57 if ((res = ber_enclen(o, p->top + 2, 5, 0)) < 0)
59 if (odr_putc(o, 0) < 0) /* no unused bits here */
63 if (odr_write(o, p->bits, p->top + 1) < 0)
66 case ODR_PRINT: return 1;
67 default: o->error = OOTHER; return 0;