X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fprt-ext.c;h=6af7c6118a9c5b3d90fe7689b1dd7dbf8fd91a6a;hp=f17099482cfb6a65a3930511c1b5bcb868057e31;hb=633f1d5078e524d7f6cf6a1674821b5464f9fb76;hpb=896b145fa7a02199bfc3e8aa824c018b9d7cbf98 diff --git a/src/prt-ext.c b/src/prt-ext.c index f170994..6af7c61 100644 --- a/src/prt-ext.c +++ b/src/prt-ext.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ /** @@ -22,7 +22,7 @@ /* * The table below should be moved to the ODR structure itself and * be an image of the association context: To help - * map indirect references when they show up. + * map indirect references when they show up. */ static Z_ext_typeent type_table[] = { @@ -85,7 +85,7 @@ Z_ext_typeent *z_ext_getentbyref(const Odr_oid *oid) encoding CHOICE { single-ASN1-type [0] ABSTRACT_SYNTAX.&Type, octet-aligned [1] IMPLICIT OCTET STRING, - arbitrary [2] IMPLICIT BIT STRING + arbitrary [2] IMPLICIT BIT STRING } } @@ -223,11 +223,11 @@ int z_External(ODR o, Z_External **p, int opt, const char *name) Odr_oct *oct; int r; if (!odr_implicit_tag(o, odr_octetstring, &oct, - ODR_CONTEXT, 1, 0, "octetaligned")) + ODR_CONTEXT, 1, 0, "octetaligned")) return 0; /* Save our decoding ODR members */ - o_bp = o->bp; + o_bp = o->bp; o_buf = o->buf; o_size = o->size; @@ -239,16 +239,16 @@ int z_External(ODR o, Z_External **p, int opt, const char *name) r = (*type->fun)(o, &voidp, 0, 0); (*p)->which = type->what; (*p)->u.single_ASN1_type = (Odr_any*) voidp; - + /* Restore our decoding ODR member */ - o->bp = o_bp; + o->bp = o_bp; o->buf = o_buf; o->size = o_size; return r && odr_sequence_end(o); } if (zclass == ODR_CONTEXT && tag == 0 && cons == 1) - { + { /* It's single ASN.1 type, bias the CHOICE. */ odr_choice_bias(o, type->what); } @@ -258,16 +258,17 @@ int z_External(ODR o, Z_External **p, int opt, const char *name) odr_sequence_end(o); } -Z_External *z_ext_record_oid(ODR o, const Odr_oid *oid, const char *buf, int len) +Z_External *z_ext_record_oid_nmem(NMEM nmem, const Odr_oid *oid, + const char *buf, int len) { Z_External *thisext; if (!oid) return 0; - thisext = (Z_External *) odr_malloc(o, sizeof(*thisext)); + thisext = (Z_External *) nmem_malloc(nmem, sizeof(*thisext)); thisext->descriptor = 0; thisext->indirect_reference = 0; - thisext->direct_reference = odr_oiddup(o, oid); + thisext->direct_reference = odr_oiddup_nmem(nmem, oid); if (len < 0) /* Structured data */ { @@ -308,13 +309,13 @@ Z_External *z_ext_record_oid(ODR o, const Odr_oid *oid, const char *buf, int len return 0; } } - else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) /* SUTRS is a single-ASN.1-type */ - { - Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs)); - + else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs)) + { /* SUTRS is a single-ASN.1-type */ + Odr_oct *sutrs = (Odr_oct *)nmem_malloc(nmem, sizeof(*sutrs)); + thisext->which = Z_External_sutrs; thisext->u.sutrs = sutrs; - sutrs->buf = (unsigned char *)odr_malloc(o, len); + sutrs->buf = (unsigned char *)nmem_malloc(nmem, len); sutrs->len = sutrs->size = len; memcpy(sutrs->buf, buf, len); } @@ -322,10 +323,10 @@ Z_External *z_ext_record_oid(ODR o, const Odr_oid *oid, const char *buf, int len { thisext->which = Z_External_octet; if (!(thisext->u.octet_aligned = (Odr_oct *) - odr_malloc(o, sizeof(Odr_oct)))) + nmem_malloc(nmem, sizeof(Odr_oct)))) return 0; if (!(thisext->u.octet_aligned->buf = (unsigned char *) - odr_malloc(o, len))) + nmem_malloc(nmem, len))) return 0; memcpy(thisext->u.octet_aligned->buf, buf, len); thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = len; @@ -333,6 +334,12 @@ Z_External *z_ext_record_oid(ODR o, const Odr_oid *oid, const char *buf, int len return thisext; } +Z_External *z_ext_record_oid(ODR o, const Odr_oid *oid, + const char *buf, int len) +{ + return z_ext_record_oid_nmem(o->mem, oid, buf, len); +} + Z_External *z_ext_record_oid_any(ODR o, const Odr_oid *oid, const char *buf, int len) {