2 * Copyright (c) 1995-2004, Index Data
3 * See the file LICENSE for details.
5 * $Id: ber_oid.c,v 1.4 2004-10-15 00:18:59 adam Exp $
10 * \brief Implements BER OID encoding and decoding
12 * This source file implements BER encoding and decoding of
21 int ber_oidc(ODR o, Odr_oid *p)
25 unsigned char octs[8];
30 if ((res = ber_declen(o->bp, &len, odr_max(o))) < 1)
32 odr_seterror(o, OPROTO, 18);
37 odr_seterror(o, OPROTO, 19);
43 odr_seterror(o, OPROTO, 20);
54 odr_seterror(o, OPROTO, 21);
61 while (*(o->bp++) & 0X80);
69 p[1] = id - p[0] * 40;
76 /* we'll allow ourselves the quiet luxury of only doing encodings
79 if (odr_putc(o, 0) < 0) /* dummy */
81 if (p[0] < 0 || p[1] < 0)
83 odr_seterror(o, ODATA, 23);
86 for (pos = 1; p[pos] >= 0; pos++)
95 octs[n++] = id & 0X7F;
103 p = octs[n] | ((n > 0) << 7);
104 if (odr_putc(o, p) < 0)
109 odr_seek(o, ODR_S_SET, lenp);
110 if (ber_enclen(o, (end - lenp) - 1, 1, 1) != 1)
112 odr_seterror(o, OOTHER, 52);
115 odr_seek(o, ODR_S_END, 0);
118 odr_seterror(o, OOTHER, 22);