2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: ber_oid.c,v 1.6 2005-05-26 21:46:40 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, int max_oid_size)
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;
72 if (pos >= max_oid_size)
74 odr_seterror(o, OPROTO, 55);
81 /* we'll allow ourselves the quiet luxury of only doing encodings
84 if (odr_putc(o, 0) < 0) /* dummy */
86 if (p[0] < 0 || p[1] < 0)
88 odr_seterror(o, ODATA, 23);
91 for (pos = 1; p[pos] >= 0; pos++)
100 octs[n++] = id & 0X7F;
108 p = octs[n] | ((n > 0) << 7);
109 if (odr_putc(o, p) < 0)
114 odr_seek(o, ODR_S_SET, lenp);
115 if (ber_enclen(o, (end - lenp) - 1, 1, 1) != 1)
117 odr_seterror(o, OOTHER, 52);
120 odr_seek(o, ODR_S_END, 0);
123 odr_seterror(o, OOTHER, 22);