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.14 2003-01-06 08:20:27 adam Exp $
14 int ber_oidc(ODR o, Odr_oid *p)
18 unsigned char octs[8];
23 if ((res = ber_declen(o->bp, &len)) < 1)
42 p[1] = *o->bp - p[0] * 40;
57 p[pos] |= *o->bp & 0X7F;
60 while (*(o->bp++) & 0X80);
66 /* we'll allow ourselves the quiet luxury of only doing encodings
69 if (odr_putc(o, 0) < 0) /* dummy */
71 if (p[0] < 0 && p[1] <= 0)
76 for (pos = 1; p[pos] >= 0; pos++)
78 id = pos > 1 ? p[pos] : p[0] * 40 + p[1];
82 octs[n++] = id & 0X7F;
90 p = octs[n] | ((n > 0) << 7);
91 if (odr_putc(o, p) < 0)
96 odr_seek(o, ODR_S_SET, lenp);
97 if (ber_enclen(o, (end - lenp) - 1, 1, 1) != 1)
102 odr_seek(o, ODR_S_END, 0);
105 o->error = OOTHER; return 0;