X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=asn%2Fproto.c;h=26ca7bf785df633abf185b196fb21b9c32891dc9;hp=3f17ff07ac34de233ba01a3851079a759cc026f8;hb=6edc916a5a8d44e1d7708f5018828e0d2020690b;hpb=f45eb9a4844db2509e24e38a043625310c1e32a1 diff --git a/asn/proto.c b/asn/proto.c index 3f17ff0..26ca7bf 100644 --- a/asn/proto.c +++ b/asn/proto.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: proto.c,v $ - * Revision 1.25 1995-05-25 11:00:08 quinn + * Revision 1.26 1995-06-02 09:49:13 quinn + * Adding access control + * + * Revision 1.25 1995/05/25 11:00:08 quinn * *** empty log message *** * * Revision 1.24 1995/05/22 13:58:18 quinn @@ -110,6 +113,97 @@ int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt) 11, opt); } +int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) && + odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) && + odr_sequence_end(o); +} + +int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo, + odr_visiblestring}, + {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo, + odr_octetstring}, + {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo, + odr_external}, + {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid}, + {-1, -1, -1, -1, 0} + }; + + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) && + odr_choice(o, arm, &(*p)->which, &(*p)->information) && + odr_sequence_end(o); +} + +int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt) +{ + if (o->direction == ODR_ENCODE) + *p = odr_malloc(o, sizeof(**p)); + + odr_implicit_settag(o, ODR_CONTEXT, 201); + if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list, + &(*p)->num_elements)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string, + odr_visiblestring}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric, + odr_integer}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +/* + * check tagging!! + */ +int z_Unit(ODR o, Z_Unit **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT, + 1, 1) && + odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT, + 2, 1) && + odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) && + odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) && + odr_sequence_end(o); +} + +int z_IntUnit(ODR o, Z_IntUnit **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) && + odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) && + odr_sequence_end(o); +} + /* ---------------------- INITIALIZE SERVICE ------------------- */ #if 0