From 1c2df7a209b83db0b04700abff3512c0abf5d967 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Thu, 17 Aug 1995 12:47:09 +0000 Subject: [PATCH] Added GRS-1. --- asn/prt-grs.c | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/prt-grs.h | 172 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 375 insertions(+) create mode 100644 asn/prt-grs.c create mode 100644 include/prt-grs.h diff --git a/asn/prt-grs.c b/asn/prt-grs.c new file mode 100644 index 0000000..183ccc2 --- /dev/null +++ b/asn/prt-grs.c @@ -0,0 +1,203 @@ +/* + * Copyright (c) 1995, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: prt-grs.c,v $ + * Revision 1.1 1995-08-17 12:47:09 quinn + * Added GRS-1. + * + * + */ + +#include + +int z_GenericRecord(ODR o, Z_GenericRecord **p, int opt); +int z_TaggedElement(ODR o, Z_TaggedElement **p, int opt); +int z_ElementData(ODR o, Z_ElementData **p, int opt); +int z_ElementMetaData(ODR o, Z_ElementMetaData **p, int opt); +int z_TagUnit(ODR o, Z_TagUnit **p, int opt); +int z_TagPath(ODR o, Z_TagPath **p, int opt); +int z_Order(ODR o, Z_Order **p, int opt); +int z_Usage(ODR o, Z_Usage **p, int opt); +int z_HitVector(ODR o, Z_HitVector **p, int opt); +int z_Triple(ODR o, Z_Triple **p, int opt); +int z_Variant(ODR o, Z_Variant **p, int opt); + +int z_GenericRecord(ODR o, Z_GenericRecord **p, int opt) +{ + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + else if (!*p) + return opt; + if (odr_sequence_of(o, z_TaggedElement, &(*p)->elements, &(*p)->num_elements)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_TaggedElement(ODR o, Z_TaggedElement **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_integer, &(*p)->tagType, ODR_CONTEXT, 1, 1) && + odr_explicit(o, z_StringOrNumeric, &(*p)->tagValue, ODR_CONTEXT, 2, 0) && + odr_implicit(o, odr_integer, &(*p)->tagOccurrence, ODR_CONTEXT, 3, 1) && + odr_explicit(o, z_ElementData, &(*p)->content, ODR_CONTEXT, 4, 0) && + odr_implicit(o, z_ElementMetaData, &(*p)->metaData, ODR_CONTEXT, 5, 1) && + odr_implicit(o, z_Variant, &(*p)->appliedVariant, ODR_CONTEXT, 6, 1) && + odr_sequence_end(o); +} + +int z_ElementData(ODR o, Z_ElementData **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_NONE, -1, -1, Z_ElementData_octets, odr_octetstring}, + {ODR_NONE, -1, -1, Z_ElementData_numeric, odr_integer}, + {ODR_NONE, -1, -1, Z_ElementData_date, odr_generalizedtime}, + {ODR_NONE, -1, -1, Z_ElementData_ext, z_External}, + {ODR_NONE, -1, -1, Z_ElementData_string, z_InternationalString}, + {ODR_NONE, -1, -1, Z_ElementData_trueOrFalse, odr_bool}, + {ODR_NONE, -1, -1, Z_ElementData_oid, odr_oid}, + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementData_intUnit, z_IntUnit}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementData_elementNotThere, odr_null}, + {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_ElementData_elementEmpty, odr_null}, + {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_ElementData_noDataRequested, odr_null}, + {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_ElementData_diagnostic, z_External}, + {ODR_EXPLICIT, ODR_CONTEXT, 6, Z_ElementData_subtree, z_GenericRecord}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + else if (!*p) + return opt; + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_ElementMetaData(ODR o, Z_ElementMetaData **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, z_Order, &(*p)->seriesOrder, ODR_CONTEXT, 1, 1) && + odr_implicit(o, z_Usage, &(*p)->usageRight, ODR_CONTEXT, 2, 1) && + odr_implicit_settag(o, ODR_CONTEXT, 3) && + (odr_sequence_of(o, z_HitVector, &(*p)->hits, &(*p)->num_hits) || + odr_ok(o)) && + odr_implicit(o, z_InternationalString, &(*p)->displayName, ODR_CONTEXT, + 4, 1) && + odr_implicit_settag(o, ODR_CONTEXT, 5) && + (odr_sequence_of(o, z_Variant, &(*p)->supportedVariants, + &(*p)->num_supportedVariants) || odr_ok(o)) && + odr_implicit(o, z_InternationalString, &(*p)->message, ODR_CONTEXT, + 6, 1) && + odr_implicit(o, odr_octetstring, &(*p)->elementDescriptor, ODR_CONTEXT, + 7, 1) && + odr_implicit(o, z_TagPath, &(*p)->surrogateFor, ODR_CONTEXT, 8, 1) && + odr_implicit(o, z_TagPath, &(*p)->surrogateElement, ODR_CONTEXT, 9, 1) && + odr_implicit(o, z_External, &(*p)->other, ODR_CONTEXT, 99, 1) && + odr_sequence_end(o); +} + +int z_TagUnit(ODR o, Z_TagUnit **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_integer, &(*p)->tagType, ODR_CONTEXT, 1, 1) && + odr_explicit(o, z_StringOrNumeric, &(*p)->tagValue, ODR_CONTEXT, 2, 0) && + odr_implicit(o, odr_integer, &(*p)->tagOccurrence, ODR_CONTEXT, 3, 1) && + odr_sequence_end(o); +} + +int z_TagPath(ODR o, Z_TagPath **p, int opt) +{ + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + else if (!*p) + return opt; + if (odr_sequence_of(o, z_TagUnit, &(*p)->tags, &(*p)->num_tags)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_Order(ODR o, Z_Order **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_bool, &(*p)->ascending, ODR_CONTEXT, 1, 0) && + odr_implicit(o, odr_integer, &(*p)->order, ODR_CONTEXT, 2, 0) && + odr_sequence_end(o); +} + +int z_Usage(ODR o, Z_Usage **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_integer, &(*p)->type, ODR_CONTEXT, 1, 0) && + odr_implicit(o, z_InternationalString, &(*p)->restriction, ODR_CONTEXT, + 2, 1) && + odr_sequence_end(o); +} + +int z_HitVector(ODR o, Z_HitVector **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + z_Term(o, &(*p)->satisfier, 1) && + odr_implicit(o, z_IntUnit, &(*p)->offsetIntoElement, ODR_CONTEXT, 1, 1) && + odr_implicit(o, z_IntUnit, &(*p)->length, ODR_CONTEXT, 2, 1) && + odr_implicit(o, odr_integer, &(*p)->hitRank, ODR_CONTEXT, 3, 1) && + odr_implicit(o, odr_octetstring, &(*p)->targetToken, ODR_CONTEXT, + 4, 1) && + odr_sequence_end(o); +} + +int z_Triple(ODR o, Z_Triple **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_NONE, -1, -1, Z_Triple_integer, odr_integer}, + {ODR_NONE, -1, -1, Z_Triple_internationalString, z_InternationalString}, + {ODR_NONE, -1, -1, Z_Triple_octetString, odr_octetstring}, + {ODR_NONE, -1, -1, Z_Triple_oid, odr_oid}, + {ODR_NONE, -1, -1, Z_Triple_boolean, odr_bool}, + {ODR_NONE, -1, -1, Z_Triple_null, odr_null}, + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Triple_unit, z_Unit}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Triple_valueAndUnit, z_IntUnit}, + {-1, -1, -1, -1, 0} + }; + + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_oid, &(*p)->variantSetId, ODR_CONTEXT, 0, 1) && + odr_implicit(o, odr_integer, &(*p)->class, ODR_CONTEXT, 1, 0) && + odr_implicit(o, odr_integer, &(*p)->type, ODR_CONTEXT, 2, 0) && + odr_constructed_begin(o, &(*p)->value, ODR_CONTEXT, 3) && + odr_choice(o, arm, &(*p)->value, &(*p)->which) && + odr_constructed_end(o) && + odr_sequence_end(o); +} + +int z_Variant(ODR o, Z_Variant **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_oid, &(*p)->globalVariantSetId, ODR_CONTEXT, + 1, 1) && + odr_implicit_settag(o, ODR_CONTEXT, 2) && + odr_sequence_of(o, z_Triple, &(*p)->triples, &(*p)->num_triples) && + odr_sequence_end(o); +} diff --git a/include/prt-grs.h b/include/prt-grs.h new file mode 100644 index 0000000..d80ad09 --- /dev/null +++ b/include/prt-grs.h @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1995, Index Data. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of Index Data or the individual authors may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR + * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + */ + +struct Z_GenericRecord; +typedef struct Z_GenericRecord Z_GenericRecord; + +typedef struct Z_ElementData +{ + enum + { + Z_ElementData_octets, + Z_ElementData_numeric, + Z_ElementData_date, + Z_ElementData_ext, + Z_ElementData_string, + Z_ElementData_trueOrFalse, + Z_ElementData_oid, + Z_ElementData_intUnit, + Z_ElementData_elementNotThere, + Z_ElementData_elementEmpty, + Z_ElementData_noDataRequested, + Z_ElementData_diagnostic, + Z_ElementData_subtree + } which; + union + { + Odr_oct *octets; + int *numeric; + char *date; + Z_External *ext; + char *string; + bool_t *trueOrFalse; + Odr_oid *oid; + Z_IntUnit *intUnit; + Odr_null *elementNotThere; + Odr_null *elementEmpty; + Odr_null *noDataRequested; + Z_External *diagnostic; + Z_GenericRecord *subtree; + } u; +} Z_ElementData; + +typedef struct Z_Order +{ + bool_t *ascending; + int *order; +} Z_Order; + +typedef struct Z_Usage +{ + int *type; +#define Z_Usage_redistributable 1 +#define Z_Usage_restricted 2 +#define Z_Usage_licensePointer 3 + char *restriction; /* OPTIONAL */ +} Z_Usage; + +typedef struct Z_HitVector +{ + Z_Term *satisfier; /* OPTIONAL */ + Z_IntUnit *offsetIntoElement; /* OPTIONAL */ + Z_IntUnit *length; /* OPTIONAL */ + int *hitRank; /* OPTIONAL */ + Odr_oct *targetToken; /* OPTIONAL */ +} Z_HitVector; + +typedef struct Z_Triple +{ + Odr_oid *variantSetId; /* OPTIONAL */ + int *class; + int *type; + enum + { + Z_Triple_integer, + Z_Triple_internationalString, + Z_Triple_octetString, + Z_Triple_oid, + Z_Triple_boolean, + Z_Triple_null, + Z_Triple_unit, + Z_Triple_valueAndUnit + } which; + union + { + int *integer; + char *internationalString; + Odr_oct *octetString; + Odr_oid *oid; + bool_t *boolean; + Odr_null *null; + Z_Unit *unit; + Z_IntUnit *valueAndUnit; + } value; +} Z_Triple; + +typedef struct Z_Variant +{ + Odr_oid *globalVariantSetId; /* OPTIONAL */ + int num_triples; + Z_Triple **triples; +} Z_Variant; + +typedef struct Z_TagUnit +{ + int *tagType; /* OPTIONAL */ + Z_StringOrNumeric *tagValue; + int *tagOccurrence; /* OPTIONAL */ +} Z_TagUnit; + +typedef struct Z_TagPath +{ + int num_tags; + Z_TagUnit **tags; +} Z_TagPath; + +typedef struct Z_ElementMetaData +{ + Z_Order *seriesOrder; /* OPTIONAL */ + Z_Usage *usageRight; /* OPTIONAL */ + int num_hits; + Z_HitVector **hits; /* OPTIONAL */ + char *displayName; /* OPTIONAL */ + int num_supportedVariants; + Z_Variant **supportedVariants; /* OPTIONAL */ + char *message; /* OPTIONAL */ + Odr_oct *elementDescriptor; /* OPTIONAL */ + Z_TagPath *surrogateFor; /* OPTIONAL */ + Z_TagPath *surrogateElement; /* OPTIONAL */ + Z_External *other; /* OPTIONAL */ +} Z_ElementMetaData; + +typedef struct Z_TaggedElement +{ + int *tagType; /* OPTIONAL */ + Z_StringOrNumeric *tagValue; + int *tagOccurrence; /* OPTIONAL */ + Z_ElementData *content; + Z_ElementMetaData *metaData; /* OPTIONAL */ + Z_Variant *appliedVariant; /* OPTIONAL */ +} Z_TaggedElement; + +struct Z_GenericRecord +{ + int num_elements; + Z_TaggedElement **elements; +}; + +int z_GenericRecord(ODR o, Z_GenericRecord **p, int opt); -- 1.7.10.4