2 * Copyright (c) 1995-2003, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: ber_oid.c,v 1.15 2003-03-11 11:03:31 adam Exp $
14 int ber_oidc(ODR o, Odr_oid *p)
18 unsigned char octs[8];
23 if ((res = ber_declen(o->bp, &len, odr_max(o))) < 1)
25 odr_seterror(o, OPROTO, 18);
30 odr_seterror(o, OPROTO, 19);
41 odr_seterror(o, OPROTO, 20);
47 p[1] = *o->bp - p[0] * 40;
58 odr_seterror(o, OPROTO, 21);
62 p[pos] |= *o->bp & 0X7F;
65 while (*(o->bp++) & 0X80);
71 /* we'll allow ourselves the quiet luxury of only doing encodings
74 if (odr_putc(o, 0) < 0) /* dummy */
76 if (p[0] < 0 && p[1] <= 0)
78 odr_seterror(o, ODATA, 23);
81 for (pos = 1; p[pos] >= 0; pos++)
83 id = pos > 1 ? p[pos] : p[0] * 40 + p[1];
87 octs[n++] = id & 0X7F;
95 p = octs[n] | ((n > 0) << 7);
96 if (odr_putc(o, p) < 0)
101 odr_seek(o, ODR_S_SET, lenp);
102 if (ber_enclen(o, (end - lenp) - 1, 1, 1) != 1)
104 odr_seterror(o, OOTHER, 52);
107 odr_seek(o, ODR_S_END, 0);
110 odr_seterror(o, OOTHER, 22);