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