From 779afe2804f2dccc96d311862afceb22f5f3ac70 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Mon, 6 Feb 1995 21:26:07 +0000 Subject: [PATCH] Repaired this evening's damages.. --- asn/proto.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 4 deletions(-) diff --git a/asn/proto.c b/asn/proto.c index dd40eb6..6cf6d17 100644 --- a/asn/proto.c +++ b/asn/proto.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: proto.c,v $ - * Revision 1.1 1995-02-06 16:44:47 quinn + * Revision 1.2 1995-02-06 21:26:07 quinn + * Repaired this evening's damages.. + * + * Revision 1.1 1995/02/06 16:44:47 quinn * First hack at Z/SR protocol * */ @@ -13,6 +16,8 @@ #include +/* ---------------------- INITIALIZE SERVICE ------------------- */ + int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt) { return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt); @@ -24,6 +29,8 @@ int z_DatabaseName(Odr o, Z_DatabaseName **p, int opt) opt); } +/* ---------------------- INITIALIZE SERVICE ------------------- */ + int z_InitRequest(ODR o, Z_InitRequest **p, int opt) { Z_InitRequest *pp; @@ -79,6 +86,152 @@ int z_InitResponse(ODR o, Z_InitResponse **p, int opt) odr_sequence_end(o); } +/* ------------------------ SEARCH SERVICE ----------------------- */ + +int z_ElementSetName(ODR o, Z_ElementSetName **p, int opt) +{ + return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103, + opt); +} + +int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt) +{ + return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt); +} + +int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt; + return + z_DatabaseName(o, &(*p)->databaseName, 0) && + z_ElementSetName(o, &(*p)->elementSetName, 0) && + odr_sequence_end(o); +} + +int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt) +{ + if (o->direction == ODR_DECODE && !*p) + *p = nalloc(o, sizeof(**p)); + else if (!*p) + return opt; + + odr_implicit_settag(o, ODR_CONTEXT, 1); + if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements, + &(*p)->num_elements)) + return 1; + *p = 0; + return 0; +} + +int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic, + z_ElementSetName}, + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific, + z_DatabaseSpecific}, + {-1, -1, -1, -1, 0} + }; + + if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19, 0)) + return opt; + + if (o->direction == ODR_DECODE && !*p) + *p = nalloc(o, sizeof(**p)); + + if (odr_choice(o, arm, &(*p)->u, &(*p)->which) && + odr_constructed_enmd(o)) + return 1; + *p = 0; + return 0; +} + +/* ----------------------- RPN QUERY -----------------------*/ + +int z_RPNStructure(ODR o, Z_RPNStructure, int opt); + +int z_Operand(ODR o, Z_Operand **p, int opt) +{ + Odr_arm arm[] = + { + {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm}, + {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction ==ODR_DECODE && !*p) + *p = nalloc(o, sizeof(**p)); + else if (!*p) + return opt; + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt; +} + +int z_Complex(ODR o, Z_Complex **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt; + return + z_RPNStructure(o, &(*p)->s1, 0) && + z_RPNStructure(o, &(*p)->s2, 0) && + z_Operator(o, &(*p)->operator) && + odr_sequence_end(o); +} + +int z_RPNStructure(ODR o, Z_RPNStructure, int opt) +{ + Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand), + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex}, + {-1 -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE && !*p) + *p = nalloc(o, sizeof(**p)); + else if (!*p) + return opt; + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt; +} + +int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p)) + return opt; + return + odr_oid(o, &(*p)->attributeSetId, 0) && + z_RPNStructure(o, &(*p)->RPNStructure, 0) && + odr_sequence_end(o); +} + +/* -----------------------END RPN QUERY ----------------------- */ + +int z_Query(ODR o, Z_Query **p, int opt) +{ + Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_oct}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE && !*p) + *p = nalloc(o, sizeof(**p); + else if (!*p) + return opt; + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt; +} + int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt) { Z_SearchRequest *pp; @@ -97,9 +250,12 @@ int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt) odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) && odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT, 17, 9) && - - /* MORE */ - + odr_implicit(o, z_ElementSetNames, &pp->smallSetElementSetNames, + ODR_CONTEXT, 100, 1) && + odr_implicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames, + ODR_CONTEXT, 101, 1) && + z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) && + odr_explicit(o, z_query, ODR_CONTEXT, 21, 0) && odr_sequence_end(o); } -- 1.7.10.4