*** empty log message ***
[yaz-moved-to-github.git] / odr / odr_util.c
1 #include <stdlib.h>
2 #include <odr.h>
3 #include <oid.h>
4
5 char *odr_indent(ODR o)
6 {
7     static char buf[512];
8
9     memset(buf, ' ', 512);
10     buf[o->indent * 4] = 0;
11     return buf;
12 }
13
14 int odp_more_chunks(ODR o, unsigned char *base, int len)
15 {
16     if (!len)
17         return 0;
18     if (len < 0) /* indefinite length */
19     {
20         if (*o->bp == 0 && *(o->bp + 1) == 0)
21         {
22             o->bp += 2;
23             o->left -= 2;
24             return 0;
25         }
26         else
27             return 1;
28     }
29     else
30         return o->bp - base < len;
31 }
32
33 Odr_oid *odr_oiddup(ODR odr, Odr_oid *o)
34 {
35     Odr_oid *r;
36
37     if (!o)
38         return 0;
39     if (!(r = odr_malloc(odr, (oid_oidlen(o) + 1) * sizeof(int))))
40         return 0;
41     oid_oidcpy(r, o);
42     return r;
43 }