16dc98471aea3bf6c0f7b63fd4f88bb67af9e023
[yaz-moved-to-github.git] / odr / odr_util.c
1 #include <odr.h>
2 #include <stdlib.h>
3
4 void *nalloc(ODR o, int size) { return malloc(size); }
5
6 char *odr_indent(ODR o)
7 {
8     static char buf[512];
9
10     memset(buf, ' ', 512);
11     buf[o->indent * 4] = 0;
12     return buf;
13 }
14
15 int odp_more_chunks(ODR o, unsigned char *base, int len)
16 {
17     if (!len)
18         return 0;
19     if (len < 0) /* indefinite length */
20     {
21         if (*o->bp == 0 && *(o->bp + 1) == 0)
22         {
23             o->bp += 2;
24             o->left -= 2;
25             return 0;
26         }
27         else
28             return 1;
29     }
30     else
31         return o->bp - base < len;
32 }