2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1995-04-18 08:15:13 quinn
8 * Added dynamic memory allocation on encoding (whew). Code is now somewhat
9 * neater. We'll make the same change for decoding one day.
11 * Revision 1.3 1995/03/08 12:12:04 quinn
12 * Added better error checking.
14 * Revision 1.2 1995/02/03 17:04:31 quinn
15 * *** empty log message ***
17 * Revision 1.1 1995/02/02 20:38:49 quinn
25 int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
33 if ((res = ber_declen(o->bp, &len)) < 0)
40 if (cons) /* fetch component strings */
43 while (odp_more_chunks(o, base, len))
44 if (!odr_bitstring(o, &p, 0))
48 /* primitive bitstring */
56 if (len - 1 > ODR_BITMASK_SIZE)
61 o->bp++; /* silently ignore the unused-bits field */
64 memcpy(p->bits + p->top + 1, o->bp, len);
70 if ((res = ber_enclen(o, p->top + 2, 5, 0)) < 0)
72 if (odr_putc(o, 0) < 0) /* no unused bits here */
76 if (odr_write(o, p->bits, p->top + 1) < 0)
79 case ODR_PRINT: return 1;
80 default: o->error = OOTHER; return 0;