2 * Copyright (c) 1995-2003, Index Data
3 * See the file LICENSE for details.
5 * $Id: odr_util.c,v 1.2 2003-11-26 16:23:42 mike Exp $
17 void odr_prname(ODR o, const char *name)
20 fprintf (o->print, "%*s%s ", o->indent*4, "", name);
22 fprintf (o->print, "%*s", o->indent*4, "");
25 int odp_more_chunks(ODR o, const unsigned char *base, int len)
29 if (len < 0) /* indefinite length */
31 if (*o->bp == 0 && *(o->bp + 1) == 0)
40 return o->bp - base < len;
43 Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o)
49 if (!(r = (int *)nmem_malloc(nmem, (oid_oidlen(o) + 1) * sizeof(int))))
55 Odr_oid *odr_oiddup(ODR odr, Odr_oid *o)
57 return odr_oiddup_nmem (odr->mem, o);
60 Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str)
68 while ((p = strchr(p, '.')))
70 ret = (int *)nmem_malloc(nmem, sizeof(*ret)*(num + 1));
74 while ((p = strchr(p, '.')) && *++p);
79 Odr_oid *odr_getoidbystr(ODR o, const char *str)
81 return odr_getoidbystr_nmem (o->mem, str);
84 int odr_missing(ODR o, int opt, const char *name)
90 odr_seterror(o, OREQUIRED, 53);
91 odr_setelement(o, name);
97 * Reallocate the buffer `old', using the ODR memory pool `o' to be
98 * big enough to hold its existing value (if any) plus `prefix' (if
99 * any) and a separator character. Copy `prefix', a forward slash and
100 * the old value into the new area and return its address. Can be
102 * initRequest->implementationName = odr_prepend(o,
103 * initRequest->implementationName, "ZOOM-C");
105 char *odr_prepend(ODR o, const char *prefix, const char *old)
107 int plen = (prefix == 0) ? 0 : strlen(prefix);
108 int olen = (old == 0) ? 0 : strlen(old);
109 char *res = (char*) odr_malloc (o, olen + plen + 2);
113 strcpy (res, prefix);
114 if (prefix != 0 && old != 0)