From f15320bf6b50a0c02636405561ac8323ae901abd Mon Sep 17 00:00:00 2001 From: Lev Walkin Date: Thu, 3 Jun 2004 03:38:44 +0000 Subject: [PATCH] Initial revision --- AUTHORS | 1 + BUGS | 31 + COPYING | 27 + ChangeLog | 130 + INSTALL | 14 + MANIFEST | 9 + Makefile.am | 8 + Makefile.in | 430 ++ NEWS | 0 README | 69 + TODO | 18 + aclocal.m4 | 998 ++++ asn1c/Makefile.am | 25 + asn1c/Makefile.in | 556 ++ asn1c/README | 1 + asn1c/asn1c.1 | 99 + asn1c/asn1c.c | 267 + asn1c/check-parsing.sh | 18 + asn1c/tests/Makefile.am | 10 + asn1c/tests/Makefile.in | 284 + asn1c/tests/README | 6 + asn1c/tests/check-22.c | 141 + asn1c/tests/check-24.c | 94 + asn1c/tests/check-25.c | 252 + asn1c/tests/check-30.c | 116 + asn1c/tests/check-31.c | 175 + asn1c/tests/check-32.c | 21 + asn1c/tests/check-33.c | 21 + asn1c/tests/check-35.c | 277 + asn1c/tests/check-41.c | 315 + asn1c/tests/check-43.c | 24 + asn1c/tests/check-assembly.sh | 56 + config.guess | 1314 +++++ config.h.in | 81 + config.sub | 1410 +++++ configure | 6937 +++++++++++++++++++++++ configure.in | 95 + depcomp | 411 ++ doc/Makefile.am | 3 + doc/Makefile.in | 221 + doc/asn1c-usage.pdf | Bin 0 -> 129406 bytes examples/Makefile.am | 4 + examples/Makefile.in | 246 + examples/README | 6 + examples/clyx2asn1.pl | 51 + examples/crfc2asn1.pl | 86 + install-sh | 251 + libasn1compiler/Makefile.am | 28 + libasn1compiler/Makefile.in | 424 ++ libasn1compiler/asn1c_C.c | 2021 +++++++ libasn1compiler/asn1c_C.h | 69 + libasn1compiler/asn1c_internal.h | 81 + libasn1compiler/asn1c_lang.c | 32 + libasn1compiler/asn1c_lang.h | 28 + libasn1compiler/asn1c_misc.c | 232 + libasn1compiler/asn1c_misc.h | 28 + libasn1compiler/asn1c_out.c | 75 + libasn1compiler/asn1c_out.h | 31 + libasn1compiler/asn1c_save.c | 225 + libasn1compiler/asn1c_save.h | 6 + libasn1compiler/asn1compiler.c | 160 + libasn1compiler/asn1compiler.h | 41 + libasn1compiler/check_compiler.c | 7 + libasn1fix/Makefile.am | 36 + libasn1fix/Makefile.in | 454 ++ libasn1fix/asn1fix.c | 354 ++ libasn1fix/asn1fix.h | 30 + libasn1fix/asn1fix_bitstring.c | 230 + libasn1fix/asn1fix_bitstring.h | 6 + libasn1fix/asn1fix_class.c | 237 + libasn1fix/asn1fix_class.h | 16 + libasn1fix/asn1fix_compat.c | 132 + libasn1fix/asn1fix_compat.h | 14 + libasn1fix/asn1fix_constr.c | 364 ++ libasn1fix/asn1fix_constr.h | 24 + libasn1fix/asn1fix_cstring.c | 73 + libasn1fix/asn1fix_cstring.h | 6 + libasn1fix/asn1fix_dereft.c | 68 + libasn1fix/asn1fix_dereft.h | 6 + libasn1fix/asn1fix_derefv.c | 56 + libasn1fix/asn1fix_derefv.h | 6 + libasn1fix/asn1fix_enum.c | 136 + libasn1fix/asn1fix_enum.h | 6 + libasn1fix/asn1fix_export.c | 48 + libasn1fix/asn1fix_export.h | 32 + libasn1fix/asn1fix_integer.c | 161 + libasn1fix/asn1fix_integer.h | 6 + libasn1fix/asn1fix_internal.h | 106 + libasn1fix/asn1fix_misc.c | 276 + libasn1fix/asn1fix_misc.h | 47 + libasn1fix/asn1fix_param.c | 165 + libasn1fix/asn1fix_param.h | 6 + libasn1fix/asn1fix_retrieve.c | 366 ++ libasn1fix/asn1fix_retrieve.h | 73 + libasn1fix/asn1fix_tags.c | 47 + libasn1fix/asn1fix_tags.h | 6 + libasn1fix/asn1fix_value.c | 159 + libasn1fix/asn1fix_value.h | 28 + libasn1fix/check_fixer.c | 313 + libasn1parser/Makefile.am | 35 + libasn1parser/Makefile.in | 459 ++ libasn1parser/asn1p_class.c | 135 + libasn1parser/asn1p_class.h | 53 + libasn1parser/asn1p_constr.c | 91 + libasn1parser/asn1p_constr.h | 79 + libasn1parser/asn1p_expr.c | 112 + libasn1parser/asn1p_expr.h | 214 + libasn1parser/asn1p_expr2uclass.h | 41 + libasn1parser/asn1p_expr_str.h | 57 + libasn1parser/asn1p_l.c | 3861 +++++++++++++ libasn1parser/asn1p_l.l | 560 ++ libasn1parser/asn1p_list.h | 57 + libasn1parser/asn1p_module.c | 62 + libasn1parser/asn1p_module.h | 88 + libasn1parser/asn1p_oid.c | 95 + libasn1parser/asn1p_oid.h | 66 + libasn1parser/asn1p_param.c | 111 + libasn1parser/asn1p_param.h | 30 + libasn1parser/asn1p_ref.c | 137 + libasn1parser/asn1p_ref.h | 62 + libasn1parser/asn1p_value.c | 178 + libasn1parser/asn1p_value.h | 60 + libasn1parser/asn1p_xports.c | 34 + libasn1parser/asn1p_xports.h | 40 + libasn1parser/asn1p_y.c | 3484 ++++++++++++ libasn1parser/asn1p_y.h | 132 + libasn1parser/asn1p_y.y | 1982 +++++++ libasn1parser/asn1parser.c | 171 + libasn1parser/asn1parser.h | 73 + libasn1parser/expr-h.pl | 49 + libasn1print/Makefile.am | 14 + libasn1print/Makefile.in | 382 ++ libasn1print/README | 4 + libasn1print/asn1print.c | 456 ++ libasn1print/asn1print.h | 16 + ltconfig | 3096 ++++++++++ ltmain.sh | 4122 ++++++++++++++ missing | 283 + mkinstalldirs | 40 + skeletons/BIT_STRING.c | 96 + skeletons/BIT_STRING.h | 18 + skeletons/BMPString.c | 65 + skeletons/BMPString.h | 17 + skeletons/BOOLEAN.c | 147 + skeletons/BOOLEAN.h | 21 + skeletons/ENUMERATED.c | 26 + skeletons/ENUMERATED.h | 15 + skeletons/GeneralString.c | 27 + skeletons/GeneralString.h | 15 + skeletons/GeneralizedTime.c | 302 + skeletons/GeneralizedTime.h | 26 + skeletons/GraphicString.c | 27 + skeletons/GraphicString.h | 15 + skeletons/IA5String.c | 57 + skeletons/IA5String.h | 20 + skeletons/INTEGER.c | 305 + skeletons/INTEGER.h | 33 + skeletons/ISO646String.c | 27 + skeletons/ISO646String.h | 15 + skeletons/Makefile.am | 7 + skeletons/Makefile.in | 364 ++ skeletons/NULL.c | 51 + skeletons/NULL.h | 19 + skeletons/NativeEnumerated.c | 32 + skeletons/NativeEnumerated.h | 19 + skeletons/NativeInteger.c | 193 + skeletons/NativeInteger.h | 24 + skeletons/NumericString.c | 62 + skeletons/NumericString.h | 17 + skeletons/OBJECT_IDENTIFIER.c | 356 ++ skeletons/OBJECT_IDENTIFIER.h | 95 + skeletons/OCTET_STRING.c | 588 ++ skeletons/OCTET_STRING.h | 51 + skeletons/ObjectDescriptor.c | 27 + skeletons/ObjectDescriptor.h | 15 + skeletons/PrintableString.c | 81 + skeletons/PrintableString.h | 17 + skeletons/README | 6 + skeletons/RELATIVE-OID.c | 155 + skeletons/RELATIVE-OID.h | 30 + skeletons/T61String.c | 27 + skeletons/T61String.h | 15 + skeletons/TeletexString.c | 27 + skeletons/TeletexString.h | 15 + skeletons/UTCTime.c | 105 + skeletons/UTCTime.h | 26 + skeletons/UTF8String.c | 112 + skeletons/UTF8String.h | 22 + skeletons/UniversalString.c | 83 + skeletons/UniversalString.h | 17 + skeletons/VideotexString.c | 27 + skeletons/VideotexString.h | 15 + skeletons/VisibleString.c | 81 + skeletons/VisibleString.h | 17 + skeletons/asn_SEQUENCE_OF.c | 41 + skeletons/asn_SEQUENCE_OF.h | 36 + skeletons/asn_SET_OF.c | 89 + skeletons/asn_SET_OF.h | 46 + skeletons/asn_types.h | 63 + skeletons/ber_decoder.c | 230 + skeletons/ber_decoder.h | 77 + skeletons/ber_tlv_length.c | 159 + skeletons/ber_tlv_length.h | 40 + skeletons/ber_tlv_tag.c | 145 + skeletons/ber_tlv_tag.h | 52 + skeletons/constr_CHOICE.c | 627 ++ skeletons/constr_CHOICE.h | 65 + skeletons/constr_SEQUENCE.c | 588 ++ skeletons/constr_SEQUENCE.h | 53 + skeletons/constr_SEQUENCE_OF.c | 84 + skeletons/constr_SEQUENCE_OF.h | 21 + skeletons/constr_SET.c | 682 +++ skeletons/constr_SET.h | 90 + skeletons/constr_SET_OF.c | 530 ++ skeletons/constr_SET_OF.h | 38 + skeletons/constr_TYPE.c | 58 + skeletons/constr_TYPE.h | 98 + skeletons/constraints.c | 111 + skeletons/constraints.h | 57 + skeletons/der_encoder.c | 143 + skeletons/der_encoder.h | 73 + skeletons/tests/Makefile.am | 9 + skeletons/tests/Makefile.in | 411 ++ skeletons/tests/check-GeneralizedTime.c | 54 + skeletons/tests/check-INTEGER.c | 56 + skeletons/tests/check-OIDs.c | 228 + skeletons/tests/check-UTCTime.c | 54 + stamp-h.in | 1 + tests/00-empty-OK.asn1 | 1 + tests/01-empty-OK.asn1 | 14 + tests/02-garbage-NP.asn1 | 17 + tests/03-enum-OK.asn1 | 22 + tests/04-enum-SE.asn1 | 19 + tests/05-enum-SE.asn1 | 21 + tests/06-enum-SE.asn1 | 20 + tests/07-int-OK.asn1 | 26 + tests/08-int-SE.asn1 | 19 + tests/09-int-SE.asn1 | 20 + tests/10-int-OK.asn1 | 29 + tests/11-int-SE.asn1 | 18 + tests/12-int-SE.asn1 | 17 + tests/13-resolver-OK.asn1 | 47 + tests/14-resolver-OK.asn1 | 45 + tests/15-resolver-SE.asn1 | 35 + tests/16-constraint-OK.asn1 | 23 + tests/17-tags-OK.asn1 | 24 + tests/18-class-OK.asn1 | 36 + tests/19-param-OK.asn1 | 30 + tests/20-constr-OK.asn1 | 30 + tests/21-tags-OK.asn1 | 34 + tests/22-tags-OK.asn1 | 23 + tests/23-bits-OK.asn1 | 22 + tests/24-sequence-OK.asn1 | 21 + tests/25-misc-OK.asn1 | 29 + tests/26-sequence-SE.asn1 | 20 + tests/27-set-SE.asn1 | 21 + tests/28-tags-SE.asn1 | 26 + tests/29-tags-OK.asn1 | 26 + tests/30-set-OK.asn1 | 21 + tests/31-set-of-OK.asn1 | 21 + tests/32-sequence-of-OK.asn1 | 22 + tests/33-misc-OK.asn1 | 33 + tests/34-class-OK.asn1 | 51 + tests/35-set-choice-OK.asn1 | 36 + tests/36-indirect-choice-SE.asn1 | 25 + tests/37-indirect-choice-OK.asn1 | 32 + tests/38-comments-OK.asn1 | 33 + tests/39-sequence-of-OK.asn1 | 24 + tests/39-sequence-of-OK.asn1.-P | 171 + tests/40-int-optional-SE.asn1 | 27 + tests/41-int-optional-OK.asn1 | 27 + tests/42-real-life-OK.asn1 | 67 + tests/42-real-life-OK.asn1.-PR | 569 ++ tests/43-recursion-OK.asn1 | 26 + tests/Makefile.am | 2 + tests/Makefile.in | 219 + tests/README | 24 + 277 files changed, 55557 insertions(+) create mode 100644 AUTHORS create mode 100644 BUGS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 MANIFEST create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 README create mode 100644 TODO create mode 100644 aclocal.m4 create mode 100644 asn1c/Makefile.am create mode 100644 asn1c/Makefile.in create mode 100644 asn1c/README create mode 100644 asn1c/asn1c.1 create mode 100644 asn1c/asn1c.c create mode 100755 asn1c/check-parsing.sh create mode 100644 asn1c/tests/Makefile.am create mode 100644 asn1c/tests/Makefile.in create mode 100644 asn1c/tests/README create mode 100644 asn1c/tests/check-22.c create mode 100644 asn1c/tests/check-24.c create mode 100644 asn1c/tests/check-25.c create mode 100644 asn1c/tests/check-30.c create mode 100644 asn1c/tests/check-31.c create mode 100644 asn1c/tests/check-32.c create mode 100644 asn1c/tests/check-33.c create mode 100644 asn1c/tests/check-35.c create mode 100644 asn1c/tests/check-41.c create mode 100644 asn1c/tests/check-43.c create mode 100755 asn1c/tests/check-assembly.sh create mode 100755 config.guess create mode 100644 config.h.in create mode 100755 config.sub create mode 100755 configure create mode 100644 configure.in create mode 100755 depcomp create mode 100644 doc/Makefile.am create mode 100644 doc/Makefile.in create mode 100644 doc/asn1c-usage.pdf create mode 100644 examples/Makefile.am create mode 100644 examples/Makefile.in create mode 100644 examples/README create mode 100755 examples/clyx2asn1.pl create mode 100755 examples/crfc2asn1.pl create mode 100755 install-sh create mode 100644 libasn1compiler/Makefile.am create mode 100644 libasn1compiler/Makefile.in create mode 100644 libasn1compiler/asn1c_C.c create mode 100644 libasn1compiler/asn1c_C.h create mode 100644 libasn1compiler/asn1c_internal.h create mode 100644 libasn1compiler/asn1c_lang.c create mode 100644 libasn1compiler/asn1c_lang.h create mode 100644 libasn1compiler/asn1c_misc.c create mode 100644 libasn1compiler/asn1c_misc.h create mode 100644 libasn1compiler/asn1c_out.c create mode 100644 libasn1compiler/asn1c_out.h create mode 100644 libasn1compiler/asn1c_save.c create mode 100644 libasn1compiler/asn1c_save.h create mode 100644 libasn1compiler/asn1compiler.c create mode 100644 libasn1compiler/asn1compiler.h create mode 100644 libasn1compiler/check_compiler.c create mode 100644 libasn1fix/Makefile.am create mode 100644 libasn1fix/Makefile.in create mode 100644 libasn1fix/asn1fix.c create mode 100644 libasn1fix/asn1fix.h create mode 100644 libasn1fix/asn1fix_bitstring.c create mode 100644 libasn1fix/asn1fix_bitstring.h create mode 100644 libasn1fix/asn1fix_class.c create mode 100644 libasn1fix/asn1fix_class.h create mode 100644 libasn1fix/asn1fix_compat.c create mode 100644 libasn1fix/asn1fix_compat.h create mode 100644 libasn1fix/asn1fix_constr.c create mode 100644 libasn1fix/asn1fix_constr.h create mode 100644 libasn1fix/asn1fix_cstring.c create mode 100644 libasn1fix/asn1fix_cstring.h create mode 100644 libasn1fix/asn1fix_dereft.c create mode 100644 libasn1fix/asn1fix_dereft.h create mode 100644 libasn1fix/asn1fix_derefv.c create mode 100644 libasn1fix/asn1fix_derefv.h create mode 100644 libasn1fix/asn1fix_enum.c create mode 100644 libasn1fix/asn1fix_enum.h create mode 100644 libasn1fix/asn1fix_export.c create mode 100644 libasn1fix/asn1fix_export.h create mode 100644 libasn1fix/asn1fix_integer.c create mode 100644 libasn1fix/asn1fix_integer.h create mode 100644 libasn1fix/asn1fix_internal.h create mode 100644 libasn1fix/asn1fix_misc.c create mode 100644 libasn1fix/asn1fix_misc.h create mode 100644 libasn1fix/asn1fix_param.c create mode 100644 libasn1fix/asn1fix_param.h create mode 100644 libasn1fix/asn1fix_retrieve.c create mode 100644 libasn1fix/asn1fix_retrieve.h create mode 100644 libasn1fix/asn1fix_tags.c create mode 100644 libasn1fix/asn1fix_tags.h create mode 100644 libasn1fix/asn1fix_value.c create mode 100644 libasn1fix/asn1fix_value.h create mode 100644 libasn1fix/check_fixer.c create mode 100644 libasn1parser/Makefile.am create mode 100644 libasn1parser/Makefile.in create mode 100644 libasn1parser/asn1p_class.c create mode 100644 libasn1parser/asn1p_class.h create mode 100644 libasn1parser/asn1p_constr.c create mode 100644 libasn1parser/asn1p_constr.h create mode 100644 libasn1parser/asn1p_expr.c create mode 100644 libasn1parser/asn1p_expr.h create mode 100644 libasn1parser/asn1p_expr2uclass.h create mode 100644 libasn1parser/asn1p_expr_str.h create mode 100644 libasn1parser/asn1p_l.c create mode 100644 libasn1parser/asn1p_l.l create mode 100644 libasn1parser/asn1p_list.h create mode 100644 libasn1parser/asn1p_module.c create mode 100644 libasn1parser/asn1p_module.h create mode 100644 libasn1parser/asn1p_oid.c create mode 100644 libasn1parser/asn1p_oid.h create mode 100644 libasn1parser/asn1p_param.c create mode 100644 libasn1parser/asn1p_param.h create mode 100644 libasn1parser/asn1p_ref.c create mode 100644 libasn1parser/asn1p_ref.h create mode 100644 libasn1parser/asn1p_value.c create mode 100644 libasn1parser/asn1p_value.h create mode 100644 libasn1parser/asn1p_xports.c create mode 100644 libasn1parser/asn1p_xports.h create mode 100644 libasn1parser/asn1p_y.c create mode 100644 libasn1parser/asn1p_y.h create mode 100644 libasn1parser/asn1p_y.y create mode 100644 libasn1parser/asn1parser.c create mode 100644 libasn1parser/asn1parser.h create mode 100755 libasn1parser/expr-h.pl create mode 100644 libasn1print/Makefile.am create mode 100644 libasn1print/Makefile.in create mode 100644 libasn1print/README create mode 100644 libasn1print/asn1print.c create mode 100644 libasn1print/asn1print.h create mode 100755 ltconfig create mode 100644 ltmain.sh create mode 100755 missing create mode 100755 mkinstalldirs create mode 100644 skeletons/BIT_STRING.c create mode 100644 skeletons/BIT_STRING.h create mode 100644 skeletons/BMPString.c create mode 100644 skeletons/BMPString.h create mode 100644 skeletons/BOOLEAN.c create mode 100644 skeletons/BOOLEAN.h create mode 100644 skeletons/ENUMERATED.c create mode 100644 skeletons/ENUMERATED.h create mode 100644 skeletons/GeneralString.c create mode 100644 skeletons/GeneralString.h create mode 100644 skeletons/GeneralizedTime.c create mode 100644 skeletons/GeneralizedTime.h create mode 100644 skeletons/GraphicString.c create mode 100644 skeletons/GraphicString.h create mode 100644 skeletons/IA5String.c create mode 100644 skeletons/IA5String.h create mode 100644 skeletons/INTEGER.c create mode 100644 skeletons/INTEGER.h create mode 100644 skeletons/ISO646String.c create mode 100644 skeletons/ISO646String.h create mode 100644 skeletons/Makefile.am create mode 100644 skeletons/Makefile.in create mode 100644 skeletons/NULL.c create mode 100644 skeletons/NULL.h create mode 100644 skeletons/NativeEnumerated.c create mode 100644 skeletons/NativeEnumerated.h create mode 100644 skeletons/NativeInteger.c create mode 100644 skeletons/NativeInteger.h create mode 100644 skeletons/NumericString.c create mode 100644 skeletons/NumericString.h create mode 100644 skeletons/OBJECT_IDENTIFIER.c create mode 100644 skeletons/OBJECT_IDENTIFIER.h create mode 100644 skeletons/OCTET_STRING.c create mode 100644 skeletons/OCTET_STRING.h create mode 100644 skeletons/ObjectDescriptor.c create mode 100644 skeletons/ObjectDescriptor.h create mode 100644 skeletons/PrintableString.c create mode 100644 skeletons/PrintableString.h create mode 100644 skeletons/README create mode 100644 skeletons/RELATIVE-OID.c create mode 100644 skeletons/RELATIVE-OID.h create mode 100644 skeletons/T61String.c create mode 100644 skeletons/T61String.h create mode 100644 skeletons/TeletexString.c create mode 100644 skeletons/TeletexString.h create mode 100644 skeletons/UTCTime.c create mode 100644 skeletons/UTCTime.h create mode 100644 skeletons/UTF8String.c create mode 100644 skeletons/UTF8String.h create mode 100644 skeletons/UniversalString.c create mode 100644 skeletons/UniversalString.h create mode 100644 skeletons/VideotexString.c create mode 100644 skeletons/VideotexString.h create mode 100644 skeletons/VisibleString.c create mode 100644 skeletons/VisibleString.h create mode 100644 skeletons/asn_SEQUENCE_OF.c create mode 100644 skeletons/asn_SEQUENCE_OF.h create mode 100644 skeletons/asn_SET_OF.c create mode 100644 skeletons/asn_SET_OF.h create mode 100644 skeletons/asn_types.h create mode 100644 skeletons/ber_decoder.c create mode 100644 skeletons/ber_decoder.h create mode 100644 skeletons/ber_tlv_length.c create mode 100644 skeletons/ber_tlv_length.h create mode 100644 skeletons/ber_tlv_tag.c create mode 100644 skeletons/ber_tlv_tag.h create mode 100644 skeletons/constr_CHOICE.c create mode 100644 skeletons/constr_CHOICE.h create mode 100644 skeletons/constr_SEQUENCE.c create mode 100644 skeletons/constr_SEQUENCE.h create mode 100644 skeletons/constr_SEQUENCE_OF.c create mode 100644 skeletons/constr_SEQUENCE_OF.h create mode 100644 skeletons/constr_SET.c create mode 100644 skeletons/constr_SET.h create mode 100644 skeletons/constr_SET_OF.c create mode 100644 skeletons/constr_SET_OF.h create mode 100644 skeletons/constr_TYPE.c create mode 100644 skeletons/constr_TYPE.h create mode 100644 skeletons/constraints.c create mode 100644 skeletons/constraints.h create mode 100644 skeletons/der_encoder.c create mode 100644 skeletons/der_encoder.h create mode 100644 skeletons/tests/Makefile.am create mode 100644 skeletons/tests/Makefile.in create mode 100644 skeletons/tests/check-GeneralizedTime.c create mode 100644 skeletons/tests/check-INTEGER.c create mode 100644 skeletons/tests/check-OIDs.c create mode 100644 skeletons/tests/check-UTCTime.c create mode 100644 stamp-h.in create mode 100644 tests/00-empty-OK.asn1 create mode 100644 tests/01-empty-OK.asn1 create mode 100644 tests/02-garbage-NP.asn1 create mode 100644 tests/03-enum-OK.asn1 create mode 100644 tests/04-enum-SE.asn1 create mode 100644 tests/05-enum-SE.asn1 create mode 100644 tests/06-enum-SE.asn1 create mode 100644 tests/07-int-OK.asn1 create mode 100644 tests/08-int-SE.asn1 create mode 100644 tests/09-int-SE.asn1 create mode 100644 tests/10-int-OK.asn1 create mode 100644 tests/11-int-SE.asn1 create mode 100644 tests/12-int-SE.asn1 create mode 100644 tests/13-resolver-OK.asn1 create mode 100644 tests/14-resolver-OK.asn1 create mode 100644 tests/15-resolver-SE.asn1 create mode 100644 tests/16-constraint-OK.asn1 create mode 100644 tests/17-tags-OK.asn1 create mode 100644 tests/18-class-OK.asn1 create mode 100644 tests/19-param-OK.asn1 create mode 100644 tests/20-constr-OK.asn1 create mode 100644 tests/21-tags-OK.asn1 create mode 100644 tests/22-tags-OK.asn1 create mode 100644 tests/23-bits-OK.asn1 create mode 100644 tests/24-sequence-OK.asn1 create mode 100644 tests/25-misc-OK.asn1 create mode 100644 tests/26-sequence-SE.asn1 create mode 100644 tests/27-set-SE.asn1 create mode 100644 tests/28-tags-SE.asn1 create mode 100644 tests/29-tags-OK.asn1 create mode 100644 tests/30-set-OK.asn1 create mode 100644 tests/31-set-of-OK.asn1 create mode 100644 tests/32-sequence-of-OK.asn1 create mode 100644 tests/33-misc-OK.asn1 create mode 100644 tests/34-class-OK.asn1 create mode 100644 tests/35-set-choice-OK.asn1 create mode 100644 tests/36-indirect-choice-SE.asn1 create mode 100644 tests/37-indirect-choice-OK.asn1 create mode 100644 tests/38-comments-OK.asn1 create mode 100644 tests/39-sequence-of-OK.asn1 create mode 100644 tests/39-sequence-of-OK.asn1.-P create mode 100644 tests/40-int-optional-SE.asn1 create mode 100644 tests/41-int-optional-OK.asn1 create mode 100644 tests/42-real-life-OK.asn1 create mode 100644 tests/42-real-life-OK.asn1.-PR create mode 100644 tests/43-recursion-OK.asn1 create mode 100644 tests/Makefile.am create mode 100644 tests/Makefile.in create mode 100644 tests/README diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..d510bcde --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Lev Walkin diff --git a/BUGS b/BUGS new file mode 100644 index 00000000..3e8145c0 --- /dev/null +++ b/BUGS @@ -0,0 +1,31 @@ + +0. ASN.1 grammar parser is written mostly with respect to constructing a tree, +so a tree destruction is not fully supported and certain memory leaks are +known. Not a huge problem for run-once programs like a compiler. +NOTE: This statement does not apply to the target code _produced_ + by the compiler. + +1. REAL type is not supported yet. + +2. For purposes of compilation, INTEGER type is modelled using a large +static type (asn_integer_t), but defined as any positive or negative value +by ASN.1. Not a problem as most specifications use very small values anyway. +NOTE: This statement does not apply to the target code _produced_ + by the compiler. + +3. ASN Macros are prohibited by the current ASN.1 standard, +and are not supported. + +4. Multiple tags applied at the same level are not supported: + BadTags ::= [0] EXPLICIT [2] IMPLICIT OtherType + The same thing could be achieved by using the indirection: + GoodTags ::= [0] EXPLICIT OtherTypePtr + OtherTypePtr ::= [2] IMPLICIT OtherType + +5. Mixed definite/indefinite length in a _single_ BER tags sequence is not +supported. Should not be a problem in the real world. Please note that it +is still possible, for example, to encode a wrapper structure using definite +length, and encode its substructure member using indefinite length. The BER +decoder is perfectly capable of decoding such sequences. + + diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..5addee94 --- /dev/null +++ b/COPYING @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..45a11c82 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,130 @@ + +0.8.10: 2004-Jun-02 + + * Added const qualifier where necessary. + * Changed position of outmost_tag fetcher within asn1_TYPE_descriptor_t + structure. + +0.8.9: 2004-May-26 + + * Added *_{get|set}_arcs_*() functions for OBJECT IDENTIFIER + and RELATIVE-OID, together with test cases. + +0.8.8: 2004-May-09 + + * Introduced subtype constraints support (incomplete!). + * Fixed compiler. If the last member of the SEQUENCE is OPTIONAL + and absent in the encoding, and the type is extensible (...) or + EXTENSIBILITY IMPLIED flag is set, then the structure could not + be correctly decoded. (Severity: high, Security impact: low). + * Compiler: fixed recursive ASN.1 types inclusion (Severity: low, + Security impact: none). + * Parser: IMPORTS/FROM fixes, now allowing multiple sections. + * Code compiled and checked on PowerPC (@MacOS X). No major portability + issues experienced. + +0.8.7: 2004-Apr-11 T-version-0-8-7 + + * Fixed SEQUENCE BER decoder: if the last member of the SEQUENCE is + OPTIONAL and absent in the encoding, RC_FAIL was returned instead + of RC_OK (Severity: high, Security impact: low). + * Added test case to check the above problem. + * Added test case to check -fnative-integers mode. + +0.8.6: 2004-Apr-03 T-version-0-8-6 + + * Fixed compiler output for embedded ASN.1 structures. + +0.8.5: 2004-Mar-28 T-version-0-8-5 + + * Fixed ber_tlv_length() computation problem (Severity: blocker, + Security impact: none). + Reported by + +0.8.4: 2004-Mar-22 + + * Removed RC_ITAG enumeration element from BER decoder. + This return code did not have much practical value. + +0.8.3: 2004-Mar-14 T-version-0-8-3 + + * Fixed SET::BER decoder: restart after reaching a buffer boundary + weas broken (Severity: blocker, Security impact: low). + * Fixed OCTET STRING::BER decoder: restart after reaching a buffer + boundary was broken (Severity: blocker, Security impact: low). + Reported by + * Added test cases to check decoders restartability. + * Slightly more general INTEGER2long decoder. + * Allowed nested /* C-type */ comments, as per X.680:2002. + +0.8.2: 2004-Mar-01 T-version-0-8-2 + + * Fixed SEQUENCE BER decoder: an OPTIONAL element was required, where + should not have been (Severity: major; Security impact: low). + * Fixed print_struct pointer inheritance. + * Added -fno-c99 and -funnamed-unions + +0.8.1: 2004-Feb-22 + + * -R switch to asn1c: Omit support code, compile only the tables. + * Introduced NativeInteger pseudotype. + * Corrected the informal print_struct()'s output format. + +0.8.0: 2004-Feb-03 T-version-0-8-0 + + * Some documentation is created (a .pdf and a short manual page). + * Last touches to the code. + +0.7.9: 2004-Feb-01 T-version-0-7-9 + + * Human readable printing support. + * Support for implicit (standard) constraints. + +0.7.8: 2004-Jan-31 + + * SET now rejects duplicate fields in the data stream. + +0.7.7: 2004-Jan-25 + + * Added types: GeneralizedTime and UTCTime. + +0.7.6: 2004-Jan-24 T-version-0-7-6 + + * DER encoding of a SET OF now involves dynamic sorting. + +0.7.5: 2004-Jan-24 T-version-0-7-5 + + * DER encoding of a SET with untagged CHOICE + now involves dynamic sorting. + +0.7.0: 2004-Jan-19 T-version-0-7-0 + + * A bunch of DER encoders is implemented. + +0.6.6: 2004-Jan-11 + + * Implemented CHOICE decoder. + * Implemented destructors support. + +0.6.5: 2004-Jan-03 + + * Implemented SET decoder. + * Implemented SET OF and SEQUENCE OF decoders. + +0.6.4: 2003-Dec-31 + + * Implemented BOOLEAN, NULL, ENUMERATED decoders. + * Implemented OCTET STRING decoder. + * Implemented BIT STRING decoder. + +0.6: 2003-Dec-30 + + * First decoding of a BER-encoded structure! + +0.5: 2003-Dec-28 + + * Framework and most of the compiler backbone coding done. + +0.1: 2003-Nov-28 + + * Programming started. diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..5d2d54c5 --- /dev/null +++ b/INSTALL @@ -0,0 +1,14 @@ +QUICK START INSTALLATION +======================== + +./configure # Configure the build infrastructure for your platform +make # Build the libraries and the compiler +make check # Ensure that the code is still behaving well + # after compiling on your platform +make install # Install the compiler into standard location + + +QUICK USAGE GUIDE +================= + +For usage guide and more information please refer to README file. diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 00000000..1be9e9f6 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,9 @@ +libasn1compiler +libasn1parser +libasn1print +libasn1fix +skeletons +examples +tests +asn1c +doc diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..da7f6821 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,8 @@ + +SUBDIRS = \ + libasn1parser libasn1print \ + libasn1fix libasn1compiler \ + skeletons examples tests \ + doc asn1c + +EXTRA_DIST = BUGS MANIFEST diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..1ce7ad4c --- /dev/null +++ b/Makefile.in @@ -0,0 +1,430 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +SUBDIRS = \ + libasn1parser libasn1print \ + libasn1fix libasn1compiler \ + skeletons examples tests \ + doc asn1c + + +EXTRA_DIST = BUGS MANIFEST +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ + Makefile.am Makefile.in NEWS TODO aclocal.m4 config.guess \ + config.h.in config.sub configure configure.in depcomp \ + install-sh ltconfig ltmain.sh missing mkinstalldirs +DIST_SUBDIRS = $(SUBDIRS) +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$@ $(SHELL) ./config.status + +$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h stamp-hT + @echo timestamp > stamp-hT 2> /dev/null + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @mv stamp-hT stamp-h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/./stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/./stamp-h.in; \ + $(MAKE) $(srcdir)/./stamp-h.in; \ + else :; fi +$(srcdir)/./stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) + @rm -f $(srcdir)/./stamp-h.in $(srcdir)/./stamp-h.inT + @echo timestamp > $(srcdir)/./stamp-h.inT 2> /dev/null + cd $(top_srcdir) && $(AUTOHEADER) + @mv $(srcdir)/./stamp-h.inT $(srcdir)/./stamp-h.in + +distclean-hdr: + -rm -f config.h +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = . +# Avoid unsightly `./'. +distdir = $(PACKAGE)-$(VERSION) + +GZIP_ENV = --best + +distdir: $(DISTFILES) + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) + mkdir $(distdir) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir) + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + chmod a-w $(distdir) + dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \ + && cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ + || (echo "Error: files left after uninstall" 1>&2; \ + exit 1) ) \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && $(MAKE) $(AM_MAKEFLAGS) distclean \ + && rm -f $(distdir).tar.gz \ + && (test `find . -type f -print | wc -l` -eq 0 \ + || (echo "Error: files left after distclean" 1>&2; \ + exit 1) ) + -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir) + @echo "$(distdir).tar.gz is ready for distribution" | \ + sed 'h;s/./=/g;p;x;p;x' +check-am: all-am +check: check-recursive +all-am: Makefile config.h +installdirs: installdirs-recursive +installdirs-am: + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +dist-all: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) +distclean: distclean-recursive + -rm -f config.status config.cache config.log +distclean-am: clean-am distclean-generic distclean-hdr distclean-libtool \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ + clean-generic clean-libtool clean-recursive dist dist-all \ + distcheck distclean distclean-generic distclean-hdr \ + distclean-libtool distclean-recursive distclean-tags distdir \ + dvi dvi-am dvi-recursive info info-am info-recursive install \ + install-am install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-libtool mostlyclean-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-info-am \ + uninstall-info-recursive uninstall-recursive + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/README b/README new file mode 100644 index 00000000..586bb3d3 --- /dev/null +++ b/README @@ -0,0 +1,69 @@ +WHAT TO READ? +============= + +For quick installation tips read INSTALL. + +For more complete documentation on this compiler and on using the +results of compilation please look into ./doc directory. + +An excellent book on ASN.1 is written by Olivier Dubuisson: +"ASN.1 Communication between heterogeneous systems", ISBN:0-12-6333361-0. + + +QUICK START +=========== + +After building [and installing] the compiler (see INSTALL), you may use +the asn1c command to compile the ASN.1 specification: + + asn1c + +If several specifications contain interdependencies, all of them must be +specified: + + asn1c ... + +The ./examples directory contains several ASN.1 modules and a script to +extract ASN.1 modules from RFC documents. To compile X.509 PKI module: + + ./asn1c/asn1c -P ./examples/*PKIX*93*.asn1 + +In this example, -P option is used to instruct the compiler to print the +compiled text on the standard output instead of creating multiple .c +and .h files for every ASN.1 type found inside the specified files. +This is useful for debugging and tests automation. + +The compiler -E and -EF options are used for testing the parser and +the semantic fixer, respectively. These options will instruct the compiler +to dump out the parsed (and fixed) ASN.1 specification as it was +"understood" by the compiler. It might be useful for checking +whether a particular syntactic construction is properly supported +by the compiler. + + asn1c -EF + + +MODEL OF OPERATION +================== + +The asn1c compiler works by processing the ASN.1 module specification +in several stages: +1. In the first stage, the ASN.1 file is parsed. + (Parsing produces an ASN.1 syntax tree for the subsequent levels.) +2. In the second stage, the syntax tree is "fixed". + (Fixing is done by checking the tree for semantic errors + and by transforming the tree into the canonical representation.) +3. In the third stage, the syntax tree is compiled into the target language. + +There are several command-line options reserved for printing the results +after each stage of operation: + + => print (-E) + => => print (-E -F) + => => => print (-P) + => => => save-compiled [default] + + +-- +Lev Walkin +vlm@lionet.info diff --git a/TODO b/TODO new file mode 100644 index 00000000..1316b857 --- /dev/null +++ b/TODO @@ -0,0 +1,18 @@ +MAJOR: + +1. Support for the explicit subtype constraints: + Name ::= IA5String (FROM("A".."Z")) + Status: in progress. + +2. Support for Information Object Classes. + Status: support for parsing IOCs is mostly present. Support for slicing + the IOCs to produce "views" is not yet designed. + +3. Support for PER encoding. Requires advanced subtype constraints support (#1) + +4. Support for XER encoding. + +MISC: + +1. Make sure asn1_DEF__tags is not an empty structure. + diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 00000000..f71fa03e --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,998 @@ +# aclocal.m4 generated automatically by aclocal 1.5 + +# Copyright 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 5 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED. +# The purpose of this macro is to provide the user with a means to +# check macros which are provided without letting her know how the +# information is coded. +# If this macro is not defined by Autoconf, define it here. +ifdef([AC_PROVIDE_IFELSE], + [], + [define([AC_PROVIDE_IFELSE], + [ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE]) +# ---------------------------------------------- +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first]) +fi + +# Define the identity of the package. +PACKAGE=$1 +AC_SUBST(PACKAGE)dnl +VERSION=$2 +AC_SUBST(VERSION)dnl +ifelse([$3],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])]) + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. +ifdef([m4_pattern_allow], + [m4_pattern_allow([^AM_[A-Z]+FLAGS])])dnl + +# Autoconf 2.50 always computes EXEEXT. However we need to be +# compatible with 2.13, for now. So we always define EXEEXT, but we +# don't compute it. +AC_SUBST(EXEEXT) +# Similar for OBJEXT -- only we only use OBJEXT if the user actually +# requests that it be used. This is a bit dumb. +: ${OBJEXT=o} +AC_SUBST(OBJEXT) + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG(AMTAR, tar) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl +AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_PROVIDE_IFELSE([AC_PROG_][CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_][CC], + defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_][CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_][CXX], + defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) + +# +# Check to make sure that the build environment is sane. +# + +# serial 3 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + + +# serial 2 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + am_backtick='`' + AC_MSG_WARN([${am_backtick}missing' script is too old or missing]) +fi +]) + +# AM_AUX_DIR_EXPAND + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], [ +# expand $ac_aux_dir to an absolute path +am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` +]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# serial 4 -*- Autoconf -*- + + + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + + +# _AM_DEPENDENCIES(NAME) +# --------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX" or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'] + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +$1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type" +AC_SUBST([$1DEPMODE]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null +AC_SUBST(DEPDIR) +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +pushdef([subst], defn([AC_SUBST])) +subst(AMDEPBACKSLASH) +popdef([subst]) +]) + +# Generate code to set up dependency tracking. +# This macro should only be invoked once -- use via AC_REQUIRE. +# Usage: +# AM_OUTPUT_DEPENDENCY_COMMANDS + +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],[ +AC_OUTPUT_COMMANDS([ +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +], [AMDEP_TRUE="$AMDEP_TRUE" +ac_aux_dir="$ac_aux_dir"])]) + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include='#' +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote='"' + _am_result=BSD + fi +fi +AC_SUBST(am__include) +AC_SUBST(am__quote) +AC_MSG_RESULT($_am_result) +rm -f confinc confmf +]) + +# serial 3 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +# +# FIXME: Once using 2.50, use this: +# m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_DEFUN([AM_CONDITIONAL], +[ifelse([$1], [TRUE], + [errprint(__file__:__line__: [$0: invalid condition: $1 +])dnl +m4exit(1)])dnl +ifelse([$1], [FALSE], + [errprint(__file__:__line__: [$0: invalid condition: $1 +])dnl +m4exit(1)])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi]) + +# Add --enable-maintainer-mode option to configure. +# From Jim Meyering + +# serial 1 + +AC_DEFUN([AM_MAINTAINER_MODE], +[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode is disabled by default + AC_ARG_ENABLE(maintainer-mode, +[ --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + USE_MAINTAINER_MODE=$enableval, + USE_MAINTAINER_MODE=no) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST(MAINT)dnl +] +) + + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library, adds --enable-ltdl-convenience to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library, and adds --enable-ltdl-install to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +# serial 3 + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. We must strip everything past the first ":", +# and everything past the last "/". + +AC_PREREQ([2.12]) + +AC_DEFUN([AM_CONFIG_HEADER], +[ifdef([AC_FOREACH],dnl + [dnl init our file count if it isn't already + m4_ifndef([_AM_Config_Header_Index], m4_define([_AM_Config_Header_Index], [0])) + dnl prepare to store our destination file list for use in config.status + AC_FOREACH([_AM_File], [$1], + [m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*])) + m4_define([_AM_Config_Header_Index], m4_incr(_AM_Config_Header_Index)) + dnl and add it to the list of files AC keeps track of, along + dnl with our hook + AC_CONFIG_HEADERS(_AM_File, +dnl COMMANDS, [, INIT-CMDS] +[# update the timestamp +echo timestamp >"AS_ESCAPE(_AM_DIRNAME(]_AM_Dest[))/stamp-h]_AM_Config_Header_Index[" +][$2]m4_ifval([$3], [, [$3]]))dnl AC_CONFIG_HEADERS + m4_popdef([_AM_Dest])])],dnl +[AC_CONFIG_HEADER([$1]) + AC_OUTPUT_COMMANDS( + ifelse(patsubst([$1], [[^ ]], []), + [], + [test -z "$CONFIG_HEADERS" || echo timestamp >dnl + patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),dnl +[am_indx=1 +for am_file in $1; do + case " \$CONFIG_HEADERS " in + *" \$am_file "*) + am_dir=\`echo \$am_file |sed 's%:.*%%;s%[^/]*\$%%'\` + if test -n "\$am_dir"; then + am_tmpdir=\`echo \$am_dir |sed 's%^\(/*\).*\$%\1%'\` + for am_subdir in \`echo \$am_dir |sed 's%/% %'\`; do + am_tmpdir=\$am_tmpdir\$am_subdir/ + if test ! -d \$am_tmpdir; then + mkdir \$am_tmpdir + fi + done + fi + echo timestamp > "\$am_dir"stamp-h\$am_indx + ;; + esac + am_indx=\`expr \$am_indx + 1\` +done]) +])]) # AM_CONFIG_HEADER + +# _AM_DIRNAME(PATH) +# ----------------- +# Like AS_DIRNAME, only do it during macro expansion +AC_DEFUN([_AM_DIRNAME], + [m4_if(m4_regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, + m4_if(m4_regexp([$1], [^//\([^/]\|$\)]), -1, + m4_if(m4_regexp([$1], [^/.*]), -1, + [.], + m4_patsubst([$1], [^\(/\).*], [\1])), + m4_patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), + m4_patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl +]) # _AM_DIRNAME + + +# AM_PROG_LEX +# Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT +AC_DEFUN([AM_PROG_LEX], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +AC_CHECK_PROGS(LEX, flex lex, [${am_missing_run}flex]) +dnl AC_PROG_LEX +AC_DECL_YYTEXT]) + diff --git a/asn1c/Makefile.am b/asn1c/Makefile.am new file mode 100644 index 00000000..2363c189 --- /dev/null +++ b/asn1c/Makefile.am @@ -0,0 +1,25 @@ + +SUBDIRS = . tests + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1compiler \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1print \ + -I${top_srcdir}/libasn1fix \ + -DDATADIR=\"${pkgdatadir}\" + +LDADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la \ + ${top_builddir}/libasn1print/libasn1print.la \ + ${top_builddir}/libasn1compiler/libasn1compiler.la + +bin_PROGRAMS = asn1c + +dist_man1_MANS = asn1c.1 + +check_SCRIPTS = check-parsing.sh +TESTS = check-parsing.sh +EXTRA_DIST = check-parsing.sh +CLEANFILES = .check-parsing.*.tmp diff --git a/asn1c/Makefile.in b/asn1c/Makefile.in new file mode 100644 index 00000000..6b7805bc --- /dev/null +++ b/asn1c/Makefile.in @@ -0,0 +1,556 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +SUBDIRS = . tests + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1compiler \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1print \ + -I${top_srcdir}/libasn1fix \ + -DDATADIR=\"${pkgdatadir}\" + + +LDADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la \ + ${top_builddir}/libasn1print/libasn1print.la \ + ${top_builddir}/libasn1compiler/libasn1compiler.la + + +bin_PROGRAMS = asn1c + +dist_man1_MANS = asn1c.1 + +check_SCRIPTS = check-parsing.sh +TESTS = check-parsing.sh +EXTRA_DIST = check-parsing.sh +CLEANFILES = .check-parsing.*.tmp +subdir = asn1c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +bin_PROGRAMS = asn1c$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + +asn1c_SOURCES = asn1c.c +asn1c_OBJECTS = asn1c.$(OBJEXT) +asn1c_LDADD = $(LDADD) +asn1c_DEPENDENCIES = ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la \ + ${top_builddir}/libasn1print/libasn1print.la \ + ${top_builddir}/libasn1compiler/libasn1compiler.la +asn1c_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1c.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = asn1c.c + +NROFF = nroff +MANS = $(dist_man1_MANS) + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README $(dist_man1_MANS) Makefile.am Makefile.in +DIST_SUBDIRS = $(SUBDIRS) +SOURCES = asn1c.c + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu asn1c/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +asn1c$(EXEEXT): $(asn1c_OBJECTS) $(asn1c_DEPENDENCIES) + @rm -f asn1c$(EXEEXT) + $(LINK) $(asn1c_LDFLAGS) $(asn1c_OBJECTS) $(asn1c_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +man1dir = $(mandir)/man1 +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(man1dir) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ + rm -f $(DESTDIR)$(man1dir)/$$inst; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: install-man1 + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man + +uninstall-info: uninstall-info-recursive + +uninstall-man: uninstall-man1 + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-TESTS check-am \ + clean clean-binPROGRAMS clean-generic clean-libtool \ + clean-recursive distclean distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-recursive \ + distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-binPROGRAMS \ + install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-man1 install-recursive install-strip installcheck \ + installcheck-am installdirs installdirs-am \ + installdirs-recursive maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ + tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am \ + uninstall-info-recursive uninstall-man uninstall-man1 \ + uninstall-recursive + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/asn1c/README b/asn1c/README new file mode 100644 index 00000000..158cd115 --- /dev/null +++ b/asn1c/README @@ -0,0 +1 @@ +The ASN.1 Compiler diff --git a/asn1c/asn1c.1 b/asn1c/asn1c.1 new file mode 100644 index 00000000..1b58f4df --- /dev/null +++ b/asn1c/asn1c.1 @@ -0,0 +1,99 @@ +.de Id +.. +.Id $Id" +.TH ASN1C 1 "\*(Dt" "ASN.1 Compiler" "ASN.1 Compiler" +.SH NAME +asn1c \- ASN.1 Compiler +.ND ASN.1 compiler +.SH SYNOPSIS +.B asn1c +.RI "[ " option " | " filename " ].\|.\|." +.SH DESCRIPTION +asn1c is a tool to compile the ASN.1 specifications into C language structures +and accompanying routines to perform data encoding and decoding. +.SH OPTIONS +.TP +.B Overall Options +\-E +\-F +\-L +\-N +\-P +.RI "\-S " directory +\-R +.TP +.B Language Options +.br +\-ftypes88 +\-fnative-integers +\-fno-c99 +\-funnamed-unions +.TP +.B Warning Options +.br +\-Werror +\-Wdebug-lexer +\-Wdebug-fixer +\-Wdebug-compiler +.SH OVERALL OPTIONS +.TP +.B \-E +Stop after the parsing stage. The output is reconstructed ASN.1 +specification code, which is sent to the standard output. +.TP +.B \-F +Used together with \c +.B \-E\c +, instructs the compiler to stop after the ASN.1 syntax +tree fixing stage and dump the reconstructed ASN.1 specification +to the standard output. +.TP +.B \-L +Generate "-- #line" comments in +.B -E +output. +.TP +.B \-N +Do not generate certain type of comments in +.B -E +output. +.TP +.B \-P +Dump the compiled output to the standard output instead of creating the +target language files on disk. +.TP +.B \-S directory +Use the specified directory with ASN.1 skeleton files. +.TP +.B \-R +Restrict the compiler to generate only the ASN.1 tables, +omitting the usual support code. +.SH LANGUAGE OPTIONS +.TP +.B \-ftypes88 +Use only ASN.1:1988 embedded types. +.TP +.B \-fnative-integers +Use native machine's integer types whenever possible, +instead of the complex ASN.1 INTEGER and ENUMERATED types. +.TP +.B \-fno-c99 +Disable use of certain C99 extensions, like designated initializers. +.TP +.B \-funnamed-unions +Enable unnamed unions in structures definitions. +.SH WARNING OPTIONS +.TP +.B \-Werror +Treat warnings as errors; abort if any warning is produced. +.TP +.B \-Wdebug-lexer +Enable lexer debugging during the ASN.1 parsing stage. +.TP +.B \-Wdebug-fixer +Enable ASN.1 syntax tree fixer debugging during the fixing stage. +.TP +.B \-Wdebug-compiler +Enable debugging during the actual compile time. +.SH AUTHORS +Lev Walkin diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c new file mode 100644 index 00000000..afedf6bf --- /dev/null +++ b/asn1c/asn1c.c @@ -0,0 +1,267 @@ +/* + * This is the program that connects the libasn1* libraries together. + * It uses them in turn to parse, fix and then compile or print the ASN.1 tree. + */ +#include +#include +#include +#include +#include /* for stat(2) */ +#include +#include /* for basename(3) */ +#include /* for EX_USAGE */ +#include +#include + +#include /* Parse the ASN.1 file and build a tree */ +#include /* Fix the ASN.1 tree */ +#include /* Print the ASN.1 tree */ +#include /* Compile the ASN.1 tree */ + +static void usage(char *av0); /* Print the Usage screen and exit(EX_USAGE) */ + +int +main(int ac, char **av) { + enum asn1p_flags asn1_parser_flags = A1P_NOFLAGS; + enum asn1f_flags asn1_fixer_flags = A1F_NOFLAGS; + enum asn1c_flags asn1_compiler_flags = A1C_NOFLAGS; + int print_arg__print_out = 0; /* Don't compile, just print parsed */ + int print_arg__fix_n_print = 0; /* Fix and print */ + enum asn1print_flags_e print_arg__flags = APF_NOFLAGS; + int warnings_as_errors = 0; /* Treat warnings as errors */ + char *skeletons_dir = NULL; /* Directory with supplementary stuff */ + asn1p_t *asn = 0; /* An ASN.1 parsed tree */ + int ret; /* Return value from misc functions */ + int ch; /* Command line character */ + int i; /* Index in some loops */ + + /* + * Process command-line options. + */ + while((ch = getopt(ac, av, "EFf:LNPRS:W:")) != -1) + switch(ch) { + case 'E': + print_arg__print_out = 1; + break; + case 'F': + print_arg__fix_n_print = 1; + break; + case 'f': + if(strcmp(optarg, "types88") == 0) { + asn1_parser_flags |= A1P_TYPES_RESTRICT_TO_1988; + } else if(strcmp(optarg, "constr90") == 0) { + asn1_parser_flags |= A1P_CONSTRUCTS_RESTRICT_TO_1990; + } else if(strcmp(optarg, "native-integers") == 0) { + asn1_compiler_flags |= A1C_USE_NATIVE_INTEGERS; + } else if(strcmp(optarg, "no-c99") == 0) { + asn1_compiler_flags |= A1C_NO_C99; + } else if(strcmp(optarg, "unnamed-unions") == 0) { + asn1_compiler_flags |= A1C_UNNAMED_UNIONS; + } else { + fprintf(stderr, "-f%s: Invalid argument\n", optarg); + exit(EX_USAGE); + } + break; + case 'L': + print_arg__flags = APF_LINE_COMMENTS; + break; + case 'N': + print_arg__flags = APF_NO_SOURCE_COMMENTS; + break; + case 'P': + asn1_compiler_flags |= A1C_PRINT_COMPILED; + break; + case 'R': + asn1_compiler_flags |= A1C_OMIT_SUPPORT_CODE; + break; + case 'S': + skeletons_dir = optarg; + break; + case 'W': + if(strcmp(optarg, "error") == 0) { + warnings_as_errors = 1; + break; + } else if(strcmp(optarg, "debug-lexer") == 0) { + asn1_parser_flags |= A1P_LEXER_DEBUG; + break; + } else if(strcmp(optarg, "debug-fixer") == 0) { + asn1_fixer_flags |= A1F_DEBUG; + break; + } else if(strcmp(optarg, "debug-compiler") == 0) { + asn1_compiler_flags |= A1C_DEBUG; + break; + } else { + fprintf(stderr, "-W%s: Invalid argument\n", optarg); + exit(EX_USAGE); + } + break; + default: + usage(av[0]); + } + + /* + * Validate the options combination. + */ + if(!print_arg__print_out) { + if(print_arg__fix_n_print) { + fprintf(stderr, "Error: -F requires -E\n"); + exit(EX_USAGE); + } + } + + /* + * Ensure that there are some input files present. + */ + if(ac > optind) { + ac -= optind; + av += optind; + } else { + fprintf(stderr, "%s: No input files specified\n", + basename(av[0])); + exit(1); + } + + /* + * Iterate over input files and parse each. + * All syntax trees from all files will be bundled together. + */ + for(i = 0; i < ac; i++) { + asn1p_t *new_asn; + + new_asn = asn1p_parse_file(av[i], asn1_parser_flags); + if(new_asn == NULL) { + fprintf(stderr, "Cannot parse \"%s\"\n", av[i]); + exit(EX_DATAERR); + } + + /* + * Bundle the parsed tree with existing one. + */ + if(asn) { + asn1p_module_t *mod; + while((mod = TQ_REMOVE(&(new_asn->modules), mod_next))) + TQ_ADD(&(asn->modules), mod, mod_next); + asn1p_free(new_asn); + } else { + asn = new_asn; + } + + } + + /* + * Dump the parsed ASN.1 tree if -E specified and -F is not given. + */ + if(print_arg__print_out && !print_arg__fix_n_print) { + if(asn1print(asn, print_arg__flags)) + exit(EX_SOFTWARE); + return 0; + } + + + /* + * Process the ASN.1 specification: perform semantic checks, + * expand references, etc, etc. + * This function will emit necessary warnings and error messages. + */ + ret = asn1f_process(asn, asn1_fixer_flags, + NULL /* default fprintf(stderr) */); + switch(ret) { + case 1: + if(!warnings_as_errors) + /* Fall through */ + case 0: + break; /* All clear */ + case -1: + exit(EX_DATAERR); /* Fatal failure */ + } + + /* + * Dump the parsed ASN.1 tree if -E specified and -F is given. + */ + if(print_arg__print_out && print_arg__fix_n_print) { + if(asn1print(asn, print_arg__flags)) + exit(EX_SOFTWARE); + return 0; + } + + /* + * Make sure the skeleton directory is out there. + */ + if(skeletons_dir == NULL) { + struct stat sb; + skeletons_dir = DATADIR; + if((av[-optind][0] == '.' || av[-optind][1] == '/') + && stat(skeletons_dir, &sb)) { + /* + * The default skeletons directory does not exist, + * compute it from my file name: + * ./asn1c/asn1c -> ./skeletons + */ + char *p; + int len; + + p = dirname(av[-optind]); + + len = strlen(p) + sizeof("/../skeletons"); + skeletons_dir = alloca(len); + snprintf(skeletons_dir, len, "%s/../skeletons", p); + if(stat(skeletons_dir, &sb)) { + fprintf(stderr, + "WARNING: skeletons are neither in " + "\"%s\" nor in \"%s\"!\n", + DATADIR, skeletons_dir); + if(warnings_as_errors) + exit(EX_SOFTWARE); + } + } + } + + /* + * Compile the ASN.1 tree into a set of source files + * of another language. + */ + if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags)) { + exit(EX_SOFTWARE); + } + + return 0; +} + +/* + * Print the usage screen and exit(EX_USAGE). + */ +static void +usage(char *av0) { + fprintf(stderr, + "ASN.1 Compiler, v" VERSION "\n" + "Copyright (c) 2003, 2004 Lev Walkin \n" + "Usage: %s [options] ...\n" + "Where [options] are:\n" + "\t-E\tRun only the ASN.1 parser and print out the tree\n" + "\t-F\tDuring -E operation, also perform tree fixing\n" + "\t-L\tGenerate \"-- #line\" comments in -E output\n" + "\t-N\tDo not generate certain type of comments in -E output\n" + "\n" + "\t-P \tConcatenate and print the compiled text\n" + "\t-S \tDirectory with support (skeleton?) files\n" + "\t \t(Default is \"%s\")\n" + "\t-R \tRestrict output (tables only, no support code)\n" + "\n" + "\t-ftypes88\tUse only ASN.1:1988 embedded types\n" +/* + "\t-fconstr90\tUse only ASN.1:1990 constructs (not available)\n" +*/ + "\t-fnative-integers\tUse native integers where possible\n" + "\t-fno-c99\tDisable C99 extensions\n" + "\t-funnamed-unions\tEnable unnamed unions in structures\n" + "\n" + "\t-Werror \tTreat warnings as errors; abort if any warning\n" + "\t-Wdebug-lexer\tEnable verbose debugging output from lexer\n" + "\t-Wdebug-fixer\tDebug ASN.1 semantics processor\n" + "\t-Wdebug-compiler\tDebug ASN.1 compiler\n" + , + basename(av0), DATADIR + ); + exit(EX_USAGE); +} + diff --git a/asn1c/check-parsing.sh b/asn1c/check-parsing.sh new file mode 100755 index 00000000..9a7bfde7 --- /dev/null +++ b/asn1c/check-parsing.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +tmpfile=".check-parsing.$$.tmp" + +ec=0 + +for ref in ../tests/*.asn1.-*; do + src=`echo "$ref" | sed -e 's/\.-[a-zA-Z]*$//'` + flags=`echo "$ref" | sed -e 's/.*\.-//'` + echo "Checking $src against $ref" + ./asn1c "-$flags" "$src" > "$tmpfile" || ec=$? + if [ $? = 0 ]; then + diff "$ref" "$tmpfile" || ec=$? + fi + rm -f "$tmpfile" +done + +exit $ec diff --git a/asn1c/tests/Makefile.am b/asn1c/tests/Makefile.am new file mode 100644 index 00000000..91dc54d3 --- /dev/null +++ b/asn1c/tests/Makefile.am @@ -0,0 +1,10 @@ + +check_SCRIPTS = ./check-assembly.sh + +TESTS_ENVIRONMENT= ./check-assembly.sh +TESTS = check-*.c + +EXTRA_DIST = ${check_SCRIPTS} check-*.c + +clean: + for t in test-*; do rm -rf $$t; done diff --git a/asn1c/tests/Makefile.in b/asn1c/tests/Makefile.in new file mode 100644 index 00000000..6689049c --- /dev/null +++ b/asn1c/tests/Makefile.in @@ -0,0 +1,284 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +check_SCRIPTS = ./check-assembly.sh + +TESTS_ENVIRONMENT = ./check-assembly.sh +TESTS = check-*.c + +EXTRA_DIST = ${check_SCRIPTS} check-*.c +subdir = asn1c/tests +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = README Makefile.am Makefile.in +all: all-am + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu asn1c/tests/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: +tags: TAGS +TAGS: + + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool distclean distclean-generic distclean-libtool \ + distdir dvi dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool uninstall uninstall-am uninstall-info-am + + +clean: + for t in test-*; do rm -rf $$t; done +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/asn1c/tests/README b/asn1c/tests/README new file mode 100644 index 00000000..b7fb5605 --- /dev/null +++ b/asn1c/tests/README @@ -0,0 +1,6 @@ + +This is a very funny test automation. The name of the check-*.c file is used +as a pointer to the file in ../..//tests/*-*.asn1. This file is compiled +using the asn1c from above directory. Then, everything is build together +in a temporary directory with a check-*.c used as a testing engine. + diff --git a/asn1c/tests/check-22.c b/asn1c/tests/check-22.c new file mode 100644 index 00000000..c80f9881 --- /dev/null +++ b/asn1c/tests/check-22.c @@ -0,0 +1,141 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 16, /* [UNIVERSAL 16], constructed */ + 12, /* L */ + /* INTEGER a */ + ((2 << 6) + 0), /* [0], primitive */ + 2, /* L */ + 150, + 70, + /* b [1] EXPLICIT CHOICE */ + 32 | ((2 << 6) + 1), /* [1] */ + 3, /* L */ + ((2 << 6) + 1), /* [1] */ + 1, + 'i', + /* UTF8String c */ + ((2 << 6) + 2), /* [2], primitive */ + 1, /* L */ + 'x' +}; + +uint8_t buf2[128]; +int buf2_pos; + +static int +buf2_fill(const void *buffer, size_t size, void *app_key) { + if(buf2_pos + size > sizeof(buf2)) + return -1; + + memcpy(buf2 + buf2_pos, buffer, size); + buf2_pos += size; + + return 0; +} + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T1_t t, *tp; + ber_dec_rval_t rval; + der_enc_rval_t erval; + int i; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_T1, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + assert(t.a.size == 2); + assert(t.b.present == b_PR_n); + assert(t.b.choice.n.size == 1); + assert(t.b.choice.n.buf[0] == 'i'); + assert(t.c.size == 1); + assert(t.c.buf[0] == 'x'); + + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 2 + || t.b.present != b_PR_n + || t.b.choice.n.size != 1 + || t.c.size != 1 + ); + } + assert(rval.consumed <= consumed); + return; + } + + fprintf(stderr, "=> Re-creating using DER encoder <=\n"); + + /* + * Try to re-create using DER encoding. + */ + buf2_pos = 0; + erval = der_encode(&asn1_DEF_T1, tp, buf2_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != sizeof(buf1)) { + printf("%d != %d\n", (int)erval.encoded, (int)sizeof(buf1)); + } + assert(erval.encoded == sizeof(buf1)); + for(i = 0; i < sizeof(buf1); i++) { + if(buf1[i] != buf2[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf1[i], buf2[i], + buf1[i], buf2[i] + ); + } + assert(buf1[i] == buf2[i]); + } + + fprintf(stderr, "=== PRINT ===\n"); + asn_fprint(stderr, &asn1_DEF_T1, tp); + fprintf(stderr, "=== EOF ===\n"); +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] ^= random(); } while(tmp[loc] == buf[loc]); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + check(1, buf1, sizeof(buf1), sizeof(buf1)); + try_corrupt(buf1, sizeof(buf1)); + check(1, buf1, sizeof(buf1) + 10, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-24.c b/asn1c/tests/check-24.c new file mode 100644 index 00000000..b74ca165 --- /dev/null +++ b/asn1c/tests/check-24.c @@ -0,0 +1,94 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | ((2 << 6) + 5), /* [5], constructed */ + 17, /* L */ + 32 | 16, /* [UNIVERSAL 16], constructed */ + 15, /* L */ + /* INTEGER a */ + 2, /* [UNIVERSAL 2] */ + 2, /* L */ + 150, + 70, + /* INTEGER b */ + ((2 << 6) + 0), /* [0] */ + 1, /* L */ + 123, + /* INTEGER c */ + ((2 << 6) + 1), /* [1] */ + 1, /* L */ + 123, + /* INTEGER d */ + 32 | ((2 << 6) + 5), /* [5], constructed */ + 3, + 2, + 1, /* L */ + 123, +}; + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 2 + || (!t.b || t.b->size != 1) + || (!t.c || t.c->size != 1) + || t.d.size != 1 + ); + } + assert(rval.consumed <= consumed); + } +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] ^= random(); } while(tmp[loc] == buf[loc]); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + check(1, buf1, sizeof(buf1), sizeof(buf1)); + try_corrupt(buf1, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-25.c b/asn1c/tests/check-25.c new file mode 100644 index 00000000..bd803da3 --- /dev/null +++ b/asn1c/tests/check-25.c @@ -0,0 +1,252 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 16, /* [UNIVERSAL 16], constructed */ + 128, /* L */ + /* a INTEGER */ + 2, /* [UNIVERSAL 2] */ + 2, /* L */ + 150, + 70, + /* b BOOLEAN */ + 128 | 2, /* [2] */ + 1, /* L */ + 0xff, + /* c NULL */ + 5, /* [UNIVERSAL 5] */ + 0, /* L */ + /* d ENUMERATED */ + 10, /* [UNIVERSAL 10] */ + 1, /* L */ + 222, + 4, /* [UNIVERSAL 4] */ + 3, /* L */ + 'x', + 'y', + 'z', + /* f OCTET STRING */ + 32 | 4, /* [UNIVERSAL 4], constructed */ + 128, /* L indefinite */ + 4, /* [UNIVERSAL 4], primitive */ + 2, + 'l', + 'o', + 32 | 4, /* [UNIVERSAL 4], recursively constructed */ + 128, + 4, + 1, + 'v', + 4, + 2, + 'e', + '_', + 0, + 0, + 4, /* [UNIVERSAL 4], primitive */ + 2, + 'i', + 't', + 0, + 0, + /* g BIT STRING */ + 3, /* [UNIVERSAL 3], primitive */ + 3, /* L */ + 2, /* Skip 2 bits */ + 147, + 150, /* => 148 */ + /* h BIT STRING */ + 32 | 3, /* [UNIVERSAL 3], constructed */ + 128, /* L indefinite */ + 3, /* [UNIVERSAL 3], primitive */ + 3, /* L */ + 0, /* Skip 0 bits */ + 140, + 141, + 3, /* [UNIVERSAL 3], primitive */ + 2, /* L */ + 1, /* Skip 1 bit */ + 143, /* => 142 */ + 0, /* End of f */ + 0, + 0, /* End of the whole structure */ + 0, + /* Three bytes of planned leftover */ + 111, 222, 223 +}; + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p (%d)\n", buf, (int)size); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d, expected %d\n", + (int)rval.code, (int)rval.consumed, (int)consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(strcmp(t.e->buf, "xyz") == 0); + assert(strcmp(t.f->buf, "love_it") == 0); + + assert(t.g->size == 3); + assert(t.g->buf[0] == 2); + assert(t.g->buf[1] == 147); + assert(t.g->buf[2] == 148); + + printf("%d\n", t.h->buf[3]); + assert(t.h->size == 4); + assert(t.h->buf[0] == 1); + assert(t.h->buf[1] == 140); + assert(t.h->buf[2] == 141); + assert(t.h->buf[3] == 142); + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 2 + || !t.d + || t.d->size != 1 + || !t.e + || t.e->size != 3 + || !t.f + || t.f->size != 7 + || !t.g + || t.g->size != 3 + || !t.h + || t.h->size != 4 + ); + } + fprintf(stderr, "%d %d\n", (int)rval.consumed, (int)consumed); + assert(rval.consumed <= consumed); + } + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); +} + +static void +try_corrupt(uint8_t *buf, int size, int allow_consume) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while( + loc == 44 /* bit skips */ + || loc == 51 /* bit skips */ + || loc == 56 /* bit skips */ + || tmp[loc] >= 70); + do { tmp[loc] = buf[loc] ^ random(); } while( + (tmp[loc] == buf[loc]) + || (buf[loc] == 0 && tmp[loc] == 0x80)); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, allow_consume); + } +} + +static void +partial_read(uint8_t *buf, int size) { + T_t t, *tp; + ber_dec_rval_t rval; + int i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + int size1 = i1; + uint8_t *chunk2 = buf + size1; + int size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + int size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + size, size1, size2, size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", size1); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", size2); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", size3); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + } + } +} + +int +main(int ac, char **av) { + + /* Check that the full buffer may be decoded normally */ + check(1, buf1, sizeof(buf1), sizeof(buf1) - 3); + + /* Check that some types of buffer corruptions will lead to failure */ + try_corrupt(buf1, sizeof(buf1) - 3, sizeof(buf1) - 3); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf1, sizeof(buf1) - 3); + + return 0; +} diff --git a/asn1c/tests/check-30.c b/asn1c/tests/check-30.c new file mode 100644 index 00000000..9e5adf22 --- /dev/null +++ b/asn1c/tests/check-30.c @@ -0,0 +1,116 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 8, /* L */ + + /* a INTEGER */ + 64 | 3, /* [APPLICATION 3] */ + 1, /* L */ + 96, + + /* b IA5String */ + 22, /* [UNIVERSAL 22] */ + 3, /* L */ + 'x', + 'y', + 'z' +}; + +/* + * This buffer aims at checking the duplication. + */ +uint8_t buf2[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 8, /* L */ + + /* a INTEGER */ + 64 | 3, /* [APPLICATION 3] */ + 1, /* L */ + 96, + + /* a INTEGER _again_ */ + 64 | 3, /* [APPLICATION 3] */ + 1, /* L */ + 97, +}; + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(t.a.size == 1); + assert(t.a.buf[0] == 96); + assert(t.b.size == 3); + assert(t.c == 0); + assert(strcmp(t.b.buf, "xyz") == 0); + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 1 + || t.b.size != 3 + || !t.c + ); + } + assert(rval.consumed <= consumed); + } +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] = buf[loc] ^ random(); } while( + (tmp[loc] == buf[loc]) + || (buf[loc] == 0 && tmp[loc] == 0x80)); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + fprintf(stderr, "Must succeed:\n"); + check(1, buf1, sizeof(buf1) + 20, sizeof(buf1)); + + fprintf(stderr, "\nMust fail:\n"); + check(0, buf2, sizeof(buf2) + 1, 5); + + fprintf(stderr, "\nPseudo-random buffer corruptions must fail\n"); + try_corrupt(buf1, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-31.c b/asn1c/tests/check-31.c new file mode 100644 index 00000000..53a90cba --- /dev/null +++ b/asn1c/tests/check-31.c @@ -0,0 +1,175 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 128, /* L, indefinite */ + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 100, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 80, + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 110, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 82, + + 0, /* End of forest */ + 0 +}; + +uint8_t buf1_reconstr[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 16, /* L */ + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 100, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 80, + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 110, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 82 + +}; + +int buf_pos; +int bytes_compare(const void *bufferp, size_t size, void *key) { + const uint8_t *buffer = bufferp; + assert(buf_pos + size <= sizeof(buf1_reconstr)); + + fprintf(stderr, " writing %d (%d)\n", (int)size, buf_pos + (int)size); + + for(; size; buf_pos++, size--, buffer++) { + if(buf1_reconstr[buf_pos] != *buffer) { + fprintf(stderr, + "Byte %d is different: %d != %d (%x != %x)\n", + buf_pos, + *buffer, buf1_reconstr[buf_pos], + *buffer, buf1_reconstr[buf_pos] + ); + assert(buf1_reconstr[buf_pos] == *buffer); + } + } + + return 0; +} + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + Forest_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_Forest, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(t.list.count == 2); + assert(t.list.array[0]->height.size == 1); + assert(t.list.array[0]->width.size == 1); + assert(t.list.array[1]->height.size == 1); + assert(t.list.array[1]->width.size == 1); + } else { + if(rval.code == RC_OK) { + assert(t.list.count != 2 + || t.list.array[0]->height.size != 1 + || t.list.array[0]->width.size != 1 + || t.list.array[1]->height.size != 1 + || t.list.array[1]->width.size != 1 + ); + } + assert(rval.consumed <= consumed); + return; + } + + /* + * Try to re-create the buffer. + */ + buf_pos = 0; + der_encode(&asn1_DEF_Forest, &t, + bytes_compare, buf1_reconstr); + assert(buf_pos == sizeof(buf1_reconstr)); + + asn_fprint(stderr, &asn1_DEF_Forest, &t); + + asn1_DEF_Forest.free_struct(&asn1_DEF_Forest, &t, 1); +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] = buf[loc] ^ random(); } while( + (tmp[loc] == buf[loc]) + || (buf[loc] == 0 && tmp[loc] == 0x80)); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + check(1, buf1, sizeof(buf1), sizeof(buf1)); + try_corrupt(buf1, sizeof(buf1)); + check(1, buf1, sizeof(buf1) + 20, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-32.c b/asn1c/tests/check-32.c new file mode 100644 index 00000000..3cb0fdac --- /dev/null +++ b/asn1c/tests/check-32.c @@ -0,0 +1,21 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +int +main(int ac, char **av) { + Programming_t p; + + memset(&p, 0, sizeof(p)); + + /* + * No plans to fill it up: just checking whether it compiles or not. + */ + + return 0; +} diff --git a/asn1c/tests/check-33.c b/asn1c/tests/check-33.c new file mode 100644 index 00000000..14f5377a --- /dev/null +++ b/asn1c/tests/check-33.c @@ -0,0 +1,21 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +int +main(int ac, char **av) { + T_t t; + + memset(&t, 0, sizeof(t)); + + /* + * No plans to fill it up: just checking whether it compiles or not. + */ + + return 0; +} diff --git a/asn1c/tests/check-35.c b/asn1c/tests/check-35.c new file mode 100644 index 00000000..6b6c04d6 --- /dev/null +++ b/asn1c/tests/check-35.c @@ -0,0 +1,277 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 13, /* L */ + + /* b CHOICE { b2 ObjectDescriptor }*/ + 7, /* [UNIVERSAL 7] */ + 1, /* L */ + 'z', + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 0, /* L */ + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's', + + /* d.r-oid RELATIVE-OID */ + 13, /* [UNIVERSAL 13] */ + 2, /* L */ + 85, + 79, + +}; + +uint8_t buf1_reconstr[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 14, /* L */ + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 1, /* L */ + 0, + + /* b CHOICE { b2 ObjectDescriptor }*/ + 7, /* [UNIVERSAL 7] */ + 1, /* L */ + 'z', + + /* d.r-oid RELATIVE-OID */ + 13, /* [UNIVERSAL 1] */ + 2, /* L */ + 85, + 79, + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's' +}; + +uint8_t buf2[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 13, /* L */ + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's', + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 1, /* L */ + 2, /* True */ + + /* b CHOICE { b1 IA5String }*/ + 22, /* [UNIVERSAL 22] */ + 1, /* L */ + 'z', + + /* d.oid RELATIVE-OID */ + 6, /* [UNIVERSAL 6] */ + 1, /* L */ + 81, + +}; + +uint8_t buf2_reconstr[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 13, /* L */ + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 1, /* L */ + 0xff, /* Canonical True */ + + /* d.oid RELATIVE-OID */ + 6, /* [UNIVERSAL 6] */ + 1, /* L */ + 81, + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's', + + /* b CHOICE { b1 IA5String }*/ + 22, /* [UNIVERSAL 22] */ + 1, /* L */ + 'z' +}; + +static void +check(T_t *tp, uint8_t *buf, int size, int consumed) { + ber_dec_rval_t rval; + + tp = memset(tp, 0, sizeof(*tp)); + + fprintf(stderr, "Buf %p (%d)\n", buf, size); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(strcmp(tp->a.buf, "ns") == 0); + assert(strcmp(tp->b.choice.b1.buf, "z") == 0 + && strcmp(tp->b.choice.b2.buf, "z") == 0); +} + +int buf_pos; +int buf_size; +uint8_t *buf; + +static int +buf_fill(const void *buffer, size_t size, void *app_key) { + + if(buf_pos + size > buf_size) { + fprintf(stderr, "%d + %d > %d\n", buf_pos, (int)size, buf_size); + return -1; + } + + memcpy(buf + buf_pos, buffer, size); + buf_pos += size; + fprintf(stderr, " written %d (%d)\n", (int)size, buf_pos); + + return 0; +} + +void +compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { + der_enc_rval_t erval; + int i; + + buf_size = cmp_buf_size + 100; + buf = alloca(buf_size); + buf_pos = 0; + + /* + * Try to re-create using DER encoding. + */ + erval = der_encode(&asn1_DEF_T, tp, buf_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != cmp_buf_size) { + printf("%d != %d\n", erval.encoded, cmp_buf_size); + } + assert(erval.encoded == cmp_buf_size); + for(i = 0; i < cmp_buf_size; i++) { + if(buf[i] != cmp_buf[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf[i], cmp_buf[i], + buf[i], cmp_buf[i] + ); + } + assert(buf[i] == cmp_buf[i]); + } +} + +static void +partial_read(uint8_t *buf, int size) { + T_t t, *tp; + ber_dec_rval_t rval; + int i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + int size1 = i1; + uint8_t *chunk2 = buf + size1; + int size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + int size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + size, size1, size2, size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", size1); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", size2); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", size3); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + } + } +} + +int +main(int ac, char **av) { + T_t t; + + check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf1, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-41.c b/asn1c/tests/check-41.c new file mode 100644 index 00000000..c2238cf5 --- /dev/null +++ b/asn1c/tests/check-41.c @@ -0,0 +1,315 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf0[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 18, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 16, /* L */ + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', +}; + +uint8_t buf0_reconstr[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 18, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 16, /* L */ + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', +}; + + + +uint8_t buf1[] = { + 32 | (2 << 6), /* [0], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* alpha [1] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 1, /* [1] */ + 1, /* L */ + 75, +}; + +uint8_t buf1_reconstr[] = { + 32 | (2 << 6), /* [0], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* alpha [1] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 1, /* [1] */ + 1, /* L */ + 75, +}; + +uint8_t buf2[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 1, /* L */ + 75, +}; + +uint8_t buf2_reconstr[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 1, /* L */ + 75, +}; + + + + + +static void +check(T_t *tp, uint8_t *buf, int size, int consumed) { + ber_dec_rval_t rval; + + tp = memset(tp, 0, sizeof(*tp)); + + fprintf(stderr, "Buf %p (%d)\n", buf, size); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + /* + assert(tp->string.size == 128); + assert(strncmp(tp->string.buf, "zz") == 0); + assert(strcmp(tp->b.choice.b1.buf, "z") == 0 + && strcmp(tp->b.choice.b2.buf, "z") == 0); + */ +} + +int buf_pos; +int buf_size; +uint8_t *buf; + +static int +buf_fill(const void *buffer, size_t size, void *app_key) { + + if(buf_pos + size > buf_size) { + fprintf(stderr, "%d + %d > %d\n", buf_pos, (int)size, buf_size); + return -1; + } + + memcpy(buf + buf_pos, buffer, size); + buf_pos += size; + fprintf(stderr, " written %d (%d)\n", (int)size, buf_pos); + + return 0; +} + +void +compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { + der_enc_rval_t erval; + int i; + + buf_size = cmp_buf_size + 100; + buf = alloca(buf_size); + buf_pos = 0; + + /* + * Try to re-create using DER encoding. + */ + erval = der_encode(&asn1_DEF_T, tp, buf_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != cmp_buf_size) { + printf("%d != %d\n", erval.encoded, cmp_buf_size); + } + assert(erval.encoded == cmp_buf_size); + for(i = 0; i < cmp_buf_size; i++) { + if(buf[i] != cmp_buf[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf[i], cmp_buf[i], + buf[i], cmp_buf[i] + ); + } + assert(buf[i] == cmp_buf[i]); + } +} + +static void +partial_read(uint8_t *buf, int size) { + T_t t, *tp; + ber_dec_rval_t rval; + int i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + int size1 = i1; + uint8_t *chunk2 = buf + size1; + int size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + int size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + size, size1, size2, size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", size1); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", size2); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", size3); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + } + } +} + +int +main(int ac, char **av) { + T_t t; + + /* Check exact buf0 */ + check(&t, buf0, sizeof(buf0), sizeof(buf0)); + compare(&t, buf0_reconstr, sizeof(buf0_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check exact buf1 */ + check(&t, buf1, sizeof(buf1), sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check slightly more than buf1 */ + check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check exact buf2 */ + check(&t, buf2, sizeof(buf2), sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check slightly more than buf2 */ + check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf0, sizeof(buf0)); + + return 0; +} diff --git a/asn1c/tests/check-43.c b/asn1c/tests/check-43.c new file mode 100644 index 00000000..e44218d8 --- /dev/null +++ b/asn1c/tests/check-43.c @@ -0,0 +1,24 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include +#include + +int +main(int ac, char **av) { + Test_structure_1_t ts1; + Sets_t s1; + + memset(&ts1, 0, sizeof(ts1)); + memset(&s1, 0, sizeof(s1)); + + /* + * No plans to fill it up: just checking whether it compiles or not. + */ + + return 0; +} diff --git a/asn1c/tests/check-assembly.sh b/asn1c/tests/check-assembly.sh new file mode 100755 index 00000000..a1756b4d --- /dev/null +++ b/asn1c/tests/check-assembly.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# +# This script is designed to quickly create lots of files in underlying +# test-* directories, do lots of other magic stuff and exit cleanly. +# + +# Compute the .asn1 spec name by the given file name. +source=$(echo "$1" | sed -e 's/.*\///') +testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'` + +args=$(echo "$source" | sed -e 's/\.c$//') +testdir=test-${args} + +OFS=$IFS +IFS="." +set $args +shift +IFS=$OFS + +if [ ! -d $testdir ]; then + mkdir $testdir || exit $? +fi +cd $testdir || exit $? +ln -fs ../$source || exit $? +# Compile the corresponding .asn1 spec. +set -x +../../asn1c \ + -S ../../../skeletons \ + -Wdebug-compiler "$@" \ + ../../../tests/${testno}-*.asn1 || exit $? +set +x + +# Create a Makefile for the project. +cat > Makefile <. +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c ; + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $dummy.c $dummy.o $dummy.rel ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-unknown ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE}" in + i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + sparc*:NetBSD:*) + echo `uname -p`-unknown-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + case "${HPUX_REV}" in + 11.[0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + esac ;; + esac + fi ;; + esac + if [ "${HP_ARCH}" = "" ]; then + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + eval $set_cc_for_build + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in + big) echo mips-unknown-linux-gnu && exit 0 ;; + little) echo mipsel-unknown-linux-gnu && exit 0 ;; + esac + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_targets=`cd /; ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-pc-linux-gnu\n", argv[1]); +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-pc-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[KW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +eval $set_cc_for_build +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.h.in b/config.h.in new file mode 100644 index 00000000..1910711f --- /dev/null +++ b/config.h.in @@ -0,0 +1,81 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strtoimax' function. */ +#undef HAVE_STRTOIMAX + +/* Define to 1 if you have the `strtoll' function. */ +#undef HAVE_STRTOLL + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER + +/* Define to `int64_t' if does not define. */ +#undef intmax_t + +/* Define to `long' if does not define. */ +#undef off_t + +/* Define to `unsigned' if does not define. */ +#undef size_t diff --git a/config.sub b/config.sub new file mode 100755 index 00000000..12ebc787 --- /dev/null +++ b/config.sub @@ -0,0 +1,1410 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-08-13' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dsp16xx \ + | fr30 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el | mips64vr4300 \ + | mips64vr4300el | mips64vr5000 | mips64vr5000el \ + | mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ns16k | ns32k \ + | openrisc \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | s390 | s390x \ + | sh | sh[34] | sh[34]eb | shbe | shle \ + | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic80 | tron \ + | v850 \ + | we32k \ + | x86 | xscale \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alphapca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armv*-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c54x-* \ + | clipper-* | cray2-* | cydra-* \ + | d10v-* | d30v-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | m32r-* \ + | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ + | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \ + | mipsle-* | mipstx39-* | mipstx39el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | s390-* | s390x-* \ + | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ + | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ + | v850-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [cjt]90) + basic_machine=${basic_machine}-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + windows32) + basic_machine=i386-pc + os=-windows32-msvcrt + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh3eb | sh4eb) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 00000000..b7be2110 --- /dev/null +++ b/configure @@ -0,0 +1,6937 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.57. +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="libasn1parser/asn1p_y.y" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION EXEEXT OBJEXT ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh INSTALL_STRIP_PROGRAM AWK SET_MAKE AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH DEPDIR PATH MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT RANLIB ac_ct_RANLIB CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC am__include am__quote CCDEPMODE LN_S LIBTOOL CONFIGURE_DEPENDS CPP YACC LEX LEXLIB LEX_OUTPUT_ROOT AR ADD_CFLAGS EGREP LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer + --enable-shared=PKGS build shared libraries default=yes + --enable-static=PKGS build static libraries default=yes + --enable-fast-install=PKGS optimize for fast installation default=yes + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-autoconf disable automatic generation of configure script + --enable-Werror abort compilation after any C compiler warning + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld default=no + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6 +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_target_alias=$target_alias +test "x$ac_cv_target_alias" = "x" && + ac_cv_target_alias=$ac_cv_host_alias +ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6 +target=$ac_cv_target +target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + am_backtick='`' + { echo "$as_me:$LINENO: WARNING: ${am_backtick}missing' script is too old or missing" >&5 +echo "$as_me: WARNING: ${am_backtick}missing' script is too old or missing" >&2;} +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null + + +# test to see if srcdir already configured +if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# Define the identity of the package. +PACKAGE=asn1c +VERSION=0.8.10 + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. + +# Autoconf 2.50 always computes EXEEXT. However we need to be +# compatible with 2.13, for now. So we always define EXEEXT, but we +# don't compute it. + +# Similar for OBJEXT -- only we only use OBJEXT if the user actually +# requests that it be used. This is a bit dumb. +: ${OBJEXT=o} + + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. + + + + +echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6 + # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval="$enable_maintainer_mode" + USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi; + echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5 +echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6 + + +if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + MAINT=$MAINTAINER_MODE_TRUE + + + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_shared=yes +fi; +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_static=yes +fi; +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_fast_install=yes +fi; +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + + ac_config_commands="$ac_config_commands default-1" + +am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include='#' +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote='"' + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE="depmode=$am_cv_CC_dependencies_compiler_type" + + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$ac_cv_c_compiler_gnu" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by GCC" >&5 +echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${ac_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$ac_cv_path_LD" +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${ac_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_gnu_ld" >&5 +echo "${ECHO_T}$ac_cv_prog_gnu_ld" >&6 + + +echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 +if test "${ac_cv_path_NM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi +fi + +NM="$ac_cv_path_NM" +echo "$as_me:$LINENO: result: $NM" >&5 +echo "${ECHO_T}$NM" >&6 + +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + + + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_c_compiler_gnu" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 3024 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 +if test "${lt_cv_cc_needs_belf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lt_cv_cc_needs_belf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +lt_cv_cc_needs_belf=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + + +esac + + +# Save cache, so that ltconfig can load it +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| { { echo "$as_me:$LINENO: error: libtool configure failed" >&5 +echo "$as_me: error: libtool configure failed" >&2;} + { (exit 1); exit 1; }; } + +# Reload cache, that may have been modified by ltconfig +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log + + +# Check whether --enable-autoconf or --disable-autoconf was given. +if test "${enable_autoconf+set}" = set; then + enableval="$enable_autoconf" + enable_autoconf=$enableval +else + enable_autoconf=yes + +fi; +# Extract the first word of "autoconf", so it can be a program name with args. +set dummy autoconf; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AUTOCONF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AUTOCONF in + [\\/]* | ?:[\\/]*) + ac_cv_path_AUTOCONF="$AUTOCONF" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AUTOCONF="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_AUTOCONF" && ac_cv_path_AUTOCONF="@echo autoconf not available" + ;; +esac +fi +AUTOCONF=$ac_cv_path_AUTOCONF + +if test -n "$AUTOCONF"; then + echo "$as_me:$LINENO: result: $AUTOCONF" >&5 +echo "${ECHO_T}$AUTOCONF" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "autoheader", so it can be a program name with args. +set dummy autoheader; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AUTOHEADER+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AUTOHEADER in + [\\/]* | ?:[\\/]*) + ac_cv_path_AUTOHEADER="$AUTOHEADER" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AUTOHEADER="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_AUTOHEADER" && ac_cv_path_AUTOHEADER="@echo autoheader not available" + ;; +esac +fi +AUTOHEADER=$ac_cv_path_AUTOHEADER + +if test -n "$AUTOHEADER"; then + echo "$as_me:$LINENO: result: $AUTOHEADER" >&5 +echo "${ECHO_T}$AUTOHEADER" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$AUTOCONF"; then enable_autoconf=no ; fi +if test -z "$AUTOHEADER"; then enable_autoconf=no ; fi +if test x$enable_autoconf = xyes; then + CONFIGURE_DEPENDS="configure.in aclocal.m4" +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE="depmode=$am_cv_CC_dependencies_compiler_type" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_YACC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + echo "$as_me:$LINENO: result: $YACC" >&5 +echo "${ECHO_T}$YACC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + + +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LEX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + echo "$as_me:$LINENO: result: $LEX" >&5 +echo "${ECHO_T}$LEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$LEX" && break +done +test -n "$LEX" || LEX="${am_missing_run}flex" + +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LEX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + echo "$as_me:$LINENO: result: $LEX" >&5 +echo "${ECHO_T}$LEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$LEX" && break +done +test -n "$LEX" || LEX=":" + +if test -z "$LEXLIB" +then + echo "$as_me:$LINENO: checking for yywrap in -lfl" >&5 +echo $ECHO_N "checking for yywrap in -lfl... $ECHO_C" >&6 +if test "${ac_cv_lib_fl_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lfl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_fl_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_fl_yywrap=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_fl_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_fl_yywrap" >&6 +if test $ac_cv_lib_fl_yywrap = yes; then + LEXLIB="-lfl" +else + echo "$as_me:$LINENO: checking for yywrap in -ll" >&5 +echo $ECHO_N "checking for yywrap in -ll... $ECHO_C" >&6 +if test "${ac_cv_lib_l_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ll $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_l_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_l_yywrap=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_l_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_l_yywrap" >&6 +if test $ac_cv_lib_l_yywrap = yes; then + LEXLIB="-ll" +fi + +fi + +fi + +if test "x$LEX" != "x:"; then + echo "$as_me:$LINENO: checking lex output file root" >&5 +echo $ECHO_N "checking lex output file root... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_root+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # The minimal lex program is just a single line: %%. But some broken lexes +# (Solaris, I think it was) want two %% lines, so accommodate them. +cat >conftest.l <<_ACEOF +%% +%% +_ACEOF +{ (eval echo "$as_me:$LINENO: \"$LEX conftest.l\"") >&5 + (eval $LEX conftest.l) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + { { echo "$as_me:$LINENO: error: cannot find output from $LEX; giving up" >&5 +echo "$as_me: error: cannot find output from $LEX; giving up" >&2;} + { (exit 1); exit 1; }; } +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_root" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_root" >&6 +rm -f conftest.l +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +echo "$as_me:$LINENO: checking whether yytext is a pointer" >&5 +echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c +ac_save_LIBS=$LIBS +LIBS="$LIBS $LEXLIB" +cat >conftest.$ac_ext <<_ACEOF +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_lex_yytext_pointer=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_save_LIBS +rm -f "${LEX_OUTPUT_ROOT}.c" + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_yytext_pointer" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6 +if test $ac_cv_prog_lex_yytext_pointer = yes; then + +cat >>confdefs.h <<\_ACEOF +#define YYTEXT_POINTER 1 +_ACEOF + +fi + +fi +# Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AR in + [\\/]* | ?:[\\/]*) + ac_cv_path_AR="$AR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$PATH:/usr/ucb:/usr/ccs/bin" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_AR" && ac_cv_path_AR="ar" + ;; +esac +fi +AR=$ac_cv_path_AR + +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + +case "$build" in +*cygwin*) + case "$target" in + *mingw*) + CC="$CC -mno-cygwin" + esac ;; +esac + +# Check whether --enable-autoconf or --disable-autoconf was given. +if test "${enable_autoconf+set}" = set; then + enableval="$enable_autoconf" + ADD_CFLAGS="-Werror" +fi; + + +case "$GCC" in + yes) + CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wshadow" + CFLAGS="$CFLAGS -Wcast-qual" + CFLAGS="$CFLAGS -Wcast-align" + CFLAGS="$CFLAGS -Wmissing-prototypes" + CFLAGS="$CFLAGS -Wmissing-declarations" + CFLAGS="$CFLAGS -Wredundant-decls" + CFLAGS="$CFLAGS -Wnested-externs" + ;; +esac + + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in errno.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((off_t *) 0) + return 0; +if (sizeof (off_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_off_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_off_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 +if test $ac_cv_type_off_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define off_t long +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_size_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 +echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 +if test "${ac_cv_struct_tm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm *tp; tp->tm_sec; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_struct_tm=time.h +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_struct_tm=sys/time.h +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 +echo "${ECHO_T}$ac_cv_struct_tm" >&6 +if test $ac_cv_struct_tm = sys/time.h; then + +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for intmax_t" >&5 +echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 +if test "${ac_cv_type_intmax_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((intmax_t *) 0) + return 0; +if (sizeof (intmax_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_intmax_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_intmax_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 +echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 +if test $ac_cv_type_intmax_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define intmax_t int64_t +_ACEOF + +fi + + + + +for ac_func in strtoimax strtoll +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ +#ifdef __STDC__ +# include +#else +# include +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + ac_config_headers="$ac_config_headers config.h" + + + ac_config_files="$ac_config_files libasn1compiler/Makefile skeletons/tests/Makefile libasn1parser/Makefile libasn1print/Makefile asn1c/tests/Makefile libasn1fix/Makefile skeletons/Makefile examples/Makefile tests/Makefile asn1c/Makefile doc/Makefile Makefile" +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.57, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" +ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "libasn1compiler/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1compiler/Makefile" ;; + "skeletons/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES skeletons/tests/Makefile" ;; + "libasn1parser/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1parser/Makefile" ;; + "libasn1print/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1print/Makefile" ;; + "asn1c/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES asn1c/tests/Makefile" ;; + "libasn1fix/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1fix/Makefile" ;; + "skeletons/Makefile" ) CONFIG_FILES="$CONFIG_FILES skeletons/Makefile" ;; + "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; + "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + "asn1c/Makefile" ) CONFIG_FILES="$CONFIG_FILES asn1c/Makefile" ;; + "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@target@,$target,;t t +s,@target_cpu@,$target_cpu,;t t +s,@target_vendor@,$target_vendor,;t t +s,@target_os@,$target_os,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@AMTAR@,$AMTAR,;t t +s,@install_sh@,$install_sh,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@PATH@,$PATH,;t t +s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t +s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t +s,@MAINT@,$MAINT,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@LN_S@,$LN_S,;t t +s,@LIBTOOL@,$LIBTOOL,;t t +s,@CONFIGURE_DEPENDS@,$CONFIGURE_DEPENDS,;t t +s,@CPP@,$CPP,;t t +s,@YACC@,$YACC,;t t +s,@LEX@,$LEX,;t t +s,@LEXLIB@,$LEXLIB,;t t +s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t +s,@AR@,$AR,;t t +s,@ADD_CFLAGS@,$ADD_CFLAGS,;t t +s,@EGREP@,$EGREP,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi + # Run the commands associated with the file. + case $ac_file in + config.h ) # update the timestamp +echo timestamp >"./stamp-h1" + ;; + esac +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + default-1 ) +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + + diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..a4ad1b06 --- /dev/null +++ b/configure.in @@ -0,0 +1,95 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(libasn1parser/asn1p_y.y) +AC_CANONICAL_SYSTEM +AC_PREREQ(2.53) +AM_INIT_AUTOMAKE(asn1c, 0.8.10) + +AC_SUBST(PATH) + +AM_MAINTAINER_MODE + +AM_PROG_LIBTOOL + +dnl *** Autoconf support *** +AC_ARG_ENABLE(autoconf, + [ --disable-autoconf disable automatic generation of configure script ], + enable_autoconf=$enableval, enable_autoconf=yes +) +AC_PATH_PROG(AUTOCONF, autoconf, @echo autoconf not available) +AC_PATH_PROG(AUTOHEADER, autoheader, @echo autoheader not available) +if test -z "$AUTOCONF"; then enable_autoconf=no ; fi +if test -z "$AUTOHEADER"; then enable_autoconf=no ; fi +if test x$enable_autoconf = xyes; then + CONFIGURE_DEPENDS="configure.in aclocal.m4" +fi +AC_SUBST(CONFIGURE_DEPENDS) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_YACC +AM_PROG_LEX +AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin) + +dnl *** Building mingw32 with cygwin compiler *** +case "$build" in +*cygwin*) + case "$target" in + *mingw*) + CC="$CC -mno-cygwin" + esac ;; +esac + +AC_ARG_ENABLE(autoconf, + [ --enable-Werror abort compilation after any C compiler warning], + ADD_CFLAGS="-Werror") +AC_SUBST(ADD_CFLAGS) + +dnl Add these flags if we're using GCC. +case "$GCC" in + yes) + CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wshadow" + CFLAGS="$CFLAGS -Wcast-qual" + CFLAGS="$CFLAGS -Wcast-align" + CFLAGS="$CFLAGS -Wmissing-prototypes" + CFLAGS="$CFLAGS -Wmissing-declarations" + CFLAGS="$CFLAGS -Wredundant-decls" + CFLAGS="$CFLAGS -Wnested-externs" + ;; +esac + + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(errno.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_BIGENDIAN +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_STRUCT_TM +AC_CHECK_TYPE(intmax_t, int64_t) + +AC_CHECK_FUNCS(strtoimax strtoll) + +AM_CONFIG_HEADER(config.h) + +AC_OUTPUT( \ +libasn1compiler/Makefile \ +skeletons/tests/Makefile \ +libasn1parser/Makefile \ +libasn1print/Makefile \ +asn1c/tests/Makefile \ +libasn1fix/Makefile \ +skeletons/Makefile \ +examples/Makefile \ +tests/Makefile \ +asn1c/Makefile \ +doc/Makefile \ +Makefile \ +) + diff --git a/depcomp b/depcomp new file mode 100755 index 00000000..65899658 --- /dev/null +++ b/depcomp @@ -0,0 +1,411 @@ +#! /bin/sh + +# depcomp - compile a program generating dependencies as side-effects +# Copyright 1999, 2000 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi +# `libtool' can also be set to `yes' or `no'. + +depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. This file always lives in the current directory. + # Also, the AIX compiler puts `$object:' at the start of each line; + # $object doesn't have directory information. + stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + outname="$stripped.o" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 AIX compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + + tmpdepfile1="$object.d" + tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` + if test "$libtool" = yes; then + "$@" -Wc,-MD + else + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + else + tmpdepfile="$tmpdepfile2" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a space and a tab in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + test -z "$dashmflag" && dashmflag=-M + ( IFS=" " + case " $* " in + *" --mode=compile "*) # this is libtool, let us make it quiet + for arg + do # cycle over the arguments + case "$arg" in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + # X makedepend + ( + shift + cleared=no + for arg in "$@"; do + case $cleared in no) + set ""; shift + cleared=yes + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift;; + -*) + ;; + *) + set fnord "$@" "$arg"; shift;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tail +3 "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 00000000..be8cd82c --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,3 @@ + +EXTRA_DIST = *.pdf +CLEANFILES = *.*~ diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 00000000..656e8774 --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,221 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +EXTRA_DIST = *.pdf +CLEANFILES = *.*~ +subdir = doc +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = Makefile.am Makefile.in +all: all-am + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: +tags: TAGS +TAGS: + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/doc/asn1c-usage.pdf b/doc/asn1c-usage.pdf new file mode 100644 index 0000000000000000000000000000000000000000..1d0d28def1788d62836475b5f98ca8e6718ef655 GIT binary patch literal 129406 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 ...\n"; + exit 64; +} + +# Convert arguments into a hash for quicker search. +for(my $i; $i <= $#ARGV; $i++) { + $modules{$ARGV[$i]} = $ARGV[$i].".asn1"; +} + +# Process incoming stream in search for ASN.1 modules. +while() { + chop; + if($inmodule) { + next if(/^$/); + if(/^\\layout /) { + print O "\n"; + next; + } + if(/^\\begin_inset Quotes/) { + print O '"'; + next; + } + next if(/^\\/); + print O; + if(/^END$/) { + $inmodule = 0; + print O "\n"; + } + } else { + next unless $modules{$_}; + open(O, '> '.$modules{$_}); + print O; + $inmodule = 1; + delete $modules{$_}; + } +} + +# Make sure noone's missing. +die "Modules not found: " . join(", ", keys %modules) . "\n" if keys %modules; diff --git a/examples/crfc2asn1.pl b/examples/crfc2asn1.pl new file mode 100755 index 00000000..20e1f9f7 --- /dev/null +++ b/examples/crfc2asn1.pl @@ -0,0 +1,86 @@ +#!/usr/bin/perl + +# +# $Id$ +# $Author$ +# +# Simple tool that fetches the ASN.1 specifications from the +# given set of RFC files. +# + + +my $inasn = 0; # Are we inside ASN.1 grammar? +my $found = 0; + +if(-t STDIN && $#ARGV == -1) { + print STDERR "Rip ASN.1 specification from RFC file\n"; + print STDERR "Usage: $0 ...\n"; + print STDERR "Usage: | $0\n"; + exit(1); +} + +while(<>) { + # + # Strip RFC page delimiters. + # + next if /^[A-Z].*\[Page [0-9]+\]$/; + next if /^ $/; + next if /^RFC [0-9].*[0-9]+$/; + + if($inasn == 0) { + # + # The least correct way to find the start of ASN + # definition. + # + if(/^[ \t]*END[ \t]*$/) { + print STDERR + "Missed an ASN.1 grammar before line ". $. ."?\n"; + exit(1); + } + + my $rfcid = ''; + $rfcid = $1 . '-' if($ARGV =~ /([a-z0-9]+)/i); + + if(/^[ \t]+([A-Za-z0-9-]+).*DEFINITIONS.*::=/) { + my $fname = $rfcid . $1 . ".asn1"; + open(O, "> $fname") or die "Can't open $fname"; + select(O); + $inasn = 1; + } elsif(/^[ \t]*([A-Za-z0-9-]+).*{.*iso/) { + my $fname = $rfcid . $1 . ".asn1"; + my @a = ($_); + my $i; + for($i = 0; $i < 8; $i++) { + $_ = <>; + push(@a, $_); + if(/DEFINITIONS/) { + $_ = join('', @a); + $inasn = 1; + last; + } + } + next unless $inasn; + open(O, "> $fname") or die "Can't open $fname"; + select(O); + } else { + next; + } + + $found++; + print "\n"; + print "-- \n"; + print "-- Grammar found in $ARGV by $0 at " . $. . "\n"; + print "-- \n"; + print "\n"; + } + + print; + + if(/^[ \t]*END[ \t]*$/) { + select(STDOUT); + close(O); + $inasn = 0; + } +} + +die "No ASN.1 specifications found\n" unless $found; diff --git a/install-sh b/install-sh new file mode 100755 index 00000000..e9de2384 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/libasn1compiler/Makefile.am b/libasn1compiler/Makefile.am new file mode 100644 index 00000000..6b2babdf --- /dev/null +++ b/libasn1compiler/Makefile.am @@ -0,0 +1,28 @@ + +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1fix + +noinst_LTLIBRARIES = libasn1compiler.la + +libasn1compiler_la_LDFLAGS = -all-static +libasn1compiler_la_SOURCES = \ + asn1compiler.c asn1compiler.h \ + asn1c_misc.c asn1c_misc.h \ + asn1c_out.c asn1c_out.h \ + asn1c_lang.c asn1c_lang.h \ + asn1c_save.c asn1c_save.h \ + asn1c_C.c asn1c_C.h \ + asn1c_internal.h + +libasn1compiler_la_LIBADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la + +check_PROGRAMS = check_compiler + +TESTS = ${check_PROGRAMS} + +LDADD = ${noinst_LTLIBRARIES} ${libasn1compiler_la_LIBADD} +DEPENDENCIES = ${LDADD} + diff --git a/libasn1compiler/Makefile.in b/libasn1compiler/Makefile.in new file mode 100644 index 00000000..3869df39 --- /dev/null +++ b/libasn1compiler/Makefile.in @@ -0,0 +1,424 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1fix + + +noinst_LTLIBRARIES = libasn1compiler.la + +libasn1compiler_la_LDFLAGS = -all-static +libasn1compiler_la_SOURCES = \ + asn1compiler.c asn1compiler.h \ + asn1c_misc.c asn1c_misc.h \ + asn1c_out.c asn1c_out.h \ + asn1c_lang.c asn1c_lang.h \ + asn1c_save.c asn1c_save.h \ + asn1c_C.c asn1c_C.h \ + asn1c_internal.h + + +libasn1compiler_la_LIBADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la + + +check_PROGRAMS = check_compiler + +TESTS = ${check_PROGRAMS} + +LDADD = ${noinst_LTLIBRARIES} ${libasn1compiler_la_LIBADD} +DEPENDENCIES = ${LDADD} +subdir = libasn1compiler +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1compiler_la_DEPENDENCIES = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la +am_libasn1compiler_la_OBJECTS = asn1compiler.lo asn1c_misc.lo \ + asn1c_out.lo asn1c_lang.lo asn1c_save.lo asn1c_C.lo +libasn1compiler_la_OBJECTS = $(am_libasn1compiler_la_OBJECTS) +check_PROGRAMS = check_compiler$(EXEEXT) +check_compiler_SOURCES = check_compiler.c +check_compiler_OBJECTS = check_compiler.$(OBJEXT) +check_compiler_LDADD = $(LDADD) +check_compiler_DEPENDENCIES = libasn1compiler.la \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la +check_compiler_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1c_C.Plo $(DEPDIR)/asn1c_lang.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1c_misc.Plo $(DEPDIR)/asn1c_out.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1c_save.Plo $(DEPDIR)/asn1compiler.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/check_compiler.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libasn1compiler_la_SOURCES) check_compiler.c +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libasn1compiler_la_SOURCES) check_compiler.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1compiler/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +libasn1compiler.la: $(libasn1compiler_la_OBJECTS) $(libasn1compiler_la_DEPENDENCIES) + $(LINK) $(libasn1compiler_la_LDFLAGS) $(libasn1compiler_la_OBJECTS) $(libasn1compiler_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check_compiler$(EXEEXT): $(check_compiler_OBJECTS) $(check_compiler_DEPENDENCIES) + @rm -f check_compiler$(EXEEXT) + $(LINK) $(check_compiler_LDFLAGS) $(check_compiler_OBJECTS) $(check_compiler_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_C.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_lang.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_out.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_save.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1compiler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_compiler.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c new file mode 100644 index 00000000..8ec476c6 --- /dev/null +++ b/libasn1compiler/asn1c_C.c @@ -0,0 +1,2021 @@ +/* + * Don't look into this file. First, because it's a mess, and second, because + * it's a brain of the compiler, and you don't wanna mess with brains do you? ;) + */ +#include "asn1c_internal.h" +#include "asn1c_C.h" +#include /* exportable stuff from libasn1fix */ + +static int asn1c_lang_C_type_SEQUENCE_def(arg_t *arg); +static int asn1c_lang_C_type_SET_def(arg_t *arg); +static int asn1c_lang_C_type_CHOICE_def(arg_t *arg); +static int asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of); +static int _print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p); +static int emit_constraint_checking_code(arg_t *arg); +static int emit_single_constraint_check(arg_t *arg, asn1p_constraint_t *ct, int mode); +static int emit_alphabet_tables(arg_t *arg, asn1p_constraint_t *ct, int *table); +static int emit_alphabet_check_cycle(arg_t *arg); +static int check_constraint_type_presence(asn1p_constraint_t *ct, enum asn1p_constraint_type_e type); +static asn1p_expr_type_e _find_terminal_type(arg_t *arg); +static int emit_value_determination_code(arg_t *arg); +static int emit_size_determination_code(arg_t *arg); +static long compute_min_size(arg_t *arg); +static long compute_max_size(arg_t *arg); +static long compute_xxx_size(arg_t *arg, int _max); + +typedef struct tag2el_s { + struct asn1p_type_tag_s el_tag; + int el_no; + asn1p_expr_t *from_expr; +} tag2el_t; + +static int _fill_tag2el_map(arg_t *arg, tag2el_t **tag2el, int *count, int el_no); +static int _add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no); + +#define C99_MODE (arg->flags & A1C_NO_C99) +#define UNNAMED_UNIONS (arg->flags & A1C_UNNAMED_UNIONS) + +#define PCTX_DEF INDENTED( \ + OUT("\n"); \ + OUT("/* Context for parsing across buffer boundaries */\n"); \ + OUT("ber_dec_ctx_t _ber_dec_ctx;\n")); + +#define DEPENDENCIES do { \ + int saved_target = arg->target->target; \ + int saved_indent = arg->indent_level; \ + int comment_printed = 0; \ + REDIR(OT_DEPS); \ + arg->indent_level = 0; \ + TQ_FOR(v, &(expr->members), next) { \ + if((!(v->expr_type & ASN_CONSTR_MASK) \ + && v->expr_type > ASN_CONSTR_MASK) \ + || v->meta_type == AMT_TYPEREF) { \ + if(!comment_printed++) \ + OUT("/* Dependencies for %s */\n", \ + asn1c_type_name(arg, expr, TNF_UNMODIFIED)); \ + OUT("#include <%s.h>\n", \ + asn1c_type_name(arg, v, TNF_INCLUDE)); \ + } \ + } \ + if(expr->expr_type == ASN_CONSTR_SET_OF) \ + OUT("#include \n"); \ + if(expr->expr_type == ASN_CONSTR_SEQUENCE_OF) \ + OUT("#include \n"); \ + OUT("\n"); \ + REDIR(saved_target); \ + INDENT(saved_indent); \ + } while(0) + +#define MKID(id) asn1c_make_identifier(0, (id), 0) + +int +asn1c_lang_C_type_ENUMERATED(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + REDIR(OT_DEPS); + + OUT("typedef enum %s {\n", MKID(expr->Identifier)); + TQ_FOR(v, &(expr->members), next) { + switch(v->expr_type) { + case A1TC_UNIVERVAL: + OUT("\t%s\t= %lld,\n", + asn1c_make_identifier(0, + expr->Identifier, + v->Identifier, 0), + v->value->value.v_integer); + break; + case A1TC_EXTENSIBLE: + OUT("\t/*\n"); + OUT("\t * Enumeration is extensible\n"); + OUT("\t */\n"); + break; + default: + return -1; + } + } + OUT("} %s_e;\n", MKID(expr->Identifier)); + + return asn1c_lang_C_type_SIMPLE_TYPE(arg); +} + + +int +asn1c_lang_C_type_INTEGER(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + REDIR(OT_DEPS); + + if(TQ_FIRST(&(expr->members))) { + OUT("typedef enum %s {\n", MKID(expr->Identifier)); + TQ_FOR(v, &(expr->members), next) { + switch(v->expr_type) { + case A1TC_UNIVERVAL: + OUT("\t%s\t= %lld,\n", + asn1c_make_identifier(0, + expr->Identifier, + v->Identifier, 0), + v->value->value.v_integer); + break; + default: + return -1; + } + } + OUT("} %s_e;\n", MKID(expr->Identifier)); + } + + return asn1c_lang_C_type_SIMPLE_TYPE(arg); +} + +int +asn1c_lang_C_type_SEQUENCE(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + + DEPENDENCIES; + + if(arg->embed) { + OUT("struct %s {\n", + MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", + MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) { + if(comp_mode < 3) comp_mode++; + } + if(comp_mode == 1 && !v->marker) + v->marker = EM_OPTIONAL; + EMBED(v); + } + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", + MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + return asn1c_lang_C_type_SEQUENCE_def(arg); +} + +static int +asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int elements; /* Number of elements */ + int tags_impl_skip = 0; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + int ext_start = -1; + int ext_stop = -1; + char *p; + + REDIR(OT_STAT_DEFS); + + OUT("#include \n"); + OUT("\n"); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SEQUENCE_element_t asn1_DEF_%s_elements[] = {\n", p); + + elements = 0; + INDENTED(TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) { + if((++comp_mode) == 1) + ext_start = elements - 1; + else + ext_stop = elements - 1; + continue; + } + OUT("{ "); + elements++; + OUT("offsetof(struct %s, ", MKID(expr->Identifier)); + OUT("%s), ", MKID(v->Identifier)); + if(v->marker) { + asn1p_expr_t *tv; + int opts = 0; + for(tv = v; tv && tv->marker; + tv = TQ_NEXT(tv, next), opts++) { + if(tv->expr_type == A1TC_EXTENSIBLE) + opts--; + } + OUT("%d,", opts); + } else { + OUT("0,"); + } + OUT("\n"); + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".tag_mode = "); + if(v->tag.tag_class) { + if(v->tag.tag_mode == TM_IMPLICIT) + OUT("-1,\t/* IMPLICIT tag at current level */\n"); + else + OUT("+1,\t/* EXPLICIT tag at current level */\n"); + } else { + OUT("0,\n"); + } + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s,\n", + asn1c_type_name(arg, v, TNF_SAFE)); + if(C99_MODE) OUT(".name = "); + OUT("\"%s\"\n", v->Identifier); + OUT("},\n"); + INDENT(-1); + }); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + OUT("static asn1_SEQUENCE_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("asn1_DEF_%s_elements,\n", p); + OUT("%d,\t/* Elements count */\n", elements); + OUT("%d,\t/* Start extensions */\n", + ext_start); + OUT("%d\t/* Stop extensions */\n", + (ext_stopIdentifier); + OUT("SEQUENCE_constraint,\n"); + OUT("SEQUENCE_decode_ber,\n"); + OUT("SEQUENCE_encode_der,\n"); + OUT("SEQUENCE_print,\n"); + OUT("SEQUENCE_free,\n"); + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + OUT("#include \n"); + OUT("\n"); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_SEQUENCE_OF(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + DEPENDENCIES; + + if(arg->embed) { + OUT("struct %s {\n", MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + INDENTED(OUT("A_SEQUENCE_OF(%s) list;\n", + asn1c_type_name(arg, v, TNF_RSAFE))); + } + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + /* + * SET OF/SEQUENCE OF definition, SEQUENCE OF mode. + */ + return asn1c_lang_C_type_SEx_OF_def(arg, 1); +} + +int +asn1c_lang_C_type_SET(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + long mcount; + char *id; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + + DEPENDENCIES; + + REDIR(OT_DEPS); + + OUT("\n"); + OUT("/*\n"); + OUT(" * Method of determining the components presence\n"); + OUT(" */\n"); + mcount = 0; + OUT("enum %s_PR_e {\n", MKID(expr->Identifier)); + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) continue; + INDENTED( + id = MKID(expr->Identifier); + OUT("%s_PR_", id); + id = MKID(v->Identifier); + OUT("%s,\t/* Member %s is present */\n", + id, id) + ); + mcount++; + } + OUT("};\n"); + + REDIR(OT_TYPE_DECLS); + + if(arg->embed) { + OUT("struct %s {\n", MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) { + if(comp_mode < 3) comp_mode++; + } + if(comp_mode == 1 && !v->marker) + v->marker = EM_OPTIONAL; + EMBED(v); + } + + INDENTED( + id = MKID(expr->Identifier); + OUT("\n"); + OUT("/* Presence bitmask: ASN_SET_ISPRESENT(p%s, %s_PR_x) */\n", + id, id); + OUT("unsigned int _presence_map\n"); + OUT("\t[((%ld+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];\n", mcount); + ); + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + return asn1c_lang_C_type_SET_def(arg); +} + +/* + * Compare tags according to their canonical order. + * Canonical order: [UNIVERSAL] [APPLICATION] [] [PRIVATE] + * As you see, the class is encoded using the two lowest bits. + */ +static arg_t *_ctc_arg; +static int _canonical_tags_cmp(const void *ap, const void *bp) + __attribute__ ((unused)); +static int +_canonical_tags_cmp(const void *ap, const void *bp) { + asn1p_expr_t *a, *b; + struct asn1p_type_tag_s ta, tb; + + (const asn1p_expr_t *)a = *(const asn1p_expr_t * const *)ap; + (const asn1p_expr_t *)b = *(const asn1p_expr_t * const *)bp; + + if(asn1f_fetch_tag(_ctc_arg->asn, _ctc_arg->mod, a, &ta) + || asn1f_fetch_tag(_ctc_arg->asn, _ctc_arg->mod, b, &tb)) + return 0; + + if(ta.tag_class == tb.tag_class) { + if(ta.tag_value == tb.tag_value) + return 0; + else if(ta.tag_value < tb.tag_value) + return -1; + else + return 1; + } else if(ta.tag_class < tb.tag_class) { + return -1; + } else { + return 1; + } +} + +static int +_tag2el_cmp(const void *ap, const void *bp) { + const tag2el_t *a = ap; + const tag2el_t *b = bp; + const struct asn1p_type_tag_s *ta = &a->el_tag; + const struct asn1p_type_tag_s *tb = &b->el_tag; + + if(ta->tag_class == tb->tag_class) { + if(ta->tag_value == tb->tag_value) + return 0; + else if(ta->tag_value < tb->tag_value) + return -1; + else + return 1; + } else if(ta->tag_class < tb->tag_class) { + return -1; + } else { + return 1; + } +} + +static int +asn1c_lang_C_type_SET_def(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int elements; + int tags_impl_skip = 0; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + int extensible = 0; + tag2el_t *tag2el = NULL; + int tag2el_count = 0; + char *p; + + /* + * Fetch every inner tag from the tag to elements map. + */ + if(_fill_tag2el_map(arg, &tag2el, &tag2el_count, -1)) { + if(tag2el) free(tag2el); + return -1; + } else { + /* + * Sort the map according to canonical order of their tags. + */ + _ctc_arg = arg; + qsort(tag2el, tag2el_count, sizeof(*tag2el), _tag2el_cmp); + } + + + REDIR(OT_STAT_DEFS); + + OUT("#include \n"); + OUT("\n"); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SET_element_t asn1_DEF_%s_elements[] = {\n", p); + + elements = 0; + INDENTED(TQ_FOR(v, &(expr->members), next) { + if(v->expr_type != A1TC_EXTENSIBLE) { + if(comp_mode == 1) + v->marker = EM_OPTIONAL; + elements++; + } else { + if(comp_mode < 3) comp_mode++; + continue; + } + OUT("{ "); + p = MKID(expr->Identifier); + OUT("offsetof(struct %s, ", p); + p = MKID(v->Identifier); + OUT("%s), ", p); + if(v->marker) { + OUT("1, /* Optional element */\n"); + } else { + OUT("0,\n"); + } + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".tag_mode = "); + if(v->tag.tag_class) { + if(v->tag.tag_mode == TM_IMPLICIT) + OUT("-1,\t/* IMPLICIT tag at current level */\n"); + else + OUT("+1,\t/* EXPLICIT tag at current level */\n"); + } else { + OUT("0,\n"); + } + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s,\n", + asn1c_type_name(arg, v, TNF_SAFE)); + if(C99_MODE) OUT(".name = "); + OUT("\"%s\"\n", v->Identifier); + OUT("},\n"); + INDENT(-1); + }); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + /* + * Tags to elements map. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SET_tag2member_t asn1_DEF_%s_tag2el[] = {\n", p); + if(tag2el_count) { + int i; + for(i = 0; i < tag2el_count; i++) { + OUT(" { "); + _print_tag(arg, expr, &tag2el[i].el_tag); + OUT(", "); + OUT("%d ", tag2el[i].el_no); + OUT("}, /* %s at %d */\n", + tag2el[i].from_expr->Identifier, + tag2el[i].from_expr->_lineno + ); + } + } + OUT("};\n"); + + /* + * Emit a map of mandatory elements. + */ + OUT("static uint8_t asn1_DEF_%s_mmap", p); + OUT("[(%d + (8 * sizeof(unsigned int)) - 1) / 8]", elements); + OUT(" = {\n", p); + INDENTED( + if(elements) { + int delimit = 0; + int el = 0; + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) continue; + if(delimit) { + OUT(",\n"); + delimit = 0; + } else if(el) { + OUT(" | "); + } + OUT("(%d << %d)", v->marker?0:1, 7 - (el % 8)); + if(el && (el % 8) == 0) + delimit = 1; + el++; + } + } else { + OUT("0"); + } + ); + OUT("\n"); + OUT("};\n"); + + OUT("static asn1_SET_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("offsetof(struct %s, _presence_map),\n", p); + OUT("asn1_DEF_%s_elements,\n", p); + OUT("%d,\t/* Elements count */\n", elements); + OUT("asn1_DEF_%s_tag2el,\n", p); + OUT("%d,\t/* Count of tags in the map */\n", tag2el_count); + OUT("%d,\t/* Whether extensible */\n", extensible); + OUT("(unsigned int *)asn1_DEF_%s_mmap\t/* Mandatory elements map */\n", p); + ); + OUT("};\n"); + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + OUT("SET_constraint,\n"); + OUT("SET_decode_ber,\n"); + OUT("SET_encode_der,\n"); + OUT("SET_print,\n"); + OUT("SET_free,\n"); + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + OUT("#include \n"); + OUT("\n"); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_SET_OF(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + DEPENDENCIES; + + if(arg->embed) { + OUT("struct %s {\n", MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", + MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + INDENTED(OUT("A_SET_OF(%s) list;\n", + asn1c_type_name(arg, v, TNF_RSAFE))); + } + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + /* + * SET OF/SEQUENCE OF definition, SET OF mode. + */ + return asn1c_lang_C_type_SEx_OF_def(arg, 0); +} + +static int +asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int tags_impl_skip = 0; + char *p; + + REDIR(OT_DEPS); + + if(seq_of) { + OUT("#include \n"); + } else { + OUT("#include \n"); + OUT("\n"); + } + + REDIR(OT_STAT_DEFS); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SET_OF_element_t asn1_DEF_%s_elements[] = {\n", p); + + INDENTED(OUT("{ "); + v = TQ_FIRST(&(expr->members)); + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s", + asn1c_type_name(arg, v, TNF_SAFE)); + OUT(" "); + OUT("},\n"); + INDENT(-1); + ); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + OUT("static asn1_SET_OF_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("asn1_DEF_%s_elements\n", p); + ); + OUT("};\n"); + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + if(seq_of) { + OUT("SEQUENCE_OF_constraint,\n"); + OUT("SEQUENCE_OF_decode_ber,\n"); + OUT("SEQUENCE_OF_encode_der,\n"); + OUT("SEQUENCE_OF_print,\n"); + OUT("SEQUENCE_OF_free,\n"); + } else { + OUT("SET_OF_constraint,\n"); + OUT("SET_OF_decode_ber,\n"); + OUT("SET_OF_encode_der,\n"); + OUT("SET_OF_print,\n"); + OUT("SET_OF_free,\n"); + } + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_CHOICE(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + char *p; + + DEPENDENCIES; + + p = MKID(expr->Identifier); + + if(arg->embed) { + OUT("struct %s {\n", p); + } else { + OUT("typedef struct %s {\n", p); + } + + INDENTED( + OUT("enum {\n"); + INDENTED( + OUT("%s_PR_NOTHING,\t" + "/* No components present */\n", p); + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) continue; + p = MKID(expr->Identifier); + OUT("%s_PR_", p); + p = MKID(v->Identifier); + OUT("%s,\n", p, p); + } + ); + OUT("} present;\n"); + + OUT("union {\n", p); + TQ_FOR(v, &(expr->members), next) { + EMBED(v); + } + if(UNNAMED_UNIONS) OUT("};\n"); + else OUT("} choice;\n"); + ); + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + return asn1c_lang_C_type_CHOICE_def(arg); +} + +static int +asn1c_lang_C_type_CHOICE_def(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int elements; /* Number of elements */ + int tags_impl_skip = 0; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + int extensible = 0; + tag2el_t *tag2el = NULL; + int tag2el_count = 0; + char *p; + + /* + * Fetch every inner tag from the tag to elements map. + */ + if(_fill_tag2el_map(arg, &tag2el, &tag2el_count, -1)) { + if(tag2el) free(tag2el); + return -1; + } else { + /* + * Sort the map according to canonical order of their tags. + */ + _ctc_arg = arg; + qsort(tag2el, tag2el_count, sizeof(*tag2el), _tag2el_cmp); + } + + REDIR(OT_STAT_DEFS); + + OUT("#include \n"); + OUT("\n"); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_CHOICE_element_t asn1_DEF_%s_elements[] = {\n", p); + + elements = 0; + INDENTED(TQ_FOR(v, &(expr->members), next) { + if(v->expr_type != A1TC_EXTENSIBLE) { + if(comp_mode == 1) + v->marker = EM_OPTIONAL; + elements++; + } else { + if(comp_mode < 3) comp_mode++; + continue; + } + OUT("{ "); + p = MKID(expr->Identifier); + OUT("offsetof(struct %s, ", p); + p = MKID(v->Identifier); + if(!UNNAMED_UNIONS) OUT("choice."); + OUT("%s), ", p); + if(v->marker) { + OUT("1, /* Optional element */\n"); + } else { + OUT("0,\n"); + } + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".tag_mode = "); + if(v->tag.tag_class) { + if(v->tag.tag_mode == TM_IMPLICIT) + OUT("-1,\t/* IMPLICIT tag at current level */\n"); + else + OUT("+1,\t/* EXPLICIT tag at current level */\n"); + } else { + OUT("0,\n"); + } + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s,\n", + asn1c_type_name(arg, v, TNF_SAFE)); + if(C99_MODE) OUT(".name = "); + OUT("\"%s\"\n", v->Identifier); + OUT("},\n"); + INDENT(-1); + }); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + if(arg->embed) { + /* + * Our parent structure has already taken this into account. + */ + } else { + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + OUT("\n"); + ); + } + OUT("};\n"); + + /* + * Tags to elements map. + */ + p = MKID(expr->Identifier); + OUT("static asn1_CHOICE_tag2member_t asn1_DEF_%s_tag2el[] = {\n", p); + if(tag2el_count) { + int i; + for(i = 0; i < tag2el_count; i++) { + OUT(" { "); + _print_tag(arg, expr, &tag2el[i].el_tag); + OUT(", "); + OUT("%d ", tag2el[i].el_no); + OUT("}, /* %s at %d */\n", + tag2el[i].from_expr->Identifier, + tag2el[i].from_expr->_lineno + ); + } + } + OUT("};\n"); + + OUT("static asn1_CHOICE_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("offsetof(struct %s, present),\n", p); + OUT("sizeof(((struct %s *)0)->present),\n", p); + OUT("asn1_DEF_%s_elements,\n", p); + OUT("%d,\t/* Elements count */\n", elements); + OUT("asn1_DEF_%s_tag2el,\n", p); + OUT("%d,\t/* Count of tags in the map */\n", tag2el_count); + OUT("%d\t/* Whether extensible */\n", extensible); + ); + OUT("};\n"); + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + OUT("CHOICE_constraint,\n"); + OUT("CHOICE_decode_ber,\n"); + OUT("CHOICE_encode_der,\n"); + OUT("CHOICE_print,\n"); + OUT("CHOICE_free,\n"); + OUT("CHOICE_outmost_tag,\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_REFERENCE(arg_t *arg) { + asn1p_ref_t *ref; + + ref = arg->expr->reference; + if(ref->components[ref->comp_count-1].name[0] == '&') { + asn1p_module_t *mod; + asn1p_expr_t *extract; + arg_t tmp; + int ret; + + extract = asn1f_class_access_ex(arg->asn, arg->mod, arg->expr, + ref, &mod); + if(extract == NULL) + return -1; + + extract = asn1p_expr_clone(extract); + if(extract) { + if(extract->Identifier) + free(extract->Identifier); + extract->Identifier = strdup(arg->expr->Identifier); + if(extract->Identifier == NULL) { + asn1p_expr_free(extract); + return -1; + } + } else { + return -1; + } + + tmp = *arg; + tmp.asn = arg->asn; + tmp.mod = mod; + tmp.expr = extract; + + ret = arg->default_cb(&tmp); + + asn1p_expr_free(extract); + + return ret; + } + + + return asn1c_lang_C_type_SIMPLE_TYPE(arg); +} + +int +asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int tags_impl_skip = 0; + char *p; + + if(arg->embed) { + REDIR(OT_TYPE_DECLS); + + OUT("%s\t", asn1c_type_name(arg, arg->expr, + expr->marker?TNF_RSAFE:TNF_CTYPE)); + OUT("%s", expr->marker?"*":" "); + OUT("%s;", MKID(expr->Identifier)); + if(expr->marker) OUT("\t/* %s */", + (expr->marker==EM_OPTIONAL)?"OPTIONAL":"DEFAULT"); + OUT("\n"); + return 0; + } + + REDIR(OT_DEPS); + + OUT("#include <%s.h>\n", asn1c_type_name(arg, expr, TNF_INCLUDE)); + + REDIR(OT_TYPE_DECLS); + + OUT("typedef %s\t", asn1c_type_name(arg, arg->expr, TNF_CTYPE)); + OUT("%s", expr->marker?"*":" "); + OUT("%s_t;\n", MKID(expr->Identifier)); + OUT("\n"); + + REDIR(OT_STAT_DEFS); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + OUT("%s_constraint,\n", p); + OUT("%s_decode_ber,\n", p); + OUT("%s_encode_der,\n", p); + OUT("%s_print,\n", p); + OUT("%s_free,\n", p); + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("-0\t/* Unknown yet */\n"); + ); + OUT("};\n"); + OUT("\n"); + + /* + * Constraint checking. + */ + if(expr->constraints) /* Emit tables with FROM() constraints */ + emit_alphabet_tables(arg, expr->constraints, 0); + p = MKID(expr->Identifier); + OUT("int\n"); + OUT("%s_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,\n", p); + INDENTED( + OUT("\t\tasn_app_consume_bytes_f *app_errlog, void *app_key) {\n"); + OUT("\n"); + if(expr->constraints) { + + emit_constraint_checking_code(arg); + + OUT("/* Check the constraints of the underlying type */\n"); + OUT("return asn1_DEF_%s.check_constraints\n", + asn1c_type_name(arg, expr, TNF_SAFE)); + OUT("\t(td, sptr, app_errlog, app_key);\n"); + } else { + OUT("/* Make the underlying type checker permanent */\n"); + OUT("td->check_constraints = asn1_DEF_%s.check_constraints;\n", + asn1c_type_name(arg, expr, TNF_SAFE)); + OUT("return td->check_constraints\n"); + OUT("\t(td, sptr, app_errlog, app_key);\n"); + } + ); + OUT("}\n"); + OUT("\n"); + + /* + * Emit suicidal functions. + */ + + { + /* + * This function replaces certain fields from the definition + * of a type with the corresponding fields from the basic type + * (from which the current type is inherited). + */ + char *type_name = asn1c_type_name(arg, expr, TNF_SAFE); + OUT("/*\n"); + OUT(" * This type is implemented using %s,\n", type_name); + OUT(" * so adjust the DEF appropriately.\n"); + OUT(" */\n"); + OUT("static void\n"); + OUT("inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {\n"); + INDENT(+1); + OUT("td->ber_decoder = asn1_DEF_%s.ber_decoder;\n", type_name); + OUT("td->der_encoder = asn1_DEF_%s.der_encoder;\n", type_name); + OUT("td->free_struct = asn1_DEF_%s.free_struct;\n", type_name); + OUT("td->print_struct = asn1_DEF_%s.print_struct;\n", type_name); + OUT("td->last_tag_form = asn1_DEF_%s.last_tag_form;\n", type_name); + OUT("td->specifics = asn1_DEF_%s.specifics;\n", type_name); + INDENT(-1); + OUT("}\n"); + OUT("\n"); + } + + p = MKID(expr->Identifier); + OUT("ber_dec_rval_t\n"); + OUT("%s_decode_ber(asn1_TYPE_descriptor_t *td,\n", p); + INDENTED( + OUT("\tvoid **structure, void *bufptr, size_t size, int tag_mode) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("return td->ber_decoder(td, structure,\n"); + OUT("\tbufptr, size, tag_mode);\n"); + ); + OUT("}\n"); + OUT("\n"); + + p = MKID(expr->Identifier); + OUT("der_enc_rval_t\n"); + OUT("%s_encode_der(asn1_TYPE_descriptor_t *td,\n", p); + INDENTED( + OUT("\tvoid *structure, int tag_mode, ber_tlv_tag_t tag,\n"); + OUT("\tasn_app_consume_bytes_f *cb, void *app_key) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);\n"); + ); + OUT("}\n"); + OUT("\n"); + + p = MKID(expr->Identifier); + OUT("int\n"); + OUT("%s_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,\n", p); + INDENTED( + OUT("\tint ilevel, asn_app_consume_bytes_f *cb, void *app_key) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("return td->print_struct(td, struct_ptr, ilevel, cb, app_key);\n"); + ); + OUT("}\n"); + OUT("\n"); + + p = MKID(expr->Identifier); + OUT("void\n"); + OUT("%s_free(asn1_TYPE_descriptor_t *td,\n", p); + INDENTED( + OUT("\tvoid *struct_ptr, int contents_only) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("td->free_struct(td, struct_ptr, contents_only);\n"); + ); + OUT("}\n"); + OUT("\n"); + + REDIR(OT_FUNC_DECLS); + + p = MKID(expr->Identifier); + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + OUT("asn_constr_check_f %s_constraint;\n", p); + OUT("ber_type_decoder_f %s_decode_ber;\n", p); + OUT("der_type_encoder_f %s_encode_der;\n", p); + OUT("asn_struct_print_f %s_print;\n", p); + OUT("asn_struct_free_f %s_free;\n", p); + + return 0; +} + +int +asn1c_lang_C_type_EXTENSIBLE(arg_t *arg) { + + OUT("/*\n"); + OUT(" * This type is extensible,\n"); + OUT(" * possible extensions are below.\n"); + OUT(" */\n"); + + return 0; +} + +static int +_print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p) { + struct asn1p_type_tag_s tag; + + if(tag_p) { + tag = *tag_p; + } else { + if(asn1f_fetch_tag(arg->asn, arg->mod, expr, &tag)) { + OUT("-1 /* Ambiguous tag (CHOICE?) */"); + return 0; + } + } + + OUT("("); + switch(tag.tag_class) { + case TC_UNIVERSAL: OUT("ASN_TAG_CLASS_UNIVERSAL"); break; + case TC_APPLICATION: OUT("ASN_TAG_CLASS_APPLICATION"); break; + case TC_CONTEXT_SPECIFIC: OUT("ASN_TAG_CLASS_CONTEXT"); break; + case TC_PRIVATE: OUT("ASN_TAG_CLASS_PRIVATE"); break; + case TC_NOCLASS: + break; + } + OUT(" | (%lld << 2))", tag.tag_value); + + return 0; +} + +/* + * For constructed types, number of external tags may be greater than + * number of elements in the type because of CHOICE type. + * T ::= SET { -- Three possible tags: + * a INTEGER, -- One tag is here... + * b Choice1 -- ... and two more tags are there. + * } + * Choice1 ::= CHOICE { + * s1 IA5String, + * s2 ObjectDescriptor + * } + */ +static int +_fill_tag2el_map(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) { + asn1p_expr_t *expr = arg->expr; + arg_t tmparg = *arg; + asn1p_expr_t *v; + int element = 0; + + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) + continue; + + tmparg.expr = v; + + if(_add_tag2el_member(&tmparg, tag2el, count, + (el_no==-1)?element:el_no)) { + return -1; + } + + element++; + } + + return 0; +} + +static int +_add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) { + struct asn1p_type_tag_s tag; + int ret; + + assert(el_no >= 0); + + ret = asn1f_fetch_tag(arg->asn, arg->mod, arg->expr, &tag); + if(ret == 0) { + void *p; + p = realloc(*tag2el, sizeof(tag2el_t) * ((*count) + 1)); + if(p) *tag2el = p; + else return -1; + + DEBUG("Found tag for %s: %ld", + arg->expr->Identifier, + (long)tag.tag_value); + + (*tag2el)[*count].el_tag = tag; + (*tag2el)[*count].el_no = el_no; + (*tag2el)[*count].from_expr = arg->expr; + (*count)++; + return 0; + } + + DEBUG("Searching tag in complex expression %s:%x at line %d", + arg->expr->Identifier, + arg->expr->expr_type, + arg->expr->_lineno); + + /* + * Iterate over members of CHOICE type. + */ + if(arg->expr->expr_type == ASN_CONSTR_CHOICE) { + return _fill_tag2el_map(arg, tag2el, count, el_no); + } + + if(arg->expr->expr_type == A1TC_REFERENCE) { + arg_t tmp = *arg; + asn1p_expr_t *expr; + expr = asn1f_lookup_symbol_ex(tmp.asn, &tmp.mod, tmp.expr, + arg->expr->reference); + if(expr) { + tmp.expr = expr; + return _add_tag2el_member(&tmp, tag2el, count, el_no); + } else { + FATAL("Cannot dereference %s at line %d", + arg->expr->Identifier, + arg->expr->_lineno); + return -1; + } + } + + DEBUG("No tag for %s at line %d", + arg->expr->Identifier, + arg->expr->_lineno); + + return -1; +} + +static int +emit_constraint_checking_code(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_type_e etype; + int size_present, value_present; + + if(expr->constraints == NULL) + return 0; /* No constraints defined */ + + etype = _find_terminal_type(arg); + + size_present = check_constraint_type_presence(expr->constraints, + ACT_CT_SIZE); + value_present = check_constraint_type_presence(expr->constraints, + ACT_EL_VALUE); + + if(size_present || value_present) { + OUT("%s_t *st = sptr;\n", MKID(arg->expr->Identifier)); + if(size_present) { + OUT("size_t size;\n"); + OUT("size_t min_size __attribute__ ((unused)) = %ld;\n", + compute_min_size(arg)); + OUT("size_t max_size __attribute__ ((unused)) = %ld;\n", + compute_max_size(arg)); + } + if(value_present) + switch(etype) { + case ASN_BASIC_INTEGER: + case ASN_BASIC_ENUMERATED: + OUT("long value;\n"); + break; + case ASN_BASIC_BOOLEAN: + OUT("int value;\n"); + break; + default: + break; + } + OUT("\n"); + } + + OUT("if(!sptr) {\n"); + INDENT(+1); + OUT("_ASN_ERRLOG(\"%%s: value not given\", td->name);\n"); + OUT("return -1;\n"); + INDENT(-1); + OUT("}\n"); + OUT("\n"); + + if(size_present) + emit_size_determination_code(arg); + if(value_present) + emit_value_determination_code(arg); + + OUT("\n"); + OUT("if(\n"); + emit_single_constraint_check(arg, expr->constraints, 0); + OUT(") {\n"); + INDENTED(OUT("/* Constraint check succeeded */\n")); + OUT("} else {\n"); + INDENT(+1); + OUT("_ASN_ERRLOG(\"%%s: constraint failed\", td->name);\n"); + OUT("return -1;\n"); + INDENT(-1); + OUT("}\n"); + + return 0; +} + +static int +emit_single_constraint_check(arg_t *arg, asn1p_constraint_t *ct, int mode) { + char *s_v; + int el; + + assert(arg && ct); + + switch(ct->type) { + case ACT_INVALID: + assert(ct->type != ACT_INVALID); + OUT("-1 /* Invalid constraint at line %d */\n", ct->_lineno); + break; + case ACT_EL_VALUE: + OUT("("); + if(mode == ACT_CT_SIZE) s_v = "size"; + else s_v = "value"; + OUT("%s", s_v); + if(ct->value->type != ATV_TRUE) + OUT(" == "); + switch(ct->value->type) { + case ATV_INTEGER: OUT("%lld", + (long long)ct->value->value.v_integer); break; + case ATV_MIN: OUT("min_%s", s_v); break; + case ATV_MAX: OUT("max_%s", s_v); break; + case ATV_FALSE: OUT("0"); break; + case ATV_TRUE: break; + default: + break; + } + OUT(")\n"); + break; + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + if(mode == ACT_CT_SIZE) { + s_v = "size"; + } else { + s_v = "value"; + } + OUT("((%s", s_v); + switch(ct->type) { + case ACT_EL_RANGE: + case ACT_EL_RLRANGE: + OUT(" >= "); break; + case ACT_EL_LLRANGE: + case ACT_EL_ULRANGE: + OUT(" > "); break; + default: break; + } + switch(ct->range_start->type) { + case ATV_INTEGER: OUT("%lld", + (long long)ct->range_start->value.v_integer); break; + case ATV_MIN: OUT("min_%s", s_v); break; + case ATV_MAX: OUT("max_%s", s_v); break; + case ATV_FALSE: OUT("0"); break; + case ATV_TRUE: break; + default: + break; + } + OUT(") && (%s", s_v); + switch(ct->type) { + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + OUT(" <= "); break; + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + OUT(" < "); break; + default: break; + } + switch(ct->range_stop->type) { + case ATV_INTEGER: OUT("%lld", + (long long)ct->range_stop->value.v_integer); break; + case ATV_MIN: OUT("min_%s", s_v); break; + case ATV_MAX: OUT("max_%s", s_v); break; + case ATV_FALSE: OUT("0"); break; + case ATV_TRUE: break; + default: + break; + } + OUT("))\n"); + break; + case ACT_EL_EXT: + OUT("0 /* Extensible (...), but not defined herein */\n"); + break; + case ACT_CT_SIZE: + if(mode) { + OUT("0 /* Invalid constraint at line %d */\n", + ct->_lineno); + return -1; + } + assert(ct->el_count == 1); + return emit_single_constraint_check(arg, + ct->elements[0], ACT_CT_SIZE); + case ACT_CT_FROM: + if(mode) { + OUT("0 /* Invalid constraint at line %d */\n", + ct->_lineno); + return -1; + } + OUT("check_alphabet_%x(sptr)\n", ct); + break; + case ACT_CT_WCOMP: + case ACT_CT_WCOMPS: + OUT("%d /* Unsupported constraint at line %d */\n", + ct->type, ct->_lineno); + return -1; + break; + case ACT_CA_SET: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("&& "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_CSV: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("|| "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_UNI: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("|| "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_INT: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("&& "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_CRC: + WARNING("Unsupported component relation constraint at line %d", + ct->_lineno); + OUT("%d /* Unsupported component relation constraint " + "at line %d */\n", + ct->type, ct->_lineno); + return -1; + case ACT_CA_EXC: + WARNING("Unsupported EXCEPT constraint at line %d", + ct->_lineno); + OUT("%d /* Unsupported EXCEPT constraint at line %d */\n", + ct->type, ct->_lineno); + return -1; + } + + return 0; +} + +static int +check_constraint_type_presence(asn1p_constraint_t *ct, enum asn1p_constraint_type_e type) { + int el; + + if(ct == NULL) return 0; + + if(ct->type == type) return 1; + + if(type == ACT_EL_VALUE) { + if(ct->type >= ACT_CT_SIZE + && ct->type <= ACT_CT_WCOMPS) + /* Values defined further + * are not really value's values */ + return 0; + if(ct->type > ACT_EL_VALUE && ct->type < ACT_CT_SIZE) + return 1; /* Also values */ + } + + for(el = 0; el < ct->el_count; el++) { + if(check_constraint_type_presence(ct->elements[el], type)) + return 1; + } + + return 0; +} + +static int +emit_alphabet_tables(arg_t *arg, asn1p_constraint_t *ct, int *table) { + int ch = 0; + int ch_start = 0; + int ch_stop = 0; + int el = 0; + + assert(arg && ct); + + switch(ct->type) { + case ACT_INVALID: + break; + case ACT_EL_VALUE: + if(!table) break; + + switch(ct->value->type) { + case ATV_INTEGER: + if(ct->value->value.v_integer < 0 + || ct->value->value.v_integer > 255) { + OUT("\n"); + OUT("#error Value %lld out of range " + "for alphabet character at line %d\n", + (long long)ct->value->value.v_integer, + ct->_lineno); + break; + } else { + ch = ct->value->value.v_integer; + table[ch] = 1; + } + break; + case ATV_STRING: + for(ch = 0; ch < ct->value->value.string.size; ch++) + table[ct->value->value.string.buf[ch]] = 1; + break; + default: + OUT("\n"); + WARNING("Invalid alphabet character specification " + "at line %d", ct->_lineno); + OUT("#error Invalid alphabet character specification " + "at line %d\n", ct->_lineno); + break; + } + break; + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + if(!table) break; + + ch_start = 0; + ch_stop = 255; + + switch(ct->range_start->type) { + case ATV_INTEGER: + ch_start = ct->range_start->value.v_integer; break; + case ATV_MIN: ch_start = 0; break; + case ATV_MAX: ch_start = 255; break; + case ATV_STRING: + if(ct->range_start->value.string.size == 1) { + ch_start = ct->range_start->value.string.buf[0]; + break; + } + /* Fall through */ + default: + OUT("\n"); + FATAL("Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + OUT("#error Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + return -1; + } + + switch(ct->range_stop->type) { + case ATV_INTEGER: + ch_stop = ct->range_stop->value.v_integer; break; + case ATV_MIN: ch_stop = 0; break; + case ATV_MAX: ch_stop = 255; break; + case ATV_STRING: + if(ct->range_stop->value.string.size == 1) { + ch_stop = ct->range_stop->value.string.buf[0]; + break; + } + /* Fall through */ + default: + OUT("\n"); + FATAL("Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + OUT("#error Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + break; + } + + switch(ct->type) { + case ACT_EL_RANGE: break; + case ACT_EL_RLRANGE: ch_stop--; break; + case ACT_EL_LLRANGE: ch_start++; break; + case ACT_EL_ULRANGE: ch_start++; ch_stop--; break; + default: break; + } + + if(ch_start > ch_stop) { + WARNING("Empty character range " + "alphabet constraint at line %d", ct->_lineno); + OUT("#warning Empty character range " + "alphabet constraint at line %d\n", ct->_lineno); + break; + } + + for(ch = ch_start; ch <= ch_stop; ch++) { + if(ch < 0 || ch > 255) continue; + table[ch] = 1; + } + + break; + case ACT_EL_EXT: + break; + case ACT_CT_SIZE: + break; + case ACT_CT_FROM: + if(table) { + OUT("#error Nested FROM in subtype constraints\n"); + return -1; + } else { + table = alloca(256 * sizeof(table[0])); + memset(table, 0, 256 * sizeof(table[0])); + + for(el = 0; el < ct->el_count; el++) { + emit_alphabet_tables(arg, ct->elements[el], + table); + } + OUT("static int alphabet_table_%x[256] = {\n", ct); + for(ch = 0; ch < 256; ch++) { + OUT("%d,", table[ch]?1:0); + if(!((ch+1) % 16)) { + if(ch) { + int c; + OUT("\t/* "); + for(c = ch - 16; c < ch; c++) { + if(table[c]) { + if(c > 0x20 + && c < 0x80) + OUT("%c", c); + else + OUT(".", c); + } else { + OUT(" "); + } + } + OUT(" */"); + } + OUT("\n"); + } + } + OUT("};\n"); + OUT("static int check_alphabet_%x(void *sptr) {\n", ct); + INDENT(+1); + OUT("int *table = alphabet_table_%x;\n", ct); + emit_alphabet_check_cycle(arg); + OUT("return 1;\n"); + INDENT(-1); + OUT("};\n"); + } + break; + case ACT_CT_WCOMP: + case ACT_CT_WCOMPS: + break; + case ACT_CA_CRC: + break; + case ACT_CA_SET: + case ACT_CA_CSV: + case ACT_CA_UNI: + for(el = 0; el < ct->el_count; el++) + emit_alphabet_tables(arg, ct->elements[el], table); + break; + case ACT_CA_INT: + if(table) { + int table2[256]; + + assert(ct->el_count >= 1); + emit_alphabet_tables(arg, ct->elements[0], table); + for(el = 1; el < ct->el_count; el++) { + memset(table2, 0, sizeof(table2)); + emit_alphabet_tables(arg, + ct->elements[el], table2); + /* Intersection */ + for(ch = 0; ch < 256; ch++) { + if(table2[ch] == 0) + table[ch] = 0; + } + } + } else { + for(el = 0; el < ct->el_count; el++) + emit_alphabet_tables(arg, ct->elements[el], 0); + } + + break; + case ACT_CA_EXC: + OUT("EXC\n"); + if(table) { + int table2[256]; + + assert(ct->el_count >= 1); + emit_alphabet_tables(arg, ct->elements[0], table); + for(el = 1; el < ct->el_count; el++) { + memset(table2, 0, sizeof(table2)); + emit_alphabet_tables(arg, + ct->elements[el], table2); + /* Exclusion */ + for(ch = 0; ch < 256; ch++) { + if(table2[ch]) + table[ch] = 0; + } + } + } else { + for(el = 0; el < ct->el_count; el++) + emit_alphabet_tables(arg, ct->elements[el], 0); + } + break; + } + + return 0; +} + +static int +emit_alphabet_check_cycle(arg_t *arg) { + asn1p_expr_type_e etype; + + etype = _find_terminal_type(arg); + if(!(etype & ASN_STRING_MASK) + && !(etype == ASN_BASIC_OCTET_STRING)) { + OUT("#error Cannot apply FROM constraint to ASN.1 type %s\n", + ASN_EXPR_TYPE2STR(etype)); + return -1; + } + + OUT("/* The underlying type is %s */\n", + ASN_EXPR_TYPE2STR(etype)); + OUT("%s_t *st = sptr;\n", MKID(arg->expr->Identifier)); + + switch(etype) { + case ASN_STRING_UTF8String: + OUT("uint8_t *ch = st->buf;\n"); + OUT("uint8_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("if(*ch >= 0x80 || !table[*ch]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + break; + case ASN_STRING_UniversalString: + OUT("uint32_t *ch = st->buf;\n"); + OUT("uint32_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("uint32_t wc = (((uint8_t *)ch)[0] << 24)\n"); + OUT("\t\t| (((uint8_t *)ch)[1] << 16)\n"); + OUT("\t\t| (((uint8_t *)ch)[2] << 8)\n"); + OUT("\t\t| ((uint8_t *)ch)[3]\n"); + OUT("if(wc > 255 || !table[wc]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + OUT("if(ch != end) return 0; /* (size%4)! */\n"); + break; + case ASN_STRING_BMPString: + OUT("uint16_t *ch = st->buf;\n"); + OUT("uint16_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("uint16_t wc = (((uint8_t *)ch)[0] << 8)\n"); + OUT("\t\t| ((uint8_t *)ch)[1];\n"); + OUT("if(wc > 255 || !table[wc]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + OUT("if(ch != end) return 0; /* (size%2)! */\n"); + break; + case ASN_BASIC_OCTET_STRING: + default: + OUT("uint8_t *ch = st->buf;\n"); + OUT("uint8_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("if(!table[*ch]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + break; + } + + return 0; +} + +static int +emit_size_determination_code(arg_t *arg) { + asn1p_expr_type_e etype = _find_terminal_type(arg); + + switch(etype) { + case ASN_BASIC_BIT_STRING: + OUT("if(st->size > 0) {\n"); + OUT("\t/* Size in bits */\n"); + OUT("\tsize = (st->size - 1) - (st->buf[0] & 0x7);\n"); + OUT("} else {\n"); + OUT("\tsize = 0;\n"); + OUT("}\n"); + break; + case ASN_STRING_UniversalString: + OUT("size = st->size >> 2;\t/* 4 byte per character */\n"); + break; + case ASN_STRING_BMPString: + OUT("size = st->size >> 1;\t/* 2 byte per character */\n"); + break; + case ASN_STRING_UTF8String: + OUT("size = UTF8String_length(st, td->name, app_errlog, app_key);\n"); + OUT("if(size == (size_t)-1) return -1;\n"); + break; + default: + if((etype & ASN_STRING_MASK) + || etype == ASN_BASIC_OCTET_STRING) { + OUT("size = st->size;\n"); + break; + } else { + WARNING("Size operation is not defined for %s", + ASN_EXPR_TYPE2STR(etype)); + OUT("#warning Size operation not defined!\n"); + OUT("size = st->size;\n"); + } + return -1; + } + + return 0; +} + +static int +emit_value_determination_code(arg_t *arg) { + asn1p_expr_type_e etype = _find_terminal_type(arg); + + switch(etype) { + case ASN_BASIC_INTEGER: + case ASN_BASIC_ENUMERATED: + OUT("if(asn1_INTEGER2long(st, &value)) {\n"); + INDENT(+1); + OUT("_ASN_ERRLOG(\"%%s: value too large\", td->name);\n"); + OUT("return -1;\n"); + INDENT(-1); + OUT("}\n"); + break; + case ASN_BASIC_BOOLEAN: + OUT("value = st->value;\n"); + break; + default: + WARNING("Value cannot be determined " + "for constraint check for %s at line %d\n", + arg->expr->Identifier, arg->expr->_lineno); + OUT("#error Value cannot be determined for %s at %d\n", + arg->expr->Identifier, arg->expr->_lineno); + break; + } + + return 0; +} + +static long compute_min_size(arg_t *arg) { return compute_xxx_size(arg, 0); } +static long compute_max_size(arg_t *arg) { return compute_xxx_size(arg, 1); } + +static long compute_xxx_size(arg_t *arg, int _max) { + asn1p_expr_type_e etype; + long basic_max = 0x7fffffff; + long basic_min = 0x80000000; + long svalue = 0; + + etype = _find_terminal_type(arg); + switch(etype) { + case ASN_BASIC_BIT_STRING: + svalue = _max?basic_max/8:0; + break; + case ASN_STRING_UTF8String: + svalue = _max?basic_max/6:0; + break; + case ASN_STRING_UniversalString: + svalue = _max?basic_max/4:0; + break; + case ASN_STRING_BMPString: + svalue = _max?basic_max/2:0; + break; + case ASN_BASIC_OCTET_STRING: + svalue = _max?basic_max:0; + break; + default: + if((etype & ASN_STRING_MASK)) { + svalue = _max?basic_max:0; + break; + } + svalue = _max?basic_max:basic_min; + break; + } + + return svalue; +} + +static asn1p_expr_type_e +_find_terminal_type(arg_t *arg) { + asn1p_expr_t *expr; + expr = asn1f_find_terminal_type_ex(arg->asn, arg->mod, arg->expr, NULL); + assert(expr); + return expr->expr_type; +} diff --git a/libasn1compiler/asn1c_C.h b/libasn1compiler/asn1c_C.h new file mode 100644 index 00000000..643d6293 --- /dev/null +++ b/libasn1compiler/asn1c_C.h @@ -0,0 +1,69 @@ +#ifndef ASN1_COMPILER_LANGUAGE_C_H +#define ASN1_COMPILER_LANGUAGE_C_H + +#include "asn1c_lang.h" + +int asn1c_lang_C_type_REFERENCE(arg_t *); +int asn1c_lang_C_type_EXTENSIBLE(arg_t *); + +int asn1c_lang_C_type_SEQUENCE(arg_t *); +int asn1c_lang_C_type_SEQUENCE_OF(arg_t *); +int asn1c_lang_C_type_SET(arg_t *); +int asn1c_lang_C_type_SET_OF(arg_t *); +int asn1c_lang_C_type_CHOICE(arg_t *); + +int asn1c_lang_C_type_INTEGER(arg_t *); +int asn1c_lang_C_type_ENUMERATED(arg_t *); +int asn1c_lang_C_type_SIMPLE_TYPE(arg_t *); + +static asn1_language_map_t asn1_lang_C[] __attribute__ ((unused)) = { + { AMT_TYPE, A1TC_REFERENCE, asn1c_lang_C_type_REFERENCE }, + { AMT_TYPEREF, A1TC_REFERENCE, asn1c_lang_C_type_REFERENCE }, + { AMT_TYPE, A1TC_EXTENSIBLE, asn1c_lang_C_type_EXTENSIBLE }, + /* + * Constructed types + */ + { AMT_TYPE, ASN_CONSTR_SEQUENCE, asn1c_lang_C_type_SEQUENCE }, + { AMT_TYPE, ASN_CONSTR_SEQUENCE_OF, asn1c_lang_C_type_SEQUENCE_OF }, + { AMT_TYPEREF, ASN_CONSTR_SEQUENCE_OF, asn1c_lang_C_type_SEQUENCE_OF }, + { AMT_TYPE, ASN_CONSTR_SET, asn1c_lang_C_type_SET }, + { AMT_TYPE, ASN_CONSTR_SET_OF, asn1c_lang_C_type_SET_OF }, + { AMT_TYPEREF, ASN_CONSTR_SET_OF, asn1c_lang_C_type_SET_OF }, + { AMT_TYPE, ASN_CONSTR_CHOICE, asn1c_lang_C_type_CHOICE }, + /* + * Basic types + */ + { AMT_TYPE, ASN_BASIC_BOOLEAN, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_NULL, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_INTEGER, asn1c_lang_C_type_INTEGER }, + /* [Skipped REAL] */ + { AMT_TYPE, ASN_BASIC_ENUMERATED, asn1c_lang_C_type_ENUMERATED }, + { AMT_TYPE, ASN_BASIC_BIT_STRING, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_OCTET_STRING, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_OBJECT_IDENTIFIER,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_RELATIVE_OID, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_CHARACTER_STRING, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_UTCTime, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_GeneralizedTime, asn1c_lang_C_type_SIMPLE_TYPE }, + /* + * String types + */ + { AMT_TYPE, ASN_STRING_BMPString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_GeneralString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_GraphicString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_IA5String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_ISO646String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_NumericString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_PrintableString,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_TeletexString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_T61String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_UniversalString,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_UTF8String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_VideotexString,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_VisibleString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_ObjectDescriptor,asn1c_lang_C_type_SIMPLE_TYPE }, + { 0, 0, 0 } +}; + + +#endif /* ASN1_COMPILER_LANGUAGE_C_H */ diff --git a/libasn1compiler/asn1c_internal.h b/libasn1compiler/asn1c_internal.h new file mode 100644 index 00000000..91772cdc --- /dev/null +++ b/libasn1compiler/asn1c_internal.h @@ -0,0 +1,81 @@ +#ifndef _ASN1_COMPILER_INTERNAL_H_ +#define _ASN1_COMPILER_INTERNAL_H_ + +#include +#include +#include /* for fstat(2) */ +#include /* for unlink(2) */ +#include /* for open(2) */ +#include /* for glob(3) */ +#include /* for basename(3) */ +#include +#include /* for isalnum(3) */ +#include +#include +#include + +#include "asn1compiler.h" + +typedef struct arg_s { + + enum asn1c_flags flags; + + void (*logger_cb)(int _severity, const char *fmt, ...); + + int (*default_cb)(struct arg_s *); + + struct compiler_streams *target; + + asn1p_t *asn; + asn1p_module_t *mod; + asn1p_expr_t *expr; + + int indent_level; + int indented; + int embed; +} arg_t; + +#include "asn1c_lang.h" /* Target language initialization */ +#include "asn1c_misc.h" /* Miscellaneous functions */ +#include "asn1c_out.h" /* Handle output during compilation */ +#include "asn1c_save.h" /* Save compiled output */ + +#define INDENT(val) arg->indent_level += (val) +#define INDENTED(code) do { \ + INDENT(+1); \ + do { code; } while(0); \ + INDENT(-1); \ + } while(0) +#define FLAT(code) do { \ + int _il = arg->indent_level; \ + arg->indent_level = 0; \ + do { code; } while(0); \ + arg->indent_level = _il; \ + } while(0) +#define EMBED(ev) do { \ + REDIR(OT_TYPE_DECLS); \ + arg->embed++; \ + INDENTED(arg_t _tmp = *arg; \ + _tmp.expr = ev; \ + _tmp.default_cb(&_tmp); \ + ); \ + arg->embed--; \ + } while(0) +#define OUT(fmt, args...) asn1c_compiled_output(arg, fmt, ##args) + +#define REDIR(foo) do { arg->target->target = foo; } while(0) + +/* + * Logging. + */ +#define LOG(ll, fmt, args...) do { \ + arg->logger_cb(ll, fmt, ##args); \ + } while(0) +#define DEBUG(fmt, args...) do { \ + if(arg->flags & A1C_DEBUG) \ + LOG(-1, fmt, ##args); \ + } while(0) +#define WARNING(fmt, args...) LOG(0, fmt, ##args); +#define FATAL(fmt, args...) LOG(1, fmt, ##args); + +#endif /* _ASN1_COMPILER_INTERNAL_H_ */ diff --git a/libasn1compiler/asn1c_lang.c b/libasn1compiler/asn1c_lang.c new file mode 100644 index 00000000..fa07540a --- /dev/null +++ b/libasn1compiler/asn1c_lang.c @@ -0,0 +1,32 @@ +#include "asn1c_internal.h" +#include "asn1c_C.h" + +asn1_language_map_t asn1_lang_map[AMT_EXPR_META_MAX][ASN_EXPR_TYPE_MAX]; + +int +asn1c_with_language(asn1c_target_language_e lang) { + asn1_language_map_t *lptr; + int lsize; + if(lang != ASN1C_LANGUAGE_C) { + errno = EINVAL; + return -1; + } + + lptr = asn1_lang_C; + lsize = sizeof(asn1_lang_C)/sizeof(asn1_lang_C[0]); + + memset(asn1_lang_map, 0, sizeof(asn1_lang_map)); + + for(; lsize && lptr->expr_match; lsize--, lptr++) { + assert(lptr->meta_match > 0); + assert(lptr->meta_match < AMT_EXPR_META_MAX); + assert(lptr->expr_match > 0); + assert(lptr->expr_match < ASN_EXPR_TYPE_MAX); + + asn1_lang_map[lptr->meta_match][lptr->expr_match] + = *lptr; + } + + return 0; +} + diff --git a/libasn1compiler/asn1c_lang.h b/libasn1compiler/asn1c_lang.h new file mode 100644 index 00000000..8c9a6ea7 --- /dev/null +++ b/libasn1compiler/asn1c_lang.h @@ -0,0 +1,28 @@ +#ifndef ASN1_COMPILER_LANGUAGE_H +#define ASN1_COMPILER_LANGUAGE_H + +struct arg_s; + +typedef struct asn1_language_map_s { + asn1p_expr_meta_e meta_match; /* meta_type */ + asn1p_expr_type_e expr_match; /* expr_type */ + /* + * A callback that would create a language-specific type declaration. + */ + int (*type_cb)(struct arg_s *arg); +} asn1_language_map_t; + + +extern asn1_language_map_t asn1_lang_map[AMT_EXPR_META_MAX][ASN_EXPR_TYPE_MAX]; + + +typedef enum asn1c_target_language { + ASN1C_LANGUAGE_C, +} asn1c_target_language_e; + +/* + * Initialize the compiler to generate specified target language. + */ +int asn1c_with_language(asn1c_target_language_e lang); + +#endif /* ASN1_COMPILER_LANGUAGE_H */ diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c new file mode 100644 index 00000000..b464b64c --- /dev/null +++ b/libasn1compiler/asn1c_misc.c @@ -0,0 +1,232 @@ +#include "asn1c_internal.h" +#include + +#ifndef DEFFILEMODE /* Normally in */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +/* + * Construct identifier from multiple parts. + * Convert unsafe characters to underscores. + */ +char * +asn1c_make_identifier(int unsafe_only_spaces, char *arg1, ...) { + static char *storage; + static int storage_size; + int nodelimiter = 0; + va_list ap; + char *str; + int size; + char *p; + + if(arg1 == NULL) + return NULL; + + /* + * Estimate the necessary storage size + */ + size = strlen(arg1); + va_start(ap, arg1); + while((str = va_arg(ap, char *))) + size += 1 + strlen(str); + va_end(ap); + + /* + * Make sure we have this amount of storage. + */ + if(storage_size <= size) { + if(storage) free(storage); + storage = malloc(size + 1); + if(storage) { + storage_size = size; + } else { + storage_size = 0; + return NULL; + } + } + + /* + * Fill-in the storage. + */ + va_start(ap, arg1); + str = arg1; + p = storage; + for(str = arg1; str; str = va_arg(ap, char *)) { + int subst_made = 0; + + if(str[0] == ' ' && str[1] == '\0') { + *p++ = ' '; + nodelimiter = 1; /* No delimiter */ + continue; + } + + if(str != arg1 && !nodelimiter) + *p++ = '_'; /* Delimiter between tokens */ + nodelimiter = 0; + + for(; *str; str++) { + if(isalnum(*str)) { + *p++ = *str; + subst_made = 0; + } else if(!subst_made++) { + if(unsafe_only_spaces && !isspace(*str)) { + *p ++ = *str; + } else { + *p++ = '_'; + } + } + } + } + va_end(ap); + *p = '\0'; + + assert((p - storage) <= storage_size); + + return storage; +} + +FILE * +asn1c_open_file(arg_t *arg, const char *name, const char *ext) { + int created = 1; + struct stat sb; + char *fname; + int len; + FILE *fp; + int fd; + + /* + * Compute filenames. + */ + len = strlen(name) + strlen(ext) + 1; + fname = alloca(len); + snprintf(fname, len, "%s%s", name, ext); + + /* + * Create files. + */ + fd = open(fname, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE); + if(fd == -1 && errno == EEXIST) { + fd = open(fname, O_WRONLY, DEFFILEMODE); + created = 0; + } + if(fd == -1) { + perror(fname); + return NULL; + } + + /* + * Check sanity. + */ + if(fstat(fd, &sb) || !S_ISREG(sb.st_mode)) { + fprintf(stderr, "%s: Not a regular file\n", fname); + if(created) unlink(fname); + close(fd); + return NULL; + } + + (void)ftruncate(fd, 0); + + /* + * Convert file descriptor into file pointer. + */ + fp = fdopen(fd, "w"); + if(fp == NULL) { + if(created) unlink(fname); + close(fd); + } + return fp; +} + +char * +asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { + char *typename; + + switch(expr->expr_type) { + case A1TC_REFERENCE: + typename = expr->reference->components[ + expr->reference->comp_count-1].name; + if(typename[0] == '&') { + arg_t tmp = *arg; + + /* + * This is a reference to a type defined in a class. + * Resolve it and use instead. + */ + tmp.expr = asn1f_class_access_ex(arg->asn, arg->mod, + arg->expr, expr->reference, &tmp.mod); + if(tmp.expr) return NULL; + + return asn1c_type_name(&tmp, tmp.expr, _format); + } else if(_format == TNF_RSAFE) { + /* + * The recursion-safe format is requested. + * The problem here is that only constructed types + * might be referenced with "struct". + * Change RSAFE to CTYPE if the terminal type + * is primitive. + */ + asn1p_expr_t *terminal; + terminal = asn1f_find_terminal_type_ex( + arg->asn, arg->mod, arg->expr, NULL); + if(terminal + && (terminal->expr_type + & (ASN_BASIC_MASK | ASN_STRING_MASK))) + _format = TNF_CTYPE; + } + break; + case ASN_CONSTR_SEQUENCE_OF: + case ASN_CONSTR_SET_OF: + if(expr->Identifier) { + typename = expr->Identifier; + } else { + asn1p_expr_t *child; + child = TQ_FIRST(&(expr->members)); + typename = asn1c_type_name(arg, child, _format); + if(typename) + return typename; + _format = TNF_SAFE; + typename = child->Identifier; + } + break; + case ASN_BASIC_INTEGER: + case ASN_BASIC_ENUMERATED: + if((arg->flags & A1C_USE_NATIVE_INTEGERS)) { + switch(_format) { + case TNF_CTYPE: + case TNF_RSAFE: + return "int"; + default: + if(expr->expr_type == ASN_BASIC_INTEGER) + return "NativeInteger"; + else + return "NativeEnumerated"; + } + } + /* Fall through */ + default: + if(expr->expr_type & (ASN_BASIC_MASK | ASN_STRING_MASK)) { + if(_format == TNF_RSAFE) + _format = TNF_CTYPE; + typename = ASN_EXPR_TYPE2STR(expr->expr_type); + } else { + _format = TNF_SAFE; + typename = expr->Identifier; + } + } + + switch(_format) { + case TNF_UNMODIFIED: + case TNF_INCLUDE: + return asn1c_make_identifier(1, typename, 0); + case TNF_SAFE: + return asn1c_make_identifier(0, typename, 0); + case TNF_CTYPE: + return asn1c_make_identifier(0, typename, "t", 0); + case TNF_RSAFE: + return asn1c_make_identifier(0, "struct", " ", typename, 0); + } + + assert("!unreachable"); + return typename; +} + diff --git a/libasn1compiler/asn1c_misc.h b/libasn1compiler/asn1c_misc.h new file mode 100644 index 00000000..2f82b0b6 --- /dev/null +++ b/libasn1compiler/asn1c_misc.h @@ -0,0 +1,28 @@ +#ifndef _ASN1_COMPILER_MISC_H_ +#define _ASN1_COMPILER_MISC_H_ + +/* + * Make the target language identifier out of one or more names. + * The function will concatenate the names and replace unsafe characters + * with safe ones. + */ +char *asn1c_make_identifier(int unsafe_only_spaces, char *arg1, ...); + +/* + * Return the type name of the specified expression. + */ +enum tnfmt { + TNF_UNMODIFIED, /* Return unmodified type name */ + TNF_INCLUDE, /* Format for #include <> */ + TNF_CTYPE, /* Format as normal C-ish type (append "_t") */ + TNF_SAFE, /* Replace unsafe characters with _ */ + TNF_RSAFE, /* Recursion-safe C type format */ +}; +char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format); + +/* + * Open the arbitrary file by its base name and extension. + */ +FILE *asn1c_open_file(arg_t *arg, const char *base_part, const char *extension); + +#endif /* _ASN1_COMPILER_MISC_H_ */ diff --git a/libasn1compiler/asn1c_out.c b/libasn1compiler/asn1c_out.c new file mode 100644 index 00000000..a6432418 --- /dev/null +++ b/libasn1compiler/asn1c_out.c @@ -0,0 +1,75 @@ +#include "asn1c_internal.h" + +/* + * Add an elementary chunk of target language text + * into appropriate output stream. + */ +int +asn1c_compiled_output(arg_t *arg, const char *fmt, ...) { + const char *p; + int lf_found; + va_list ap; + out_chunk_t *m; + char *buf; + int ret; + + /* + * Make sure the output has a single LF and only at the end. + */ + for(lf_found = 0, p = fmt; *p; p++) { + if(*p == '\n') { + lf_found++; + assert(p[1] == '\0'); + } + } + assert(lf_found <= 1); + + /* + * Print out the indentation. + */ + if(arg->indented == 0) { + int i = arg->indent_level; + arg->indented = 1; + while(i--) { + ret = asn1c_compiled_output(arg, "\t"); + if(ret == -1) return -1; + } + } + + /* + * Estimate necessary size. + */ + buf = ""; + va_start(ap, fmt); + ret = vsnprintf(buf, 0, fmt, ap); + va_end(ap); + assert(ret >= 0); + + /* + * Allocate buffer. + */ + m = calloc(1, sizeof(out_chunk_t)); + if(m == NULL) return -1; + m->len = ret + 1; + m->buf = malloc(ret + 1); + if(m->buf == NULL) { + free(m); + return -1; + } + + /* + * Fill the buffer. + */ + va_start(ap, fmt); + ret = vsnprintf(m->buf, m->len, fmt, ap); + assert(ret < m->len); + m->len = ret; + va_end(ap); + + TQ_ADD(&(arg->target->targets[arg->target->target]), m, next); + + if(lf_found) + arg->indented = 0; + + return 0; +} diff --git a/libasn1compiler/asn1c_out.h b/libasn1compiler/asn1c_out.h new file mode 100644 index 00000000..2267d5db --- /dev/null +++ b/libasn1compiler/asn1c_out.h @@ -0,0 +1,31 @@ +#ifndef _ASN1_COMPILED_OUTPUT_H_ +#define _ASN1_COMPILED_OUTPUT_H_ + +/* + * An elementary chunk of target language text. + */ +typedef struct out_chunk { + char *buf; + int len; + + TQ_ENTRY(struct out_chunk) next; +} out_chunk_t; + +typedef struct compiler_streams { + enum { + OT_DEPS, /* Dependencies */ + OT_TYPE_DECLS, /* Type declarations */ + OT_FUNC_DECLS, /* Function declarations */ + OT_STAT_DEFS, /* Static definitions */ + OT_CODE, /* Some code */ + OT_MAX + } target; + TQ_HEAD(out_chunk_t) targets[OT_MAX]; +} compiler_streams_t; + +static char *_compiler_stream2str[] __attribute__ ((unused)) + = { "DEPS", "TYPE-DECLS", "FUNC-DECLS", "STAT-DEFS", "CODE" }; + +int asn1c_compiled_output(arg_t *arg, const char *fmt, ...); + +#endif /* _ASN1_COMPILED_OUTPUT_H_ */ diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c new file mode 100644 index 00000000..0e5b0fbc --- /dev/null +++ b/libasn1compiler/asn1c_save.c @@ -0,0 +1,225 @@ +#include "asn1c_internal.h" + +static int asn1c_dump_streams(arg_t *arg); +static int asn1c_print_streams(arg_t *arg); +static int asn1c_save_streams(arg_t *arg); +static int asn1c_copy_over(arg_t *arg, char *path); + +int +asn1c_save_compiled_output(arg_t *arg, const char *datadir) { + + (void)datadir; + + TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) { + TQ_FOR(arg->expr, &(arg->mod->members), next) { + if(asn1_lang_map[arg->expr->meta_type] + [arg->expr->expr_type].type_cb) { + if(asn1c_dump_streams(arg)) + return -1; + } + } + } + + /* + * Dump out the Makefile template and the rest of the support code. + */ + if((arg->flags & A1C_PRINT_COMPILED) == 0 + && (arg->flags & A1C_OMIT_SUPPORT_CODE) == 0) { + glob_t pg; + FILE *mkf; + char *p; + int i; + + i = strlen(datadir) + sizeof("/*.[ch]"); + p = alloca(i); + snprintf(p, i, "%s/*.[ch]", datadir); + + memset(&pg, 0, sizeof(pg)); + if(glob(p, GLOB_ERR +#ifdef GLOB_TILDE + | GLOB_TILDE +#endif /* GLOB_TILDE */ + , NULL, &pg)) { + fprintf(stderr, + "Bad skeletons directory (-S) %s: %s\n", + datadir, strerror(errno)); + return -1; + } + + mkf = asn1c_open_file(arg, "Makefile.am", ".sample"); + if(mkf == NULL) { + globfree(&pg); + perror("Makefile.am.sample"); + return -1; + } + + fprintf(mkf, "ASN_SRCS="); + TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) { + TQ_FOR(arg->expr, &(arg->mod->members), next) { + if(asn1_lang_map[arg->expr->meta_type] + [arg->expr->expr_type].type_cb) { + fprintf(mkf, "\t\\\n\t%s.c %s.h", + arg->expr->Identifier, + arg->expr->Identifier); + } + } + } + + for(i = 0; i < pg.gl_pathc; i++) { + if(asn1c_copy_over(arg, pg.gl_pathv[i])) { + fprintf(mkf, ">>>ABORTED<<<"); + fclose(mkf); + globfree(&pg); + return -1; + } else { + fprintf(mkf, "\t\\\n\t%s", + basename(pg.gl_pathv[i])); + } + } + + fprintf(mkf, "\n\n"); + fprintf(mkf, "lib_LTLIBRARIES=libsomething.la\n"); + fprintf(mkf, "libsomething_la_SOURCES=${ASN_SRCS}\n"); + fclose(mkf); + fprintf(stderr, "Generated Makefile.am.sample\n"); + globfree(&pg); + } + + return 0; +} + +/* + * Dump the streams. + */ +static int +asn1c_dump_streams(arg_t *arg) { + if(arg->flags & A1C_PRINT_COMPILED) { + return asn1c_print_streams(arg); + } else { + return asn1c_save_streams(arg); + } +} + +static int +asn1c_print_streams(arg_t *arg) { + compiler_streams_t *cs = arg->expr->data; + asn1p_expr_t *expr = arg->expr; + int i; + + for(i = 0; i < OT_MAX; i++) { + out_chunk_t *ot; + if(TQ_FIRST(&cs->targets[i]) == NULL) + continue; + + printf("\n/*** <<< %s [%s] >>> ***/\n\n", + _compiler_stream2str[i], + expr->Identifier); + + TQ_FOR(ot, &(cs->targets[i]), next) { + fwrite(ot->buf, ot->len, 1, stdout); + } + } + + return 0; +} + +static int +asn1c_save_streams(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + compiler_streams_t *cs = expr->data; + out_chunk_t *ot; + FILE *fp_c, *fp_h; + char *header_id; + + if(cs == NULL) { + fprintf(stderr, "Cannot compile %s at line %d\n", + expr->Identifier, expr->_lineno); + return -1; + } + + fp_c = asn1c_open_file(arg, expr->Identifier, ".c"); + fp_h = asn1c_open_file(arg, expr->Identifier, ".h"); + if(fp_c == NULL || fp_h == NULL) { + if(fp_c) fclose(fp_c); /* lacks unlink() */ + if(fp_h) fclose(fp_h); /* lacks unlink() */ + return -1; + } + + header_id = alloca(strlen(expr->Identifier) + 1); + if(1) { + char *src, *dst; + for(src = expr->Identifier, dst = header_id; + (*dst=*src); src++, dst++) + if(!isalnum(*src)) *dst = '_'; + *dst = '\0'; + } + + fprintf(fp_h, + "#ifndef\t_%s_H_\n" + "#define\t_%s_H_\n" + "\n", header_id, header_id); + + fprintf(fp_h, "#include \n\n"); + + TQ_FOR(ot, &(cs->targets[OT_DEPS]), next) + fwrite(ot->buf, ot->len, 1, fp_h); + fprintf(fp_h, "\n"); + TQ_FOR(ot, &(cs->targets[OT_TYPE_DECLS]), next) + fwrite(ot->buf, ot->len, 1, fp_h); + fprintf(fp_h, "\n"); + TQ_FOR(ot, &(cs->targets[OT_FUNC_DECLS]), next) + fwrite(ot->buf, ot->len, 1, fp_h); + + fprintf(fp_c, "#include <%s.h>\n\n", expr->Identifier); + TQ_FOR(ot, &(cs->targets[OT_STAT_DEFS]), next) + fwrite(ot->buf, ot->len, 1, fp_c); + TQ_FOR(ot, &(cs->targets[OT_CODE]), next) + fwrite(ot->buf, ot->len, 1, fp_c); + + assert(OT_MAX == 5); + + fprintf(fp_h, "\n#endif\t/* _%s_H_ */\n", header_id); + + fclose(fp_c); + fclose(fp_h); + fprintf(stderr, "Compiled %s.c\n", expr->Identifier); + fprintf(stderr, "Compiled %s.h\n", expr->Identifier); + return 0; +} + +static int +asn1c_copy_over(arg_t *arg, char *path) { + char *fname = basename(path); + + if(symlink(path, fname)) { + if(errno == EEXIST) { + struct stat sb1, sb2; + if(stat(path, &sb1) == 0 + && stat(fname, &sb2) == 0 + && sb1.st_dev == sb2.st_dev + && sb1.st_ino == sb2.st_ino) { + /* + * Nothing to do. + */ + fprintf(stderr, + "File %s is already here as %s\n", + path, fname); + return 0; + } else { + fprintf(stderr, + "Retaining local %s (%s suggested)\n", + fname, path); + return 0; + } + } else { + fprintf(stderr, "Symlink %s -> %s failed: %s\n", + path, fname, strerror(errno)); + return -1; + } + } + + fprintf(stderr, "Symlinked %s\t-> %s\n", path, fname); + + return 0; +} + diff --git a/libasn1compiler/asn1c_save.h b/libasn1compiler/asn1c_save.h new file mode 100644 index 00000000..487e625b --- /dev/null +++ b/libasn1compiler/asn1c_save.h @@ -0,0 +1,6 @@ +#ifndef _ASN1_SAVE_H_ +#define _ASN1_SAVE_H_ + +int asn1c_save_compiled_output(arg_t *arg, const char *datadir); + +#endif /* _ASN1_SAVE_H_ */ diff --git a/libasn1compiler/asn1compiler.c b/libasn1compiler/asn1compiler.c new file mode 100644 index 00000000..d647c05b --- /dev/null +++ b/libasn1compiler/asn1compiler.c @@ -0,0 +1,160 @@ +#include "asn1c_internal.h" + +static void default_logger_cb(int, const char *fmt, ...); +static int asn1c_compile_expr(arg_t *arg); +static int asn1c_attach_streams(asn1p_expr_t *expr); + +int +asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags) { + arg_t arg_s; + arg_t *arg = &arg_s; + int ret; + + /* + * Initialize target language. + */ + ret = asn1c_with_language(ASN1C_LANGUAGE_C); + assert(ret == 0); + + memset(arg, 0, sizeof(*arg)); + arg->default_cb = asn1c_compile_expr; + arg->logger_cb = default_logger_cb; + arg->flags = flags; + arg->asn = asn; + + /* + * Compile each individual top level structure. + */ + TQ_FOR(arg->mod, &(asn->modules), mod_next) { + TQ_FOR(arg->expr, &(arg->mod->members), next) { + compiler_streams_t *cs = NULL; + + if(asn1c_attach_streams(arg->expr)) + return -1; + + cs = arg->expr->data; + cs->target = OT_TYPE_DECLS; + arg->target = cs; + + ret = asn1c_compile_expr(arg); + if(ret) { + FATAL("Cannot compile %s (%x:%x) at line %d", + arg->expr->Identifier, + arg->expr->expr_type, + arg->expr->meta_type, + arg->expr->_lineno); + return ret; + } + } + } + + DEBUG("Saving compiled data"); + + /* + * Save or print out the compiled result. + */ + if(asn1c_save_compiled_output(arg, datadir)) + return -1; + + return 0; +} + +static int +asn1c_compile_expr(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int (*type_cb)(arg_t *); + int ret; + + assert(expr->meta_type >= AMT_INVALID); + assert(expr->meta_type < AMT_EXPR_META_MAX); + assert(expr->expr_type >= A1TC_INVALID); + assert(expr->expr_type < ASN_EXPR_TYPE_MAX); + + type_cb = asn1_lang_map[expr->meta_type][expr->expr_type].type_cb; + if(type_cb) { + + if(arg->indent_level == 0) + OUT("\n"); + + DEBUG("Compiling %s at line %d", + expr->Identifier, + expr->_lineno); + + ret = type_cb(arg); + } else { + ret = -1; + /* + * Even if the target language compiler does not know + * how to compile the given expression, we know that + * certain expressions need not to be compiled at all. + */ + switch(expr->meta_type) { + case AMT_PARAMTYPE: + case AMT_OBJECT: + case AMT_OBJECTSET: + case AMT_VALUE: + case AMT_VALUESET: + ret = 0; + break; + default: + break; + } + + switch(expr->expr_type) { + case A1TC_TYPEID: + ret = 0; /* TYPE-IDENTIFIER is a CLASS */ + default: + break; + } + } + + if(ret == -1) { + OUT("#error Cannot compile \"%s\" (%x/%x) at line %d\n", + arg->expr->Identifier, + arg->expr->meta_type, + arg->expr->expr_type, + arg->expr->_lineno + ); + } + + return ret; +} + +static int +asn1c_attach_streams(asn1p_expr_t *expr) { + compiler_streams_t *cs; + int i; + + if(expr->data) + return 0; /* Already attached? */ + + expr->data = calloc(1, sizeof(compiler_streams_t)); + if(expr->data == NULL) + return -1; + + cs = expr->data; + for(i = 0; i < OT_MAX; i++) { + TQ_INIT(&(cs->targets[i])); + } + + return 0; +} + +static void +default_logger_cb(int _severity, const char *fmt, ...) { + va_list ap; + char *pfx = ""; + + switch(_severity) { + case -1: pfx = "DEBUG: "; break; + case 0: pfx = "WARNING: "; break; + case 1: pfx = "FATAL: "; break; + } + + fprintf(stderr, "%s", pfx); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + diff --git a/libasn1compiler/asn1compiler.h b/libasn1compiler/asn1compiler.h new file mode 100644 index 00000000..d104dc9a --- /dev/null +++ b/libasn1compiler/asn1compiler.h @@ -0,0 +1,41 @@ +#ifndef ASN1_COMPILER_H +#define ASN1_COMPILER_H + +#include + +enum asn1c_flags { + A1C_NOFLAGS, + /* + * Debug the compiler. + */ + A1C_DEBUG = 0x0001, + /* + * Do not split the target output in several files, just print it. + * (Note: the output is not likely to be compilable in this case). + */ + A1C_PRINT_COMPILED = 0x0002, + /* + * Generate only the tables for ASN.1 types, + * do not emit ASN.1 parsing support code. + */ + A1C_OMIT_SUPPORT_CODE = 0x0004, + /* + * Use native integers instead of INTEGER_t and ENUMERATED_t types. + */ + A1C_USE_NATIVE_INTEGERS = 0x0008, + /* + * Do not use C99 extensions. + */ + A1C_NO_C99 = 0x0010, + /* + * Enable use of unnamed unions (non-portable feature). + */ + A1C_UNNAMED_UNIONS = 0x0020, +}; + +/* + * Compile the ASN.1 specification. + */ +int asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags); + +#endif /* ASN1_COMPILER_H */ diff --git a/libasn1compiler/check_compiler.c b/libasn1compiler/check_compiler.c new file mode 100644 index 00000000..1da6902f --- /dev/null +++ b/libasn1compiler/check_compiler.c @@ -0,0 +1,7 @@ +#include "asn1compiler.h" + +int +main(int ac, char **av) { + return 0; +} + diff --git a/libasn1fix/Makefile.am b/libasn1fix/Makefile.am new file mode 100644 index 00000000..0e52b4f3 --- /dev/null +++ b/libasn1fix/Makefile.am @@ -0,0 +1,36 @@ + + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1fix.la + +libasn1fix_la_LDFLAGS = -all-static +libasn1fix_la_SOURCES = \ + asn1fix.c asn1fix.h \ + asn1fix_internal.h \ + asn1fix_misc.c asn1fix_misc.h \ + asn1fix_value.c asn1fix_value.h \ + asn1fix_compat.c asn1fix_compat.h \ + asn1fix_constr.c asn1fix_constr.h \ + asn1fix_cstring.c asn1fix_cstring.h \ + asn1fix_retrieve.c asn1fix_retrieve.h \ + asn1fix_bitstring.c asn1fix_bitstring.h \ + asn1fix_integer.c asn1fix_integer.h \ + asn1fix_dereft.c asn1fix_dereft.h \ + asn1fix_derefv.c asn1fix_derefv.h \ + asn1fix_export.c asn1fix_export.h \ + asn1fix_param.c asn1fix_param.h \ + asn1fix_class.c asn1fix_class.h \ + asn1fix_tags.c asn1fix_tags.h \ + asn1fix_enum.c asn1fix_enum.h +libasn1fix_la_LIBADD = ${top_builddir}/libasn1parser/libasn1parser.la + +check_PROGRAMS = check_fixer + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS_ENVIRONMENT= ./check_fixer +TESTS = ${top_srcdir}/tests/*.asn1 +## TESTS = ${check_PROGRAMS} # This is an alternate form of testing diff --git a/libasn1fix/Makefile.in b/libasn1fix/Makefile.in new file mode 100644 index 00000000..8d919c20 --- /dev/null +++ b/libasn1fix/Makefile.in @@ -0,0 +1,454 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1fix.la + +libasn1fix_la_LDFLAGS = -all-static +libasn1fix_la_SOURCES = \ + asn1fix.c asn1fix.h \ + asn1fix_internal.h \ + asn1fix_misc.c asn1fix_misc.h \ + asn1fix_value.c asn1fix_value.h \ + asn1fix_compat.c asn1fix_compat.h \ + asn1fix_constr.c asn1fix_constr.h \ + asn1fix_cstring.c asn1fix_cstring.h \ + asn1fix_retrieve.c asn1fix_retrieve.h \ + asn1fix_bitstring.c asn1fix_bitstring.h \ + asn1fix_integer.c asn1fix_integer.h \ + asn1fix_dereft.c asn1fix_dereft.h \ + asn1fix_derefv.c asn1fix_derefv.h \ + asn1fix_export.c asn1fix_export.h \ + asn1fix_param.c asn1fix_param.h \ + asn1fix_class.c asn1fix_class.h \ + asn1fix_tags.c asn1fix_tags.h \ + asn1fix_enum.c asn1fix_enum.h + +libasn1fix_la_LIBADD = ${top_builddir}/libasn1parser/libasn1parser.la + +check_PROGRAMS = check_fixer + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS_ENVIRONMENT = ./check_fixer +TESTS = ${top_srcdir}/tests/*.asn1 +subdir = libasn1fix +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1fix_la_DEPENDENCIES = \ + ${top_builddir}/libasn1parser/libasn1parser.la +am_libasn1fix_la_OBJECTS = asn1fix.lo asn1fix_misc.lo asn1fix_value.lo \ + asn1fix_compat.lo asn1fix_constr.lo asn1fix_cstring.lo \ + asn1fix_retrieve.lo asn1fix_bitstring.lo asn1fix_integer.lo \ + asn1fix_dereft.lo asn1fix_derefv.lo asn1fix_export.lo \ + asn1fix_param.lo asn1fix_class.lo asn1fix_tags.lo \ + asn1fix_enum.lo +libasn1fix_la_OBJECTS = $(am_libasn1fix_la_OBJECTS) +check_PROGRAMS = check_fixer$(EXEEXT) +check_fixer_SOURCES = check_fixer.c +check_fixer_OBJECTS = check_fixer.$(OBJEXT) +check_fixer_LDADD = $(LDADD) +check_fixer_DEPENDENCIES = libasn1fix.la \ + ${top_builddir}/libasn1parser/libasn1parser.la +check_fixer_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1fix.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_bitstring.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_class.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_compat.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_constr.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_cstring.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_dereft.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_derefv.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_enum.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_export.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_integer.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_misc.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_param.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_retrieve.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_tags.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_value.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/check_fixer.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libasn1fix_la_SOURCES) check_fixer.c +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libasn1fix_la_SOURCES) check_fixer.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1fix/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +libasn1fix.la: $(libasn1fix_la_OBJECTS) $(libasn1fix_la_DEPENDENCIES) + $(LINK) $(libasn1fix_la_LDFLAGS) $(libasn1fix_la_OBJECTS) $(libasn1fix_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check_fixer$(EXEEXT): $(check_fixer_OBJECTS) $(check_fixer_DEPENDENCIES) + @rm -f check_fixer$(EXEEXT) + $(LINK) $(check_fixer_LDFLAGS) $(check_fixer_OBJECTS) $(check_fixer_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_bitstring.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_class.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_compat.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_constr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_cstring.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_dereft.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_derefv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_enum.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_export.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_integer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_param.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_retrieve.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_tags.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_value.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_fixer.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1fix/asn1fix.c b/libasn1fix/asn1fix.c new file mode 100644 index 00000000..af110999 --- /dev/null +++ b/libasn1fix/asn1fix.c @@ -0,0 +1,354 @@ +#include +#include +#include +#include + +#include "asn1fix.h" +#include "asn1fix_internal.h" + +/* Print everything to stderr */ +static void _default_error_logger(int _severity, const char *fmt, ...); + +/* + * Internal check functions. + */ +static int asn1f_fix_module(arg_t *arg); +static int asn1f_fix_simple(arg_t *arg); /* For INTEGER/ENUMERATED */ +static int asn1f_fix_constructed(arg_t *arg); /* For SEQUENCE/SET/CHOICE */ +static int asn1f_fix_constraints(arg_t *arg); /* For subtype constraints */ + + +/* + * Scan every module defined here in search for inconsistences. + */ +int +asn1f_process(asn1p_t *asn, enum asn1f_flags flags, + error_logger_f error_logger) { + arg_t arg; + int fatals = 0; + int warnings = 0; + + /* + * Check validity of arguments. + */ + if(asn == NULL) { + errno = EINVAL; + return -1; + } + + /* + * If errors handler is not specified, default to internal one. + */ + if(error_logger == 0) { + error_logger = _default_error_logger; + } + + memset(&arg, 0, sizeof(arg)); + arg.asn = asn; + arg.eh = error_logger; + + if(flags & A1F_DEBUG) { + arg.debug = arg.eh; + arg.debug(-1, "Called %s() with flags %d", __func__, flags); + flags &= ~A1F_DEBUG; + } + + /* + * Check that we haven't missed an unknown flag. + */ + if(flags) { + errno = EINVAL; + return -1; + } + + /* + * Process each module in the list. + */ + TQ_FOR(arg.mod, &(asn->modules), mod_next) { + int ret = asn1f_fix_module(&arg); + /* + * These lines are used for illustration purposes. + * RET2RVAL() is used everywhere else. + */ + if(ret == -1) fatals++; + if(ret == 1) warnings++; + } + + /* + * Compute a return value. + */ + return fatals?-1:warnings?1:0; +} + +/* + * Check the internals of a single module. + */ +static int +asn1f_fix_module(arg_t *arg) { + asn1p_expr_t *expr; + int rvalue = 0; + + switch((arg->mod->module_flags + & (MSF_EXPLICIT_TAGS | MSF_IMPLICIT_TAGS | MSF_AUTOMATIC_TAGS))) { + case MSF_NOFLAGS: + case MSF_EXPLICIT_TAGS: + case MSF_IMPLICIT_TAGS: + case MSF_AUTOMATIC_TAGS: + break; + default: + FATAL("Module %s defined with ambiguous global tagging mode", + arg->mod->Identifier); + RET2RVAL(-1, rvalue); + } + + /* + * Do various non-recursive transformations. + * Order is not important. + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + arg->expr = expr; + + if(expr->meta_type == AMT_PARAMTYPE) + /* Do not process the parametrized type just yet */ + continue; + + DEBUG("=== Now processing \"%s\" at line %d ===", + expr->Identifier, expr->_lineno); + assert(expr->meta_type != AMT_INVALID); + + /* + * 2.1 Pre-process simple types (ENUMERATED, INTEGER, etc). + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_simple); + RET2RVAL(ret, rvalue); + + /* + * 2.[234] Process SEQUENCE/SET/CHOICE types. + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_constructed); + RET2RVAL(ret, rvalue); + + /* + * 2.5.4 + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_types); + RET2RVAL(ret, rvalue); + + /* + * 2.5.5 + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_values); + RET2RVAL(ret, rvalue); + + /* + * Resolve references in constraints. + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_constraints); + RET2RVAL(ret, rvalue); + + /* + * 6. INTEGER value processed at 2.5.4. + */ + + /* + * Make sure everybody's behaving well. + */ + assert(arg->expr == expr); + } + + /* + * 5. Automatic tagging + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + + arg->expr = expr; + + ret = asn1f_recurse_expr(arg, asn1f_fix_constr_autotag); + RET2RVAL(ret, rvalue); + + assert(arg->expr == expr); + } + + /* + * 8. fix BIT STRING + * 9. fix spaces in cstrings + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + arg->expr = expr; + + ret = asn1f_recurse_expr(arg, asn1f_fix_bit_string); + RET2RVAL(ret, rvalue); + + ret = asn1f_recurse_expr(arg, asn1f_fix_cstring); + RET2RVAL(ret, rvalue); + + assert(arg->expr == expr); + } + + /* + * ... Check for tags distinctness. + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + arg->expr = expr; + + ret = asn1f_recurse_expr(arg, asn1f_check_constr_tags_distinct); + RET2RVAL(ret, rvalue); + + assert(arg->expr == expr); + } + + return rvalue; +} + + +static int +asn1f_fix_simple(arg_t *arg) { + int rvalue = 0; + int ret; + + ret = asn1f_fix_enum(arg); + RET2RVAL(ret, rvalue); + + ret = asn1f_fix_integer(arg); + RET2RVAL(ret, rvalue); + + return rvalue; +} + +static int +asn1f_fix_constructed(arg_t *arg) { + int rvalue = 0; + int ret; + + switch(arg->expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + /* Check identifier distinctness */ + ret = asn1f_check_unique_expr(arg, NULL); + RET2RVAL(ret, rvalue); + + /* Fix extensibility */ + ret = asn1f_fix_constr_ext(arg); + RET2RVAL(ret, rvalue); + + /* Fix tagging */ + ret = asn1f_fix_constr_tag(arg); + RET2RVAL(ret, rvalue); + + return rvalue; +} + +static int +_constraint_value_resolve(arg_t *arg, asn1p_value_t **value) { + asn1p_expr_t expr; + asn1p_expr_t *tmp_expr; + asn1p_module_t *tmp_mod; + asn1p_module_t *mod_r = NULL; + int rvalue = 0; + int ret; + + tmp_expr = asn1f_lookup_symbol(arg, (*value)->value.reference, &mod_r); + if(tmp_expr == NULL) { + FATAL("Cannot find symbol %s " + "used in %s subtype constraint at line %d", + asn1f_printable_reference((*value)->value.reference), + arg->expr->Identifier, arg->expr->_lineno); + assert((*value)->type == ATV_REFERENCED); + return -1; + } + + memset(&expr, 0, sizeof(expr)); + expr.meta_type = tmp_expr->meta_type; + expr.expr_type = tmp_expr->expr_type; + expr.Identifier = tmp_expr->Identifier; + expr.value = *value; + tmp_expr = arg->expr; + tmp_mod = arg->mod; + arg->expr = &expr; + arg->mod = mod_r; + ret = asn1f_fix_dereference_values(arg); + RET2RVAL(ret, rvalue); + arg->expr = tmp_expr; + arg->mod = tmp_mod; + assert(expr.value); + *value = expr.value; + + return rvalue; +} + +static int +_resolve_constraints(arg_t *arg, asn1p_constraint_t *ct) { + int rvalue = 0; + int ret; + int el; + + /* Don't touch information object classes */ + if(ct->type == ACT_CT_WCOMP + || ct->type == ACT_CT_WCOMPS + || ct->type == ACT_CA_CRC) + return 0; + + if(ct->value && ct->value->type == ATV_REFERENCED) { + ret = _constraint_value_resolve(arg, &ct->value); + RET2RVAL(ret, rvalue); + } + if(ct->range_start && ct->range_start->type == ATV_REFERENCED) { + ret = _constraint_value_resolve(arg, &ct->range_start); + RET2RVAL(ret, rvalue); + } + if(ct->range_stop && ct->range_stop->type == ATV_REFERENCED) { + ret = _constraint_value_resolve(arg, &ct->range_stop); + RET2RVAL(ret, rvalue); + } + + for(el = 0; el < ct->el_count; el++) { + ret = _resolve_constraints(arg, ct->elements[el]); + RET2RVAL(ret, rvalue); + } + + return rvalue; +} + +static int +asn1f_fix_constraints(arg_t *arg) { + int rvalue = 0; + int ret; + + if(arg->expr->constraints) { + ret = _resolve_constraints(arg, arg->expr->constraints); + RET2RVAL(ret, rvalue); + } + + return rvalue; +} + +/* + * Print everything to stderr + */ +static void +_default_error_logger(int _severity, const char *fmt, ...) { + va_list ap; + char *pfx = ""; + + switch(_severity) { + case -1: pfx = "DEBUG: "; break; + case 0: pfx = "WARNING: "; break; + case 1: pfx = "FATAL: "; break; + } + + fprintf(stderr, "%s", pfx); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} diff --git a/libasn1fix/asn1fix.h b/libasn1fix/asn1fix.h new file mode 100644 index 00000000..4847330a --- /dev/null +++ b/libasn1fix/asn1fix.h @@ -0,0 +1,30 @@ +/* + * This is the public interface for the processor (fixer) of the ASN.1 tree + * produced by the libasn1parser. + */ +#ifndef ASN1FIX_H +#define ASN1FIX_H + +#include + +/* + * Operation flags for the function below. + */ +enum asn1f_flags { + A1F_NOFLAGS, + A1F_DEBUG, /* Print debugging output using (_is_fatal = -1) */ +}; + +/* + * Perform a set of semantics checks, transformations and small fixes + * on the given tree. + * RETURN VALUES: + * -1: Some fatal problems were encountered. + * 0: No inconsistencies were found. + * 1: Some warnings were issued, but no fatal problems encountered. + */ +int asn1f_process(asn1p_t *_asn, + enum asn1f_flags, + void (*error_log_callback)(int _severity, const char *fmt, ...)); + +#endif /* ASN1FIX_H */ diff --git a/libasn1fix/asn1fix_bitstring.c b/libasn1fix/asn1fix_bitstring.c new file mode 100644 index 00000000..0d3961d4 --- /dev/null +++ b/libasn1fix/asn1fix_bitstring.c @@ -0,0 +1,230 @@ +#include "asn1fix_internal.h" + +int asn1f_fix_bit_string_value(arg_t *arg, asn1p_expr_t *ttype); +static void asn1f_BS_remove_trailing_zero_bits(asn1p_value_t *value); +static int asn1f_BS_unparsed_convert(arg_t *arg, asn1p_value_t *value, asn1p_expr_t *ttype); + +int +asn1f_fix_bit_string(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + int ret; + + if(expr->meta_type == AMT_VALUE) { + asn1p_expr_t *ttype; + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + ttype = asn1f_find_terminal_type(arg, expr, 0); + if(ttype && ttype->expr_type == ASN_BASIC_BIT_STRING) { + ret = asn1f_fix_bit_string_value(arg, ttype); + RET2RVAL(ret, r_value); + } + } + + return r_value; +} + +int +asn1f_fix_bit_string_value(arg_t *arg, asn1p_expr_t *ttype) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + switch(expr->value->type) { + case ATV_UNPARSED: + /* + * Most definitely we have something like + * value BitStringType1 ::= { a, b, c } + * which could not be parsed by the LALR parser, mostly + * because it requires knowledge about BitStringType1 + * during the parsing. So, here's a little hack: we create + * a buffer containing the full specification of a module, + * which contains some pre-defined INTEGER type with the + * opaque definition "{ a, b, c }" from the bit string. + */ + if(asn1f_BS_unparsed_convert(arg, expr->value, ttype)) { + r_value = -1; + break; + } + /* Fall through: remove trailing zero bits */ + case ATV_BITVECTOR: + asn1f_BS_remove_trailing_zero_bits(expr->value); + break; + default: + break; + } + + return r_value; +} + +static void +asn1f_BS_remove_trailing_zero_bits(asn1p_value_t *value) { + int lmfb = -1; /* Last meaningful byte position */ + int bits; /* Number of bits in the BIT STRING value */ + int b; + + assert(value->type == ATV_BITVECTOR); + + bits = value->value.binary_vector.size_in_bits; + /* + * Figure out the rightmost meaningful byte. + */ + for(b = 0; b < ((bits + 7) >> 3); b++) { + uint8_t uc = value->value.binary_vector.bits[b]; + if(uc && b > lmfb) + lmfb = b; + } + if(lmfb == -1) { + bits = 0; + } else { + uint8_t uc; + uc = value->value.binary_vector.bits[lmfb]; + bits = (lmfb+1) * 8; + /* + * Squeeze the bit string width until the rightmost + * bit is set. + */ + for(; uc && (uc & 1) == 0; uc >>= 1) + bits--; + if(uc == 0) { + bits = lmfb * 8; + } + } + value->value.binary_vector.size_in_bits = bits; +} + +static int +asn1f_BS_unparsed_convert(arg_t *arg, asn1p_value_t *value, asn1p_expr_t *ttype) { + asn1p_t *asn; + asn1p_module_t *mod; + asn1p_expr_t *V; + asn1p_expr_t *bit; + asn1_integer_t aI; + uint8_t *bitbuf; + int bits; + int psize; + char *p; + int ret; + int r_value = 0; + + assert(value->type == ATV_UNPARSED); + + psize = value->value.string.size + 64; + p = malloc(psize); + if(p == NULL) + return -1; + + ret = snprintf(p, psize, + "M DEFINITIONS ::=\nBEGIN\n" + "V ::= INTEGER %s\n" + "END\n", + value->value.string.buf + ); + assert(ret < psize); + psize = ret; + + asn = asn1p_parse_buffer(p, psize, A1P_NOFLAGS); + free(p); + if(asn == NULL) { + FATAL("Cannot parse BIT STRING value %s " + "defined as %s at line %d", + arg->expr->Identifier, + value->value.string.buf, + arg->expr->_lineno + ); + return -1; + } + + mod = TQ_FIRST(&(asn->modules)); + assert(mod); + V = TQ_FIRST(&(mod->members)); + assert(V); + assert(strcmp(V->Identifier, "V") == 0); + assert(TQ_FIRST(&(V->members))); + + /* + * Simple loop just to fetch the maximal bit position + * out of the BIT STRING value defined as NamedBitList. + */ + aI = -1; + TQ_FOR(bit, &(V->members), next) { + asn1p_expr_t *bitdef; + bitdef = asn1f_lookup_child(ttype, bit->Identifier); + if(bitdef && bitdef->value + && bitdef->value->type == ATV_INTEGER) { + if(bitdef->value->value.v_integer > aI) + aI = bitdef->value->value.v_integer; + } + } + + if(aI > 1024 * 1024 * 8) { /* One megabyte */ + FATAL("Unsupportedly large BIT STRING value \"%s\" " + "defined at line %d " + "(larger than 1MByte)", + arg->expr->Identifier, + arg->expr->_lineno + ); + asn1p_free(asn); + return -1; + } + + bits = aI + 1; /* Number of bits is more than a last bit position */ + bitbuf = calloc(1, 1 + ((bits + 7) / 8)); + if(bitbuf == NULL) { + asn1p_free(asn); + return -1; + } + + TQ_FOR(bit, &(V->members), next) { + asn1p_expr_t *bitdef; + int set_bit_pos; + + if(bit->value) { + WARNING("Identifier \"%s\" at line %d " + "must not have a value", + bit->Identifier, bit->_lineno); + RET2RVAL(1, r_value); + } + bitdef = asn1f_lookup_child(ttype, bit->Identifier); + if(bitdef == NULL) { + FATAL("Identifier \"%s\" at line %d is not defined " + "in the \"%s\" type definition at line %d", + bit->Identifier, + bit->_lineno, + ttype->Identifier, + ttype->_lineno + ); + RET2RVAL(-1, r_value); + continue; + } + if(bitdef->value == NULL + || bitdef->value->type != ATV_INTEGER) { + FATAL("Broken identifier " + "\"%s\" at line %d " + "referenced by \"%s\" at line %d", + bitdef->Identifier, + bitdef->_lineno, + arg->expr->Identifier, + arg->expr->_lineno + ); + RET2RVAL(-1, r_value); + continue; + } + + assert(bitdef->value->value.v_integer < bits); + set_bit_pos = bitdef->value->value.v_integer; + bitbuf[set_bit_pos>>3] |= 1 << (7-(set_bit_pos % 8)); + } + + asn1p_free(asn); + free(value->value.string.buf); + value->type = ATV_BITVECTOR; + value->value.binary_vector.bits = bitbuf; + value->value.binary_vector.size_in_bits = bits; + + return r_value; +} diff --git a/libasn1fix/asn1fix_bitstring.h b/libasn1fix/asn1fix_bitstring.h new file mode 100644 index 00000000..1230856f --- /dev/null +++ b/libasn1fix/asn1fix_bitstring.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_BIT_STRING_H_ +#define _ASN1FIX_BIT_STRING_H_ + +int asn1f_fix_bit_string(arg_t *); + +#endif /* _ASN1FIX_BIT_STRING_H_ */ diff --git a/libasn1fix/asn1fix_class.c b/libasn1fix/asn1fix_class.c new file mode 100644 index 00000000..c541fd62 --- /dev/null +++ b/libasn1fix/asn1fix_class.c @@ -0,0 +1,237 @@ +#include "asn1fix_internal.h" + +typedef enum field_category { + OFC_INVALID, /* Invalid object field category */ + OFC_TYPE, + OFC_FIXED_TYPE_VALUE, + OFC_VARIABLE_TYPE_VALUE, + OFC_FIXED_TYPE_VALUE_SET, + OFC_VARIABLE_TYPE_VALUE_SET, + OFC_INFORMATION_OBJECT, + OFC_INFORMATION_OBJECT_SET, +} field_category_e; + +typedef enum object_category { + OC_INVALID, + OC_OBJECT, + OC_OBJECTSET, +} object_category_e; + +static field_category_e asn1f_class_field_category(asn1p_expr_t *ofield); +static object_category_e asn1f_class_object_category(asn1p_expr_t *expr); +static asn1p_expr_t * +asn1f_class_dot_lookup(arg_t *arg, asn1p_expr_t *obj, asn1p_ref_t *ref); + +asn1p_expr_t * +asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) { + asn1p_expr_t *obj; /* Information Object or Object Set */ + object_category_e obj_cat; /* Object category */ + //field_category_e field_cat; /* Field category */ + asn1p_expr_t *result; + asn1p_ref_t tmpref; + + assert(ref->comp_count > 1); + + DEBUG("%s(%s) for line %d", __func__, + asn1f_printable_reference(ref), + ref->_lineno); + + /* + * Fetch the first part of the reference (OBJECT or ObjectSet). + * OBJECT.&... + * ObjectSet.&... + */ + assert(isupper(ref->components[0].name[0])); + + tmpref = *ref; + tmpref.comp_count = 1; + obj = asn1f_lookup_symbol(arg, &tmpref, 0); + if(obj == NULL) { + errno = ESRCH; + return NULL; + } + + /* + * Make sure the symbol lexical property (upper-case, lower-case) + * corresponds to the type of the expression returned by + * lookup_symbol(). + */ + obj_cat = asn1f_class_object_category(obj); + switch(obj_cat) { + case OC_OBJECT: + case OC_OBJECTSET: + if(ref->components[0].lex_type + == (obj_cat==OC_OBJECT) + ? RLT_CAPITALS + : RLT_Uppercase) + break; + /* Fall through */ + case OC_INVALID: + WARNING("Symbol \"%s\" is not compatible " + "with referenced expression \"%s\" at line %d", + ref->components[0].name, + obj->Identifier, obj->_lineno); + errno = EPERM; + return NULL; + } + + /* + * Find the specified field within the object. + */ + result = asn1f_class_dot_lookup(arg, obj, ref); + if(result == NULL) { + return NULL; + } + + //field_cat = asn1f_class_field_category(result); + + DEBUG("FILLME: %s", result->Identifier); + + return result; +} + +static object_category_e +asn1f_class_object_category(asn1p_expr_t *expr) { + + switch(expr->meta_type) { + case AMT_OBJECT: + return OC_OBJECT; + case AMT_OBJECTSET: + return OC_OBJECTSET; + case AMT_VALUESET: + if(expr->expr_type == A1TC_REFERENCE + && expr->reference + && expr->reference->comp_count == 1 + && expr->reference->components[0].lex_type == RLT_CAPITALS) + { + /* FIXME: use find_terminal_type instead! */ + return OC_OBJECTSET; + } + break; + default: + break; + } + + return OC_INVALID; +} + +static field_category_e +asn1f_class_field_category(asn1p_expr_t *ofield) { + if(ofield->Identifier[0] != '&') { + assert(ofield->Identifier[0] == '&'); + return OFC_INVALID; + } + + if(isupper(ofield->Identifier[1])) { + if(ofield->reference) { + enum asn1p_ref_lex_type_e lex_type + = ofield->reference->components[0].lex_type; + + switch(lex_type) { + case RLT_CAPITALS: + return OFC_INFORMATION_OBJECT_SET; + case RLT_Uppercase: + return OFC_FIXED_TYPE_VALUE_SET; + case RLT_AmpUppercase: + return OFC_VARIABLE_TYPE_VALUE_SET; + default: + break; + } + } else { + if(ofield->expr_type == A1TC_CLASSFIELD) + return OFC_TYPE; + + switch(ofield->meta_type) { + case AMT_TYPE: + case AMT_TYPEREF: + return OFC_FIXED_TYPE_VALUE_SET; + default: + break; + } + + } + } else { + if(ofield->reference) { + enum asn1p_ref_lex_type_e lex_type + = ofield->reference->components[0].lex_type; + + switch(lex_type) { + case RLT_CAPITALS: + return OFC_INFORMATION_OBJECT; + case RLT_Uppercase: + return OFC_FIXED_TYPE_VALUE; + case RLT_AmpUppercase: + return OFC_VARIABLE_TYPE_VALUE; + default: + break; + } + } else { + switch(ofield->meta_type) { + case AMT_TYPE: + case AMT_TYPEREF: + return OFC_FIXED_TYPE_VALUE; + default: + break; + } + } + } + + return OFC_INVALID; +} + + +static asn1p_expr_t * +asn1f_class_dot_lookup(arg_t *arg, asn1p_expr_t *obj, asn1p_ref_t *ref) { + asn1p_expr_t *ofield = NULL; /* Information Object's Field */ + field_category_e field_cat; /* Field category */ + int comp; + + assert(ref->comp_count >= 2); + + for(comp = 1 /* sic! */; comp < ref->comp_count; comp++) { + int is_last_component = (comp + 1 == ref->comp_count); + char *comp_name = ref->components[comp].name; + + ofield = asn1f_lookup_child(obj, comp_name); + if(ofield == NULL) { + DEBUG("Cannot find field \"%s\" in \"%s\" at line %d", + ref->components[1].name, + obj->Identifier, + obj->_lineno); + } + + /* + * Compute the category of the field of + * the information object class. + */ + field_cat = asn1f_class_field_category(ofield); + + switch(field_cat) { + case OFC_INVALID: + WARNING("Invalid field category of \"%s\" at line %d", + ofield->Identifier, ofield->_lineno); + errno = EPERM; + return NULL; + case OFC_TYPE: + case OFC_FIXED_TYPE_VALUE: + case OFC_VARIABLE_TYPE_VALUE: + case OFC_FIXED_TYPE_VALUE_SET: + case OFC_VARIABLE_TYPE_VALUE_SET: + if(!is_last_component) { + FATAL("Field name component \"%s\" at line %d " + "specifies non-dereferenceable thing", + comp_name, ref->_lineno); + errno = EPERM; + return NULL; + } + break; + case OFC_INFORMATION_OBJECT: + case OFC_INFORMATION_OBJECT_SET: + obj = ofield; + break; + } + } + + assert(ofield); + return ofield; +} diff --git a/libasn1fix/asn1fix_class.h b/libasn1fix/asn1fix_class.h new file mode 100644 index 00000000..c849b2b3 --- /dev/null +++ b/libasn1fix/asn1fix_class.h @@ -0,0 +1,16 @@ +#ifndef _ASN1FIX_CLASS_H_ +#define _ASN1FIX_CLASS_H_ + +/* + * Fetch the element from the class-related stuff (thing) by its reference. + */ +asn1p_expr_t * +asn1f_class_access(arg_t *, asn1p_ref_t *, asn1p_module_t **mod_r); + +/* + * Externally accessible version of above function. + */ +asn1p_expr_t *asn1f_class_access2(asn1p_t *asn, asn1p_module_t *mod, + asn1p_expr_t *expr, asn1p_ref_t *, asn1p_module_t **mod_r); + +#endif /* _ASN1FIX_CLASS_H_ */ diff --git a/libasn1fix/asn1fix_compat.c b/libasn1fix/asn1fix_compat.c new file mode 100644 index 00000000..aef26c0b --- /dev/null +++ b/libasn1fix/asn1fix_compat.c @@ -0,0 +1,132 @@ +#include "asn1fix_internal.h" + +static int asn1f_check_same_children(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b); + +/* + * Check that the expressions given are compatible in their type. + * ORDER DOES MATTER! (See .h). + */ +int +asn1f_check_type_compatibility(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { + asn1p_expr_type_e atype, btype; + + atype = a->expr_type; + btype = b->expr_type; + + DEBUG("%s(%s:%x@%d, %s:%x@%d)", __func__, + a->Identifier, atype, a->_lineno, + b->Identifier, btype, b->_lineno); + + /* + * Expected terminal type! + */ + assert(atype != A1TC_REFERENCE); + assert(btype != A1TC_REFERENCE); + + if(atype != btype) { + /* + * Limited compatibility. + */ + if((atype == A1TC_UNIVERVAL && btype == ASN_BASIC_INTEGER) + || (atype == A1TC_UNIVERVAL && btype == ASN_BASIC_ENUMERATED) + ) + return 0; + DEBUG("\t%s and %s are not compatible", + a->Identifier, b->Identifier); + return -1; /* Fairly obviously */ + } + + if(a == b) + return 0; /* Fairly obviously */ + + switch(atype) { + case ASN_BASIC_INTEGER: + /* All integers are compatible */ + return 0; + case ASN_BASIC_ENUMERATED: + /* + * Enumerations are not compatible + * unless their definitions are the same. + */ + if(asn1f_check_same_children(arg, a, b)) { + DEBUG("\tEnumerations are different %s and %s", + a->Identifier, b->Identifier); + return -1; + } + return 0; + default: + /* Compatibility is not defined yet */ + DEBUG("\tCompatibility rule is not defined for %s and %s", + a->Identifier, b->Identifier); + return -1; + } + + return 0; +} + +/* + * Check that the children are exactly same. + */ +static int +asn1f_check_same_children(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { + asn1p_expr_t *achild; + asn1p_expr_t *bchild; + + achild = TQ_FIRST(&(a->members)); + bchild = TQ_FIRST(&(b->members)); + + while(1) { + if(achild->expr_type != bchild->expr_type) + return -1; + + if(achild->Identifier && bchild->Identifier) { + if(strcmp(achild->Identifier, bchild->Identifier)) + return -1; + } else if(!(!achild->Identifier && !bchild->Identifier)) { + return -1; + } + + if(achild->value && bchild->value) { + if(achild->value->type != bchild->value->type) + return -1; + switch(achild->value->type) { + case ATV_INTEGER: + if(achild->value->value.v_integer + != bchild->value->value.v_integer) + return -1; + break; + case ATV_REFERENCED: + default: + DEBUG("Value %s at lines %d and " + "%d cannot be used in " + "semantical equality check", + asn1f_printable_value(achild->value), + achild->value->value.reference->_lineno, + bchild->value->value.reference->_lineno + ); + return -1; + } + } else if(!(!achild->value && !bchild->value)) { + /* One of values is defined, and another is not */ + return -1; + } + + achild = TQ_NEXT(achild, next); + bchild = TQ_NEXT(bchild, next); + + if(achild && bchild) + continue; + else if(!achild && !bchild) + break; + else + return -1; + } + + DEBUG("\t%s:%x@%d and %s:%x@%d are semantically equivalent", + a->Identifier, a->expr_type, a->_lineno, + b->Identifier, b->expr_type, b->_lineno); + + return 0; +} + + diff --git a/libasn1fix/asn1fix_compat.h b/libasn1fix/asn1fix_compat.h new file mode 100644 index 00000000..429e7dd8 --- /dev/null +++ b/libasn1fix/asn1fix_compat.h @@ -0,0 +1,14 @@ +#ifndef _ASN1FIX_COMPAT_H_ +#define _ASN1FIX_COMPAT_H_ + +/* + * Check that the expressions given are compatible in their type. + * ORDER DOES MATTER! + * The compatibility is being checked as if the value of b were used + * to assign it to type a. + */ +int asn1f_check_type_compatibility(arg_t *arg, + asn1p_expr_t *a, + asn1p_expr_t *b); + +#endif /* _ASN1FIX_COMPAT_H_ */ diff --git a/libasn1fix/asn1fix_constr.c b/libasn1fix/asn1fix_constr.c new file mode 100644 index 00000000..2aa79827 --- /dev/null +++ b/libasn1fix/asn1fix_constr.c @@ -0,0 +1,364 @@ +#include "asn1fix_internal.h" + +static int _asn1f_check_if_tag_must_be_explicit(arg_t *arg, asn1p_expr_t *v); +static int _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b); + + +int +asn1f_fix_constr_ext(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + TQ_HEAD(asn1p_expr_t) root_list; + TQ_HEAD(asn1p_expr_t) ext_list; + TQ_HEAD(asn1p_expr_t) *cur_list; + int r_value = 0; + int ext_count = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + TQ_INIT(&root_list); + TQ_INIT(&ext_list); + cur_list = (void *)&root_list; + + while((v = TQ_REMOVE(&(expr->members), next))) { + if(v->expr_type == A1TC_EXTENSIBLE) { + ext_count++; + switch(ext_count) { + case 1: cur_list = (void *)&ext_list; break; + case 2: + cur_list = (void *)&root_list; + if(v->value) { + FATAL("Optional extension marker " + "must not contain " + "an exception mark " + "at line %d", v->_lineno); + r_value = -1; + } + asn1p_expr_free(v); + continue; + case 3: + FATAL("Third extension marker " + "is not allowed at line %d", v->_lineno); + default: + r_value = -1; + } + } + + TQ_ADD(cur_list, v, next); + } + + /* + * Copy the root list and extension list back into the main list. + */ + TQ_HEAD_COPY(&(expr->members), &root_list); + while((v = TQ_REMOVE(&ext_list, next))) + TQ_ADD(&(expr->members), v, next); + + if(arg->mod->module_flags & MSF_EXTENSIBILITY_IMPLIED + && ext_count < 1) { + v = asn1p_expr_new(0); + if(v) { + v->Identifier = strdup("..."); + v->expr_type = A1TC_EXTENSIBLE; + v->meta_type = AMT_TYPE; + if(v->Identifier == NULL) { + asn1p_expr_free(v); + r_value = -1; + } else { + TQ_ADD(&(expr->members), v, next); + } + } else { + r_value = -1; + } + } + + return r_value; +} + + +int +asn1f_fix_constr_tag(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int fl_impl_tags = 0; + int fl_auto_tags = 0; + int root_tagged = 0; /* The root component is manually tagged */ + int ext_tagged = 0; /* The extensions are manually tagged */ + int component_number = 0; + int r_value = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + fl_impl_tags = (arg->mod->module_flags & MSF_IMPLICIT_TAGS); + fl_auto_tags = (arg->mod->module_flags & MSF_AUTOMATIC_TAGS); + + DEBUG("%s(%s) {%d, %d} for line %d", __func__, + expr->Identifier, fl_impl_tags, fl_auto_tags, expr->_lineno); + + TQ_FOR(v, &(expr->members), next) { + int must_explicit = 0; + + if(v->expr_type == A1TC_EXTENSIBLE) { + component_number++; + continue; + } + + if(v->tag.tag_class == TC_NOCLASS) { + continue; + } else { + switch(component_number) { + case 0: case 2: + root_tagged = 1; break; + default: + ext_tagged = 1; break; + } + } + + must_explicit = _asn1f_check_if_tag_must_be_explicit(arg, v); + + if(fl_impl_tags) { + if(v->tag.tag_mode != TM_EXPLICIT) { + if(must_explicit) + v->tag.tag_mode = TM_EXPLICIT; + else + v->tag.tag_mode = TM_IMPLICIT; + } + } else { + if(v->tag.tag_mode == TM_DEFAULT) { + v->tag.tag_mode = TM_EXPLICIT; + } + } + + /* + * Perform a final sanity check. + */ + if(must_explicit) { + if(v->tag.tag_mode == TM_IMPLICIT) { + FATAL("%s tagged in IMPLICIT mode " + "but must be EXPLICIT at line %d", + v->Identifier, v->_lineno); + r_value = -1; + } else { + v->tag.tag_mode = TM_EXPLICIT; + } + } + } + + if(ext_tagged && !root_tagged) { + FATAL("In %s at line %d: " + "extensions are tagged " + "but root components are not", + expr->Identifier, expr->_lineno); + r_value = -1; + } else if(!root_tagged && !ext_tagged && fl_auto_tags) { + expr->auto_tags_OK = 1; + } + + return r_value; +} + +int +asn1f_fix_constr_autotag(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + asn1_integer_t tag_value = 0; + int r_value = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + if(expr->auto_tags_OK) + break; + /* Automatic tagging is not applicable */ + /* Fall through */ + default: + return 0; + } + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + TQ_FOR(v, &(expr->members), next) { + int must_explicit; + + if(v->expr_type == A1TC_EXTENSIBLE) + break; + + assert(v->tag.tag_class == TC_NOCLASS); + + must_explicit = _asn1f_check_if_tag_must_be_explicit(arg, v); + + v->tag.tag_class = TC_CONTEXT_SPECIFIC; + v->tag.tag_mode = must_explicit ? TM_EXPLICIT : TM_IMPLICIT; + v->tag.tag_value = tag_value++; + } + + return r_value; +} + +/* + * Check that tags are distinct. + */ +int +asn1f_check_constr_tags_distinct(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int r_value = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + TQ_FOR(v, &(expr->members), next) { + /* + * In every series of non-mandatory components, + * the tags must be distinct from each other AND the + * tag of the following mandatory component. + * For SET and CHOICE treat everything as a big set of + * non-mandatory components. + */ + if(expr->expr_type != ASN_CONSTR_SEQUENCE || v->marker) { + asn1p_expr_t *nv; + for(nv = v; (nv = TQ_NEXT(nv, next));) { + if(_asn1f_compare_tags(arg, v, nv)) + r_value = -1; + if(expr->expr_type == ASN_CONSTR_SEQUENCE + && !nv->marker) break; + } + } + } + + return r_value; +} + +static int +_asn1f_check_if_tag_must_be_explicit(arg_t *arg, asn1p_expr_t *v) { + asn1p_expr_t *reft; + + reft = asn1f_find_terminal_type(arg, v, 0); + if(reft) { + switch(reft->expr_type) { + case ASN_CONSTR_CHOICE: + return 1; + default: + return 0; + } + } + + return 0; +} + +/* + * Check that the tags are distinct. + */ +static int +_asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { + struct asn1p_type_tag_s ta, tb; + int ra, rb; + int ret; + + ra = asn1f_fetch_tag(arg->asn, arg->mod, a, &ta); + rb = asn1f_fetch_tag(arg->asn, arg->mod, b, &tb); + + /* + * If both tags are explicitly or implicitly given, use them. + */ + if(ra == 0 && rb == 0) { + /* + * Simple case: fetched both tags. + */ + if(ta.tag_value == tb.tag_value + && ta.tag_class == tb.tag_class) { + char *p = (a->expr_type == A1TC_EXTENSIBLE) + ?"potentially ":""; + FATAL("Component \"%s\" at line %d %shas the same tag " + "with component \"%s\" at line %d", + a->Identifier, + a->_lineno, + p, + b->Identifier, + b->_lineno + ); + return -1; + } else { + /* Tags are distinct */ + return 0; + } + } + + /********************************************************** + * Now we must perform some very funny recursion to check + * multiple components of CHOICE type, etc. + */ + + DEBUG("Comparing tags %s:%x <-> %s:%x", + a->Identifier, a->expr_type, + b->Identifier, b->expr_type); + + if(a->meta_type == AMT_TYPEREF) { + asn1p_module_t *mod; + + DEBUG(" %s is a type reference", a->Identifier); + + a = asn1f_lookup_symbol(arg, a->reference, &mod); + if(!a) return 0; /* Already FATAL()'ed somewhere else */ + WITH_MODULE(mod, ret = _asn1f_compare_tags(arg, a, b)); + return ret; + } + + if(a->expr_type == ASN_CONSTR_CHOICE) { + asn1p_expr_t *v; + + DEBUG(" %s is a choice type (%d)", a->Identifier, a->_mark); + + /* + * Iterate over members of CHOICE. + */ + //if(a->_mark & TM_RECURSION) return 0; + TQ_FOR(v, &(a->members), next) { + //a->_mark |= TM_RECURSION; + ret = _asn1f_compare_tags(arg, v, b); + //a->_mark &= ~TM_RECURSION; + if(ret) return ret; + } + return 0; + } + + if(b->expr_type == ASN_CONSTR_CHOICE) { + return _asn1f_compare_tags(arg, b, a); + } + + if(a->_mark & TM_RECURSION) return 0; + if(b->_mark & TM_RECURSION) return 0; + a->_mark |= TM_RECURSION; + b->_mark |= TM_RECURSION; + ret = _asn1f_compare_tags(arg, b, a); + a->_mark &= ~TM_RECURSION; + b->_mark &= ~TM_RECURSION; + + return ret; +} + diff --git a/libasn1fix/asn1fix_constr.h b/libasn1fix/asn1fix_constr.h new file mode 100644 index 00000000..aeb05c0a --- /dev/null +++ b/libasn1fix/asn1fix_constr.h @@ -0,0 +1,24 @@ +#ifndef _ASN1FIX_CONSTRUCTED_H_ +#define _ASN1FIX_CONSTRUCTED_H_ + +/* + * Fix extensions in constructed types. + */ +int asn1f_fix_constr_ext(arg_t *); + +/* + * Fix tagging in constructed types. + */ +int asn1f_fix_constr_tag(arg_t *); + +/* + * Check distinctive tagging in constructed types. + */ +int asn1f_check_constr_tags_distinct(arg_t *); + +/* + * Perform automatic tagging. + */ +int asn1f_fix_constr_autotag(arg_t *); + +#endif /* _ASN1FIX_CONSTRUCTED_H_ */ diff --git a/libasn1fix/asn1fix_cstring.c b/libasn1fix/asn1fix_cstring.c new file mode 100644 index 00000000..b8a38833 --- /dev/null +++ b/libasn1fix/asn1fix_cstring.c @@ -0,0 +1,73 @@ +#include "asn1fix_internal.h" + +struct _cstring_pattern { + char *start; + int length; +}; +static int _asn1f_cstring_find_line_pattern(char *s, struct _cstring_pattern *); + +int +asn1f_fix_cstring(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + + if(expr->value && expr->value->type == ATV_STRING) { + struct _cstring_pattern cp; + char *buf = expr->value->value.string.buf; + int buflen = expr->value->value.string.size; + int start = 0; + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + while(_asn1f_cstring_find_line_pattern(buf + start, &cp)) { + assert(cp.length); + memmove(cp.start, cp.start + cp.length, + buflen - ((cp.start + cp.length) - buf)); + buflen -= cp.length; + start = cp.start - buf; + buf[buflen] = '\0'; + } + } + + return r_value; +} + +/* + * If a string has a newline, the tabulation and spaces before and + * after it must be eliminated. + */ +static int +_asn1f_cstring_find_line_pattern(char *s, struct _cstring_pattern *cp) { + int newline_found = 0; + + cp->start = NULL; + + for(;;s++) { + switch(*s) { + case '\r': case '\n': + newline_found = 1; + /* Fall through */ + case ' ': case '\t': + if(cp->start == NULL) + cp->start = s; + continue; + case '\0': + default: + if(newline_found) { + cp->length = s - cp->start; + return 1; + } + + cp->start = NULL; + if(*s == '\0') + break; + continue; + } + break; + } + + return 0; +} + + diff --git a/libasn1fix/asn1fix_cstring.h b/libasn1fix/asn1fix_cstring.h new file mode 100644 index 00000000..bd647abe --- /dev/null +++ b/libasn1fix/asn1fix_cstring.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_CSTRING_H_ +#define _ASN1FIX_CSTRING_H_ + +int asn1f_fix_cstring(arg_t *); + +#endif /* _ASN1FIX_CSTRING_H_ */ diff --git a/libasn1fix/asn1fix_dereft.c b/libasn1fix/asn1fix_dereft.c new file mode 100644 index 00000000..f0ec9a6c --- /dev/null +++ b/libasn1fix/asn1fix_dereft.c @@ -0,0 +1,68 @@ +#include "asn1fix_internal.h" + +int +asn1f_fix_dereference_types(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *type_expr; + int r_value = 0; + + if(expr->expr_type == A1TC_PARAMETRIZED) + return asn1f_fix_parametrized_assignment(arg); + + if(expr->expr_type != A1TC_REFERENCE + || expr->meta_type != AMT_TYPEREF) { + //assert(expr->reference == 0); + return 0; /* Just ignore it */ + } + + DEBUG("%s(\"%s\":%x ::= \"%s\") for line %d", + __func__, expr->Identifier, expr->expr_type, + asn1f_printable_value(expr->value), + expr->_lineno); + + assert(TQ_FIRST(&(expr->members)) == 0); + assert(expr->reference); + + /* + * Follow the reference. + */ + type_expr = asn1f_find_terminal_type(arg, expr, 0); + if(type_expr == NULL) { + FATAL("Unknown type \"%s\" referenced by \"%s\" at line %d", + asn1f_printable_reference(expr->reference), + expr->Identifier, expr->_lineno); + return -1; + } + + /* + * Copying members of the source expression + * into the current expression. + */ + if(0) { + asn1p_expr_t *tmp_clone; + + tmp_clone = asn1p_expr_clone(type_expr); + if(tmp_clone == NULL) { + FATAL("Could not clone \"%s\" at line %d", + type_expr->Identifier, type_expr->_lineno); + return -1; + } + + /* + * Replace the referenced type with its definition. + */ + DEBUG("\tChanging type of \"%s\":%x to %x for line %d", + expr->Identifier, + expr->expr_type, + type_expr->expr_type, + expr->_lineno + ); + expr->expr_type = type_expr->expr_type; + expr->members = tmp_clone->members; + memset(&tmp_clone->members, 0, sizeof(tmp_clone->members)); + asn1p_expr_free(tmp_clone); + } + + return r_value; +} + diff --git a/libasn1fix/asn1fix_dereft.h b/libasn1fix/asn1fix_dereft.h new file mode 100644 index 00000000..bee8151a --- /dev/null +++ b/libasn1fix/asn1fix_dereft.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_DEREFT_H_ +#define _ASN1FIX_DEREFT_H_ + +int asn1f_fix_dereference_types(arg_t *); + +#endif /* _ASN1FIX_DEREFT_H_ */ diff --git a/libasn1fix/asn1fix_derefv.c b/libasn1fix/asn1fix_derefv.c new file mode 100644 index 00000000..7be9d6d2 --- /dev/null +++ b/libasn1fix/asn1fix_derefv.c @@ -0,0 +1,56 @@ +#include "asn1fix_internal.h" + +/* + * Dereference DefinedValues: + */ +int +asn1f_fix_dereference_values(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + + if(expr->meta_type != AMT_VALUE) + return 0; /* Just ignore it */ + + if(expr->value == NULL) + return 0; /* Just ignore it */ + + if(expr->value && expr->value->type != ATV_REFERENCED) + return 0; /* Not a reference */ + + DEBUG("%s(%s %x ::= %s) for line %d", __func__, + expr->Identifier, expr->expr_type, + asn1f_printable_value(expr->value), expr->_lineno); + + /* + * If this integer has a value, check that this value + * is an integer. If it is a reference, resolve it. + */ + if(expr->value) { + + if(asn1f_value_resolve(arg, expr)) { + /* This function will emit messages */ + r_value = -1; + } + + if(expr->value->type != ATV_INTEGER) { + FATAL( + "INTEGER value %s at line %d: " + "Incompatible value specified: %s", + expr->Identifier, + expr->_lineno, + asn1f_printable_value(expr->value) + ); + r_value = -1; + } + } else { + FATAL("Value of \"%s\" at line %d: " + "Incompatible value specified", + expr->Identifier, + expr->_lineno + ); + r_value = -1; + } + + return r_value; +} + diff --git a/libasn1fix/asn1fix_derefv.h b/libasn1fix/asn1fix_derefv.h new file mode 100644 index 00000000..93153851 --- /dev/null +++ b/libasn1fix/asn1fix_derefv.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_DEREFV_H_ +#define _ASN1FIX_DEREFV_H_ + +int asn1f_fix_dereference_values(arg_t *); + +#endif /* _ASN1FIX_DEREFV_H_ */ diff --git a/libasn1fix/asn1fix_enum.c b/libasn1fix/asn1fix_enum.c new file mode 100644 index 00000000..8a90a435 --- /dev/null +++ b/libasn1fix/asn1fix_enum.c @@ -0,0 +1,136 @@ +#include "asn1fix_internal.h" + +/* + * Check the validity of an enumeration. + */ +int +asn1f_fix_enum(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *ev; + asn1_integer_t max_value = -1; + int rvalue = 0; + asn1p_expr_t *ext_marker = NULL; /* "..." position */ + int ret; + + if(expr->expr_type != ASN_BASIC_ENUMERATED) + return 0; /* Just ignore it */ + + DEBUG("%s(%s)", __func__, expr->Identifier); + + /* + * 1. Scan the enumeration values in search for inconsistencies. + */ + TQ_FOR(ev, &(expr->members), next) { + asn1_integer_t eval; + + if(ev->value) + DEBUG("\tItem %s(%s)", ev->Identifier, + asn1f_printable_value(ev->value)); + else + DEBUG("\tItem %s", ev->Identifier); + + /* + * 1.1 Found an extension mark "...", check correctness. + */ + if(ev->expr_type == A1TC_EXTENSIBLE) { + if(ext_marker) { + arg->eh(1, + "Enumeration %s at line %d: " + "Second extension marker is not allowed", + expr->Identifier, + ev->_lineno); + rvalue = -1; + } else { + /* + * Remember the marker's position. + */ + ext_marker = ev; + } + continue; + } else if(ev->Identifier == NULL + || ev->expr_type != A1TC_UNIVERVAL) { + FATAL( + "Enumeration %s at line %d: " + "Unsupported enumeration element %s", + expr->Identifier, + ev->_lineno, + ev->Identifier?ev->Identifier:""); + rvalue = -1; + continue; + } + + /* + * 1.2 Compute the value of the enumeration element. + */ + if(ev->value) { + switch(ev->value->type) { + case ATV_INTEGER: + eval = ev->value->value.v_integer; + break; + case ATV_REFERENCED: + FATAL("HERE HERE HERE", 1); + rvalue = -1; + continue; + break; + default: + FATAL("ENUMERATED type %s at line %d " + "contain element %s(%s) at line %d", + expr->Identifier, expr->_lineno, + ev->Identifier, + asn1f_printable_value(ev->value), + ev->_lineno); + rvalue = -1; + continue; + } + } else { + eval = max_value + 1; + ev->value = asn1p_value_fromint(eval); + if(ev->value == NULL) { + rvalue = -1; + continue; + } + } + + /* + * 1.3 Check the applicability of this value. + */ + if(eval <= max_value) { + if(ext_marker) { + /* + * Enumeration is allowed to be unordered + * before the first marker. + */ + FATAL( + "Enumeration %s at line %d: " + "Explicit value \"%s(%lld)\" " + "is not greater " + "than previous values (max %lld)", + expr->Identifier, + ev->_lineno, + ev->Identifier, + eval, + max_value); + rvalue = -1; + } + } else if(eval > max_value) { + max_value = eval; + } + + /* + * 1.4 Check that all identifiers before the current one + * differs from it. + */ + ret = asn1f_check_unique_expr_child(arg, ev, NULL); + RET2RVAL(ret, rvalue); + } + + + /* + * 2. Reorder the first half (before optional "...") of the + * identifiers alphabetically. + */ + // TODO + + return rvalue; +} + diff --git a/libasn1fix/asn1fix_enum.h b/libasn1fix/asn1fix_enum.h new file mode 100644 index 00000000..14c6fb52 --- /dev/null +++ b/libasn1fix/asn1fix_enum.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_ENUM_H_ +#define _ASN1FIX_ENUM_H_ + +int asn1f_fix_enum(arg_t *); /* Enumeration ::= ENUMERATED { a(1), b(2) } */ + +#endif /* _ASN1FIX_ENUM_H_ */ diff --git a/libasn1fix/asn1fix_export.c b/libasn1fix/asn1fix_export.c new file mode 100644 index 00000000..d6bb37b4 --- /dev/null +++ b/libasn1fix/asn1fix_export.c @@ -0,0 +1,48 @@ +#include "asn1fix_internal.h" +#include "asn1fix_export.h" + +asn1p_expr_t * +asn1f_lookup_symbol_ex( + asn1p_t *asn, + asn1p_module_t **module_rw, + asn1p_expr_t *expr, + asn1p_ref_t *ref) { + arg_t arg; + + memset(&arg, 0, sizeof(arg)); + + arg.asn = asn; + arg.mod = *module_rw; + arg.expr = expr; + + return asn1f_lookup_symbol(&arg, ref, module_rw); +} + +asn1p_expr_t * +asn1f_class_access_ex(asn1p_t *asn, + asn1p_module_t *mod, + asn1p_expr_t *expr, + asn1p_ref_t *ref, + asn1p_module_t **mod_r) { + static arg_t arg; + + arg.asn = asn; + arg.mod = mod; + arg.expr = expr; + + return asn1f_class_access(&arg, ref, mod_r); +} + +asn1p_expr_t * +asn1f_find_terminal_type_ex(asn1p_t *asn, + asn1p_module_t *mod, + asn1p_expr_t *expr, + asn1p_module_t **mod_r) { + static arg_t arg; + + arg.asn = asn; + arg.mod = mod; + arg.expr = expr; + + return asn1f_find_terminal_type(&arg, expr, mod_r); +} diff --git a/libasn1fix/asn1fix_export.h b/libasn1fix/asn1fix_export.h new file mode 100644 index 00000000..2ade0c9a --- /dev/null +++ b/libasn1fix/asn1fix_export.h @@ -0,0 +1,32 @@ +/* + * This header exports fixer procedures that are common enough to be used + * in other modules. + */ +#ifndef _ASN1FIX_EXPORT_H_ +#define _ASN1FIX_EXPORT_H_ + +#include + +/* + * Exportable version of an asn1f_lookup_symbol(). + */ +asn1p_expr_t *asn1f_lookup_symbol_ex( + asn1p_t *asn, + asn1p_module_t **module_rw, + asn1p_expr_t *expr, + asn1p_ref_t *ref); + +/* + * Exportable version of an asn1f_class_access(). + */ +asn1p_expr_t *asn1f_class_access_ex(asn1p_t *asn, asn1p_module_t *mod, + asn1p_expr_t *expr, asn1p_ref_t *, asn1p_module_t **mod_r); + +/* + * Exportable version of asn1f_find_terminal_type(). + */ +asn1p_expr_t *asn1f_find_terminal_type_ex(asn1p_t *asn, asn1p_module_t *mod, + asn1p_expr_t *tc, asn1p_module_t **opt_module_r); + +#endif /* _ASN1FIX_EXPORT_H_ */ + diff --git a/libasn1fix/asn1fix_integer.c b/libasn1fix/asn1fix_integer.c new file mode 100644 index 00000000..514ab70e --- /dev/null +++ b/libasn1fix/asn1fix_integer.c @@ -0,0 +1,161 @@ +#include "asn1fix_internal.h" + +static int _compare_value(asn1p_expr_t *expr1, asn1p_expr_t *expr2) { + if(expr2->value->type == ATV_INTEGER + && expr1->value->type == ATV_INTEGER) { + return expr2->value->value.v_integer + - expr1->value->value.v_integer; + } else { + return -1; + } +} + +/* + * Check the validity of an INTEGER type. + */ +int +asn1f_fix_integer(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *iv; + int rvalue = 0; + int ret; + + if(expr->expr_type != ASN_BASIC_INTEGER) + return 0; /* Just ignore it */ + + DEBUG("%s(\"%s\", %x) for line %d", __func__, + expr->Identifier, expr->expr_type, expr->_lineno); + + /* + * Scan the integer values in search for inconsistencies. + */ + TQ_FOR(iv, &(expr->members), next) { + + DEBUG("\tItem %s(%s)", iv->Identifier, + asn1f_printable_value(iv->value)); + + /* + * Found "...", check correctness. + */ + if(iv->expr_type == A1TC_EXTENSIBLE) { + arg->eh(1, + "INTEGER %s at line %d: " + "Extension marker is not allowed", + expr->Identifier, + iv->_lineno + ); + rvalue = -1; + continue; + } + + if(iv->Identifier == NULL + || iv->expr_type != A1TC_UNIVERVAL) { + arg->eh(1, + "INTEGER %s at line %d: " + "Unsupported enumeration element %s", + expr->Identifier, + iv->_lineno, + iv->Identifier?iv->Identifier:"" + ); + rvalue = -1; + continue; + } + + if(iv->value == NULL) { + arg->eh(1, + "INTEGER %s at line %d: " + "Value for the identifier %s " + "must be set explicitly", + expr->Identifier, + iv->_lineno, + iv->Identifier + ); + rvalue = -1; + continue; + } else if(iv->value->type == ATV_REFERENCED) { + /* + * Resolve the value, once and for all. + */ + if(asn1f_value_resolve(arg, iv)) { + /* This function will emit messages */ + rvalue = -1; + continue; + } + } + + if(iv->value->type != ATV_INTEGER) { + arg->eh(1, + "INTEGER %s at line %d: " + "Value for the identifier %s " + "is not compatible with INTEGER type", + expr->Identifier, + iv->_lineno); + rvalue = -1; + continue; + } + + /* + * Check that all identifiers are distinct. + */ + ret = asn1f_check_unique_expr_child(arg, iv, NULL); + RET2RVAL(ret, rvalue); + /* + * Check that all values are distinct. + */ + ret = asn1f_check_unique_expr_child(arg, iv, _compare_value); + RET2RVAL(ret, rvalue); + } + + + return rvalue; +} + +static int +_asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type) { + asn1p_module_t *mod = NULL; + asn1p_expr_t *next_expr; + int expr_type; + int ret; + + expr_type = expr->expr_type; + + /* + * Here we're trying to make sure that the type of the given + * expression is really what is expected. + * This is ensured in two ways. + * First, if the immediate type matches the provided one, + * this is a clear hit. + */ + if(expr_type == type) + return 0; + + /* + * Otherwise, it must be either a reference or a different type. + */ + if(expr_type != A1TC_REFERENCE) { + errno = EPERM; + return -1; + } + + assert(expr_type == A1TC_REFERENCE); + assert(expr->reference); + + /* + * Then, it is a reference. For a reference, try to resolve type + * and try again. + */ + next_expr = asn1f_lookup_symbol(arg, expr->reference, &mod); + if(next_expr == NULL) { + errno = ESRCH; + return -1; + } + + /* + * If symbol is here, recursively check that it conforms to the type. + */ + WITH_MODULE(mod, ret = _asn1f_make_sure_type_is(arg, next_expr, type)); + + return ret; +} + + diff --git a/libasn1fix/asn1fix_integer.h b/libasn1fix/asn1fix_integer.h new file mode 100644 index 00000000..d306fc03 --- /dev/null +++ b/libasn1fix/asn1fix_integer.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_INTEGER_H_ +#define _ASN1FIX_INTEGER_H_ + +int asn1f_fix_integer(arg_t *); /* Type1 ::= INTEGER { a(1), b(2) } */ + +#endif /* _ASN1FIX_INTEGER_H_ */ diff --git a/libasn1fix/asn1fix_internal.h b/libasn1fix/asn1fix_internal.h new file mode 100644 index 00000000..ff3b4e96 --- /dev/null +++ b/libasn1fix/asn1fix_internal.h @@ -0,0 +1,106 @@ +#ifndef _ASN1FIX_INTERNAL_H_ +#define _ASN1FIX_INTERNAL_H_ + +/* + * System headers required in various modules. + */ +#include +#include +#include +#include /* isupper() */ +#include +#include + +#include /* Our lovely ASN.1 parser module */ + +/* + * A definition of a function that will log error messages. + */ +typedef void (*error_logger_f)(int _is_fatal, const char *fmt, ...); + +/* + * Universal argument. + */ +typedef struct arg_s { + asn1p_t *asn; + asn1p_module_t *mod; + asn1p_expr_t *expr; + error_logger_f eh; + error_logger_f debug; + void *key; /* The next level key */ +} arg_t; + +/* + * Functions performing normalization of various types. + */ +#include "asn1fix_misc.h" /* Support functions */ +#include "asn1fix_value.h" /* Value processing */ +#include "asn1fix_cstring.h" /* Fix cstring values */ +#include "asn1fix_compat.h" /* Data compatibility */ +#include "asn1fix_constr.h" /* Constructed types */ +#include "asn1fix_class.h" /* CLASS support */ +#include "asn1fix_param.h" /* Parametrization */ +#include "asn1fix_retrieve.h" /* Data retrieval */ +#include "asn1fix_enum.h" /* Process ENUMERATED */ +#include "asn1fix_integer.h" /* Process INTEGER */ +#include "asn1fix_bitstring.h" /* Process BIT STRING */ +#include "asn1fix_dereft.h" /* Dereference types */ +#include "asn1fix_derefv.h" /* Dereference values */ +#include "asn1fix_tags.h" /* Tags-related stuff */ + + +/* + * Merge the return value of the called function with the already + * partially computed return value of the current function. + */ +#define RET2RVAL(ret,rv) do { \ + int __ret = ret; \ + switch(__ret) { \ + case 0: break; \ + case 1: if(rv) break; \ + case -1: rv = __ret; break; \ + default: \ + assert(__ret >= -1 && __ret <= 1); \ + rv = -1; \ + } \ + } while(0) + +/* + * Temporary substitute module for the purposes of evaluating expression. + */ +#define WITH_MODULE(tmp_mod, expr) do { \ + void *_saved_mod = arg->mod; \ + arg->mod = tmp_mod; \ + do { expr; } while(0); \ + arg->mod = _saved_mod; \ + } while(0) + +#define LOG(code, fmt, args...) do { \ + int _save_errno = errno; \ + if(code < 0) { \ + if(arg->debug) \ + arg->debug(code, fmt, ##args); \ + } else { \ + arg->eh(code, fmt " in %s", ##args, \ + arg->mod->source_file_name); \ + } \ + errno = _save_errno; \ + } while(0) + +#define DEBUG(fmt, args...) LOG(-1, fmt, ##args) +#define FATAL(fmt, args...) LOG( 1, fmt, ##args) +#define WARNING(fmt, args...) LOG( 0, fmt, ##args) + + +/* + * Define the symbol corresponding to the name of the current function. + */ +#if __STDC_VERSION__ < 199901 +#if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3) +#define __func__ (char *)0 /* Name of the current function */ +#endif /* GNUC */ +/* __func__ is supposed to be defined */ +#endif + + +#endif /* _ASN1FIX_INTERNAL_H_ */ diff --git a/libasn1fix/asn1fix_misc.c b/libasn1fix/asn1fix_misc.c new file mode 100644 index 00000000..5fe69034 --- /dev/null +++ b/libasn1fix/asn1fix_misc.c @@ -0,0 +1,276 @@ +#include "asn1fix_internal.h" + + +char const * +asn1f_printable_reference(asn1p_ref_t *ref) { + if(ref) { + asn1p_value_t v; + + v.type = ATV_REFERENCED; + v.value.reference = ref; + + return asn1f_printable_value(&v); + } else { + return ""; + } +} + +char const * +asn1f_printable_value(asn1p_value_t *v) { + static char buf[128]; + static char *managedptr; + static int managedptr_len; + int ret; + +#define ENSURE(len) do { \ + if(len >= managedptr_len) { \ + if(managedptr) \ + free(managedptr); \ + managedptr = malloc(len + 1); \ + if(managedptr) { \ + managedptr_len = len; \ + } else { \ + managedptr_len = 0; \ + return ""; \ + } \ + } \ + } while(0) + + if(v == NULL) + return ""; + + switch(v->type) { + case ATV_NOVALUE: + return ""; + case ATV_REFERENCED: + { + asn1p_ref_t *ref; + char reflen; + char *ptr; + int i; + + assert(v->value.reference); + ref = v->value.reference; + reflen = ref->comp_count; /* Number of dots */ + for(i = 0; i < ref->comp_count; i++) + reflen += strlen(ref->components[i].name); + /* + * Make sure we have a buffer of this size. + */ + ENSURE(reflen); + + /* + * Fill-up the buffer. + */ + ptr = managedptr; + for(i = 0; i < ref->comp_count; i++) { + char *nc; + if(i) *ptr++ = '.'; + for(nc = ref->components[i].name; *nc; nc++) + *ptr++ = *nc; + } + *ptr++ = '\0'; + assert(reflen == (ptr - managedptr)); + return managedptr; + } + case ATV_REAL: + ret = snprintf(buf, sizeof(buf), "%f", v->value.v_double); + if(ret >= sizeof(buf)) + memcpy(buf + sizeof(buf) - 4, "...", 4); + return buf; + case ATV_INTEGER: + ret = snprintf(buf, sizeof(buf), "%lld", + (long long)v->value.v_integer); + if(ret >= sizeof(buf)) + memcpy(buf + sizeof(buf) - 4, "...", 4); + return buf; + case ATV_MIN: return "MIN"; + case ATV_MAX: return "MAX"; + case ATV_FALSE: return "FALSE"; + case ATV_TRUE: return "TRUE"; + case ATV_STRING: + case ATV_UNPARSED: + /* Buffer is guaranteed to be null-terminated */ + assert(v->value.string.buf[v->value.string.size] == '\0'); + return v->value.string.buf; + case ATV_BITVECTOR: + { + uint8_t *bitvector; + char *ptr; + int len; + int i; + /* + * Compute number of bytes necessary + * to represend the binary value. + */ + int bits = v->value.binary_vector.size_in_bits; + len = ((bits%8)?bits:(bits >> 2)) + sizeof("''H"); + /* + * Reallocate managed buffer + */ + ENSURE(len); + + /* + * Fill the buffer. + */ + ptr = managedptr; + bitvector = v->value.binary_vector.bits; + *ptr++ = '\''; + if(bits%8) { + /* + * Dump bit by bit. + */ + for(i = 0; i < bits; i++) { + uint8_t uc; + uc = bitvector[i>>3]; + *ptr++ = ((uc >> (7-(i%8)))&1)?'1':'0'; + } + } else { + char hextable[16] = "0123456789ABCDEF"; + /* + * Dump byte by byte. + */ + for(i = 0; i < (bits >> 3); i++) { + *ptr++ = hextable[bitvector[i] >> 4]; + *ptr++ = hextable[bitvector[i] & 0x0f]; + } + } + *ptr++ = '\''; + *ptr++ = (bits%8)?'B':'H'; + *ptr++ = 'H'; + assert((ptr - managedptr) == len); + return managedptr; + } + } + + return ""; +} + + +/* + * Recursively invoke a given function over the given expr and all its + * children. + */ +int +asn1f_recurse_expr(arg_t *arg, int (*callback)(arg_t *arg)) { + asn1p_expr_t *expr = arg->expr; + int rvalue = 0; + int ret; + + assert(expr); + + /* + * Invoke the callback at this very level. + */ + ret = callback(arg); + RET2RVAL(ret, rvalue); + + /* + * Recursively invoke myself + * to iterate over each element in the tree. + */ + TQ_FOR(arg->expr, &(expr->members), next) { + assert(arg->expr->expr_type != A1TC_INVALID); + ret = asn1f_recurse_expr(arg, callback); + RET2RVAL(ret, rvalue); + } + + arg->expr = expr; /* Restore original position */ + + return rvalue; +} + + +/* + * Check that every child of a given expr has unique name or does not have any. + */ +int +asn1f_check_unique_expr(arg_t *arg, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)) { + asn1p_expr_t *expr; + int rvalue = 0; + + TQ_FOR(expr, &(arg->expr->members), next) { + if(expr->Identifier) { + int ret = asn1f_check_unique_expr_child(arg, expr, + opt_compare); + if(ret) rvalue = -1; + } else { + /* + * No point of comparing this child with any other: + * this one does not have a name. + */ + } + } + + return rvalue; +} + +/* + * Check that every preceeding child of the given expr is not + * having the name of the given one. + */ +int +asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)) { + asn1p_expr_t *expr; + int rvalue = 0; + + assert(child); + assert(opt_compare || child->Identifier); + + TQ_FOR(expr, &(arg->expr->members), next) { + int ret; + + if(expr == child) + break; + + /* + * Compare according to the custom rule or default + * names comparisons. + */ + if(opt_compare) { + ret = opt_compare(expr, child); + } else { + if(expr->Identifier == NULL + || expr->expr_type == A1TC_EXTENSIBLE) + continue; + ret = strcasecmp(expr->Identifier, child->Identifier); + } + + if(ret == 0) { + char *msg; + msg = opt_compare + ?"Expressions clash" + :"Identifiers name clash"; + arg->eh(1, + "%s: " + "\"%s\" at line %d has similar %s with " + "\"%s\" at line %d", + msg, + expr->Identifier, + expr->_lineno, + opt_compare?"property":"name", + child->Identifier, + child->_lineno + ); + + rvalue = -1; + } + } + + return rvalue; +} + +int +asn1f_count_children(asn1p_expr_t *expr) { + asn1p_expr_t *child; + int count = 0; + + TQ_FOR(child, &(expr->members), next) { + count++; + } + + return count; +} + diff --git a/libasn1fix/asn1fix_misc.h b/libasn1fix/asn1fix_misc.h new file mode 100644 index 00000000..e88e4322 --- /dev/null +++ b/libasn1fix/asn1fix_misc.h @@ -0,0 +1,47 @@ +/* + * Miscellaneous functions necessary for several other modules. + */ +#ifndef _ASN1FIX_MISC_H_ +#define _ASN1FIX_MISC_H_ + +/* + * Return a pointer to the locally held string with human-readable + * definition of the value. + */ +char const *asn1f_printable_value(asn1p_value_t *); + +/* + * Return a pointer to the locally held string with human-readable + * definition of the reference. + */ +char const *asn1f_printable_reference(asn1p_ref_t *); + +/* + * Recursively invoke a given function over the given expr and all its + * children. + */ +int asn1f_recurse_expr(arg_t *arg, int (*f)(arg_t *arg)); + +/* + * Check that every child of a given expr has unique name or does not have any. + * If opt_compare == NULL, the default comparison of the argument's + * names (identifiers) will be performed. + */ +int asn1f_check_unique_expr(arg_t *arg, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)); + +/* + * Check that every preceeding child of the given expr is not + * having the name of the given one. + * If opt_compare == NULL, the default comparison of the argument's + * names (identifiers) will be performed. + */ +int asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)); + +/* + * Return number of children. + */ +int asn1f_count_children(asn1p_expr_t *parent); + +#endif /* _ASN1FIX_MISC_H_ */ diff --git a/libasn1fix/asn1fix_param.c b/libasn1fix/asn1fix_param.c new file mode 100644 index 00000000..0c838cc5 --- /dev/null +++ b/libasn1fix/asn1fix_param.c @@ -0,0 +1,165 @@ +#include "asn1fix_internal.h" + +static int asn1f_parametrize(arg_t *arg, asn1p_expr_t *ex, asn1p_expr_t *ptype); +static int asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs); +static asn1p_expr_t *_referenced_argument(asn1p_ref_t *ref, asn1p_expr_t *ptype, asn1p_expr_t *actargs); + +int +asn1f_fix_parametrized_assignment(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *ptype; + + assert(expr->expr_type == A1TC_PARAMETRIZED); + assert(expr->reference); + + DEBUG("%s(\"%s\" ::= \"%s\" { %s }) for line %d", + __func__, expr->Identifier, + asn1f_printable_reference(expr->reference), + asn1f_printable_value(expr->value), + expr->_lineno); + + /* + * Find the corresponding parametrized type definition. + */ + DEBUG("Looking for parametrized type definition \"%s\"", + asn1f_printable_reference(expr->reference)); + ptype = asn1f_lookup_symbol(arg, expr->reference, 0); + if(ptype == NULL) { + DEBUG("%s: missing parametrized type declaration", + asn1f_printable_reference(expr->reference)); + return -1; + } + + /* + * Check that the number of arguments which are expected by + * the parametrized type declaration is consistent with the + * number of arguments supplied by the parametrized assignment. + */ + if(asn1f_count_children(expr) != ptype->params->params_count) { + FATAL("Number of actual arguments %d in %s at line %d " + "is not equal to number of expected arguments " + "%d in %s at line %d", + asn1f_count_children(expr), + asn1f_printable_reference(expr->reference), + expr->_lineno, + ptype->params->params_count, + ptype->Identifier, + ptype->_lineno + ); + return -1; + } + + /* + * Perform an expansion of a parametrized assignment. + */ + return asn1f_parametrize(arg, expr, ptype); +} + +#define SUBSTITUTE(to, from) do { \ + asn1p_expr_t tmp; \ + tmp = *(to); \ + *(to) = *(from); \ + *(from) = tmp; \ + (to)->next = tmp.next; \ + memset(&((from)->next), 0, \ + sizeof((from)->next)); \ + asn1p_expr_free(from); \ + } while(0) + +static int +asn1f_parametrize(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype) { + asn1p_expr_t *nex; + void *p; + int ret; + + /* + * The algorithm goes like that: + * 1. Replace the expression's type with parametrized type. + * 2. For every child in the parametrized type, import it + * as a child of the expression, replacing all occurences of + * symbols which are defined as parametrized type arguments + * with the actual values. + */ + + nex = asn1p_expr_clone(ptype); + if(nex == NULL) return -1; + + /* + * Cleanup the new expression so there is no ptype-related + * stuff hanging around. + */ + p = strdup(expr->Identifier); + if(p) { + free(nex->Identifier); + nex->Identifier = p; + } else { + asn1p_expr_free(nex); + return -1; + } + asn1p_paramlist_free(nex->params); + nex->params = NULL; + nex->meta_type = expr->meta_type; + + ret = asn1f_param_process_recursive(arg, nex, ptype, expr); + if(ret != 0) { + asn1p_expr_free(nex); + return ret; + } + + SUBSTITUTE(expr, nex); + + return ret; +} + +static int +asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs) { + asn1p_expr_t *child; + + TQ_FOR(child, &(expr->members), next) { + asn1p_expr_t *ra; + asn1p_expr_t *ne; + + ra = _referenced_argument(child->reference, ptype, actargs); + if(ra == NULL) continue; + + DEBUG("Substituting parameter for %s %s at line %d", + child->Identifier, + asn1f_printable_reference(child->reference), + child->_lineno + ); + + assert(child->meta_type == AMT_TYPEREF); + assert(child->expr_type == A1TC_REFERENCE); + + ne = asn1p_expr_clone(ra); + if(ne == NULL) return -1; + assert(ne->Identifier == 0); + ne->Identifier = strdup(child->Identifier); + if(ne->Identifier == 0) { + asn1p_expr_free(ne); + return -1; + } + SUBSTITUTE(child, ne); + } + + return 0; +} + +static asn1p_expr_t * +_referenced_argument(asn1p_ref_t *ref, asn1p_expr_t *ptype, asn1p_expr_t *actargs) { + asn1p_expr_t *aa; + int i; + + if(ref == NULL || ref->comp_count != 1) + return NULL; + + aa = TQ_FIRST(&(actargs->members)); + for(i = 0; i < ptype->params->params_count; + i++, aa = TQ_NEXT(aa, next)) { + if(strcmp(ref->components[0].name, + ptype->params->params[i].argument) == 0) + return aa; + } + + return NULL; +} diff --git a/libasn1fix/asn1fix_param.h b/libasn1fix/asn1fix_param.h new file mode 100644 index 00000000..062ad8bd --- /dev/null +++ b/libasn1fix/asn1fix_param.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_PARAMETRIZATION_H_ +#define _ASN1FIX_PARAMETRIZATION_H_ + +int asn1f_fix_parametrized_assignment(arg_t *arg); + +#endif /* _ASN1FIX_PARAMETRIZATION_H_ */ diff --git a/libasn1fix/asn1fix_retrieve.c b/libasn1fix/asn1fix_retrieve.c new file mode 100644 index 00000000..0dfcce40 --- /dev/null +++ b/libasn1fix/asn1fix_retrieve.c @@ -0,0 +1,366 @@ +#include "asn1fix_internal.h" + +static asn1p_expr_t *asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, asn1p_module_t **optm, int type_or_value); +static int asn1f_compatible_with_exports(arg_t *arg, asn1p_module_t *mod, const char *name); + + +/* + * Lookup a child by its name. + */ +asn1p_expr_t * +asn1f_lookup_child(asn1p_expr_t *tc, const char *name) { + asn1p_expr_t *child_tc; + + TQ_FOR(child_tc, &(tc->members), next) { + if(child_tc->Identifier + && strcmp(child_tc->Identifier, name) == 0) { + return child_tc; + } + } + + errno = ESRCH; + return NULL; +} + +asn1p_module_t * +asn1f_lookup_in_imports(arg_t *arg, const char *name) { + asn1p_module_t *mod; + asn1p_xports_t *xp; + asn1p_expr_t *tc; + + /* + * Search in which exactly module this name is defined. + */ + TQ_FOR(xp, &(arg->mod->imports), xp_next) { + TQ_FOR(tc, &(xp->members), next) { + if(strcmp(name, tc->Identifier) == 0) + break; + } + if(tc) break; + } + if(xp == NULL) { + errno = ESRCH; + return NULL; + } + + /* + * Okay, right now we have a module name and, hopefully, an OID. + * Search the arg->asn for the specified module. + */ + mod = asn1f_lookup_module(arg, xp->from, xp->from_oid); + if(mod == NULL) { + /* ENOENT/ETOOMANYREFS */ + return NULL; + } + + /* + * Check that the EXPORTS section of this module contains + * the symbol we care about, or it is EXPORTS ALL. + */ + if(asn1f_compatible_with_exports(arg, mod, name)) { + errno = EPERM; + return NULL; + } + + return mod; +} + +asn1p_module_t * +asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) { + asn1p_module_t *mod; + + assert(module_name); + + /* + * If OID is given, the module_name is unused. + * If OID is not given, the module_name may mean + * either the real module's name, or the symbol which is the + * result of renaming. Check this first. + */ + if(oid == 0) { + asn1p_xports_t *xp; + /* + * Check inside the IMPORTS section for possible renaming. + * Renaming practically means that a module_name is mentioned + * somewhere in the IMPORTS section AND OID is given. + */ + TQ_FOR(xp, &(arg->mod->imports), xp_next) { + if(strcmp(module_name, xp->from)) + continue; + if(oid) { + FATAL("Ambiguous reference: " + "%s " + "matches several modules", + module_name); + errno = ETOOMANYREFS; + return NULL; + } + /* + * Yes, there is a renaming. + * Make lookup use OID instead. + */ + oid = xp->from_oid; + } + } + + /* + * Perform lookup using OID or module_name. + */ + TQ_FOR(mod, &(arg->asn->modules), mod_next) { + if(oid) { + if(mod->module_oid) { + if(asn1p_oid_compare(oid, + mod->module_oid)) { + continue; + } else { + /* Match! Even if name doesn't. */ + return mod; + } + } else { + /* Not match, even if name is the same. */ + continue; + } + } + + if(strcmp(module_name, mod->Identifier) == 0) + return mod; + } + + DEBUG("\tModule \"%s\" not found", module_name); + + errno = ENOENT; + return NULL; +} + + + +asn1p_expr_t * +asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) { + asn1p_expr_t *ref_tc; /* Referenced tc */ + asn1p_module_t *src_mod; + char *modulename; + char *identifier; + + /* + * First of all, a reference to a symbol may be specified + * using several possible forms: + * a) simple identifier + * v INTEGER ::= value + * b) external reference + * v INTEGER ::= Module1.value + * c) class-related stuff (the most complex stuff) + * v ::= <[A-Z][A-Z0-9a-z-]*>.&<[A-Z0-9a-z-]+>. + * All other forms are not implemented at this moment. + */ + + DEBUG("%s(%s) in %s for line %d", __func__, + asn1f_printable_reference(ref), + arg->mod->Identifier, + ref->_lineno); + + if(ref->comp_count == 1) { + modulename = NULL; + identifier = ref->components[0].name; + } else if(ref->comp_count == 2 + && ref->components[1].name[0] != '&') { + modulename = ref->components[0].name; + identifier = ref->components[1].name; + } else if(ref->comp_count > 1 + && isupper(ref->components[0].name[0]) + && ref->components[1].name[0] == '&') { + asn1p_expr_t *extract; + /* + * This is a reference to a CLASS-related stuff. + * Employ a separate function for that. + */ + extract = asn1f_class_access(arg, ref, module_r); + + return extract; + } else { + DEBUG("\tToo many components: %d", ref->comp_count); + errno = EINVAL; + return NULL; + } + + /* + * If module name is specified explicitly + * OR the current module's IMPORTS clause contains the identifier, + * fetch that module. + */ + if(modulename) { + src_mod = asn1f_lookup_module(arg, modulename, 0); + if(src_mod == NULL) { + FATAL("Module \"%s\" " + "mentioned at line %d is not found", + modulename, ref->_lineno); + return NULL; + } + + /* + * Check that the EXPORTS section of this module contains + * the symbol we care about, or it is EXPORTS ALL. + */ + if(asn1f_compatible_with_exports(arg, src_mod, identifier)) { + errno = EPERM; + return NULL; + } + } else { + src_mod = asn1f_lookup_in_imports(arg, identifier); + if(src_mod == NULL && errno != ESRCH) { + /* + * Return only of the name was not found. + * If module was not found or more serious error + * encountered, just return preserving the errno. + */ + return NULL; + } + } + + if(src_mod == 0) src_mod = arg->mod; + + /* + * Now we know where to search for a value. + */ + TQ_FOR(ref_tc, &(src_mod->members), next) { + if(ref_tc->Identifier) + if(strcmp(ref_tc->Identifier, identifier) == 0) + break; + } + if(ref_tc == NULL) { + DEBUG("Module \"%s\" does not contain \"%s\" " + "mentioned at line %d", + src_mod->Identifier, + identifier, + ref->_lineno + ); + errno = ESRCH; + return NULL; + } + + if(module_r) + *module_r = src_mod; + + return ref_tc; +} + + +asn1p_expr_t * +asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *expr, + asn1p_module_t **optm) { + return asn1f_find_terminal_thing(arg, expr, optm, 0); +} + +asn1p_expr_t * +asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *expr, + asn1p_module_t **optm) { + return asn1f_find_terminal_thing(arg, expr, optm, 1); +} + +static asn1p_expr_t * +asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, + asn1p_module_t **optm, int type_or_value) { + asn1p_module_t *mod; + asn1p_ref_t *ref; + asn1p_expr_t *tc; + + if(type_or_value) { + /* VALUE */ + assert(expr->meta_type == AMT_VALUE); + assert(expr->value); + if(expr->value->type != ATV_REFERENCED) { + /* Expression is a terminal value itself */ + if(optm) *optm = arg->mod; + return expr; + } + ref = expr->value->value.reference; + } else { + /* TYPE */ + if(expr->expr_type != A1TC_REFERENCE) { + /* Expression is a terminal type itself */ + if(optm) *optm = arg->mod; + return expr; + } + ref = expr->reference; + } + + DEBUG("%s:%s(%s->%s) for line %d", + __func__, type_or_value?"VALUE":"TYPE", + expr->Identifier, asn1f_printable_reference(ref), + expr->_lineno); + + assert(ref); + + /* + * Lookup inside the type itself (ENUMERATED, INTEGER, etc). + */ + if(type_or_value) { + asn1p_expr_t *val_type_tc; + val_type_tc = asn1f_find_terminal_type(arg, expr, 0); + if(val_type_tc + && asn1f_look_value_in_type(arg, val_type_tc, expr)) + return NULL; + if(expr->value->type != ATV_REFERENCED) { + if(optm) *optm = arg->mod; + return expr; + } + assert(ref == expr->value->value.reference); + ref = expr->value->value.reference; + } + + /* + * Lookup inside the default module. + */ + tc = asn1f_lookup_symbol(arg, ref, &mod); + if(tc == NULL) { + DEBUG("\tSymbol \"%s\" not found", + asn1f_printable_reference(ref)); + return NULL; + } + + /* + * Recursive loops detection. + */ + if(tc->_mark & TM_RECURSION) { + DEBUG("Recursion loop detected for %s at line %d", + asn1f_printable_reference(ref), ref->_lineno); + errno = EPERM; + return NULL; + } + + tc->_mark |= TM_RECURSION; + WITH_MODULE(mod, + expr = asn1f_find_terminal_thing(arg, tc, optm, type_or_value)); + tc->_mark &= ~TM_RECURSION; + + return expr; +} + +/* + * Make sure that the specified name is present or otherwise does + * not contradict with the EXPORTS clause of the specified module. + */ +static int +asn1f_compatible_with_exports(arg_t *arg, asn1p_module_t *mod, const char *name) { + asn1p_xports_t *exports; + asn1p_expr_t *item; + + assert(mod); + assert(name); + + exports = TQ_FIRST(&(mod->exports)); + if(exports == NULL) { + /* No EXPORTS section or EXPORTS ALL; */ + return 0; + } + + TQ_FOR(item, &(exports->members), next) { + if(strcmp(item->Identifier, name) == 0) + return 0; + } + + DEBUG("Symbol \"%s\" contradicts with EXPORTS of module %s", + name, mod->Identifier); + + errno = ESRCH; + return -1; +} diff --git a/libasn1fix/asn1fix_retrieve.h b/libasn1fix/asn1fix_retrieve.h new file mode 100644 index 00000000..47aa0a5b --- /dev/null +++ b/libasn1fix/asn1fix_retrieve.h @@ -0,0 +1,73 @@ +/* + * Miscellaneous functions necessary for several other modules. + */ +#ifndef _ASN1FIX_RETRIEVE_H_ +#define _ASN1FIX_RETRIEVE_H_ + +/* + * Simple search for the label in the descendants of the given node. + * ERRORS: + * NULL/ESRCH + */ +asn1p_expr_t *asn1f_lookup_child(asn1p_expr_t *tc, const char *name); + +/* + * Return a module which contain a specified name, as stated in appropriate + * IMPORTS section of the current module (arg->mod). + * + * RETURN VALUES: + * NULL/ESRCH: The name was not found in IMPORTS section. + * NULL/EPERM: The name was not found in EXPORTS section of the source module. + * Also, NULL with errno values defined by asn1f_lookup_module(). + */ +asn1p_module_t *asn1f_lookup_in_imports(arg_t *arg, const char *name); + +/* + * Return a module by its name or optional OID. + * + * RETURN VALUES: + * NULL/ENOENT: No module was found by the specified name and oid + * NULL/ETOOMANYREFS: Several modules are matching the specified name and oid + */ +asn1p_module_t *asn1f_lookup_module(arg_t *arg, + const char *module_name, + asn1p_oid_t *module_oid); + +/* + * Return the reference to a destination of the given reference, + * symbol lookup. Not a recursive function. + * Optional module reference may be assigned a module in which the + * particular expr was found. + */ +asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, + asn1p_module_t **opt_module_r); + +/* + * Recursively find the original type for the given expression. + * i.e.: + * If the original specification defines + * v Type1 ::= 5 + * Type1 ::= Type2 (1..5) + * Type3 ::= Type4 (2..7) + * Type4 ::= INTEGER (1..10) + * Then this function, given the the first expression as an argument, + * would return an expression for Type4. + * WARNING: No attempts are made to honor constraints at this moment. + */ +asn1p_expr_t *asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *tc, + asn1p_module_t **opt_module_r); + +/* + * Recursively find the original value for the given expression. + * i.e.: + * If the original specification defines + * v Type1 ::= value + * value Type2 ::= value2 + * value2 Type3 ::= 3 + * Then this function will return the expression for value2 if given + * the v as an argment. + */ +asn1p_expr_t *asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *tc, + asn1p_module_t **opt_module_r); + +#endif /* _ASN1FIX_RETRIEVE_H_ */ diff --git a/libasn1fix/asn1fix_tags.c b/libasn1fix/asn1fix_tags.c new file mode 100644 index 00000000..ed8c19f2 --- /dev/null +++ b/libasn1fix/asn1fix_tags.c @@ -0,0 +1,47 @@ +#include "asn1fix_internal.h" + +int +asn1f_fetch_tag(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag) { + int ret; + + if(expr->tag.tag_class != TC_NOCLASS) { + *tag = expr->tag; + return 0; + } + + if(expr->expr_type == A1TC_EXTENSIBLE) { + memset(tag, 0, sizeof(*tag)); + tag->tag_class = -1; + return 0; + } + + if(expr->meta_type == AMT_TYPE) { + memset(tag, 0, sizeof(*tag)); + tag->tag_class = TC_UNIVERSAL; + tag->tag_value = expr_type2uclass_value[expr->expr_type]; + return (tag->tag_value == 0) ? -1 : 0; + } + + if(expr->meta_type == AMT_TYPEREF) { + arg_t arg; + + memset(&arg, 0, sizeof(arg)); + arg.asn = asn; + arg.mod = mod; + arg.expr = expr; + + expr = asn1f_lookup_symbol(&arg, expr->reference, &mod); + if(expr == NULL) return -1; + + if(expr->_mark & TM_RECURSION) + return -1; + + expr->_mark |= TM_RECURSION; + ret = asn1f_fetch_tag(asn, mod, expr, tag); + expr->_mark &= ~TM_RECURSION; + return ret; + } + + return -1; +} + diff --git a/libasn1fix/asn1fix_tags.h b/libasn1fix/asn1fix_tags.h new file mode 100644 index 00000000..9d3595b9 --- /dev/null +++ b/libasn1fix/asn1fix_tags.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_TAGS_H_ +#define _ASN1FIX_TAGS_H_ + +int asn1f_fetch_tag(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag); + +#endif /* _ASN1FIX_TAGS_H_ */ diff --git a/libasn1fix/asn1fix_value.c b/libasn1fix/asn1fix_value.c new file mode 100644 index 00000000..a22fd3dc --- /dev/null +++ b/libasn1fix/asn1fix_value.c @@ -0,0 +1,159 @@ +#include "asn1fix_internal.h" + +static int _asn1f_copy_value(arg_t *arg, asn1p_expr_t *to,asn1p_expr_t *from); + +int +asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) { + asn1p_module_t *val_mod; + asn1p_expr_t *val_type_expr; + asn1p_expr_t *value_expr; + asn1p_expr_t *type_expr; + int ret; + + /* Make sure this IS a value assignment */ + assert(expr->meta_type == AMT_VALUE); + assert(expr->value); + + DEBUG("%s(=\"%s\", %x)", __func__, + asn1f_printable_value(expr->value), expr->expr_type); + + /* + * 1. Find the terminal type for this assignment. + */ + type_expr = asn1f_find_terminal_type(arg, expr, 0); + if(type_expr == 0) { + DEBUG("\tTerminal type for %s not found", expr->Identifier); + return -1; + } + + if(asn1f_look_value_in_type(arg, type_expr, expr) == -1) + return -1; + + /* + * 2. Find the terminal value also. + */ + value_expr = asn1f_find_terminal_value(arg, expr, &val_mod); + if(value_expr) { + DEBUG("\tTerminal value for %s->%s is %s at line %d", + expr->Identifier, asn1f_printable_value(expr->value), + value_expr->Identifier, value_expr->_lineno); + } else { + DEBUG("\tTerminal value for %s->%s not found", + expr->Identifier, asn1f_printable_value(expr->value)); + return -1; + } + + /* + * 3. Find the _type_ of a _terminal value_. + */ + WITH_MODULE(val_mod, + val_type_expr = asn1f_find_terminal_type(arg, value_expr, 0)); + if(val_type_expr) { + DEBUG("\tTerminal type of value %s->%s is %s at line %d", + expr->Identifier, asn1f_printable_value(expr->value), + val_type_expr->Identifier, val_type_expr->_lineno); + } else { + DEBUG("\tTerminal type of value %s->%s not found", + expr->Identifier, asn1f_printable_value(expr->value)); + return -1; + } + + /* + * 4. Check compatibility between the type of the current expression + * and the type of the discovered value. + */ + ret = asn1f_check_type_compatibility(arg, type_expr, val_type_expr); + if(ret == -1) { + DEBUG("\tIncompatible type of %s at %d with %s at %d", + type_expr->Identifier, type_expr->_lineno, + val_type_expr->Identifier, val_type_expr->_lineno); + return -1; + } + + if(asn1f_look_value_in_type(arg, val_type_expr, expr) == -1) + return -1; + + /* + * 5. Copy value from the terminal value into the current expression. + */ + ret = _asn1f_copy_value(arg, expr, value_expr); + if(ret == -1) { + DEBUG("\tValue %s cannot be copied from line %d to line %d", + asn1f_printable_value(value_expr->value), + value_expr->_lineno, expr->_lineno); + return -1; + } + + DEBUG("\tFinal value for \"%s\" at line %d is %s", + expr->Identifier, expr->_lineno, + asn1f_printable_value(expr->value)); + + return 0; +} + +static int +_asn1f_copy_value(arg_t *arg, asn1p_expr_t *to, asn1p_expr_t *from) { + asn1p_value_t *v; + + v = asn1p_value_clone(from->value); + if(v) { + asn1p_value_free(to->value); + to->value = v; + DEBUG("Copied value %s from \"%s\" on line %d " + "to \"%s\" on line %d", + asn1f_printable_value(v), + from->Identifier, + from->_lineno, + to->Identifier, + to->_lineno + ); + return 0; + } else { + return -1; + } +} + +int +asn1f_look_value_in_type(arg_t *arg, + asn1p_expr_t *type_expr, + asn1p_expr_t *value_expr) { + asn1p_expr_t *child_expr; + char *identifier; + + if(value_expr->value->type != ATV_REFERENCED + || value_expr->value->value.reference->comp_count != 1) + return 0; + if(type_expr->expr_type != ASN_BASIC_INTEGER + && type_expr->expr_type != ASN_BASIC_ENUMERATED) + return 0; + + DEBUG("%s(for %s in %s %x) for line %d", __func__, + asn1f_printable_value(value_expr->value), + type_expr->Identifier, + type_expr->expr_type, + value_expr->_lineno); + + /* + * Look into the definitions of the type itself: + * Type1 ::= INTEGER { a(1), b(2) } + * value Type1 = b -- will assign 2 + */ + identifier = value_expr->value->value.reference->components[0].name; + + child_expr = asn1f_lookup_child(type_expr, identifier); + DEBUG("\tLooking into a type %s at line %d for %s at line %d: %s", + type_expr->Identifier, type_expr->_lineno, + identifier, value_expr->_lineno, + child_expr + ? asn1f_printable_value(child_expr->value) + : "" + ); + + if(child_expr && child_expr->value) { + if(_asn1f_copy_value(arg, value_expr, child_expr)) + return -1; + /* Fall through */ + } + + return 0; +} diff --git a/libasn1fix/asn1fix_value.h b/libasn1fix/asn1fix_value.h new file mode 100644 index 00000000..7234035e --- /dev/null +++ b/libasn1fix/asn1fix_value.h @@ -0,0 +1,28 @@ +/* + * Functions related with processing values. + */ +#ifndef _ASN1FIX_VALUE_H_ +#define _ASN1FIX_VALUE_H_ + +/* + * Resolve the value given by reference. + * This function also takes a parameter which specifies the desired + * value's type. + * + * RETURN VALUES: + * 0: Value resolved successfully. + * -1/EPERM: Recursive looping detected. + * -1/EEXIST: Reference is not compatible with the desired type. + * -1/ESRCH: Cannot find the terminal reference. + */ +int asn1f_value_resolve(arg_t *arg, asn1p_expr_t *tc); + +/* + * Check if a value in value_expr refers to the enumeration or integer element + * within the type provided. If yes, it will replace referenced value with + * the appropriate inline value. + */ +int asn1f_look_value_in_type(arg_t *arg, + asn1p_expr_t *type_expr, asn1p_expr_t *value_expr); + +#endif /* _ASN1FIX_VALUE_H_ */ diff --git a/libasn1fix/check_fixer.c b/libasn1fix/check_fixer.c new file mode 100644 index 00000000..21c5b12f --- /dev/null +++ b/libasn1fix/check_fixer.c @@ -0,0 +1,313 @@ +#undef NDEBUG +#include +#include +#include +#include +#include +#include +#include +#include + +#include "asn1fix.h" +#include "asn1fix_internal.h" + +static int check(const char *fname, + enum asn1p_flags parser_flags, + enum asn1f_flags fixer_flags); +static int post_fix_check(asn1p_t *asn); +static int post_fix_check_element(asn1p_module_t *mod, asn1p_expr_t *expr); + +int +main(int ac, char **av) { + struct dirent *dp; + DIR *dir; + int failed = 0; + int completed = 0; + enum asn1p_flags parser_flags = A1P_NOFLAGS; + enum asn1f_flags fixer_flags = A1F_NOFLAGS; + int ret; + + /* + * Just in case when one decides that some flags better be + * enabled during `ASN1_FIXER_FLAGS=1 make check` or some + * similar usage. + */ + if(getenv("ASN1_PARSER_FLAGS")) + parser_flags = atoi(getenv("ASN1_PARSER_FLAGS")); + if(getenv("ASN1_FIXER_FLAGS")) + fixer_flags = atoi(getenv("ASN1_FIXER_FLAGS")); + + /* + * Go into a directory with tests. + */ + if(ac <= 1) { + fprintf(stderr, "Testing in ./tests...\n"); + ret = chdir("../tests"); + assert(ret == 0); + dir = opendir("."); + assert(dir); + } else { + dir = 0; + } + + /* + * Scan every *.asn1 file and try to parse and fix it. + */ + if(dir) { + while((dp = readdir(dir))) { + int len = strlen(dp->d_name); + if(len && strcmp(dp->d_name + len - 5, ".asn1") == 0) { + ret = check(dp->d_name, + parser_flags, fixer_flags); + if(ret) { + fprintf(stderr, + "FAILED: %s\n", + dp->d_name); + failed++; + } + completed++; + } + } + closedir(dir); + + fprintf(stderr, + "Tests COMPLETED: %d\n" + "Tests FAILED: %d\n" + , + completed, failed + ); + } else { + int i; + for(i = 1; i < ac; i++) { + ret = check(av[i], parser_flags, fixer_flags); + if(ret) { + fprintf(stderr, "FAILED: %s\n", av[i]); + failed++; + } + completed++; + } + } + + if(completed == 0) { + fprintf(stderr, "No tests defined?!\n"); + exit(EX_NOINPUT); + } + + if(failed) + exit(EX_DATAERR); + return 0; +} + +static int +check(const char *fname, + enum asn1p_flags parser_flags, + enum asn1f_flags fixer_flags) { + asn1p_t *asn; + int expected_parseable; /* Is it expected to be parseable? */ + int expected_fix_code; /* What code a fixer must return */ + int r_value = 0; + + /* + * Figure out how the processing should go by inferring + * expectations from the file name. + */ + if(strstr(fname, "-OK.")) { + expected_parseable = 1; + expected_fix_code = 0; + } else if(strstr(fname, "-NP.")) { + expected_parseable = 0; + expected_fix_code = 123; /* Does not matter */ + } else if(strstr(fname, "-SE.")) { + expected_parseable = 1; + expected_fix_code = -1; /* Semantically incorrect */ + } else if(strstr(fname, "-SW.")) { + expected_parseable = 1; + expected_fix_code = 1; /* Semantically suspicious */ + } else { + fprintf(stderr, "%s: Invalid file name format\n", fname); + return -1; + } + + fprintf(stderr, "[=> %s]\n", fname); + + /* + * Perform low-level parsing. + */ + if(!expected_parseable) + fprintf(stderr, "Expecting error...\n"); + asn = asn1p_parse_file(fname, parser_flags); + if(asn == NULL) { + if(expected_parseable) { + fprintf(stderr, "Cannot parse file \"%s\"\n", fname); + r_value = -1; + } else { + fprintf(stderr, + "Previous error is EXPECTED, no worry\n"); + } + } else if(!expected_parseable) { + fprintf(stderr, + "The file \"%s\" is not expected to be parseable, " + "yet parsing was successfull!\n", fname); + r_value = -1; + } + + /* + * Perform semantical checks and fixes. + */ + if(asn && r_value == 0) { + int ret; + + if(expected_fix_code) + fprintf(stderr, "Expecting some problems...\n"); + + ret = asn1f_process(asn, fixer_flags, 0); + if(ret) { + if(ret == expected_fix_code) { + fprintf(stderr, + "Previous error is EXPECTED, " + "no worry\n"); + } else { + fprintf(stderr, + "Cannot process file \"%s\": %d\n", + fname, ret); + r_value = -1; + } + } else if(ret != expected_fix_code) { + fprintf(stderr, + "File \"%s\" is expected " + "to be semantically incorrect, " + "yet processing was successful!\n", + fname); + r_value = -1; + } + } + + /* + * Check validity of some values, if grammar has special + * instructions for that. + */ + if(asn && r_value == 0) { + if(post_fix_check(asn)) + r_value = -1; + } + + /* + * TODO: destroy the asn. + */ + + return r_value; +} + + +static int +post_fix_check(asn1p_t *asn) { + asn1p_module_t *mod; + asn1p_expr_t *expr; + int r_value = 0; + + TQ_FOR(mod, &(asn->modules), mod_next) { + TQ_FOR(expr, &(mod->members), next) { + assert(expr->Identifier); + if(strncmp(expr->Identifier, "check-", 6) == 0) { + if(post_fix_check_element(mod, expr)) + r_value = -1; + } + } + } + + return r_value; +} + + +static int +post_fix_check_element(asn1p_module_t *mod, asn1p_expr_t *check_expr) { + asn1p_expr_t *expr = NULL; + char *name; + asn1p_value_t *value; + + if(check_expr->expr_type != ASN_BASIC_INTEGER + || check_expr->meta_type != AMT_VALUE) { + fprintf(stderr, + "CHECKER: Unsupported type of \"%s\" value: " + "%d at line %d of %s\n", + check_expr->Identifier, + check_expr->expr_type, + check_expr->_lineno, + mod->source_file_name + ); + return -1; + } + + assert(check_expr->meta_type == AMT_VALUE); + + value = check_expr->value; + if(value == NULL || value->type != ATV_INTEGER) { + fprintf(stderr, + "CHECKER: Unsupported value type of \"%s\": " + "%d at line %d of %s\n", + check_expr->Identifier, + value?value->type:-1, + expr->_lineno, + mod->source_file_name + ); + return -1; + } + + name = check_expr->Identifier + sizeof("check-") - 1; + + /* + * Scan in search for the original. + */ + TQ_FOR(expr, &(mod->members), next) { + if(strcmp(expr->Identifier, name) == 0) + break; + } + + if(expr == NULL) { + fprintf(stderr, + "CHECKER: Value \"%s\" requested by " + "\"check-%s\" at line %d of %s is not found!\n", + name, name, check_expr->_lineno, + mod->source_file_name + ); + return -1; + } + + if(0 && expr->expr_type != check_expr->expr_type) { + fprintf(stderr, + "CHECKER: Value type of \"%s\" (=%d) at line %d " + "does not have desired type %d as requested by " + "\"check-%s\" in %s\n", + expr->Identifier, + expr->expr_type, + expr->_lineno, + check_expr->expr_type, + name, + mod->source_file_name + ); + return -1; + } + + if(expr->value == NULL + || expr->value->type != value->type) { + fprintf(stderr, + "CHECKER: Value of \"%s\" (\"%s\", type=%d) at line %d " + "does not have desired type %d as requested by " + "\"check-%s\" in %s\n", + expr->Identifier, + asn1f_printable_value(expr->value), + expr->value->type, + expr->_lineno, + value->type, + name, + mod->source_file_name + ); + return -1; + } + + assert(value->type = ATV_INTEGER); + + return 0; +} + + diff --git a/libasn1parser/Makefile.am b/libasn1parser/Makefile.am new file mode 100644 index 00000000..0f9ff161 --- /dev/null +++ b/libasn1parser/Makefile.am @@ -0,0 +1,35 @@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_YFLAGS = -p asn1p_ -d +AM_LFLAGS = -sp -Cem -Pasn1p_ -olex.yy.c + +noinst_LTLIBRARIES = libasn1parser.la + +libasn1parser_la_LDFLAGS = -all-static +libasn1parser_la_SOURCES = \ + asn1parser.c asn1parser.h \ + asn1p_y.y asn1p_l.l \ + asn1p_module.c asn1p_module.h \ + asn1p_oid.c asn1p_oid.h \ + asn1p_value.c asn1p_value.h \ + asn1p_expr.c asn1p_expr.h \ + asn1p_expr_str.h \ + asn1p_expr2uclass.h \ + asn1p_xports.c asn1p_xports.h \ + asn1p_constr.c asn1p_constr.h \ + asn1p_param.c asn1p_param.h \ + asn1p_class.c asn1p_class.h \ + asn1p_ref.c asn1p_ref.h \ + asn1p_list.h + +asn1p_expr_str.h: expr-h.pl asn1p_expr.h + ./expr-h.pl asn1p_expr.h > $@ + +EXTRA_DIST = expr-h.pl + +check_PROGRAMS = check_parser + +LDADD = ${noinst_LTLIBRARIES} +DEPENDENCIES = ${noinst_LTLIBRARIES} + +TESTS = ${check_PROGRAMS} diff --git a/libasn1parser/Makefile.in b/libasn1parser/Makefile.in new file mode 100644 index 00000000..7c4bd5f8 --- /dev/null +++ b/libasn1parser/Makefile.in @@ -0,0 +1,459 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_YFLAGS = -p asn1p_ -d +AM_LFLAGS = -sp -Cem -Pasn1p_ -olex.yy.c + +noinst_LTLIBRARIES = libasn1parser.la + +libasn1parser_la_LDFLAGS = -all-static +libasn1parser_la_SOURCES = \ + asn1parser.c asn1parser.h \ + asn1p_y.y asn1p_l.l \ + asn1p_module.c asn1p_module.h \ + asn1p_oid.c asn1p_oid.h \ + asn1p_value.c asn1p_value.h \ + asn1p_expr.c asn1p_expr.h \ + asn1p_expr_str.h \ + asn1p_expr2uclass.h \ + asn1p_xports.c asn1p_xports.h \ + asn1p_constr.c asn1p_constr.h \ + asn1p_param.c asn1p_param.h \ + asn1p_class.c asn1p_class.h \ + asn1p_ref.c asn1p_ref.h \ + asn1p_list.h + + +EXTRA_DIST = expr-h.pl + +check_PROGRAMS = check_parser + +LDADD = ${noinst_LTLIBRARIES} +DEPENDENCIES = ${noinst_LTLIBRARIES} + +TESTS = ${check_PROGRAMS} +subdir = libasn1parser +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1parser_la_LIBADD = +am_libasn1parser_la_OBJECTS = asn1parser.lo asn1p_y.lo asn1p_l.lo \ + asn1p_module.lo asn1p_oid.lo asn1p_value.lo asn1p_expr.lo \ + asn1p_xports.lo asn1p_constr.lo asn1p_param.lo asn1p_class.lo \ + asn1p_ref.lo +libasn1parser_la_OBJECTS = $(am_libasn1parser_la_OBJECTS) +check_PROGRAMS = check_parser$(EXEEXT) +check_parser_SOURCES = check_parser.c +check_parser_OBJECTS = check_parser.$(OBJEXT) +check_parser_LDADD = $(LDADD) +check_parser_DEPENDENCIES = libasn1parser.la +check_parser_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1p_class.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_constr.Plo $(DEPDIR)/asn1p_expr.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_l.Plo $(DEPDIR)/asn1p_module.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_oid.Plo $(DEPDIR)/asn1p_param.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_ref.Plo $(DEPDIR)/asn1p_value.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_xports.Plo $(DEPDIR)/asn1p_y.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1parser.Plo $(DEPDIR)/check_parser.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) +YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) +DIST_SOURCES = $(libasn1parser_la_SOURCES) check_parser.c +DIST_COMMON = Makefile.am Makefile.in asn1p_l.c asn1p_y.c asn1p_y.h +SOURCES = $(libasn1parser_la_SOURCES) check_parser.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .l .lo .o .obj .y + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1parser/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +asn1p_y.h: asn1p_y.c +libasn1parser.la: $(libasn1parser_la_OBJECTS) $(libasn1parser_la_DEPENDENCIES) + $(LINK) $(libasn1parser_la_LDFLAGS) $(libasn1parser_la_OBJECTS) $(libasn1parser_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check_parser$(EXEEXT): $(check_parser_OBJECTS) $(check_parser_DEPENDENCIES) + @rm -f check_parser$(EXEEXT) + $(LINK) $(check_parser_LDFLAGS) $(check_parser_OBJECTS) $(check_parser_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_class.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_constr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_expr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_l.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_oid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_param.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_ref.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_value.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_xports.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_y.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1parser.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_parser.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ + +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LEXLIB = @LEXLIB@ + +.l.c: + $(LEXCOMPILE) $< && mv $(LEX_OUTPUT_ROOT).c $@ + +.y.c: + $(YACCCOMPILE) $< && mv y.tab.c $@ + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then \ + rm -f y.tab.h; \ + else \ + mv y.tab.h $*.h; \ + fi; \ + fi +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "asn1p_y.h" || rm -f asn1p_y.h +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + + +asn1p_expr_str.h: expr-h.pl asn1p_expr.h + ./expr-h.pl asn1p_expr.h > $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1parser/asn1p_class.c b/libasn1parser/asn1p_class.c new file mode 100644 index 00000000..cd0e385a --- /dev/null +++ b/libasn1parser/asn1p_class.c @@ -0,0 +1,135 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_new() { + asn1p_wsyntx_chunk_t *wc; + + wc = calloc(1, sizeof(*wc)); + + return wc; +} + +void +asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *wc) { + if(wc) { + if(wc->ref) + asn1p_ref_free(wc->ref); + if(wc->buf) + free(wc->buf); + free(wc); + } +} + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *wc) { + asn1p_wsyntx_chunk_t *nc; + + nc = asn1p_wsyntx_chunk_new(); + if(nc) { + if(wc->buf) { + nc->buf = malloc(wc->len + 1); + if(nc->buf) { + nc->len = wc->len; + memcpy(nc->buf, wc->buf, wc->len); + nc->buf[nc->len] = '\0'; + } + } + if(wc->ref) { + nc->ref = asn1p_ref_clone(wc->ref); + } + + if(!nc->ref && !nc->buf) { + asn1p_wsyntx_chunk_free(nc); + return NULL; + } + } + + return nc; +} + +asn1p_wsyntx_t * +asn1p_wsyntx_new() { + asn1p_wsyntx_t *wx; + + wx = calloc(1, sizeof(*wx)); + if(wx) { + TQ_INIT(&(wx->chunks)); + } + + return wx; +} + +void +asn1p_wsyntx_free(asn1p_wsyntx_t *wx) { + if(wx) { + asn1p_wsyntx_chunk_t *wc; + while((wc = TQ_REMOVE(&(wx->chunks), next))) + asn1p_wsyntx_chunk_free(wc); + free(wx); + } +} + +asn1p_wsyntx_t * +asn1p_wsyntx_clone(asn1p_wsyntx_t *wx) { + asn1p_wsyntx_t *nw; + + nw = asn1p_wsyntx_new(); + if(nw) { + asn1p_wsyntx_chunk_t *wc; + asn1p_wsyntx_chunk_t *nc; + TQ_FOR(wc, &(wx->chunks), next) { + nc = asn1p_wsyntx_chunk_clone(wc); + if(nc) { + TQ_ADD(&(nw->chunks), nc, next); + } else { + asn1p_wsyntx_free(nw); + return NULL; + } + } + } + + return nw; +} + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_fromref(asn1p_ref_t *ref, int do_copy) { + asn1p_wsyntx_chunk_t *wc; + + if(do_copy) { + static asn1p_wsyntx_chunk_t tmp; + tmp.ref = ref; + wc = asn1p_wsyntx_chunk_clone(&tmp); + } else { + wc = asn1p_wsyntx_chunk_new(); + if(wc) wc->ref = ref; + } + + return wc; +} + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_frombuf(char *buf, int len, int do_copy) { + asn1p_wsyntx_chunk_t *wc; + + if(do_copy) { + static asn1p_wsyntx_chunk_t tmp; + tmp.buf = buf; + tmp.len = len; + wc = asn1p_wsyntx_chunk_clone(&tmp); + } else { + wc = asn1p_wsyntx_chunk_new(); + if(wc) { + wc->buf = buf; + wc->len = len; + } + } + + return wc; +} + diff --git a/libasn1parser/asn1p_class.h b/libasn1parser/asn1p_class.h new file mode 100644 index 00000000..4a0f19e1 --- /dev/null +++ b/libasn1parser/asn1p_class.h @@ -0,0 +1,53 @@ +/* + * CLASS-related stuff. + */ +#ifndef ASN1_PARSER_CLASS_H +#define ASN1_PARSER_CLASS_H + +#include + +/* + * WITH SYNTAX free-form chunks. + */ +typedef struct asn1p_wsyntx_chunk_s { + /* + * It could be the union, but the story is: + * if ref is here, the ref is used. + * Otherwise, buf/len is used. + */ + asn1p_ref_t *ref; + + char *buf; + int len; + + TQ_ENTRY(struct asn1p_wsyntx_chunk_s) next; +} asn1p_wsyntx_chunk_t; + +typedef struct asn1p_wsyntx_s { + + TQ_HEAD(struct asn1p_wsyntx_chunk_s) chunks; + +} asn1p_wsyntx_t; + + +/* + * Constructor, destructor and cloning function. + */ +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_new(void); +void asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *); +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *); + +asn1p_wsyntx_t *asn1p_wsyntx_new(void); +void asn1p_wsyntx_free(asn1p_wsyntx_t *); +asn1p_wsyntx_t *asn1p_wsyntx_clone(asn1p_wsyntx_t *); + +/* + * RETURN VALUES: + * 0: Component has been added + * -1: Failure to add component (refer to errno) + */ +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromref(asn1p_ref_t *ref, int do_copy); +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_frombuf(char *buf, int len, int do_copy); + + +#endif /* ASN1_PARSER_CLASS_H */ diff --git a/libasn1parser/asn1p_constr.c b/libasn1parser/asn1p_constr.c new file mode 100644 index 00000000..6e198892 --- /dev/null +++ b/libasn1parser/asn1p_constr.c @@ -0,0 +1,91 @@ +#include +#include +#include +#include + +#include "asn1parser.h" + +asn1p_constraint_t * +asn1p_constraint_new(int _lineno) { + asn1p_constraint_t *ct; + + ct = calloc(1, sizeof(*ct)); + if(ct) { + ct->_lineno = _lineno; + } + + return ct; +} + + +void +asn1p_constraint_free(asn1p_constraint_t *ct) { + if(ct) { + + if(ct->value) + asn1p_value_free(ct->value); + if(ct->range_start) + asn1p_value_free(ct->range_start); + if(ct->range_stop) + asn1p_value_free(ct->range_stop); + + if(ct->elements) { + while(ct->el_count--) { + asn1p_constraint_free( + ct->elements[ct->el_count]); + } + free(ct->elements); + } + + free(ct); + } +} + +asn1p_constraint_t * +asn1p_constraint_clone(asn1p_constraint_t *src) { + asn1p_constraint_t *clone; + +#define CLONE(field, func) do { if(src->field) { \ + clone->field = func(src->field); \ + if(clone->field == NULL) { \ + asn1p_constraint_free(clone); \ + return NULL; \ + } \ + } } while(0) + + clone = asn1p_constraint_new(src->_lineno); + if(clone) { + clone->type = src->type; + CLONE(value, asn1p_value_clone); + CLONE(range_start, asn1p_value_clone); + CLONE(range_stop, asn1p_value_clone); + } + + return clone; +} + +int +asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what) { + assert(into); + assert(what); + + /* + * Make sure there's enough space to add an element. + */ + if(into->el_count == into->el_size) { + int newsize = into->el_size?into->el_size<<2:4; + void *p; + p = realloc(into->elements, + newsize * sizeof(into->elements[0])); + if(p) { + into->elements = p; + into->el_size = newsize; + } else { + return -1; + } + } + + into->elements[into->el_count++] = what; + + return 0; +} diff --git a/libasn1parser/asn1p_constr.h b/libasn1parser/asn1p_constr.h new file mode 100644 index 00000000..19099b2f --- /dev/null +++ b/libasn1parser/asn1p_constr.h @@ -0,0 +1,79 @@ +/* + * Type constraints. + */ +#ifndef ASN1_PARSER_CONSTRAINT_H +#define ASN1_PARSER_CONSTRAINT_H + +typedef struct asn1p_constraint_s { + + enum asn1p_constraint_type_e { + ACT_INVALID, /* for assertions */ + /* + * Constraint elements. + */ + ACT_EL_VALUE, /* 123, "A", T (elementary value) */ + ACT_EL_RANGE, /* 1..2 (elementary range) */ + ACT_EL_LLRANGE, /* 1<..2 (elementary range) */ + ACT_EL_RLRANGE, /* 1..<2 (elementary range) */ + ACT_EL_ULRANGE, /* 1<..<2 (elementary range) */ + ACT_EL_EXT, /* ... (extensibility mark) */ + /* + * Constraint types. + */ + ACT_CT_SIZE, /* SIZE constraint type */ + ACT_CT_FROM, /* FROM constraint type */ + ACT_CT_WCOMP, /* WITH COMPONENT */ + ACT_CT_WCOMPS, /* WITH COMPONENTS */ + /* + * Arrays of constraints. + */ + ACT_CA_SET, /* A set of constraints: (c1)(c2) */ + ACT_CA_CRC, /* Comp. relation c-t: ({a})({@b}) */ + ACT_CA_CSV, /* Comma-separated constraints array */ + ACT_CA_UNI, /* UNION (|) */ + ACT_CA_INT, /* INTERSECTION (^) */ + ACT_CA_EXC, /* EXCEPT */ + } type; + + enum asn1p_constr_pres_e { + ACPRES_DEFAULT, + ACPRES_PRESENT, + ACPRES_ABSENT, + ACPRES_OPTIONAL, + } presence; + + /* + * A single values. + */ + asn1p_value_t *value; + asn1p_value_t *range_start; + asn1p_value_t *range_stop; + + /* + * A collection of constraint elements. + */ + struct asn1p_constraint_s **elements; + int el_count; /* Number of meaningful elements */ + int el_size; /* Size of the allocated (elements) */ + + int _lineno; /* Position in a source file */ +} asn1p_constraint_t; + + +/* + * Constructors and a recursive destructor. + */ +asn1p_constraint_t *asn1p_constraint_new(int _lineno); +void asn1p_constraint_free(asn1p_constraint_t *); + +/* + * Clone the constraint and all its children. + */ +asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone); + +/* + * Insert additional element into the element array of a (to) constraint. + */ +int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what); + +#endif /* ASN1_PARSER_CONSTRAINT_H */ diff --git a/libasn1parser/asn1p_expr.c b/libasn1parser/asn1p_expr.c new file mode 100644 index 00000000..23ab4cb3 --- /dev/null +++ b/libasn1parser/asn1p_expr.c @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty types collection. + */ +asn1p_expr_t * +asn1p_expr_new(int _lineno) { + asn1p_expr_t *expr; + + expr = calloc(1, sizeof *expr); + if(expr) { + TQ_INIT(&(expr->members)); + expr->_lineno = _lineno; + } + + return expr; +} + +asn1p_expr_t * +asn1p_expr_clone(asn1p_expr_t *expr) { + asn1p_expr_t *clone; + asn1p_expr_t *tcmemb; /* Child of tc */ + + clone = asn1p_expr_new(expr->_lineno); + if(clone == NULL) return NULL; + +#define CLCOPY(field) do { clone->field = expr->field; } while(0) +#define CLCLONE(field, func) do { if(expr->field) { \ + clone->field = func(expr->field); \ + if(clone->field == NULL) { \ + asn1p_expr_free(clone); \ + return NULL; \ + } \ + } } while(0) + + /* + * Copy simple fields. + */ + CLCOPY(meta_type); + CLCOPY(expr_type); + CLCOPY(tag); + CLCOPY(marker); + CLCOPY(_mark); + + clone->data = 0; /* Do not clone this */ + clone->data_free = 0; /* Do not clone this */ + + /* + * Clone complex fields. + */ + CLCLONE(Identifier, strdup); + CLCLONE(reference, asn1p_ref_clone); + CLCLONE(constraints, asn1p_constraint_clone); + CLCLONE(params, asn1p_paramlist_clone); + CLCLONE(value, asn1p_value_clone); + CLCLONE(with_syntax, asn1p_wsyntx_clone); + + /* + * Copy all the children of this expr. + */ + TQ_FOR(tcmemb, &(expr->members), next) { + asn1p_expr_t *cmemb = asn1p_expr_clone(tcmemb); + if(cmemb == NULL) { + asn1p_expr_free(clone); + return NULL; + } + TQ_ADD(&(clone->members), cmemb, next); + } + + return clone; +} + +/* + * Destruct the types collection structure. + */ +void +asn1p_expr_free(asn1p_expr_t *expr) { + if(expr) { + asn1p_expr_t *tm; + + if(expr->Identifier) + free(expr->Identifier); + if(expr->reference) + asn1p_ref_free(expr->reference); + if(expr->constraints) + asn1p_constraint_free(expr->constraints); + if(expr->params) + asn1p_paramlist_free(expr->params); + if(expr->value) + asn1p_value_free(expr->value); + if(expr->with_syntax) + asn1p_wsyntx_free(expr->with_syntax); + + /* Remove all children */ + while((tm = TQ_REMOVE(&(expr->members), next))) { + asn1p_expr_free(tm); + } + + if(expr->data && expr->data_free) + expr->data_free(expr->data); + + memset(expr, 0, sizeof(*expr)); + free(expr); + } +} + diff --git a/libasn1parser/asn1p_expr.h b/libasn1parser/asn1p_expr.h new file mode 100644 index 00000000..331285c7 --- /dev/null +++ b/libasn1parser/asn1p_expr.h @@ -0,0 +1,214 @@ +/* + * A collection of data members of unspecified types. + */ +#ifndef ASN1_PARSER_EXPR_H +#define ASN1_PARSER_EXPR_H + +/* + * Meta type of the ASN expression. + */ +typedef enum asn1p_expr_meta { + AMT_INVALID, + AMT_TYPE, /* Type1 ::= INTEGER */ + AMT_TYPEREF, /* Type2 ::= Type1 */ + AMT_PARAMTYPE, /* Type3{Parameter} ::= SET { ... } */ + AMT_VALUE, /* value1 Type1 ::= 1 */ + AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */ + AMT_OBJECT, /* FUNCTION ::= CLASS {...} */ + AMT_OBJECTSET, /* Functions FUNCTION ::= {...} */ + AMT_OBJECTFIELD, /* ... */ + AMT_EXPR_META_MAX +} asn1p_expr_meta_e; + +/* + * ASN type of the expression. + */ +typedef enum asn1p_expr_type { + /* + * Internal types. + */ + A1TC_INVALID, /* Invalid type */ + A1TC_REFERENCE, /* Reference to the type defined elsewhere */ + A1TC_EXPORTVAR, /* We're exporting this definition */ + A1TC_UNIVERVAL, /* A value of an ENUMERATED, INTEGER or BS */ + A1TC_BOOLBITPOS, /* A bit position in a BIT STRING */ + A1TC_BITVECTOR, /* A plain collection of bits */ + A1TC_OPAQUE, /* Opaque data encoded as a bitvector */ + A1TC_EXTENSIBLE, /* An extension marker "..." */ + A1TC_PARAMETRIZED, /* A parametrized type declaration */ + A1TC_VALUESET, /* Value set definition */ + A1TC_CLASSDEF, /* Information Object Class */ + A1TC_CLASSFIELD, /* Information Object Class field */ + A1TC_INSTANCE, /* Instance of Object Class */ + A1TC_TYPEID, /* Type identifier */ + /* + * ASN.1 Constructed types + */ +#define ASN_CONSTR_MASK 0x10 /* Every constructed type */ + ASN_CONSTR_SEQUENCE = ASN_CONSTR_MASK, /* SEQUENCE */ + ASN_CONSTR_CHOICE, /* CHOICE */ + ASN_CONSTR_SET, /* SET */ + ASN_CONSTR_SEQUENCE_OF, /* SEQUENCE OF */ + ASN_CONSTR_SET_OF, /* SET OF */ + ASN_CONSTR_ANY, /* ANY (deprecated) */ + /* + * ASN.1 Basic types + */ +#define ASN_BASIC_MASK 0x20 /* Every basic type */ + ASN_BASIC_BOOLEAN = ASN_BASIC_MASK, + ASN_BASIC_NULL, + ASN_BASIC_INTEGER, + ASN_BASIC_REAL, + ASN_BASIC_ENUMERATED, + ASN_BASIC_BIT_STRING, + ASN_BASIC_OCTET_STRING, + ASN_BASIC_OBJECT_IDENTIFIER, + ASN_BASIC_RELATIVE_OID, + ASN_BASIC_EXTERNAL, + ASN_BASIC_EMBEDDED_PDV, + ASN_BASIC_CHARACTER_STRING, + ASN_BASIC_UTCTime, + ASN_BASIC_GeneralizedTime, + /* + * ASN.1 String types + */ +#define ASN_STRING_MASK 0x40 /* Every string type */ + ASN_STRING_BMPString = ASN_STRING_MASK, + ASN_STRING_GeneralString, + ASN_STRING_GraphicString, + ASN_STRING_IA5String, + ASN_STRING_ISO646String, + ASN_STRING_NumericString, + ASN_STRING_PrintableString, + ASN_STRING_TeletexString, + ASN_STRING_T61String, + ASN_STRING_UniversalString, + ASN_STRING_UTF8String, + ASN_STRING_VideotexString, + ASN_STRING_VisibleString, + ASN_STRING_ObjectDescriptor, + ASN_EXPR_TYPE_MAX +} asn1p_expr_type_e; + +#include "asn1p_expr_str.h" +#include "asn1p_expr2uclass.h" + +/* + * A named collection of types. + */ +typedef struct asn1p_expr_s { + + /* + * Human readable name. + */ + char *Identifier; + + /* + * Meta type of the expression (type, value, value set, etc). + */ + asn1p_expr_meta_e meta_type; + + /* + * ASN type of the expression. + */ + asn1p_expr_type_e expr_type; + + /* + * Referenced type, if defined elsewhere. + * (If expr_type == A1TC_REFERENCE) + */ + asn1p_ref_t *reference; + + /* + * Constraints for the type. + */ + asn1p_constraint_t *constraints; + + /* + * A list of parameters for parametrized type declaration + * (AMT_PARAMTYPE). + */ + asn1p_paramlist_t *params; + + /* + * The actual value (DefinedValue or inlined value). + */ + asn1p_value_t *value; + + /* + * The WITH SYHTAX clause. + */ + asn1p_wsyntx_t *with_syntax; + + /* + * A tag. + */ + struct asn1p_type_tag_s { + enum { + TC_NOCLASS, + TC_UNIVERSAL, + TC_APPLICATION, + TC_CONTEXT_SPECIFIC, + TC_PRIVATE, + } tag_class; + enum { + TM_DEFAULT, + TM_IMPLICIT, + TM_EXPLICIT, + } tag_mode; + asn1_integer_t tag_value; + } tag; + + /* + * Whether automatic tagging is applicable for subtypes. + */ + int auto_tags_OK; + + enum asn1p_expr_marker_e { + EM_NOMARK, + EM_OPTIONAL, + EM_DEFAULT, /* FIXME: store the value somewhere. */ + } marker; + int unique; /* UNIQUE */ + + /* + * Members of the constructed type. + */ + TQ_HEAD(struct asn1p_expr_s) members; + + /* + * Next expression in the list. + */ + TQ_ENTRY(struct asn1p_expr_s) next; + + /* + * Line number where this structure is defined in the original + * grammar source. + */ + int _lineno; + /* + * Marks are used for various purposes. + * Here are some predefined ones. + */ + enum { + TM_NOMARK, + TM_RECURSION, /* Used to break recursion */ + } _mark; + + /* + * Opaque data may be attached to this structure, + * probably by compiler. + */ + void *data; + void (*data_free)(void *data); +} asn1p_expr_t; + + +/* + * Constructor and destructor. + */ +asn1p_expr_t *asn1p_expr_new(int _lineno); +asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *); +void asn1p_expr_free(asn1p_expr_t *expr); + +#endif /* ASN1_PARSER_EXPR_H */ diff --git a/libasn1parser/asn1p_expr2uclass.h b/libasn1parser/asn1p_expr2uclass.h new file mode 100644 index 00000000..416c9f72 --- /dev/null +++ b/libasn1parser/asn1p_expr2uclass.h @@ -0,0 +1,41 @@ +#ifndef ASN1_PARSER_EXPR2UCLASS_H +#define ASN1_PARSER_EXPR2UCLASS_H + +static int +expr_type2uclass_value[ASN_EXPR_TYPE_MAX] + __attribute__ ((unused)) = { + [ ASN_BASIC_BOOLEAN ] = 1, + [ ASN_BASIC_INTEGER ] = 2, + [ ASN_BASIC_BIT_STRING ] = 3, + [ ASN_BASIC_OCTET_STRING ] = 4, + [ ASN_BASIC_NULL ] = 5, + [ ASN_BASIC_OBJECT_IDENTIFIER ] = 6, + [ ASN_BASIC_EXTERNAL ] = 7, + [ ASN_STRING_ObjectDescriptor ] = 7, + [ ASN_BASIC_REAL ] = 9, + [ ASN_BASIC_ENUMERATED ] = 10, + [ ASN_BASIC_EMBEDDED_PDV ] = 11, + [ ASN_STRING_UTF8String ] = 12, + [ ASN_BASIC_RELATIVE_OID ] = 13, + [ ASN_CONSTR_SEQUENCE ] = 16, + [ ASN_CONSTR_SEQUENCE_OF ] = 16, + [ ASN_CONSTR_SET ] = 17, + [ ASN_CONSTR_SET_OF ] = 17, + [ ASN_STRING_NumericString ] = 18, + [ ASN_STRING_PrintableString ] = 19, + [ ASN_STRING_TeletexString ] = 20, + [ ASN_STRING_T61String ] = 20, + [ ASN_STRING_VideotexString ] = 21, + [ ASN_STRING_IA5String ] = 22, + [ ASN_BASIC_UTCTime ] = 23, + [ ASN_BASIC_GeneralizedTime ] = 24, + [ ASN_STRING_GraphicString ] = 25, + [ ASN_STRING_VisibleString ] = 26, + [ ASN_STRING_ISO646String ] = 26, + [ ASN_STRING_GeneralString ] = 27, + [ ASN_STRING_UniversalString ] = 28, + [ ASN_BASIC_CHARACTER_STRING ] = 29, + [ ASN_STRING_BMPString ] = 30, +}; + +#endif /* ASN1_PARSER_EXPR2UCLASS_H */ diff --git a/libasn1parser/asn1p_expr_str.h b/libasn1parser/asn1p_expr_str.h new file mode 100644 index 00000000..02de131b --- /dev/null +++ b/libasn1parser/asn1p_expr_str.h @@ -0,0 +1,57 @@ +/* + * This file is automatically generated by ./expr-h.pl + * DO NOT EDIT MANUALLY, fix the ./expr-h.pl instead if necessary. + */ +#ifndef ASN1_PARSER_EXPR_STR_H +#define ASN1_PARSER_EXPR_STR_H + +static char *asn1p_expr_type2str[] __attribute__ ((unused)) = { + [ ASN_CONSTR_SEQUENCE ] = "SEQUENCE", + [ ASN_CONSTR_CHOICE ] = "CHOICE", + [ ASN_CONSTR_SET ] = "SET", + [ ASN_CONSTR_SEQUENCE_OF ] = "SEQUENCE OF", + [ ASN_CONSTR_SET_OF ] = "SET OF", + [ ASN_CONSTR_ANY ] = "ANY", + [ ASN_BASIC_BOOLEAN ] = "BOOLEAN", + [ ASN_BASIC_NULL ] = "NULL", + [ ASN_BASIC_INTEGER ] = "INTEGER", + [ ASN_BASIC_REAL ] = "REAL", + [ ASN_BASIC_ENUMERATED ] = "ENUMERATED", + [ ASN_BASIC_BIT_STRING ] = "BIT STRING", + [ ASN_BASIC_OCTET_STRING ] = "OCTET STRING", + [ ASN_BASIC_OBJECT_IDENTIFIER ] = "OBJECT IDENTIFIER", + [ ASN_BASIC_RELATIVE_OID ] = "RELATIVE-OID", + [ ASN_BASIC_EXTERNAL ] = "EXTERNAL", + [ ASN_BASIC_EMBEDDED_PDV ] = "EMBEDDED PDV", + [ ASN_BASIC_CHARACTER_STRING ] = "CHARACTER STRING", + [ ASN_BASIC_UTCTime ] = "UTCTime", + [ ASN_BASIC_GeneralizedTime ] = "GeneralizedTime", + [ ASN_STRING_BMPString ] = "BMPString", + [ ASN_STRING_GeneralString ] = "GeneralString", + [ ASN_STRING_GraphicString ] = "GraphicString", + [ ASN_STRING_IA5String ] = "IA5String", + [ ASN_STRING_ISO646String ] = "ISO646String", + [ ASN_STRING_NumericString ] = "NumericString", + [ ASN_STRING_PrintableString ] = "PrintableString", + [ ASN_STRING_TeletexString ] = "TeletexString", + [ ASN_STRING_T61String ] = "T61String", + [ ASN_STRING_UniversalString ] = "UniversalString", + [ ASN_STRING_UTF8String ] = "UTF8String", + [ ASN_STRING_VideotexString ] = "VideotexString", + [ ASN_STRING_VisibleString ] = "VisibleString", + [ ASN_STRING_ObjectDescriptor ] = "ObjectDescriptor", +}; + +/* + * Convert the ASN.1 expression type back into the string representation. + */ +#define ASN_EXPR_TYPE2STR(type) \ + ( \ + ((type) < 0 \ + || (type) >= sizeof(asn1p_expr_type2str) \ + / sizeof(asn1p_expr_type2str[0])) \ + ? (char *)0 \ + : asn1p_expr_type2str[(type)] \ + ) + +#endif /* ASN1_PARSER_EXPR_STR_H */ diff --git a/libasn1parser/asn1p_l.c b/libasn1parser/asn1p_l.c new file mode 100644 index 00000000..6a6eb446 --- /dev/null +++ b/libasn1parser/asn1p_l.c @@ -0,0 +1,3861 @@ +#define yy_create_buffer asn1p__create_buffer +#define yy_delete_buffer asn1p__delete_buffer +#define yy_scan_buffer asn1p__scan_buffer +#define yy_scan_string asn1p__scan_string +#define yy_scan_bytes asn1p__scan_bytes +#define yy_flex_debug asn1p__flex_debug +#define yy_init_buffer asn1p__init_buffer +#define yy_flush_buffer asn1p__flush_buffer +#define yy_load_buffer_state asn1p__load_buffer_state +#define yy_switch_to_buffer asn1p__switch_to_buffer +#define yyin asn1p_in +#define yyleng asn1p_leng +#define yylex asn1p_lex +#define yyout asn1p_out +#define yyrestart asn1p_restart +#define yytext asn1p_text +#define yylineno asn1p_lineno + +#line 20 "lex.yy.c" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header$ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define YY_USES_REJECT + +#define yywrap() 1 +#define YY_SKIP_YYWRAP + +#define FLEX_DEBUG +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; + +#define FLEX_DEBUG +extern int yylineno; +int yylineno = 1; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 123 +#define YY_END_OF_BUFFER 124 +static yyconst short int yy_acclist[1196] = + { 0, + 124, 122, 123, 117, 122, 123, 117, 123, 116, 122, + 123, 15, 122, 123, 116, 122, 123, 122, 123, 116, + 122, 123, 122, 123, 116, 122, 123, 122, 123, 23, + 122, 123, 22, 122, 123, 116, 122, 123, 122, 123, + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 111, 112, 122, 123, + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 111, 112, 122, 123, + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 111, 112, 122, 123, + + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 116, 122, 123, 110, + 122, 123, 5, 122, 123, 2, 123, 2, 122, 123, + 4, 122, 123, 7, 9, 122, 123, 7, 123, 9, + 122, 123, 9, 122, 123, 17, 122, 123, 17, 123, + 18, 122, 123, 12, 122, 123, 12, 123, 14, 122, + 123, 14, 122, 123, 10, 122, 123, 11, 122, 123, + 119, 122, 123, 120, 122, 123, 120, 123, 122, 123, + 121, 122, 123, 117, 15, 15, 108, 109, 1, 21, + 115, 6, 22, 111, 112, 111, 112, 111, 112, 111, + + 112, 111, 112, 111, 112, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 36, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 112, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 112, 111, 112, 111, 112, 79, 111, + 112, 111, 112, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 112, 111, 112, 111, 112, 112, 112, 111, 112, + + 110, 5, 3, 8, 17, 16, 12, 119, 120, 118, + 108, 109, 21, 114, 113, 111, 112, 28, 111, 112, + 29, 111, 112, 111, 112, 111, 112, 111, 112, 33, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 49, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 112, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 71, 111, 112, 72, 111, 112, 111, + 112, 112, 111, 112, 111, 112, 111, 112, 112, 111, + + 112, 82, 111, 112, 111, 112, 111, 112, 111, 112, + 112, 111, 112, 111, 112, 111, 112, 90, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 112, 111, 112, 111, 112, 111, + 112, 112, 112, 112, 111, 112, 24, 13, 20, 19, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 57, 111, 112, 112, + + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 74, + 111, 112, 112, 111, 112, 111, 112, 111, 112, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 112, 87, + 111, 112, 111, 112, 111, 112, 91, 111, 112, 111, + 112, 111, 112, 111, 112, 95, 111, 112, 97, 111, + 112, 111, 112, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 112, 112, 112, 107, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 32, 111, + 112, 112, 111, 112, 111, 112, 111, 112, 39, 111, + + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 56, 111, 112, + 112, 112, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 112, 111, 112, 78, 111, 112, 111, 112, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 112, 111, 112, + 112, 99, 111, 112, 111, 112, 111, 112, 112, 111, + 112, 112, 112, 112, 25, 26, 111, 112, 111, 112, + + 111, 112, 111, 112, 112, 111, 112, 111, 112, 38, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 51, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 112, 112, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 112, 76, 111, 112, 111, 112, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 112, + 111, 112, 111, 112, 92, 111, 112, 93, 111, 112, + 112, 111, 112, 112, 100, 111, 112, 111, 112, 112, + + 112, 112, 112, 112, 111, 112, 111, 112, 111, 112, + 112, 35, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 44, 111, 112, 45, 111, 112, 111, 112, + 111, 112, 48, 111, 112, 111, 112, 111, 112, 53, + 111, 112, 111, 112, 111, 112, 112, 112, 112, 111, + 112, 111, 112, 64, 111, 112, 65, 111, 112, 111, + 112, 111, 112, 68, 111, 112, 111, 112, 111, 112, + 111, 112, 112, 111, 112, 112, 81, 111, 112, 111, + 112, 84, 111, 112, 86, 111, 112, 112, 111, 112, + 111, 112, 112, 111, 112, 112, 111, 112, 103, 112, + + 112, 112, 112, 112, 111, 112, 111, 112, 111, 112, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 47, 111, 112, 111, 112, 52, 111, 112, 111, + 112, 55, 111, 112, 112, 112, 112, 112, 111, 112, + 63, 111, 112, 66, 111, 112, 67, 111, 112, 111, + 112, 112, 111, 112, 112, 80, 111, 112, 112, 111, + 112, 112, 111, 112, 89, 111, 112, 112, 111, 112, + 112, 111, 112, 112, 112, 112, 112, 111, 112, 111, + 112, 31, 111, 112, 34, 112, 37, 111, 112, 40, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + + 111, 112, 112, 112, 112, 61, 112, 111, 112, 111, + 112, 112, 111, 112, 112, 112, 111, 112, 112, 111, + 112, 94, 112, 111, 112, 112, 101, 111, 112, 112, + 112, 112, 112, 111, 112, 111, 112, 41, 111, 112, + 42, 111, 112, 43, 111, 112, 111, 112, 50, 111, + 112, 111, 112, 112, 112, 112, 62, 111, 112, 111, + 112, 112, 111, 112, 112, 112, 111, 112, 112, 111, + 112, 111, 112, 112, 104, 112, 112, 112, 112, 111, + 112, 30, 111, 112, 46, 111, 112, 111, 112, 112, + 112, 112, 111, 112, 112, 111, 112, 112, 112, 111, + + 112, 112, 111, 112, 111, 112, 112, 112, 112, 112, + 24, 25, 111, 112, 111, 112, 112, 112, 112, 69, + 111, 112, 70, 112, 111, 112, 112, 112, 111, 112, + 112, 88, 111, 112, 111, 112, 112, 112, 112, 112, + 111, 112, 54, 111, 112, 59, 112, 112, 60, 112, + 111, 112, 75, 112, 112, 83, 111, 112, 112, 111, + 112, 96, 112, 112, 112, 106, 112, 111, 112, 112, + 73, 111, 112, 112, 112, 111, 112, 112, 105, 112, + 27, 111, 112, 58, 112, 112, 85, 112, 98, 111, + 112, 102, 112, 77, 112 + + } ; + +static yyconst short int yy_accept[676] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 4, 7, 9, 12, 15, 18, + 20, 23, 25, 28, 30, 33, 36, 39, 41, 45, + 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, + 89, 93, 97, 101, 105, 109, 113, 117, 120, 123, + 126, 128, 131, 134, 138, 140, 143, 146, 149, 151, + 154, 157, 159, 162, 165, 168, 171, 174, 177, 179, + 181, 184, 184, 185, 186, 187, 187, 188, 188, 189, + 189, 189, 190, 191, 192, 193, 194, 194, 196, 198, + 200, 202, 204, 206, 207, 209, 211, 213, 215, 218, + + 220, 222, 224, 226, 228, 230, 232, 234, 236, 237, + 238, 240, 242, 244, 246, 248, 250, 252, 254, 255, + 257, 259, 262, 264, 265, 267, 269, 271, 273, 274, + 276, 278, 280, 282, 284, 286, 288, 290, 292, 293, + 295, 297, 298, 299, 301, 301, 301, 301, 301, 301, + 302, 303, 304, 305, 306, 307, 308, 308, 309, 310, + 311, 311, 312, 313, 313, 313, 314, 315, 316, 318, + 321, 324, 326, 328, 330, 333, 335, 337, 339, 341, + 343, 345, 347, 349, 351, 353, 356, 358, 360, 362, + 364, 366, 368, 369, 370, 372, 374, 376, 378, 380, + + 382, 384, 387, 390, 392, 393, 395, 397, 399, 400, + 402, 405, 407, 409, 411, 412, 414, 416, 418, 421, + 423, 425, 427, 429, 431, 433, 435, 436, 438, 440, + 442, 443, 444, 445, 447, 448, 448, 448, 448, 448, + 449, 449, 450, 451, 453, 455, 457, 459, 461, 463, + 465, 467, 469, 471, 473, 475, 477, 479, 481, 483, + 485, 487, 489, 491, 493, 495, 497, 500, 501, 502, + 504, 506, 508, 510, 512, 514, 516, 518, 520, 523, + 524, 526, 528, 530, 531, 533, 535, 537, 539, 540, + 543, 545, 547, 550, 552, 554, 556, 559, 562, 564, + + 565, 567, 569, 571, 573, 575, 576, 577, 578, 581, + 581, 581, 581, 581, 583, 585, 587, 589, 592, 593, + 595, 597, 599, 602, 604, 606, 608, 610, 612, 614, + 616, 618, 620, 622, 624, 626, 628, 631, 632, 633, + 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, + 653, 655, 658, 660, 661, 663, 665, 667, 669, 670, + 672, 674, 676, 678, 679, 681, 682, 685, 687, 689, + 690, 692, 693, 694, 695, 696, 696, 696, 696, 699, + 701, 703, 705, 706, 708, 710, 713, 715, 717, 719, + 721, 723, 725, 727, 729, 731, 734, 736, 738, 740, + + 742, 743, 744, 745, 747, 749, 751, 753, 755, 757, + 759, 761, 763, 765, 766, 769, 771, 772, 774, 776, + 778, 780, 781, 783, 785, 788, 791, 792, 794, 795, + 798, 800, 801, 802, 803, 804, 805, 805, 805, 805, + 807, 809, 811, 812, 815, 817, 819, 821, 823, 826, + 829, 831, 833, 836, 838, 840, 843, 845, 847, 848, + 849, 850, 852, 854, 857, 860, 862, 864, 867, 869, + 871, 873, 874, 876, 877, 880, 882, 885, 888, 889, + 891, 893, 894, 896, 897, 899, 901, 902, 903, 904, + 905, 905, 905, 905, 907, 909, 911, 912, 914, 916, + + 918, 920, 922, 925, 927, 930, 932, 935, 936, 937, + 938, 939, 941, 944, 947, 950, 952, 953, 955, 956, + 959, 960, 962, 963, 965, 968, 969, 971, 972, 974, + 975, 976, 977, 978, 978, 978, 978, 980, 982, 985, + 987, 990, 993, 995, 997, 999, 1001, 1003, 1004, 1005, + 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1020, + 1022, 1024, 1026, 1027, 1030, 1031, 1032, 1033, 1034, 1034, + 1034, 1034, 1036, 1038, 1041, 1044, 1047, 1049, 1052, 1054, + 1055, 1056, 1057, 1060, 1062, 1063, 1065, 1066, 1067, 1069, + 1070, 1072, 1074, 1075, 1077, 1078, 1079, 1080, 1080, 1080, + + 1080, 1082, 1085, 1088, 1090, 1091, 1092, 1093, 1095, 1096, + 1098, 1099, 1100, 1102, 1103, 1105, 1107, 1108, 1109, 1110, + 1111, 1111, 1113, 1113, 1115, 1117, 1118, 1119, 1120, 1123, + 1125, 1127, 1128, 1129, 1131, 1132, 1135, 1137, 1138, 1139, + 1140, 1141, 1141, 1143, 1146, 1148, 1149, 1151, 1153, 1155, + 1156, 1159, 1160, 1162, 1164, 1165, 1166, 1168, 1168, 1170, + 1171, 1174, 1175, 1176, 1178, 1179, 1181, 1184, 1186, 1187, + 1189, 1192, 1194, 1196, 1196 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 6, 1, 1, 1, 7, 8, 9, + 9, 10, 1, 9, 11, 12, 13, 14, 15, 16, + 16, 17, 18, 19, 16, 20, 16, 21, 22, 23, + 24, 1, 1, 9, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 1, 52, 53, 1, 1, 54, 55, 56, 57, + + 58, 59, 60, 61, 62, 63, 59, 64, 65, 66, + 67, 68, 59, 69, 70, 71, 72, 73, 59, 74, + 59, 75, 76, 77, 78, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[79] = + { 0, + 1, 2, 3, 3, 1, 4, 5, 6, 1, 1, + 7, 1, 1, 8, 8, 8, 8, 8, 8, 8, + 9, 1, 1, 9, 8, 8, 8, 8, 8, 8, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 1, 1, 1, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 12, 1, 12 + } ; + +static yyconst short int yy_base[691] = + { 0, + 0, 0, 76, 78, 80, 81, 82, 89, 83, 93, + 96, 106, 844, 833, 116, 119, 822, 821, 177, 126, + 4166, 127, 816, 123, 4166, 134, 805, 4166, 242, 292, + 141, 298, 152, 314, 322, 130, 338, 359, 360, 376, + 382, 397, 410, 437, 440, 462, 463, 495, 0, 0, + 4166, 4166, 811, 4166, 4166, 807, 807, 0, 0, 809, + 0, 0, 787, 4166, 4166, 4166, 0, 160, 191, 104, + 4166, 800, 261, 0, 798, 797, 0, 79, 0, 426, + 793, 4166, 511, 787, 4166, 527, 771, 512, 513, 528, + 529, 544, 550, 0, 561, 567, 578, 589, 595, 611, + + 617, 628, 641, 644, 664, 661, 672, 685, 727, 737, + 696, 702, 713, 719, 730, 741, 747, 758, 725, 771, + 774, 787, 795, 725, 798, 811, 822, 835, 720, 851, + 857, 868, 874, 885, 900, 901, 916, 917, 716, 932, + 933, 716, 45, 948, 980, 987, 736, 97, 120, 0, + 0, 4166, 4166, 0, 4166, 0, 750, 0, 291, 4166, + 761, 0, 0, 79, 739, 994, 4166, 4166, 990, 1003, + 1011, 1014, 1027, 1035, 1038, 1051, 1059, 1067, 1075, 1088, + 1096, 1099, 1120, 1121, 1136, 1142, 1153, 1159, 1170, 1176, + 1187, 1198, 707, 693, 1211, 1219, 1222, 1237, 1240, 1243, + + 1267, 1261, 1264, 1282, 702, 1285, 1300, 1306, 696, 1317, + 1328, 1334, 1345, 1356, 686, 1367, 1373, 1384, 1390, 1405, + 1406, 1421, 1432, 1438, 1453, 1459, 692, 1470, 1481, 1492, + 675, 686, 681, 1503, 4166, 1542, 697, 143, 158, 4166, + 683, 4166, 4166, 1527, 1528, 1543, 1549, 1564, 1565, 1582, + 1581, 1597, 1603, 1614, 1625, 1643, 1640, 1646, 1661, 1664, + 1667, 1682, 1688, 1699, 1710, 1725, 1731, 664, 668, 1742, + 1748, 1763, 1764, 1779, 1785, 1796, 1809, 1817, 1825, 658, + 1840, 1843, 1856, 670, 1864, 1880, 1879, 1896, 649, 1897, + 1912, 1925, 1933, 1936, 1954, 1951, 1957, 1972, 1975, 648, + + 1978, 1993, 1999, 2010, 2016, 660, 649, 660, 2031, 2063, + 283, 280, 305, 2048, 2064, 2072, 2080, 2088, 644, 2096, + 2104, 2117, 2125, 2128, 2146, 2143, 2149, 2164, 2170, 2185, + 2186, 2201, 2216, 2222, 2233, 2239, 2254, 653, 641, 627, + 2255, 2275, 2272, 2293, 2292, 2310, 2309, 2325, 2331, 633, + 2342, 2353, 2359, 623, 2370, 2381, 2387, 2398, 639, 2411, + 2414, 2422, 2435, 616, 2446, 625, 2452, 2467, 2468, 613, + 2483, 607, 604, 610, 4166, 302, 321, 96, 2489, 2504, + 2507, 2515, 610, 2530, 2536, 2547, 2553, 2564, 2570, 2581, + 2592, 2598, 2615, 2621, 2637, 2638, 2653, 2654, 2669, 2675, + + 605, 607, 599, 2686, 2692, 2707, 2708, 2728, 2729, 2744, + 2752, 2765, 2773, 604, 2776, 2794, 631, 2791, 2797, 2812, + 2815, 603, 2823, 2838, 2841, 2844, 590, 2859, 574, 2862, + 2865, 588, 576, 574, 583, 581, 317, 309, 328, 2880, + 2883, 2896, 572, 2904, 2917, 2925, 2928, 2941, 2949, 2952, + 2965, 2976, 2973, 2989, 3000, 3011, 3017, 3028, 54, 589, + 564, 3034, 3045, 3056, 3062, 3073, 3079, 3094, 3095, 3110, + 3111, 583, 3126, 566, 3127, 3144, 3147, 3150, 558, 3165, + 3171, 554, 3186, 576, 3192, 0, 555, 559, 536, 566, + 347, 226, 339, 3203, 3209, 3224, 548, 3230, 3241, 3254, + + 3262, 3265, 3280, 3283, 3291, 3304, 3307, 531, 525, 525, + 531, 3322, 3328, 3339, 3345, 3356, 516, 3367, 512, 3373, + 511, 3384, 521, 3395, 3401, 517, 3412, 504, 3418, 506, + 507, 520, 466, 325, 465, 348, 3429, 3440, 3451, 0, + 3457, 3468, 3479, 3490, 3496, 3511, 3512, 467, 476, 464, + 0, 3527, 3528, 470, 3544, 450, 462, 3545, 474, 3560, + 0, 3566, 447, 3577, 444, 454, 423, 424, 361, 3616, + 353, 3601, 3602, 3617, 3618, 3633, 3634, 3649, 3650, 430, + 434, 428, 3665, 3673, 421, 3681, 421, 412, 3689, 403, + 3697, 3705, 410, 0, 400, 401, 403, 189, 3737, 519, + + 3722, 3723, 3738, 3746, 398, 417, 394, 3759, 398, 3767, + 391, 391, 3770, 383, 3783, 3794, 383, 378, 383, 378, + 371, 4166, 3833, 3818, 3819, 378, 363, 359, 3834, 0, + 3840, 357, 347, 3851, 351, 3857, 3868, 330, 315, 305, + 295, 558, 3884, 3881, 0, 282, 0, 3892, 0, 262, + 3907, 256, 3910, 0, 188, 141, 0, 3954, 3939, 138, + 3940, 120, 105, 3955, 95, 0, 3956, 0, 37, 0, + 3972, 0, 0, 4166, 4017, 4029, 4041, 4053, 4065, 4077, + 4088, 4089, 4093, 4104, 4116, 4128, 4139, 4144, 4149, 4154 + } ; + +static yyconst short int yy_def[691] = + { 0, + 674, 1, 675, 675, 676, 676, 677, 677, 678, 678, + 679, 679, 674, 674, 674, 674, 674, 680, 674, 681, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 682, 683, 684, + 674, 674, 674, 674, 674, 674, 674, 685, 685, 674, + 686, 686, 674, 674, 674, 674, 687, 674, 674, 19, + 674, 674, 674, 680, 680, 674, 688, 674, 689, 681, + 681, 674, 674, 674, 674, 674, 674, 29, 29, 29, + 29, 29, 29, 690, 29, 29, 29, 29, 29, 29, + + 29, 29, 29, 29, 29, 29, 29, 29, 690, 690, + 29, 29, 29, 29, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 690, 29, + 29, 690, 690, 29, 674, 682, 146, 146, 146, 683, + 684, 674, 674, 685, 674, 686, 674, 687, 674, 674, + 674, 688, 689, 674, 674, 674, 674, 674, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 690, 690, 29, 29, 29, 29, 29, 29, + + 29, 29, 29, 29, 690, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 690, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 690, 29, 29, 29, + 690, 690, 690, 29, 674, 674, 146, 146, 146, 674, + 674, 674, 674, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 690, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 690, + 29, 29, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 690, + + 29, 29, 29, 29, 29, 690, 690, 690, 29, 674, + 146, 146, 146, 29, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 690, 690, 690, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 690, + 29, 29, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 690, 29, 690, 29, 29, 29, 690, + 29, 690, 690, 690, 674, 146, 146, 146, 29, 29, + 29, 29, 690, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + + 690, 690, 690, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 690, 29, 29, 690, 29, 29, 29, + 29, 690, 29, 29, 29, 29, 690, 29, 690, 29, + 29, 690, 690, 690, 690, 690, 146, 146, 146, 29, + 29, 29, 690, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 690, 690, + 690, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 690, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 690, 29, 690, 29, 690, 690, 690, 690, 690, + 146, 146, 146, 29, 29, 29, 690, 29, 29, 29, + + 29, 29, 29, 29, 29, 29, 29, 690, 690, 690, + 690, 29, 29, 29, 29, 29, 690, 29, 690, 29, + 690, 29, 690, 29, 29, 690, 29, 690, 29, 690, + 690, 690, 690, 146, 146, 146, 29, 29, 29, 690, + 29, 29, 29, 29, 29, 29, 29, 690, 690, 690, + 690, 29, 29, 690, 29, 690, 690, 29, 690, 29, + 690, 29, 690, 29, 690, 690, 690, 690, 146, 674, + 146, 29, 29, 29, 29, 29, 29, 29, 29, 690, + 690, 690, 29, 29, 690, 29, 690, 690, 29, 690, + 29, 29, 690, 690, 690, 690, 690, 146, 674, 146, + + 29, 29, 29, 29, 690, 690, 690, 29, 690, 29, + 690, 690, 29, 690, 29, 29, 690, 690, 690, 690, + 146, 674, 674, 29, 29, 690, 690, 690, 29, 690, + 29, 690, 690, 29, 690, 29, 29, 690, 690, 690, + 690, 146, 29, 29, 690, 690, 690, 29, 690, 690, + 29, 690, 29, 690, 690, 690, 690, 674, 29, 690, + 29, 690, 690, 29, 690, 690, 29, 690, 690, 690, + 29, 690, 690, 0, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674 + } ; + +static yyconst short int yy_nxt[4245] = + { 0, + 14, 15, 16, 15, 17, 18, 19, 20, 21, 14, + 22, 23, 24, 25, 26, 26, 26, 26, 26, 26, + 27, 17, 28, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 36, 36, 36, 38, 39, 40, 41, + 36, 42, 43, 44, 45, 46, 47, 36, 36, 36, + 48, 17, 14, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 21, 17, 21, 51, 52, + 51, 52, 55, 55, 59, 62, 53, 60, 53, 56, + 56, 59, 57, 57, 60, 62, 508, 68, 69, 68, + + 76, 232, 70, 63, 242, 673, 64, 68, 69, 68, + 243, 674, 70, 63, 233, 509, 64, 73, 73, 73, + 73, 73, 73, 72, 439, 674, 72, 80, 80, 80, + 72, 78, 85, 72, 72, 147, 147, 82, 238, 80, + 80, 83, 83, 83, 83, 83, 83, 86, 86, 86, + 86, 86, 86, 86, 672, 88, 674, 239, 65, 147, + 66, 159, 159, 159, 670, 88, 88, 88, 65, 88, + 66, 28, 100, 71, 88, 312, 101, 88, 88, 102, + 88, 28, 147, 71, 72, 88, 669, 88, 104, 105, + 313, 88, 159, 159, 159, 668, 88, 147, 76, 106, + + 666, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 621, 147, 78, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 88, 665, 535, 88, 88, 88, 88, 88, + 88, 88, 73, 73, 73, 147, 88, 89, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 90, 88, 91, + 88, 92, 88, 88, 88, 88, 93, 88, 88, 88, + 88, 88, 159, 159, 159, 94, 94, 94, 94, 94, + + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 88, 376, 147, + 95, 663, 147, 88, 96, 377, 103, 88, 97, 88, + 98, 88, 662, 88, 437, 88, 88, 88, 107, 88, + 99, 147, 88, 491, 147, 438, 660, 88, 147, 88, + 378, 88, 492, 88, 657, 108, 147, 88, 88, 88, + 147, 88, 111, 88, 147, 112, 88, 147, 569, 493, + 656, 534, 571, 88, 113, 114, 655, 88, 147, 109, + 115, 536, 88, 116, 88, 88, 147, 147, 600, 654, + 110, 117, 147, 598, 88, 88, 88, 88, 88, 88, + + 147, 120, 121, 88, 118, 122, 125, 88, 642, 126, + 147, 88, 652, 88, 650, 123, 649, 127, 647, 88, + 88, 88, 88, 128, 646, 130, 88, 80, 80, 80, + 124, 119, 88, 164, 88, 88, 88, 645, 131, 80, + 80, 88, 132, 641, 640, 88, 639, 88, 638, 88, + 129, 635, 633, 133, 88, 135, 632, 630, 134, 628, + 627, 136, 88, 626, 620, 88, 570, 570, 570, 619, + 618, 617, 88, 614, 88, 88, 88, 140, 137, 88, + 612, 88, 611, 141, 88, 138, 609, 88, 88, 607, + 606, 605, 597, 596, 139, 144, 595, 88, 88, 88, + + 88, 88, 88, 594, 147, 142, 88, 88, 145, 145, + 145, 145, 145, 145, 145, 593, 590, 588, 587, 146, + 623, 623, 623, 143, 166, 166, 166, 166, 166, 166, + 166, 585, 582, 581, 148, 580, 568, 88, 88, 149, + 86, 86, 86, 86, 86, 86, 86, 88, 88, 88, + 88, 88, 88, 88, 88, 169, 88, 88, 147, 658, + 658, 658, 567, 170, 88, 88, 88, 88, 88, 88, + 566, 565, 88, 88, 563, 88, 561, 171, 559, 88, + 557, 88, 556, 172, 554, 88, 88, 88, 88, 88, + 551, 174, 88, 173, 88, 550, 88, 147, 88, 549, + + 88, 548, 88, 88, 88, 88, 88, 540, 533, 532, + 175, 88, 531, 88, 88, 88, 530, 176, 528, 526, + 88, 523, 88, 521, 88, 519, 88, 177, 88, 511, + 88, 510, 88, 88, 88, 178, 88, 497, 490, 88, + 489, 180, 88, 488, 487, 486, 88, 484, 88, 179, + 88, 482, 88, 88, 88, 88, 88, 479, 474, 472, + 461, 88, 460, 88, 181, 182, 88, 88, 459, 184, + 183, 443, 88, 436, 435, 434, 88, 432, 88, 88, + 88, 88, 429, 88, 427, 88, 88, 188, 88, 88, + 185, 186, 422, 417, 414, 403, 88, 88, 88, 88, + + 189, 88, 402, 88, 190, 88, 401, 191, 187, 88, + 88, 88, 383, 195, 374, 373, 88, 372, 366, 359, + 88, 88, 88, 192, 88, 354, 350, 88, 339, 88, + 196, 88, 338, 88, 160, 88, 311, 88, 88, 88, + 88, 88, 308, 307, 88, 198, 88, 306, 88, 300, + 88, 289, 197, 284, 88, 88, 88, 88, 88, 280, + 269, 199, 200, 88, 268, 88, 88, 88, 201, 88, + 243, 241, 88, 240, 88, 147, 88, 231, 88, 227, + 88, 215, 88, 88, 203, 88, 88, 209, 202, 205, + 194, 88, 193, 204, 168, 88, 88, 88, 167, 88, + + 165, 161, 88, 160, 206, 160, 88, 157, 88, 88, + 88, 88, 88, 88, 155, 88, 85, 207, 88, 153, + 88, 152, 88, 88, 88, 87, 88, 84, 75, 72, + 88, 88, 88, 88, 88, 88, 88, 88, 208, 88, + 72, 210, 88, 674, 674, 674, 88, 88, 88, 674, + 88, 674, 674, 674, 674, 88, 211, 88, 674, 88, + 88, 88, 674, 213, 674, 674, 212, 214, 674, 674, + 88, 674, 88, 674, 88, 216, 88, 674, 674, 88, + 674, 674, 88, 674, 674, 674, 217, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 218, 674, 88, + + 219, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 223, 221, 674, 220, 88, 674, + 88, 674, 222, 674, 88, 88, 88, 674, 674, 88, + 674, 224, 674, 674, 674, 88, 88, 88, 88, 88, + 88, 88, 88, 674, 88, 88, 674, 674, 674, 674, + 674, 88, 88, 88, 88, 88, 226, 88, 88, 229, + 225, 88, 230, 674, 228, 674, 674, 88, 88, 88, + 88, 88, 88, 88, 674, 674, 88, 88, 674, 674, + 674, 674, 674, 88, 674, 88, 674, 88, 236, 236, + 236, 234, 88, 145, 145, 145, 145, 145, 145, 145, + + 674, 674, 674, 674, 674, 674, 674, 166, 166, 166, + 166, 166, 166, 166, 674, 88, 674, 674, 244, 674, + 674, 674, 674, 674, 674, 88, 237, 88, 88, 88, + 674, 235, 674, 245, 88, 674, 88, 674, 88, 88, + 88, 674, 88, 674, 674, 674, 88, 88, 88, 246, + 88, 88, 88, 88, 674, 88, 674, 674, 88, 674, + 88, 674, 88, 88, 88, 247, 88, 248, 674, 674, + 88, 88, 88, 88, 88, 88, 88, 88, 674, 88, + 674, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 249, 250, 88, 88, 674, 88, 674, + + 88, 674, 88, 88, 88, 674, 88, 252, 251, 674, + 88, 88, 88, 88, 88, 674, 674, 674, 674, 88, + 674, 88, 674, 88, 88, 88, 674, 88, 674, 674, + 253, 88, 88, 88, 88, 254, 88, 674, 88, 674, + 88, 255, 256, 88, 257, 88, 88, 674, 674, 259, + 674, 674, 258, 674, 674, 88, 88, 88, 88, 88, + 88, 88, 674, 674, 88, 88, 674, 88, 674, 674, + 674, 88, 674, 88, 260, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 88, 674, 88, 262, 88, 261, + 88, 674, 88, 674, 88, 88, 88, 88, 88, 674, + + 674, 88, 674, 88, 265, 263, 674, 88, 264, 88, + 674, 88, 88, 88, 88, 88, 674, 674, 674, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 266, + 674, 88, 674, 88, 267, 88, 88, 88, 674, 674, + 674, 674, 88, 674, 88, 674, 88, 88, 88, 674, + 88, 674, 674, 270, 88, 88, 271, 272, 88, 88, + 273, 88, 88, 88, 674, 88, 88, 674, 88, 674, + 674, 276, 274, 674, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 275, 88, 277, 88, 88, 674, 88, + 674, 674, 88, 674, 674, 674, 88, 674, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 88, 278, 674, + 88, 88, 674, 281, 674, 674, 674, 279, 674, 88, + 88, 88, 88, 674, 88, 88, 88, 674, 282, 88, + 674, 88, 674, 674, 674, 88, 674, 88, 283, 88, + 674, 88, 88, 88, 88, 88, 674, 674, 674, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 88, + 285, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 674, 674, 286, 674, 88, 674, + 88, 88, 88, 674, 88, 674, 674, 287, 674, 88, + 674, 88, 88, 88, 674, 88, 674, 291, 88, 674, + + 88, 288, 290, 674, 88, 674, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 674, 88, 674, 88, 292, 88, + 88, 88, 674, 293, 88, 674, 674, 674, 294, 674, + 88, 88, 88, 88, 88, 88, 88, 674, 674, 88, + 88, 674, 674, 674, 674, 674, 88, 88, 88, 674, + 88, 674, 674, 88, 295, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 296, 88, 88, 88, 88, 674, + 297, 298, 88, 674, 88, 674, 674, 299, 88, 674, + 88, 674, 88, 674, 88, 88, 88, 88, 88, 674, + + 674, 674, 674, 88, 674, 88, 88, 88, 301, 88, + 302, 305, 674, 674, 88, 303, 88, 88, 88, 674, + 88, 674, 674, 674, 304, 88, 674, 88, 88, 88, + 674, 88, 674, 674, 309, 674, 88, 674, 88, 674, + 88, 674, 88, 236, 236, 236, 674, 88, 674, 674, + 674, 674, 88, 88, 674, 310, 310, 310, 310, 310, + 310, 310, 88, 88, 314, 88, 88, 88, 88, 315, + 674, 88, 88, 674, 88, 316, 674, 674, 88, 674, + 88, 674, 88, 674, 88, 317, 88, 88, 88, 88, + 88, 674, 674, 88, 674, 674, 674, 674, 674, 88, + + 88, 318, 88, 88, 88, 321, 88, 88, 88, 88, + 320, 674, 674, 674, 674, 674, 88, 88, 88, 88, + 88, 88, 88, 322, 674, 88, 88, 674, 88, 674, + 674, 674, 88, 674, 88, 319, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 323, 674, 88, 674, 88, + 88, 88, 324, 88, 674, 674, 674, 674, 88, 674, + 88, 674, 88, 674, 88, 88, 325, 326, 88, 88, + 674, 88, 674, 674, 674, 88, 674, 88, 88, 88, + 88, 88, 88, 328, 327, 88, 88, 88, 329, 88, + 88, 330, 88, 674, 674, 331, 88, 674, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 88, 88, 674, + 674, 88, 674, 88, 674, 674, 674, 88, 674, 88, + 333, 332, 674, 88, 88, 88, 88, 88, 674, 674, + 674, 674, 88, 674, 88, 88, 88, 674, 88, 674, + 334, 674, 674, 88, 674, 88, 674, 335, 674, 88, + 88, 336, 674, 337, 88, 674, 88, 674, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 674, 88, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 88, 88, + 674, 341, 88, 674, 674, 342, 674, 674, 88, 88, + + 88, 88, 88, 88, 88, 343, 674, 88, 88, 345, + 88, 674, 340, 674, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 344, 88, 348, 346, 674, 674, 88, + 674, 88, 674, 88, 88, 88, 674, 347, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 349, + 88, 88, 88, 674, 88, 88, 351, 674, 88, 88, + 674, 674, 674, 674, 674, 88, 674, 88, 88, 88, + 88, 88, 88, 674, 88, 674, 352, 88, 674, 88, + 356, 88, 355, 88, 353, 88, 674, 674, 674, 88, + + 88, 88, 674, 88, 88, 88, 674, 357, 88, 674, + 674, 674, 674, 674, 88, 88, 88, 88, 88, 88, + 358, 88, 88, 88, 88, 674, 674, 674, 674, 674, + 674, 88, 88, 88, 88, 88, 88, 88, 674, 674, + 88, 88, 674, 674, 674, 674, 674, 88, 674, 88, + 88, 88, 674, 361, 674, 360, 88, 674, 88, 674, + 88, 88, 88, 674, 88, 674, 674, 674, 88, 88, + 88, 88, 88, 362, 674, 88, 88, 88, 363, 88, + 88, 674, 88, 674, 674, 365, 88, 674, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 674, + + 88, 88, 674, 88, 674, 674, 674, 88, 674, 88, + 88, 88, 88, 88, 88, 367, 88, 88, 88, 88, + 674, 364, 88, 674, 88, 674, 674, 369, 88, 674, + 88, 674, 88, 674, 88, 88, 88, 368, 88, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 88, 88, 88, 674, 371, 674, + 88, 674, 674, 674, 674, 674, 88, 674, 88, 674, + 88, 370, 674, 88, 674, 88, 310, 310, 310, 310, + 310, 310, 310, 88, 674, 88, 674, 88, 380, 88, + 674, 379, 88, 674, 674, 674, 674, 88, 381, 88, + + 674, 88, 674, 88, 382, 88, 674, 88, 88, 88, + 674, 88, 674, 88, 375, 88, 88, 88, 674, 88, + 384, 88, 674, 88, 88, 88, 674, 88, 674, 88, + 385, 88, 88, 88, 674, 88, 674, 674, 674, 88, + 88, 88, 88, 88, 674, 386, 674, 674, 88, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 674, + 88, 88, 88, 88, 88, 387, 674, 88, 88, 88, + 388, 88, 88, 674, 88, 389, 674, 674, 88, 674, + 88, 88, 88, 88, 390, 88, 88, 88, 88, 88, + 88, 674, 391, 88, 674, 88, 392, 393, 674, 88, + + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 394, 88, 674, 674, 674, 674, 674, + 88, 88, 88, 88, 88, 88, 88, 395, 674, 88, + 88, 674, 674, 674, 674, 674, 88, 674, 88, 674, + 88, 88, 397, 674, 396, 88, 674, 88, 674, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 88, 398, 88, 674, 88, 674, + 88, 674, 88, 674, 88, 399, 400, 88, 88, 88, + 88, 674, 674, 88, 674, 674, 674, 404, 674, 88, + 88, 88, 88, 88, 88, 674, 674, 88, 88, 88, + + 88, 405, 674, 406, 674, 674, 674, 88, 674, 88, + 88, 88, 88, 674, 88, 407, 88, 88, 88, 88, + 408, 674, 674, 674, 674, 674, 674, 88, 88, 409, + 88, 88, 88, 674, 88, 88, 88, 88, 410, 674, + 674, 413, 674, 412, 88, 88, 88, 88, 88, 88, + 88, 411, 674, 88, 88, 674, 88, 674, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 674, 674, 674, 88, 674, 88, 88, 88, + 674, 88, 674, 674, 88, 415, 88, 674, 88, 674, + 88, 674, 88, 674, 88, 88, 416, 88, 88, 674, + + 674, 674, 674, 88, 674, 88, 88, 88, 674, 88, + 674, 418, 88, 419, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 420, 88, 88, 674, 674, 674, + 674, 88, 674, 88, 674, 88, 88, 88, 674, 88, + 674, 421, 88, 423, 674, 674, 88, 88, 88, 88, + 88, 424, 425, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 674, 674, 88, 674, 674, 674, + 88, 88, 88, 674, 88, 674, 674, 88, 428, 88, + 674, 88, 426, 88, 674, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 674, 430, 88, 674, 674, 674, + + 674, 674, 88, 88, 88, 88, 88, 88, 88, 431, + 674, 88, 88, 674, 88, 674, 674, 674, 88, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 440, 441, 88, 88, 674, 674, 674, 674, 674, 88, + 88, 88, 88, 88, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 433, 88, 88, 674, 674, 442, 88, + 674, 88, 674, 674, 674, 88, 674, 444, 674, 88, + 674, 88, 88, 88, 88, 88, 674, 674, 88, 445, + 88, 446, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 88, 447, 88, 674, 88, + + 674, 88, 674, 88, 674, 88, 88, 448, 88, 88, + 674, 674, 674, 674, 88, 674, 88, 88, 88, 450, + 88, 674, 674, 88, 449, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 674, 674, + 88, 451, 88, 452, 674, 674, 88, 674, 453, 674, + 88, 674, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 454, 88, 88, 674, 88, 674, 674, 674, 674, + 674, 674, 88, 88, 88, 88, 88, 88, 88, 88, + 674, 88, 88, 674, 674, 455, 674, 674, 88, 88, + 88, 88, 88, 88, 88, 674, 456, 88, 88, 458, + + 88, 457, 674, 674, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 88, 88, 462, 674, 88, 674, 88, + 674, 88, 674, 88, 463, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 464, 674, 88, 674, 674, 674, + 674, 674, 88, 88, 88, 88, 88, 88, 674, 674, + 465, 88, 88, 88, 88, 467, 466, 674, 674, 674, + 674, 674, 674, 88, 88, 88, 88, 88, 88, 88, + 674, 674, 88, 88, 674, 674, 674, 88, 674, 88, + 469, 88, 674, 88, 674, 468, 674, 88, 88, 88, + 88, 88, 674, 674, 674, 674, 88, 674, 88, 674, + + 88, 88, 88, 674, 88, 471, 674, 470, 88, 88, + 88, 88, 88, 88, 674, 88, 88, 88, 473, 88, + 88, 674, 88, 674, 674, 674, 88, 674, 475, 88, + 88, 88, 88, 88, 476, 88, 88, 88, 88, 674, + 88, 88, 674, 478, 674, 674, 674, 88, 88, 88, + 88, 88, 88, 674, 88, 477, 88, 674, 88, 88, + 88, 674, 88, 88, 481, 674, 88, 88, 480, 88, + 674, 674, 674, 88, 674, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 483, 88, 88, 674, + 88, 674, 674, 674, 88, 674, 88, 88, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 485, 88, 88, + 674, 674, 674, 674, 674, 88, 674, 88, 88, 88, + 88, 88, 88, 494, 88, 674, 495, 88, 496, 88, + 674, 88, 674, 88, 674, 88, 674, 674, 674, 88, + 88, 88, 88, 88, 674, 498, 674, 674, 88, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 674, + 88, 88, 499, 88, 88, 500, 88, 88, 674, 88, + 674, 674, 88, 501, 88, 674, 88, 88, 88, 674, + 88, 674, 674, 674, 88, 88, 88, 88, 88, 88, + 88, 88, 674, 88, 674, 674, 88, 502, 88, 674, + + 88, 88, 88, 503, 88, 674, 674, 674, 88, 88, + 88, 88, 88, 88, 88, 88, 674, 88, 674, 674, + 88, 674, 674, 674, 88, 88, 88, 674, 88, 674, + 674, 674, 504, 88, 674, 88, 88, 88, 674, 88, + 674, 674, 506, 505, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 674, 674, 88, + 674, 88, 674, 507, 674, 88, 512, 88, 674, 88, + 88, 88, 88, 88, 674, 674, 674, 674, 88, 674, + 88, 88, 88, 674, 88, 674, 674, 88, 513, 88, + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + + 88, 88, 674, 674, 88, 674, 88, 515, 88, 674, + 88, 674, 88, 674, 88, 514, 88, 88, 88, 88, + 88, 516, 674, 88, 674, 674, 674, 674, 674, 88, + 88, 88, 88, 88, 88, 88, 88, 674, 88, 88, + 674, 674, 674, 674, 674, 88, 88, 88, 518, 88, + 88, 88, 88, 674, 88, 88, 674, 674, 674, 674, + 674, 520, 88, 88, 88, 88, 88, 674, 674, 88, + 88, 88, 88, 522, 674, 88, 674, 674, 674, 88, + 517, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 674, 524, 88, 674, 88, 674, 674, 525, + + 88, 674, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 88, 674, 537, 527, 88, 529, 88, 674, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 88, 674, 88, 674, 88, 674, + 88, 538, 88, 674, 88, 674, 88, 88, 88, 88, + 539, 674, 674, 88, 674, 88, 674, 674, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 88, 88, + 674, 541, 674, 674, 88, 674, 88, 674, 88, 88, + 88, 674, 543, 674, 542, 88, 674, 88, 674, 88, + 88, 88, 674, 88, 674, 674, 674, 88, 88, 544, + + 88, 88, 88, 545, 88, 88, 88, 674, 88, 88, + 674, 546, 674, 674, 674, 88, 88, 88, 88, 88, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 88, 674, 674, 88, 547, 674, 674, 88, + 674, 88, 88, 88, 88, 674, 88, 88, 88, 674, + 552, 88, 674, 88, 674, 674, 674, 88, 674, 88, + 674, 88, 674, 88, 88, 88, 88, 88, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 88, 88, 674, 674, 674, 674, 88, + 674, 88, 88, 88, 674, 88, 555, 674, 88, 553, + + 88, 674, 88, 674, 88, 560, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 674, 558, 88, 674, 88, + 88, 88, 674, 88, 674, 674, 88, 674, 88, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 674, 88, 674, 88, 674, 88, 674, 562, + 674, 88, 674, 564, 88, 88, 88, 88, 674, 674, + 674, 674, 88, 674, 88, 88, 88, 674, 88, 674, + 674, 572, 674, 88, 674, 88, 88, 88, 573, 88, + 674, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 674, 674, 674, + + 674, 88, 674, 88, 88, 88, 575, 88, 674, 674, + 574, 674, 88, 674, 88, 88, 88, 674, 88, 674, + 576, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 577, 88, 88, 88, 88, 578, 674, + 88, 674, 674, 674, 674, 674, 88, 579, 88, 88, + 88, 88, 88, 88, 674, 88, 88, 674, 674, 674, + 584, 674, 88, 88, 88, 88, 88, 88, 583, 88, + 88, 88, 88, 674, 674, 674, 586, 674, 674, 88, + 88, 88, 589, 88, 88, 88, 674, 674, 88, 88, + 674, 88, 674, 674, 674, 88, 674, 88, 591, 88, + + 674, 88, 88, 88, 88, 88, 674, 674, 674, 592, + 88, 674, 88, 674, 88, 674, 88, 570, 570, 570, + 674, 88, 674, 674, 674, 674, 88, 88, 674, 599, + 599, 599, 599, 599, 599, 599, 88, 88, 88, 602, + 88, 88, 88, 88, 674, 88, 88, 674, 674, 601, + 674, 674, 88, 88, 88, 88, 88, 88, 88, 88, + 674, 88, 88, 674, 674, 674, 674, 674, 88, 88, + 88, 88, 88, 88, 88, 88, 603, 88, 88, 674, + 674, 674, 604, 674, 88, 88, 88, 88, 88, 88, + 88, 674, 674, 88, 88, 674, 674, 674, 88, 674, + + 88, 674, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 608, 88, 674, 88, 674, 88, 88, 610, 674, + 88, 613, 88, 674, 88, 88, 88, 674, 88, 615, + 88, 674, 88, 88, 88, 674, 88, 616, 674, 674, + 88, 88, 88, 674, 88, 674, 674, 88, 88, 88, + 599, 599, 599, 599, 599, 599, 599, 88, 88, 624, + 88, 88, 88, 88, 674, 674, 88, 88, 674, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 674, 674, + 674, 88, 88, 88, 88, 88, 674, 674, 622, 625, + 88, 674, 88, 674, 88, 88, 629, 674, 88, 631, + + 674, 674, 88, 88, 88, 88, 88, 88, 88, 88, + 636, 88, 674, 634, 88, 674, 674, 674, 88, 88, + 88, 674, 88, 637, 674, 674, 674, 88, 674, 88, + 674, 88, 674, 88, 623, 623, 623, 674, 88, 674, + 674, 674, 674, 88, 88, 674, 599, 599, 599, 599, + 599, 599, 599, 88, 88, 88, 88, 88, 88, 88, + 674, 643, 88, 88, 674, 88, 674, 644, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 88, 88, + 674, 674, 88, 648, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 674, 674, 651, + + 653, 88, 674, 88, 674, 88, 88, 88, 659, 88, + 674, 674, 88, 674, 674, 674, 88, 88, 88, 88, + 88, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 674, 88, 88, 674, 674, 88, 88, 674, 664, 674, + 661, 674, 88, 674, 88, 88, 88, 88, 674, 88, + 674, 88, 674, 674, 88, 658, 658, 658, 674, 674, + 674, 674, 674, 674, 88, 88, 674, 599, 599, 599, + 599, 599, 599, 599, 88, 88, 88, 88, 88, 88, + 88, 88, 674, 88, 88, 674, 667, 674, 674, 674, + 88, 88, 88, 88, 88, 88, 671, 88, 674, 88, + + 88, 674, 674, 674, 674, 674, 674, 88, 674, 88, + 674, 88, 674, 674, 674, 674, 88, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 74, 74, 74, + 674, 74, 74, 74, 74, 74, 74, 74, 74, 81, + 81, 674, 674, 81, 674, 81, 147, 674, 147, 150, + + 150, 674, 150, 150, 151, 151, 674, 151, 151, 151, + 674, 151, 151, 151, 151, 151, 154, 154, 154, 674, + 154, 154, 154, 154, 154, 154, 154, 154, 156, 156, + 156, 156, 156, 156, 156, 156, 674, 156, 156, 158, + 674, 674, 158, 674, 158, 158, 158, 158, 158, 158, + 162, 162, 674, 162, 162, 163, 163, 674, 163, 163, + 94, 94, 674, 94, 94, 13, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674 + } ; + +static yyconst short int yy_chk[4245] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, + 4, 4, 5, 6, 7, 9, 3, 7, 4, 5, + 6, 8, 5, 6, 8, 10, 459, 11, 11, 11, + + 78, 143, 11, 9, 164, 669, 9, 12, 12, 12, + 164, 70, 12, 10, 143, 459, 10, 15, 15, 15, + 16, 16, 16, 15, 378, 70, 16, 20, 20, 20, + 24, 78, 24, 20, 22, 378, 148, 22, 148, 20, + 20, 22, 22, 22, 22, 22, 22, 26, 26, 26, + 26, 26, 26, 26, 665, 36, 70, 149, 9, 149, + 9, 68, 68, 68, 663, 36, 31, 36, 10, 36, + 10, 11, 31, 11, 36, 238, 31, 33, 31, 31, + 31, 12, 238, 12, 19, 31, 662, 33, 33, 33, + 239, 33, 69, 69, 69, 660, 33, 239, 19, 33, + + 656, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 598, 598, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 29, 655, 492, 29, 29, 29, 29, 29, + 29, 29, 73, 73, 73, 492, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 159, 159, 159, 29, 29, 29, 29, 29, + + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 30, 311, 312, + 30, 652, 311, 32, 30, 312, 32, 30, 30, 30, + 30, 30, 650, 32, 376, 32, 30, 32, 34, 34, + 30, 376, 32, 437, 313, 377, 646, 35, 438, 34, + 313, 34, 438, 34, 641, 34, 437, 35, 34, 35, + 377, 35, 37, 37, 534, 37, 35, 439, 534, 439, + 640, 491, 536, 37, 37, 37, 639, 37, 493, 35, + 37, 493, 37, 38, 38, 39, 491, 536, 571, 638, + 35, 38, 571, 569, 38, 39, 38, 39, 38, 39, + + 569, 40, 40, 38, 39, 40, 41, 41, 621, 41, + 621, 40, 635, 40, 633, 40, 632, 41, 628, 41, + 40, 41, 42, 41, 627, 42, 41, 80, 80, 80, + 40, 39, 42, 80, 42, 43, 42, 626, 43, 80, + 80, 42, 43, 620, 619, 43, 618, 43, 617, 43, + 41, 614, 612, 43, 43, 44, 611, 609, 43, 607, + 606, 44, 44, 605, 597, 45, 535, 535, 535, 596, + 595, 593, 44, 590, 44, 45, 44, 45, 44, 45, + 588, 44, 587, 45, 45, 44, 585, 46, 47, 582, + 581, 580, 568, 567, 44, 47, 566, 46, 47, 46, + + 47, 46, 47, 565, 535, 45, 46, 47, 48, 48, + 48, 48, 48, 48, 48, 563, 559, 557, 556, 48, + 600, 600, 600, 46, 83, 83, 83, 83, 83, 83, + 83, 554, 550, 549, 48, 548, 533, 88, 89, 48, + 86, 86, 86, 86, 86, 86, 86, 88, 89, 88, + 89, 88, 89, 90, 91, 89, 88, 89, 600, 642, + 642, 642, 532, 90, 91, 90, 91, 90, 91, 92, + 531, 530, 90, 91, 528, 93, 526, 91, 523, 92, + 521, 92, 519, 92, 517, 93, 95, 93, 92, 93, + 511, 95, 96, 93, 93, 510, 95, 642, 95, 509, + + 95, 508, 96, 97, 96, 95, 96, 497, 490, 489, + 96, 96, 488, 97, 98, 97, 487, 97, 484, 482, + 99, 479, 97, 474, 98, 472, 98, 98, 98, 461, + 99, 460, 99, 98, 99, 100, 100, 443, 436, 99, + 435, 101, 101, 434, 433, 432, 100, 429, 100, 100, + 100, 427, 101, 102, 101, 100, 101, 422, 417, 414, + 403, 101, 402, 102, 102, 102, 103, 102, 401, 104, + 103, 383, 102, 374, 373, 372, 103, 370, 103, 104, + 103, 104, 366, 104, 364, 103, 106, 106, 104, 105, + 105, 105, 359, 354, 350, 340, 106, 107, 106, 105, + + 106, 105, 339, 105, 106, 106, 338, 107, 105, 107, + 108, 107, 319, 111, 308, 307, 107, 306, 300, 289, + 108, 111, 108, 108, 108, 284, 280, 112, 269, 108, + 112, 111, 268, 111, 241, 111, 237, 112, 113, 112, + 111, 112, 233, 232, 114, 114, 112, 231, 113, 227, + 113, 215, 113, 209, 114, 115, 114, 113, 114, 205, + 194, 114, 114, 114, 193, 115, 116, 115, 115, 115, + 165, 161, 117, 157, 115, 147, 116, 142, 116, 139, + 116, 129, 117, 118, 117, 116, 117, 124, 116, 119, + 110, 117, 109, 118, 87, 118, 120, 118, 84, 121, + + 81, 76, 118, 75, 120, 72, 120, 63, 120, 121, + 120, 121, 122, 121, 60, 120, 57, 121, 121, 56, + 123, 53, 122, 125, 122, 27, 122, 23, 18, 17, + 123, 122, 123, 125, 123, 125, 126, 125, 123, 123, + 14, 125, 125, 13, 0, 0, 126, 127, 126, 0, + 126, 0, 0, 0, 0, 126, 126, 127, 0, 127, + 128, 127, 0, 128, 0, 0, 127, 128, 0, 0, + 128, 0, 128, 0, 128, 130, 130, 0, 0, 128, + 0, 0, 131, 0, 0, 0, 130, 0, 130, 0, + 130, 0, 131, 132, 131, 130, 131, 131, 0, 133, + + 131, 131, 0, 132, 0, 132, 0, 132, 0, 133, + 134, 133, 132, 133, 135, 133, 0, 132, 133, 0, + 134, 0, 134, 0, 134, 135, 136, 0, 0, 134, + 0, 136, 0, 0, 0, 135, 136, 135, 136, 135, + 136, 137, 138, 0, 135, 136, 0, 0, 0, 0, + 0, 137, 138, 137, 138, 137, 138, 140, 141, 141, + 137, 138, 141, 0, 140, 0, 0, 140, 141, 140, + 141, 140, 141, 144, 0, 0, 140, 141, 0, 0, + 0, 0, 0, 144, 0, 144, 0, 144, 146, 146, + 146, 144, 144, 145, 145, 145, 145, 145, 145, 145, + + 146, 146, 146, 146, 146, 146, 146, 166, 166, 166, + 166, 166, 166, 166, 0, 169, 0, 0, 169, 0, + 0, 0, 0, 0, 0, 169, 146, 169, 170, 169, + 0, 145, 0, 169, 169, 0, 171, 0, 170, 172, + 170, 0, 170, 0, 0, 0, 171, 170, 171, 172, + 171, 172, 173, 172, 0, 171, 0, 0, 172, 0, + 174, 0, 173, 175, 173, 173, 173, 174, 0, 0, + 174, 173, 174, 175, 174, 175, 176, 175, 0, 174, + 0, 0, 175, 0, 177, 0, 176, 0, 176, 0, + 176, 0, 178, 176, 177, 176, 177, 0, 177, 0, + + 179, 0, 178, 177, 178, 0, 178, 179, 178, 0, + 179, 178, 179, 180, 179, 0, 0, 0, 0, 179, + 0, 181, 0, 180, 182, 180, 0, 180, 0, 0, + 180, 181, 180, 181, 182, 181, 182, 0, 182, 0, + 181, 182, 182, 182, 183, 183, 184, 0, 0, 184, + 0, 0, 183, 0, 0, 183, 184, 183, 184, 183, + 184, 185, 0, 0, 183, 184, 0, 186, 0, 0, + 0, 185, 0, 185, 185, 185, 0, 186, 187, 186, + 185, 186, 0, 0, 188, 0, 186, 188, 187, 187, + 187, 0, 187, 0, 188, 189, 188, 187, 188, 0, + + 0, 190, 0, 188, 190, 189, 0, 189, 189, 189, + 0, 190, 191, 190, 189, 190, 0, 0, 0, 0, + 190, 0, 191, 192, 191, 0, 191, 0, 0, 191, + 0, 191, 0, 192, 192, 192, 195, 192, 0, 0, + 0, 0, 192, 0, 196, 0, 195, 197, 195, 0, + 195, 0, 0, 195, 196, 195, 196, 197, 196, 197, + 197, 197, 198, 196, 0, 199, 197, 0, 200, 0, + 0, 200, 198, 0, 198, 199, 198, 199, 200, 199, + 200, 198, 200, 199, 199, 201, 202, 200, 0, 203, + 0, 0, 201, 0, 0, 0, 202, 0, 202, 203, + + 202, 203, 201, 203, 201, 202, 201, 204, 203, 0, + 206, 201, 0, 206, 0, 0, 0, 204, 0, 204, + 206, 204, 206, 0, 206, 207, 204, 0, 207, 206, + 0, 208, 0, 0, 0, 207, 0, 207, 208, 207, + 0, 208, 210, 208, 207, 208, 0, 0, 0, 0, + 208, 0, 210, 211, 210, 0, 210, 0, 0, 212, + 210, 210, 0, 211, 0, 211, 0, 211, 0, 212, + 213, 212, 211, 212, 0, 0, 212, 0, 212, 0, + 213, 214, 213, 0, 213, 0, 0, 213, 0, 213, + 0, 214, 216, 214, 0, 214, 0, 217, 217, 0, + + 214, 214, 216, 0, 216, 0, 216, 0, 217, 218, + 217, 216, 217, 0, 0, 219, 0, 217, 0, 218, + 0, 218, 0, 218, 0, 219, 0, 219, 218, 219, + 220, 221, 0, 220, 219, 0, 0, 0, 221, 0, + 220, 221, 220, 221, 220, 221, 222, 0, 0, 220, + 221, 0, 0, 0, 0, 0, 222, 223, 222, 0, + 222, 0, 0, 224, 222, 222, 0, 223, 0, 223, + 0, 223, 0, 224, 223, 224, 223, 224, 225, 0, + 224, 225, 224, 0, 226, 0, 0, 226, 225, 0, + 225, 0, 225, 0, 226, 228, 226, 225, 226, 0, + + 0, 0, 0, 226, 0, 228, 229, 228, 228, 228, + 228, 230, 0, 0, 228, 228, 229, 230, 229, 0, + 229, 0, 0, 0, 229, 229, 0, 230, 234, 230, + 0, 230, 0, 0, 234, 0, 230, 0, 234, 0, + 234, 0, 234, 236, 236, 236, 0, 234, 0, 0, + 0, 0, 244, 245, 0, 236, 236, 236, 236, 236, + 236, 236, 244, 245, 244, 245, 244, 245, 246, 245, + 0, 244, 245, 0, 247, 246, 0, 0, 246, 0, + 246, 0, 246, 0, 247, 247, 247, 246, 247, 248, + 249, 0, 0, 247, 0, 0, 0, 0, 0, 248, + + 249, 248, 249, 248, 249, 251, 251, 250, 248, 249, + 250, 0, 0, 0, 0, 0, 251, 250, 251, 250, + 251, 250, 252, 252, 0, 251, 250, 0, 253, 0, + 0, 0, 252, 0, 252, 249, 252, 0, 253, 254, + 253, 252, 253, 0, 0, 253, 0, 253, 0, 254, + 255, 254, 254, 254, 0, 0, 0, 0, 254, 0, + 255, 0, 255, 0, 255, 257, 255, 256, 256, 255, + 0, 258, 0, 0, 0, 257, 0, 257, 256, 257, + 256, 258, 256, 258, 257, 258, 259, 256, 259, 260, + 258, 260, 261, 0, 0, 261, 259, 0, 259, 260, + + 259, 260, 261, 260, 261, 259, 261, 262, 260, 0, + 0, 261, 0, 263, 0, 0, 0, 262, 0, 262, + 263, 262, 0, 263, 264, 263, 262, 263, 0, 0, + 0, 0, 263, 0, 264, 265, 264, 0, 264, 0, + 264, 0, 0, 264, 0, 265, 0, 265, 0, 265, + 266, 265, 0, 266, 265, 0, 267, 0, 0, 0, + 266, 0, 266, 0, 266, 0, 267, 270, 267, 266, + 267, 0, 0, 271, 0, 267, 0, 270, 0, 270, + 0, 270, 0, 271, 0, 271, 270, 271, 272, 273, + 0, 271, 271, 0, 0, 272, 0, 0, 272, 273, + + 272, 273, 272, 273, 274, 273, 0, 272, 273, 275, + 275, 0, 270, 0, 274, 0, 274, 0, 274, 0, + 275, 276, 275, 274, 275, 277, 276, 0, 0, 275, + 0, 276, 0, 276, 277, 276, 0, 276, 0, 0, + 276, 0, 278, 0, 277, 0, 277, 0, 277, 0, + 279, 0, 278, 277, 278, 0, 278, 0, 0, 278, + 279, 278, 279, 0, 279, 281, 281, 0, 282, 279, + 0, 0, 0, 0, 0, 281, 0, 281, 282, 281, + 282, 283, 282, 0, 281, 0, 282, 282, 0, 285, + 286, 283, 285, 283, 283, 283, 0, 0, 0, 285, + + 283, 285, 0, 285, 287, 286, 0, 287, 285, 0, + 0, 0, 0, 0, 287, 286, 287, 286, 287, 286, + 288, 288, 290, 287, 286, 0, 0, 0, 0, 0, + 0, 288, 290, 288, 290, 288, 290, 291, 0, 0, + 288, 290, 0, 0, 0, 0, 0, 291, 0, 291, + 292, 291, 0, 292, 0, 291, 291, 0, 293, 0, + 292, 294, 292, 0, 292, 0, 0, 0, 293, 292, + 293, 294, 293, 294, 0, 294, 296, 293, 295, 295, + 294, 0, 297, 0, 0, 299, 296, 0, 296, 295, + 296, 295, 297, 295, 297, 296, 297, 298, 295, 0, + + 299, 297, 0, 301, 0, 0, 0, 298, 0, 298, + 299, 298, 299, 301, 299, 301, 298, 301, 302, 299, + 0, 296, 301, 0, 303, 0, 0, 303, 302, 0, + 302, 0, 302, 0, 303, 304, 303, 302, 303, 0, + 0, 305, 0, 303, 0, 304, 0, 304, 0, 304, + 0, 305, 0, 305, 304, 305, 309, 0, 305, 0, + 305, 0, 0, 0, 0, 0, 309, 0, 309, 0, + 309, 304, 0, 314, 0, 309, 310, 310, 310, 310, + 310, 310, 310, 314, 0, 314, 0, 314, 315, 315, + 0, 314, 314, 0, 0, 0, 0, 316, 316, 315, + + 0, 315, 0, 315, 317, 317, 0, 316, 315, 316, + 0, 316, 0, 318, 310, 317, 316, 317, 0, 317, + 320, 320, 0, 318, 317, 318, 0, 318, 0, 321, + 321, 320, 318, 320, 0, 320, 0, 0, 0, 321, + 320, 321, 322, 321, 0, 322, 0, 0, 321, 0, + 323, 0, 322, 324, 322, 0, 322, 0, 0, 0, + 323, 322, 323, 324, 323, 324, 0, 324, 326, 323, + 325, 325, 324, 0, 327, 326, 0, 0, 326, 0, + 326, 325, 326, 325, 327, 325, 327, 326, 327, 328, + 325, 0, 328, 327, 0, 329, 328, 329, 0, 328, + + 0, 328, 0, 328, 0, 329, 0, 329, 328, 329, + 330, 331, 0, 330, 329, 0, 0, 0, 0, 0, + 330, 331, 330, 331, 330, 331, 332, 331, 0, 330, + 331, 0, 0, 0, 0, 0, 332, 0, 332, 0, + 332, 333, 333, 0, 332, 332, 0, 334, 0, 0, + 0, 333, 0, 333, 0, 333, 0, 334, 335, 334, + 333, 334, 0, 0, 336, 334, 334, 0, 335, 0, + 335, 0, 335, 0, 336, 335, 336, 335, 336, 337, + 341, 0, 0, 336, 0, 0, 0, 341, 0, 337, + 341, 337, 341, 337, 341, 0, 0, 343, 337, 341, + + 342, 342, 0, 342, 0, 0, 0, 343, 0, 343, + 342, 343, 342, 0, 342, 343, 343, 345, 344, 342, + 344, 0, 0, 0, 0, 0, 0, 345, 344, 345, + 344, 345, 344, 0, 347, 346, 345, 344, 346, 0, + 0, 349, 0, 348, 347, 346, 347, 346, 347, 346, + 348, 347, 0, 347, 346, 0, 349, 0, 0, 0, + 348, 0, 348, 0, 348, 0, 349, 351, 349, 348, + 349, 0, 0, 0, 0, 349, 0, 351, 352, 351, + 0, 351, 0, 0, 353, 351, 351, 0, 352, 0, + 352, 0, 352, 0, 353, 355, 353, 352, 353, 0, + + 0, 0, 0, 353, 0, 355, 356, 355, 0, 355, + 0, 355, 357, 356, 355, 0, 356, 0, 356, 0, + 356, 0, 357, 358, 357, 356, 357, 0, 0, 0, + 0, 357, 0, 358, 0, 358, 360, 358, 0, 361, + 0, 358, 358, 360, 0, 0, 360, 362, 360, 361, + 360, 361, 362, 361, 0, 360, 0, 362, 361, 362, + 363, 362, 0, 0, 0, 0, 362, 0, 0, 0, + 363, 365, 363, 0, 363, 0, 0, 367, 365, 363, + 0, 365, 363, 365, 0, 365, 0, 367, 0, 367, + 365, 367, 368, 369, 0, 368, 367, 0, 0, 0, + + 0, 0, 368, 369, 368, 369, 368, 369, 371, 369, + 0, 368, 369, 0, 379, 0, 0, 0, 371, 0, + 371, 0, 371, 0, 379, 0, 379, 371, 379, 380, + 380, 381, 381, 379, 0, 0, 0, 0, 0, 380, + 382, 380, 381, 380, 381, 0, 381, 0, 380, 0, + 382, 381, 382, 371, 382, 384, 0, 0, 382, 382, + 0, 385, 0, 0, 0, 384, 0, 384, 0, 384, + 0, 385, 386, 385, 384, 385, 0, 0, 387, 385, + 385, 387, 386, 0, 386, 0, 386, 0, 387, 388, + 387, 386, 387, 0, 0, 389, 388, 387, 0, 388, + + 0, 388, 0, 388, 0, 389, 390, 389, 388, 389, + 0, 0, 0, 0, 389, 0, 390, 391, 390, 391, + 390, 0, 0, 392, 390, 390, 0, 391, 0, 391, + 0, 391, 0, 392, 0, 392, 391, 392, 0, 0, + 393, 392, 392, 393, 0, 0, 394, 0, 394, 0, + 393, 0, 393, 0, 393, 0, 394, 0, 394, 393, + 394, 395, 395, 396, 0, 394, 0, 0, 0, 0, + 0, 0, 395, 396, 395, 396, 395, 396, 397, 398, + 0, 395, 396, 0, 0, 397, 0, 0, 397, 398, + 397, 398, 397, 398, 399, 0, 398, 397, 398, 400, + + 400, 399, 0, 0, 399, 0, 399, 0, 399, 0, + 400, 404, 400, 399, 400, 404, 0, 405, 0, 400, + 0, 404, 0, 404, 405, 404, 0, 405, 0, 405, + 404, 405, 406, 407, 406, 0, 405, 0, 0, 0, + 0, 0, 406, 407, 406, 407, 406, 407, 0, 0, + 407, 406, 407, 408, 409, 409, 408, 0, 0, 0, + 0, 0, 0, 408, 409, 408, 409, 408, 409, 410, + 0, 0, 408, 409, 0, 0, 0, 411, 0, 410, + 411, 410, 0, 410, 0, 410, 0, 411, 410, 411, + 412, 411, 0, 0, 0, 0, 411, 0, 413, 0, + + 412, 415, 412, 0, 412, 413, 0, 412, 413, 412, + 413, 415, 413, 415, 0, 415, 418, 413, 416, 416, + 415, 0, 419, 0, 0, 0, 418, 0, 418, 416, + 418, 416, 419, 416, 419, 418, 419, 420, 416, 0, + 421, 419, 0, 421, 0, 0, 0, 420, 423, 420, + 421, 420, 421, 0, 421, 420, 420, 0, 423, 421, + 423, 0, 423, 424, 424, 0, 425, 423, 423, 426, + 0, 0, 0, 424, 0, 424, 425, 424, 425, 426, + 425, 426, 424, 426, 428, 425, 428, 430, 426, 0, + 431, 0, 0, 0, 428, 0, 428, 430, 428, 430, + + 431, 430, 431, 428, 431, 440, 430, 431, 441, 431, + 0, 0, 0, 0, 0, 440, 0, 440, 441, 440, + 441, 442, 441, 440, 440, 0, 441, 441, 442, 444, + 0, 442, 0, 442, 0, 442, 0, 0, 0, 444, + 442, 444, 445, 444, 0, 445, 0, 0, 444, 0, + 446, 0, 445, 447, 445, 0, 445, 0, 0, 0, + 446, 445, 446, 447, 446, 447, 448, 447, 0, 446, + 0, 0, 447, 448, 449, 0, 448, 450, 448, 0, + 448, 0, 0, 0, 449, 448, 449, 450, 449, 450, + 451, 450, 0, 449, 0, 0, 450, 451, 453, 0, + + 451, 452, 451, 452, 451, 0, 0, 0, 453, 451, + 453, 452, 453, 452, 454, 452, 0, 453, 0, 0, + 452, 0, 0, 0, 454, 455, 454, 0, 454, 0, + 0, 0, 454, 454, 0, 455, 456, 455, 0, 455, + 0, 0, 457, 455, 455, 0, 456, 0, 456, 0, + 456, 0, 457, 458, 457, 456, 457, 0, 0, 462, + 0, 457, 0, 458, 0, 458, 462, 458, 0, 462, + 463, 462, 458, 462, 0, 0, 0, 0, 462, 0, + 463, 464, 463, 0, 463, 0, 0, 465, 463, 463, + 0, 464, 0, 464, 0, 464, 0, 465, 466, 465, + + 464, 465, 0, 0, 467, 0, 465, 467, 466, 0, + 466, 0, 466, 0, 467, 466, 467, 466, 467, 468, + 469, 469, 0, 467, 0, 0, 0, 0, 0, 468, + 469, 468, 469, 468, 469, 470, 471, 0, 468, 469, + 0, 0, 0, 0, 0, 470, 471, 470, 471, 470, + 471, 473, 475, 0, 470, 471, 0, 0, 0, 0, + 0, 473, 475, 473, 475, 473, 475, 0, 0, 476, + 473, 475, 477, 476, 0, 478, 0, 0, 0, 476, + 470, 476, 477, 476, 477, 478, 477, 478, 476, 478, + 480, 477, 0, 480, 478, 0, 481, 0, 0, 481, + + 480, 0, 480, 0, 480, 0, 481, 0, 481, 480, + 481, 483, 0, 494, 483, 481, 485, 485, 0, 0, + 0, 483, 0, 483, 0, 483, 0, 485, 494, 485, + 483, 485, 0, 0, 495, 0, 485, 0, 494, 0, + 494, 495, 494, 0, 495, 0, 495, 494, 495, 496, + 496, 0, 0, 495, 0, 498, 0, 0, 0, 496, + 0, 496, 0, 496, 0, 498, 499, 498, 496, 498, + 0, 498, 0, 0, 498, 0, 499, 0, 499, 500, + 499, 0, 500, 0, 499, 499, 0, 501, 0, 500, + 502, 500, 0, 500, 0, 0, 0, 501, 500, 501, + + 502, 501, 502, 502, 502, 503, 501, 0, 504, 502, + 0, 504, 0, 0, 0, 503, 505, 503, 504, 503, + 504, 0, 504, 0, 503, 0, 505, 504, 505, 506, + 505, 0, 507, 0, 0, 505, 506, 0, 0, 506, + 0, 506, 507, 506, 507, 0, 507, 512, 506, 0, + 512, 507, 0, 513, 0, 0, 0, 512, 0, 512, + 0, 512, 0, 513, 514, 513, 512, 513, 0, 0, + 515, 0, 513, 0, 514, 0, 514, 0, 514, 0, + 515, 516, 515, 514, 515, 0, 0, 0, 0, 515, + 0, 516, 518, 516, 0, 516, 518, 0, 520, 516, + + 516, 0, 518, 0, 518, 524, 518, 0, 520, 522, + 520, 518, 520, 0, 0, 0, 522, 520, 0, 522, + 524, 522, 0, 522, 0, 0, 525, 0, 522, 0, + 524, 0, 524, 0, 524, 0, 525, 527, 525, 524, + 525, 0, 0, 529, 0, 525, 0, 527, 0, 527, + 0, 527, 0, 529, 537, 529, 527, 529, 0, 0, + 0, 0, 529, 0, 537, 538, 537, 0, 537, 0, + 0, 537, 0, 537, 0, 538, 539, 538, 538, 538, + 0, 0, 541, 0, 538, 0, 539, 0, 539, 0, + 539, 0, 541, 542, 541, 539, 541, 0, 0, 0, + + 0, 541, 0, 542, 543, 542, 543, 542, 0, 0, + 542, 0, 542, 0, 543, 544, 543, 0, 543, 0, + 544, 545, 0, 543, 0, 544, 0, 544, 0, 544, + 0, 545, 0, 545, 544, 545, 546, 547, 546, 0, + 545, 0, 0, 0, 0, 0, 546, 547, 546, 547, + 546, 547, 552, 553, 0, 546, 547, 0, 0, 0, + 553, 0, 552, 553, 552, 553, 552, 553, 552, 555, + 558, 552, 553, 0, 0, 0, 555, 0, 0, 555, + 558, 555, 558, 555, 558, 560, 0, 0, 555, 558, + 0, 562, 0, 0, 0, 560, 0, 560, 560, 560, + + 0, 562, 564, 562, 560, 562, 0, 0, 0, 562, + 562, 0, 564, 0, 564, 0, 564, 570, 570, 570, + 0, 564, 0, 0, 0, 0, 572, 573, 0, 570, + 570, 570, 570, 570, 570, 570, 572, 573, 572, 573, + 572, 573, 574, 575, 0, 572, 573, 0, 0, 572, + 0, 0, 574, 575, 574, 575, 574, 575, 576, 577, + 0, 574, 575, 0, 0, 0, 0, 0, 576, 577, + 576, 577, 576, 577, 578, 579, 577, 576, 577, 0, + 0, 0, 579, 0, 578, 579, 578, 579, 578, 579, + 583, 0, 0, 578, 579, 0, 0, 0, 584, 0, + + 583, 0, 583, 0, 583, 0, 586, 0, 584, 583, + 584, 584, 584, 0, 589, 0, 586, 584, 586, 0, + 586, 589, 591, 0, 589, 586, 589, 0, 589, 591, + 592, 0, 591, 589, 591, 0, 591, 592, 0, 0, + 592, 591, 592, 0, 592, 0, 0, 601, 602, 592, + 599, 599, 599, 599, 599, 599, 599, 601, 602, 601, + 602, 601, 602, 603, 0, 0, 601, 602, 0, 0, + 0, 604, 0, 603, 0, 603, 0, 603, 0, 0, + 0, 604, 603, 604, 608, 604, 0, 0, 599, 604, + 604, 0, 610, 0, 608, 613, 608, 0, 608, 610, + + 0, 0, 610, 608, 610, 613, 610, 613, 615, 613, + 615, 610, 0, 613, 613, 0, 0, 0, 615, 616, + 615, 0, 615, 616, 0, 0, 0, 615, 0, 616, + 0, 616, 0, 616, 623, 623, 623, 0, 616, 0, + 0, 0, 0, 624, 625, 0, 623, 623, 623, 623, + 623, 623, 623, 624, 625, 624, 625, 624, 625, 629, + 0, 624, 624, 625, 0, 631, 0, 625, 0, 629, + 0, 629, 0, 629, 0, 631, 634, 631, 629, 631, + 0, 0, 636, 631, 631, 0, 634, 0, 634, 0, + 634, 0, 636, 637, 636, 634, 636, 0, 0, 634, + + 637, 636, 0, 637, 0, 637, 644, 637, 643, 643, + 0, 0, 637, 0, 0, 0, 644, 648, 644, 643, + 644, 643, 0, 643, 0, 644, 0, 648, 643, 648, + 0, 648, 651, 0, 0, 653, 648, 0, 653, 0, + 648, 0, 651, 0, 651, 653, 651, 653, 0, 653, + 0, 651, 0, 0, 653, 658, 658, 658, 0, 0, + 0, 0, 0, 0, 659, 661, 0, 658, 658, 658, + 658, 658, 658, 658, 659, 661, 659, 661, 659, 661, + 664, 667, 0, 659, 661, 0, 659, 0, 0, 0, + 664, 667, 664, 667, 664, 667, 664, 671, 0, 664, + + 667, 0, 0, 0, 0, 0, 0, 671, 0, 671, + 0, 671, 0, 0, 0, 0, 671, 675, 675, 675, + 675, 675, 675, 675, 675, 675, 675, 675, 675, 676, + 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, + 676, 677, 677, 677, 677, 677, 677, 677, 677, 677, + 677, 677, 677, 678, 678, 678, 678, 678, 678, 678, + 678, 678, 678, 678, 678, 679, 679, 679, 679, 679, + 679, 679, 679, 679, 679, 679, 679, 680, 680, 680, + 0, 680, 680, 680, 680, 680, 680, 680, 680, 681, + 681, 0, 0, 681, 0, 681, 682, 0, 682, 683, + + 683, 0, 683, 683, 684, 684, 0, 684, 684, 684, + 0, 684, 684, 684, 684, 684, 685, 685, 685, 0, + 685, 685, 685, 685, 685, 685, 685, 685, 686, 686, + 686, 686, 686, 686, 686, 686, 0, 686, 686, 687, + 0, 0, 687, 0, 687, 687, 687, 687, 687, 687, + 688, 688, 0, 688, 688, 689, 689, 0, 689, 689, + 690, 690, 0, 690, 690, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674 + } ; + +extern int yy_flex_debug; +int yy_flex_debug = 1; + +static yyconst short int yy_rule_linenum[123] = + { 0, + 101, 104, 106, 107, 108, 111, 113, 114, 115, 127, + 134, 141, 147, 156, 164, 172, 173, 175, 194, 200, + 207, 214, 221, 231, 265, 272, 273, 274, 275, 283, + 284, 285, 286, 287, 292, 293, 294, 295, 296, 297, + 298, 299, 300, 301, 302, 311, 312, 313, 314, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, + 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, + + 366, 367, 372, 373, 378, 379, 380, 383, 389, 396, + 405, 416, 422, 424, 425, 427, 429, 431, 444, 450, + 456, 464 + } ; + +static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; +static char *yy_full_match; +static int yy_lp; +#define REJECT \ +{ \ +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yy_full_match; /* restore poss. backed-over text */ \ +++yy_lp; \ +goto find_rule; \ +} +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "asn1p_l.l" +#define INITIAL 0 +#line 2 "asn1p_l.l" + +#include +#include +#include + +#include "asn1parser.h" +#include "asn1p_y.h" + +int asn1p_lex(void); +void asn1p_lexer_hack_push_opaque_state(void); /* Used in .y */ +void asn1p_lexer_hack_enable_with_syntax(void); /* Used in .y */ + +#define YY_FATAL_ERROR(msg) do { \ + fprintf(stderr, \ + "lexer error at line %d, " \ + "text \"%s\"\n", \ + yylineno, yytext); \ + exit(1); \ + } while(0) + +int asn1p_lexer_pedantic_1990 = 0; +int asn1p_lexer_types_year = 0; +int asn1p_lexer_constructs_year = 0; +static int _check_dashes(char *ptr); +static asn1_integer_t asn1p_atoi(char *ptr); /* errno is either 0 or ERANGE */ + +/* + * Check that the type is defined in the year of the standard choosen. + */ +#define TYPE_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_types_year \ + || (fyr && fyr <= asn1p_lexer_types_year) \ + || (lyr && lyr > asn1p_lexer_types_year)) + +/* + * Check the the construction (or concept, i.e. CLASS) is defined in + * a given year. + */ +#define CONSTRUCT_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_constructs_year \ + || (fyr && fyr <= asn1p_lexer_constructs_year) \ + || (lyr && lyr > asn1p_lexer_constructs_year)) + +/* + * Make sure that the label is compliant with the naming rules. + */ +#define CHECK_DASHES do { \ + if(_check_dashes(yytext)) { \ + fprintf(stderr, \ + "%s: Identifier format invalid: " \ + "Improper dash location\n", yytext); \ + return -1; \ + } } while(0) + +/* + * Append quoted string. + */ +#define QAPPEND(text, tlen) do { \ + char *prev_text = asn1p_lval.tv_opaque.buf; \ + int prev_len = asn1p_lval.tv_opaque.len; \ + char *p; \ + \ + p = malloc((tlen) + prev_len + 1); \ + if(p == NULL) return -1; \ + \ + if(prev_text) memcpy(p, prev_text, prev_len); \ + memcpy(p + prev_len, text, tlen); \ + p[prev_len + (tlen)] = '\0'; \ + \ + free(asn1p_lval.tv_opaque.buf); \ + asn1p_lval.tv_opaque.buf = p; \ + asn1p_lval.tv_opaque.len = (tlen) + prev_len; \ + } while(0) + +#define YY_NEVER_INTERACTIVE 1 +#define YY_NO_INPUT 1 +#define YY_NO_UNPUT 1 +#define YY_STACK_USED 1 +/* Performance penalty is OK */ +/* Controlled from within application */ +#define dash_comment 1 + +#define cpp_comment 2 + +#define quoted 3 + +#define opaque 4 + +#define with_syntax 5 + +/* Newline */ +/* White-space */ +#line 1806 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 99 "asn1p_l.l" + + +#line 1960 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; + yy_state_ptr = yy_state_buf; + *yy_state_ptr++ = yy_current_state; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 675 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yy_state_ptr++ = yy_current_state; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 4166 ); + +yy_find_action: + yy_current_state = *--yy_state_ptr; + yy_lp = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[yy_lp]; + { + yy_full_match = yy_cp; + break; + } + } + --yy_cp; + yy_current_state = *--yy_state_ptr; + yy_lp = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + ++yylineno; + } + +do_action: /* This label is used only to access EOF actions. */ + + if ( yy_flex_debug ) + { + if ( yy_act == 0 ) + fprintf( stderr, "--scanner backing up\n" ); + else if ( yy_act < 123 ) + fprintf( stderr, "--accepting rule at line %d (\"%s\")\n", + yy_rule_linenum[yy_act], yytext ); + else if ( yy_act == 123 ) + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yytext ); + else if ( yy_act == 124 ) + fprintf( stderr, "--(end of buffer or a NUL)\n" ); + else + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + } + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +YY_RULE_SETUP +#line 101 "asn1p_l.l" +yy_push_state(dash_comment); + YY_BREAK + +case 2: +YY_RULE_SETUP +#line 104 "asn1p_l.l" +yy_pop_state(); + YY_BREAK +case 3: +YY_RULE_SETUP +#line 106 "asn1p_l.l" +yy_pop_state(); /* End of comment */ + YY_BREAK +case 4: +YY_RULE_SETUP +#line 107 "asn1p_l.l" +/* Eat single dash */ + YY_BREAK +case 5: +YY_RULE_SETUP +#line 108 "asn1p_l.l" +/* Eat */ + YY_BREAK + +case 6: +YY_RULE_SETUP +#line 111 "asn1p_l.l" +yy_push_state(cpp_comment); + YY_BREAK + +case 7: +YY_RULE_SETUP +#line 113 "asn1p_l.l" +/* Eat */ + YY_BREAK +case 8: +YY_RULE_SETUP +#line 114 "asn1p_l.l" +yy_pop_state(); + YY_BREAK +case 9: +YY_RULE_SETUP +#line 115 "asn1p_l.l" +/* Eat */ + YY_BREAK + +/* + * This is state is being set from corresponding .y module when + * higher-level data is necessary to make proper parsing of the + * underlying data. Thus, we enter the state and save + * everything for later processing. + */ + +case 10: +YY_RULE_SETUP +#line 127 "asn1p_l.l" +{ + yy_push_state(opaque); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 134 "asn1p_l.l" +{ + yy_pop_state(); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 141 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 147 "asn1p_l.l" +{ + fprintf(stderr, + "ASN.1 Parser syncronization failure: " + "\"%s\" at line %d must not appear " + "inside value definition\n", + yytext, yylineno); + return -1; + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 156 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK + +case 15: +YY_RULE_SETUP +#line 164 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = 0; + asn1p_lval.tv_opaque.len = 0; + QAPPEND(yytext+1, yyleng-1); + yy_push_state(quoted); + } + YY_BREAK + +case 16: +YY_RULE_SETUP +#line 172 "asn1p_l.l" +{ QAPPEND(yytext, yyleng-1); } /* Add a single quote */ + YY_BREAK +case 17: +YY_RULE_SETUP +#line 173 "asn1p_l.l" +{ QAPPEND(yytext, yyleng); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 175 "asn1p_l.l" +{ + yy_pop_state(); + /* Do not append last quote: + // QAPPEND(yytext, yyleng); */ + + if(asn1p_lexer_pedantic_1990 + && strchr(yytext, '\n')) { + fprintf(stderr, "%s: " + "Newlines are prohibited by ASN.1:1990\n", + asn1p_lval.tv_opaque.buf); + return -1; + } + + return TOK_cstring; + } + YY_BREAK + +case 19: +YY_RULE_SETUP +#line 194 "asn1p_l.l" +{ + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = yytext; + return TOK_hstring; + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 200 "asn1p_l.l" +{ + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = strdup(yytext); + return TOK_bstring; + } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 207 "asn1p_l.l" +{ + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number_negative; + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 214 "asn1p_l.l" +{ + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 221 "asn1p_l.l" +{ + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + YY_BREAK +/* + * Tags + */ +case 24: +YY_RULE_SETUP +#line 231 "asn1p_l.l" +{ + char *p; + memset(&asn1p_lval.a_tag, 0, sizeof(asn1p_lval.a_tag)); + switch(yytext[1]) { + case 'U': + asn1p_lval.a_tag.tag_class = TC_UNIVERSAL; + p = yytext + sizeof("UNIVERSAL") + 1; + break; + case 'A': + asn1p_lval.a_tag.tag_class = TC_APPLICATION; + p = yytext + sizeof("APPLICATION") + 1; + break; + case 'P': + asn1p_lval.a_tag.tag_class = TC_PRIVATE; + p = yytext + sizeof("PRIVATE") + 1; + break; + default: + assert(yytext[1] >= '0' && yytext[1] <= '9'); + asn1p_lval.a_tag.tag_class = TC_CONTEXT_SPECIFIC; + p = yytext + 1; + break; + } + asn1p_lval.a_tag.tag_value = asn1p_atoi(p); + if(*p == '0' && asn1p_lval.a_tag.tag_value) { + fprintf(stderr, + "Tag value at line %d " + "cannot start with zero " + "and have multiple digits: \"%s\"\n", + yylineno, yytext); + return -1; + } + return TOK_tag; + } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 265 "asn1p_l.l" +{ + fprintf(stderr, + "Unsupported tag syntax at line %d: \"%s\"\n", + yylineno, yytext); + return -1; + } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 272 "asn1p_l.l" +return TOK_ABSENT; + YY_BREAK +case 27: +YY_RULE_SETUP +#line 273 "asn1p_l.l" +return TOK_ABSTRACT_SYNTAX; + YY_BREAK +case 28: +YY_RULE_SETUP +#line 274 "asn1p_l.l" +return TOK_ALL; + YY_BREAK +case 29: +YY_RULE_SETUP +#line 275 "asn1p_l.l" +{ + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_ANY; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + REJECT; + } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 283 "asn1p_l.l" +return TOK_APPLICATION; + YY_BREAK +case 31: +YY_RULE_SETUP +#line 284 "asn1p_l.l" +return TOK_AUTOMATIC; + YY_BREAK +case 32: +YY_RULE_SETUP +#line 285 "asn1p_l.l" +return TOK_BEGIN; + YY_BREAK +case 33: +YY_RULE_SETUP +#line 286 "asn1p_l.l" +return TOK_BIT; + YY_BREAK +case 34: +YY_RULE_SETUP +#line 287 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + return TOK_BMPString; + REJECT; + } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 292 "asn1p_l.l" +return TOK_BOOLEAN; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 293 "asn1p_l.l" +return TOK_BY; + YY_BREAK +case 37: +YY_RULE_SETUP +#line 294 "asn1p_l.l" +return TOK_CHARACTER; + YY_BREAK +case 38: +YY_RULE_SETUP +#line 295 "asn1p_l.l" +return TOK_CHOICE; + YY_BREAK +case 39: +YY_RULE_SETUP +#line 296 "asn1p_l.l" +return TOK_CLASS; + YY_BREAK +case 40: +YY_RULE_SETUP +#line 297 "asn1p_l.l" +return TOK_COMPONENT; + YY_BREAK +case 41: +YY_RULE_SETUP +#line 298 "asn1p_l.l" +return TOK_COMPONENTS; + YY_BREAK +case 42: +YY_RULE_SETUP +#line 299 "asn1p_l.l" +return TOK_CONSTRAINED; + YY_BREAK +case 43: +YY_RULE_SETUP +#line 300 "asn1p_l.l" +return TOK_CONTAINING; + YY_BREAK +case 44: +YY_RULE_SETUP +#line 301 "asn1p_l.l" +return TOK_DEFAULT; + YY_BREAK +case 45: +YY_RULE_SETUP +#line 302 "asn1p_l.l" +{ + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_DEFINED; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + /* Deprecated since */ + REJECT; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 311 "asn1p_l.l" +return TOK_DEFINITIONS; + YY_BREAK +case 47: +YY_RULE_SETUP +#line 312 "asn1p_l.l" +return TOK_EMBEDDED; + YY_BREAK +case 48: +YY_RULE_SETUP +#line 313 "asn1p_l.l" +return TOK_ENCODED; + YY_BREAK +case 49: +YY_RULE_SETUP +#line 314 "asn1p_l.l" +return TOK_END; + YY_BREAK +case 50: +YY_RULE_SETUP +#line 315 "asn1p_l.l" +return TOK_ENUMERATED; + YY_BREAK +case 51: +YY_RULE_SETUP +#line 316 "asn1p_l.l" +return TOK_EXCEPT; + YY_BREAK +case 52: +YY_RULE_SETUP +#line 317 "asn1p_l.l" +return TOK_EXPLICIT; + YY_BREAK +case 53: +YY_RULE_SETUP +#line 318 "asn1p_l.l" +return TOK_EXPORTS; + YY_BREAK +case 54: +YY_RULE_SETUP +#line 319 "asn1p_l.l" +return TOK_EXTENSIBILITY; + YY_BREAK +case 55: +YY_RULE_SETUP +#line 320 "asn1p_l.l" +return TOK_EXTERNAL; + YY_BREAK +case 56: +YY_RULE_SETUP +#line 321 "asn1p_l.l" +return TOK_FALSE; + YY_BREAK +case 57: +YY_RULE_SETUP +#line 322 "asn1p_l.l" +return TOK_FROM; + YY_BREAK +case 58: +YY_RULE_SETUP +#line 323 "asn1p_l.l" +return TOK_GeneralizedTime; + YY_BREAK +case 59: +YY_RULE_SETUP +#line 324 "asn1p_l.l" +return TOK_GeneralString; + YY_BREAK +case 60: +YY_RULE_SETUP +#line 325 "asn1p_l.l" +return TOK_GraphicString; + YY_BREAK +case 61: +YY_RULE_SETUP +#line 326 "asn1p_l.l" +return TOK_IA5String; + YY_BREAK +case 62: +YY_RULE_SETUP +#line 327 "asn1p_l.l" +return TOK_IDENTIFIER; + YY_BREAK +case 63: +YY_RULE_SETUP +#line 328 "asn1p_l.l" +return TOK_IMPLICIT; + YY_BREAK +case 64: +YY_RULE_SETUP +#line 329 "asn1p_l.l" +return TOK_IMPLIED; + YY_BREAK +case 65: +YY_RULE_SETUP +#line 330 "asn1p_l.l" +return TOK_IMPORTS; + YY_BREAK +case 66: +YY_RULE_SETUP +#line 331 "asn1p_l.l" +return TOK_INCLUDES; + YY_BREAK +case 67: +YY_RULE_SETUP +#line 332 "asn1p_l.l" +return TOK_INSTANCE; + YY_BREAK +case 68: +YY_RULE_SETUP +#line 333 "asn1p_l.l" +return TOK_INTEGER; + YY_BREAK +case 69: +YY_RULE_SETUP +#line 334 "asn1p_l.l" +return TOK_INTERSECTION; + YY_BREAK +case 70: +YY_RULE_SETUP +#line 335 "asn1p_l.l" +return TOK_ISO646String; + YY_BREAK +case 71: +YY_RULE_SETUP +#line 336 "asn1p_l.l" +return TOK_MAX; + YY_BREAK +case 72: +YY_RULE_SETUP +#line 337 "asn1p_l.l" +return TOK_MIN; + YY_BREAK +case 73: +YY_RULE_SETUP +#line 338 "asn1p_l.l" +return TOK_MINUS_INFINITY; + YY_BREAK +case 74: +YY_RULE_SETUP +#line 339 "asn1p_l.l" +return TOK_NULL; + YY_BREAK +case 75: +YY_RULE_SETUP +#line 340 "asn1p_l.l" +return TOK_NumericString; + YY_BREAK +case 76: +YY_RULE_SETUP +#line 341 "asn1p_l.l" +return TOK_OBJECT; + YY_BREAK +case 77: +YY_RULE_SETUP +#line 342 "asn1p_l.l" +return TOK_ObjectDescriptor; + YY_BREAK +case 78: +YY_RULE_SETUP +#line 343 "asn1p_l.l" +return TOK_OCTET; + YY_BREAK +case 79: +YY_RULE_SETUP +#line 344 "asn1p_l.l" +return TOK_OF; + YY_BREAK +case 80: +YY_RULE_SETUP +#line 345 "asn1p_l.l" +return TOK_OPTIONAL; + YY_BREAK +case 81: +YY_RULE_SETUP +#line 346 "asn1p_l.l" +return TOK_PATTERN; + YY_BREAK +case 82: +YY_RULE_SETUP +#line 347 "asn1p_l.l" +return TOK_PDV; + YY_BREAK +case 83: +YY_RULE_SETUP +#line 348 "asn1p_l.l" +return TOK_PLUS_INFINITY; + YY_BREAK +case 84: +YY_RULE_SETUP +#line 349 "asn1p_l.l" +return TOK_PRESENT; + YY_BREAK +case 85: +YY_RULE_SETUP +#line 350 "asn1p_l.l" +return TOK_PrintableString; + YY_BREAK +case 86: +YY_RULE_SETUP +#line 351 "asn1p_l.l" +return TOK_PRIVATE; + YY_BREAK +case 87: +YY_RULE_SETUP +#line 352 "asn1p_l.l" +return TOK_REAL; + YY_BREAK +case 88: +YY_RULE_SETUP +#line 353 "asn1p_l.l" +return TOK_RELATIVE_OID; + YY_BREAK +case 89: +YY_RULE_SETUP +#line 354 "asn1p_l.l" +return TOK_SEQUENCE; + YY_BREAK +case 90: +YY_RULE_SETUP +#line 355 "asn1p_l.l" +return TOK_SET; + YY_BREAK +case 91: +YY_RULE_SETUP +#line 356 "asn1p_l.l" +return TOK_SIZE; + YY_BREAK +case 92: +YY_RULE_SETUP +#line 357 "asn1p_l.l" +return TOK_STRING; + YY_BREAK +case 93: +YY_RULE_SETUP +#line 358 "asn1p_l.l" +return TOK_SYNTAX; + YY_BREAK +case 94: +YY_RULE_SETUP +#line 359 "asn1p_l.l" +return TOK_T61String; + YY_BREAK +case 95: +YY_RULE_SETUP +#line 360 "asn1p_l.l" +return TOK_TAGS; + YY_BREAK +case 96: +YY_RULE_SETUP +#line 361 "asn1p_l.l" +return TOK_TeletexString; + YY_BREAK +case 97: +YY_RULE_SETUP +#line 362 "asn1p_l.l" +return TOK_TRUE; + YY_BREAK +case 98: +YY_RULE_SETUP +#line 363 "asn1p_l.l" +return TOK_TYPE_IDENTIFIER; + YY_BREAK +case 99: +YY_RULE_SETUP +#line 364 "asn1p_l.l" +return TOK_UNION; + YY_BREAK +case 100: +YY_RULE_SETUP +#line 365 "asn1p_l.l" +return TOK_UNIQUE; + YY_BREAK +case 101: +YY_RULE_SETUP +#line 366 "asn1p_l.l" +return TOK_UNIVERSAL; + YY_BREAK +case 102: +YY_RULE_SETUP +#line 367 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + return TOK_UniversalString; + REJECT; + } + YY_BREAK +case 103: +YY_RULE_SETUP +#line 372 "asn1p_l.l" +return TOK_UTCTime; + YY_BREAK +case 104: +YY_RULE_SETUP +#line 373 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + return TOK_UTF8String; + REJECT; + } + YY_BREAK +case 105: +YY_RULE_SETUP +#line 378 "asn1p_l.l" +return TOK_VideotexString; + YY_BREAK +case 106: +YY_RULE_SETUP +#line 379 "asn1p_l.l" +return TOK_VisibleString; + YY_BREAK +case 107: +YY_RULE_SETUP +#line 380 "asn1p_l.l" +return TOK_WITH; + YY_BREAK +case 108: +YY_RULE_SETUP +#line 383 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typefieldreference; + } + YY_BREAK +case 109: +YY_RULE_SETUP +#line 389 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_valuefieldreference; + } + YY_BREAK +case 110: +YY_RULE_SETUP +#line 396 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_identifier; + } + YY_BREAK +/* + * objectclassreference + */ +case 111: +YY_RULE_SETUP +#line 405 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_objectclassreference; + } + YY_BREAK +/* + * typereference, modulereference + * NOTE: TOK_objectclassreference must be combined + * with this token to produce true typereference. + */ +case 112: +YY_RULE_SETUP +#line 416 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typereference; + } + YY_BREAK +case 113: +YY_RULE_SETUP +#line 422 "asn1p_l.l" +return TOK_PPEQ; + YY_BREAK +case 114: +YY_RULE_SETUP +#line 424 "asn1p_l.l" +return TOK_ThreeDots; + YY_BREAK +case 115: +YY_RULE_SETUP +#line 425 "asn1p_l.l" +return TOK_TwoDots; + YY_BREAK +case 116: +YY_RULE_SETUP +#line 427 "asn1p_l.l" +return yytext[0]; + YY_BREAK +case 117: +YY_RULE_SETUP +#line 429 "asn1p_l.l" +/* Ignore whitespace */ + YY_BREAK +case 118: +YY_RULE_SETUP +#line 431 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + fprintf(stderr, "ERROR: "); + fprintf(stderr, + "Symbol '%c' at line %d is prohibited " + "by ASN.1:1994 and ASN.1:1997\n", + yytext[0], yylineno); + if(TYPE_LIFETIME(1994, 0)) + return -1; + } + YY_BREAK + +case 119: +YY_RULE_SETUP +#line 444 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 120: +YY_RULE_SETUP +#line 450 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 121: +YY_RULE_SETUP +#line 456 "asn1p_l.l" +{ + yy_pop_state(); + return '}'; + } + YY_BREAK + +case 122: +YY_RULE_SETUP +#line 464 "asn1p_l.l" +{ + fprintf(stderr, + "Unexpected token at line %d: \"%s\"\n", + yylineno, yytext); + while(YYSTATE != INITIAL) + yy_pop_state(); + yy_top_state(); /* Just to use this function. */ + yyterminate(); + yy_fatal_error("Unexpected token"); + return -1; +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(dash_comment): +case YY_STATE_EOF(cpp_comment): +case YY_STATE_EOF(quoted): +case YY_STATE_EOF(opaque): +case YY_STATE_EOF(with_syntax): +#line 476 "asn1p_l.l" +{ + while(YYSTATE != INITIAL) + yy_pop_state(); + yyterminate(); + } + YY_BREAK +case 123: +YY_RULE_SETUP +#line 483 "asn1p_l.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 2902 "lex.yy.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + yy_state_ptr = yy_state_buf; + *yy_state_ptr++ = yy_current_state; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 675 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yy_state_ptr++ = yy_current_state; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 675 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 674); + if ( ! yy_is_jam ) + *yy_state_ptr++ = yy_current_state; + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + if ( c == '\n' ) + --yylineno; + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + if ( c == '\n' ) + ++yylineno; + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 483 "asn1p_l.l" + + +/* + * Very dirty but wonderful hack allowing to rule states from within .y file. + */ +void +asn1p_lexer_hack_push_opaque_state() { + yy_push_state(opaque); +} + +/* + * Another hack which disables recognizing some tokens when inside WITH SYNTAX. + */ +void +asn1p_lexer_hack_enable_with_syntax() { + yy_push_state(with_syntax); +} + +/* + * Check that a token does not end with dash and does not contain + * several dashes in succession. + * "Name", "Type-Id", "T-y-p-e-i-d" are OK + * "end-", "vustom--value" are INVALID + */ +static int +_check_dashes(char *ptr) { + int prev_dash = 0; + + assert(*ptr != '-'); + + for(;; ptr++) { + switch(*ptr) { + case '-': + if(prev_dash++) /* No double dashes */ + return -1; + continue; + case '\0': + if(prev_dash) /* No dashes at the end */ + return -1; + break; + default: + prev_dash = 0; + continue; + } + break; + } + + return 0; +} + +static asn1_integer_t +asn1p_atoi(char *ptr) { + asn1_integer_t value; + errno = 0; /* Clear the error code */ + + if(sizeof(value) <= sizeof(int)) { + value = strtol(ptr, 0, 10); + } else { +#ifdef HAVE_STRTOIMAX + value = strtoimax(ptr, 0, 10); +#elif HAVE_STRTOLL + value = strtoll(ptr, 0, 10); +#else + value = strtol(ptr, 0, 10); +#endif + } + + if(errno == ERANGE) { + fprintf(stderr, + "Value \"%s\" at line %d is too large " + "for this compiler! Please contact the vendor.", + ptr, yylineno); + errno = ERANGE; /* Restore potentially clobbered errno */ + } + + return value; +} + diff --git a/libasn1parser/asn1p_l.l b/libasn1parser/asn1p_l.l new file mode 100644 index 00000000..0d86cb74 --- /dev/null +++ b/libasn1parser/asn1p_l.l @@ -0,0 +1,560 @@ +%{ + +#include +#include +#include + +#include "asn1parser.h" +#include "asn1p_y.h" + +int asn1p_lex(void); +void asn1p_lexer_hack_push_opaque_state(void); /* Used in .y */ +void asn1p_lexer_hack_enable_with_syntax(void); /* Used in .y */ + +#define YY_FATAL_ERROR(msg) do { \ + fprintf(stderr, \ + "lexer error at line %d, " \ + "text \"%s\"\n", \ + yylineno, yytext); \ + exit(1); \ + } while(0) + +int asn1p_lexer_pedantic_1990 = 0; +int asn1p_lexer_types_year = 0; +int asn1p_lexer_constructs_year = 0; +static int _check_dashes(char *ptr); +static asn1_integer_t asn1p_atoi(char *ptr); /* errno is either 0 or ERANGE */ + +/* + * Check that the type is defined in the year of the standard choosen. + */ +#define TYPE_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_types_year \ + || (fyr && fyr <= asn1p_lexer_types_year) \ + || (lyr && lyr > asn1p_lexer_types_year)) + +/* + * Check the the construction (or concept, i.e. CLASS) is defined in + * a given year. + */ +#define CONSTRUCT_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_constructs_year \ + || (fyr && fyr <= asn1p_lexer_constructs_year) \ + || (lyr && lyr > asn1p_lexer_constructs_year)) + +/* + * Make sure that the label is compliant with the naming rules. + */ +#define CHECK_DASHES do { \ + if(_check_dashes(yytext)) { \ + fprintf(stderr, \ + "%s: Identifier format invalid: " \ + "Improper dash location\n", yytext); \ + return -1; \ + } } while(0) + +/* + * Append quoted string. + */ +#define QAPPEND(text, tlen) do { \ + char *prev_text = asn1p_lval.tv_opaque.buf; \ + int prev_len = asn1p_lval.tv_opaque.len; \ + char *p; \ + \ + p = malloc((tlen) + prev_len + 1); \ + if(p == NULL) return -1; \ + \ + if(prev_text) memcpy(p, prev_text, prev_len); \ + memcpy(p + prev_len, text, tlen); \ + p[prev_len + (tlen)] = '\0'; \ + \ + free(asn1p_lval.tv_opaque.buf); \ + asn1p_lval.tv_opaque.buf = p; \ + asn1p_lval.tv_opaque.len = (tlen) + prev_len; \ + } while(0) + +%} + +%option never-interactive +%option noinput nounput +%option noyywrap stack +/* Performance penalty is OK */ +%option yylineno +/* Controlled from within application */ +%option debug + +%pointer + +%x dash_comment +%x cpp_comment +%x quoted +%x opaque +%x with_syntax + +/* Newline */ +NL [\r\v\f\n] +/* White-space */ +WSP [\t\r\v\f\n ] + +%% + +"--" yy_push_state(dash_comment); +{ + + {NL} yy_pop_state(); + + -- yy_pop_state(); /* End of comment */ + - /* Eat single dash */ + [^\r\v\f\n-]+ /* Eat */ + +} +"/*" yy_push_state(cpp_comment); +{ + [^*/] /* Eat */ + "*/" yy_pop_state(); + . /* Eat */ +} + + + /* + * This is state is being set from corresponding .y module when + * higher-level data is necessary to make proper parsing of the + * underlying data. Thus, we enter the state and save + * everything for later processing. + */ +{ + + "{" { + yy_push_state(opaque); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + "}" { + yy_pop_state(); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + [^{}:=]+ { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + "::=" { + fprintf(stderr, + "ASN.1 Parser syncronization failure: " + "\"%s\" at line %d must not appear " + "inside value definition\n", + yytext, yylineno); + return -1; + } + + [:=] { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + } + +\"[^\"]* { + asn1p_lval.tv_opaque.buf = 0; + asn1p_lval.tv_opaque.len = 0; + QAPPEND(yytext+1, yyleng-1); + yy_push_state(quoted); + } +{ + + \"\" { QAPPEND(yytext, yyleng-1); } /* Add a single quote */ + [^\"]+ { QAPPEND(yytext, yyleng); } + + \" { + yy_pop_state(); + /* Do not append last quote: + // QAPPEND(yytext, yyleng); */ + + if(asn1p_lexer_pedantic_1990 + && strchr(yytext, '\n')) { + fprintf(stderr, "%s: " + "Newlines are prohibited by ASN.1:1990\n", + asn1p_lval.tv_opaque.buf); + return -1; + } + + return TOK_cstring; + } + + } + + +'[0-9A-F \t\r\v\f\n]+'H { + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = yytext; + return TOK_hstring; + } + +'[01 \t\r\v\f\n]+'B { + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = strdup(yytext); + return TOK_bstring; + } + + +-[1-9][0-9]* { + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number_negative; + } + +[1-9][0-9]* { + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + +"0" { + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + + /* + * Tags + */ +\[(UNIVERSAL[ \t\r\v\f\n]+|APPLICATION[ \t\r\v\f\n]+|PRIVATE[ \t\r\v\f\n]+)?[0-9]+\] { + char *p; + memset(&asn1p_lval.a_tag, 0, sizeof(asn1p_lval.a_tag)); + switch(yytext[1]) { + case 'U': + asn1p_lval.a_tag.tag_class = TC_UNIVERSAL; + p = yytext + sizeof("UNIVERSAL") + 1; + break; + case 'A': + asn1p_lval.a_tag.tag_class = TC_APPLICATION; + p = yytext + sizeof("APPLICATION") + 1; + break; + case 'P': + asn1p_lval.a_tag.tag_class = TC_PRIVATE; + p = yytext + sizeof("PRIVATE") + 1; + break; + default: + assert(yytext[1] >= '0' && yytext[1] <= '9'); + asn1p_lval.a_tag.tag_class = TC_CONTEXT_SPECIFIC; + p = yytext + 1; + break; + } + asn1p_lval.a_tag.tag_value = asn1p_atoi(p); + if(*p == '0' && asn1p_lval.a_tag.tag_value) { + fprintf(stderr, + "Tag value at line %d " + "cannot start with zero " + "and have multiple digits: \"%s\"\n", + yylineno, yytext); + return -1; + } + return TOK_tag; + } + +\[[A-Z]+[ \t\r\v\f\n]+[0-9]+\] { + fprintf(stderr, + "Unsupported tag syntax at line %d: \"%s\"\n", + yylineno, yytext); + return -1; + } + +ABSENT return TOK_ABSENT; +ABSTRACT-SYNTAX return TOK_ABSTRACT_SYNTAX; +ALL return TOK_ALL; +ANY { + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_ANY; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + REJECT; + } +APPLICATION return TOK_APPLICATION; +AUTOMATIC return TOK_AUTOMATIC; +BEGIN return TOK_BEGIN; +BIT return TOK_BIT; +BMPString { + if(TYPE_LIFETIME(1994, 0)) + return TOK_BMPString; + REJECT; + } +BOOLEAN return TOK_BOOLEAN; +BY return TOK_BY; +CHARACTER return TOK_CHARACTER; +CHOICE return TOK_CHOICE; +CLASS return TOK_CLASS; +COMPONENT return TOK_COMPONENT; +COMPONENTS return TOK_COMPONENTS; +CONSRAINED return TOK_CONSTRAINED; +CONTAINING return TOK_CONTAINING; +DEFAULT return TOK_DEFAULT; +DEFINED { + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_DEFINED; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + /* Deprecated since */ + REJECT; + } +DEFINITIONS return TOK_DEFINITIONS; +EMBEDDED return TOK_EMBEDDED; +ENCODED return TOK_ENCODED; +END return TOK_END; +ENUMERATED return TOK_ENUMERATED; +EXCEPT return TOK_EXCEPT; +EXPLICIT return TOK_EXPLICIT; +EXPORTS return TOK_EXPORTS; +EXTENSIBILITY return TOK_EXTENSIBILITY; +EXTERNAL return TOK_EXTERNAL; +FALSE return TOK_FALSE; +FROM return TOK_FROM; +GeneralizedTime return TOK_GeneralizedTime; +GeneralString return TOK_GeneralString; +GraphicString return TOK_GraphicString; +IA5String return TOK_IA5String; +IDENTIFIER return TOK_IDENTIFIER; +IMPLICIT return TOK_IMPLICIT; +IMPLIED return TOK_IMPLIED; +IMPORTS return TOK_IMPORTS; +INCLUDES return TOK_INCLUDES; +INSTANCE return TOK_INSTANCE; +INTEGER return TOK_INTEGER; +INTERSECTION return TOK_INTERSECTION; +ISO646String return TOK_ISO646String; +MAX return TOK_MAX; +MIN return TOK_MIN; +MINUS-INFINITY return TOK_MINUS_INFINITY; +NULL return TOK_NULL; +NumericString return TOK_NumericString; +OBJECT return TOK_OBJECT; +ObjectDescriptor return TOK_ObjectDescriptor; +OCTET return TOK_OCTET; +OF return TOK_OF; +OPTIONAL return TOK_OPTIONAL; +PATTERN return TOK_PATTERN; +PDV return TOK_PDV; +PLUS-INFINITY return TOK_PLUS_INFINITY; +PRESENT return TOK_PRESENT; +PrintableString return TOK_PrintableString; +PRIVATE return TOK_PRIVATE; +REAL return TOK_REAL; +RELATIVE-OID return TOK_RELATIVE_OID; +SEQUENCE return TOK_SEQUENCE; +SET return TOK_SET; +SIZE return TOK_SIZE; +STRING return TOK_STRING; +SYNTAX return TOK_SYNTAX; +T61String return TOK_T61String; +TAGS return TOK_TAGS; +TeletexString return TOK_TeletexString; +TRUE return TOK_TRUE; +TYPE-IDENTIFIER return TOK_TYPE_IDENTIFIER; +UNION return TOK_UNION; +UNIQUE return TOK_UNIQUE; +UNIVERSAL return TOK_UNIVERSAL; +UniversalString { + if(TYPE_LIFETIME(1994, 0)) + return TOK_UniversalString; + REJECT; + } +UTCTime return TOK_UTCTime; +UTF8String { + if(TYPE_LIFETIME(1994, 0)) + return TOK_UTF8String; + REJECT; + } +VideotexString return TOK_VideotexString; +VisibleString return TOK_VisibleString; +WITH return TOK_WITH; + + +&[A-Z][A-Za-z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typefieldreference; + } + +&[a-z][a-zA-Z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_valuefieldreference; + } + + +[a-z][a-zA-Z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_identifier; + } + + /* + * objectclassreference + */ +[A-Z][A-Z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_objectclassreference; + } + + /* + * typereference, modulereference + * NOTE: TOK_objectclassreference must be combined + * with this token to produce true typereference. + */ +[A-Z][A-Za-z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typereference; + } + +"::=" return TOK_PPEQ; + +"..." return TOK_ThreeDots; +".." return TOK_TwoDots; + +[(){},;:|!.&@\[\]] return yytext[0]; + +{WSP}+ /* Ignore whitespace */ + +[^A-Za-z0-9:=,{}<.@()[]'\"|&^*;!-] { + if(TYPE_LIFETIME(1994, 0)) + fprintf(stderr, "ERROR: "); + fprintf(stderr, + "Symbol '%c' at line %d is prohibited " + "by ASN.1:1994 and ASN.1:1997\n", + yytext[0], yylineno); + if(TYPE_LIFETIME(1994, 0)) + return -1; + } + +{ + + [^&{} \t\r\v\f\n]+ { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + {WSP}+ { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + "}" { + yy_pop_state(); + return '}'; + } + +} + + +<*>. { + fprintf(stderr, + "Unexpected token at line %d: \"%s\"\n", + yylineno, yytext); + while(YYSTATE != INITIAL) + yy_pop_state(); + yy_top_state(); /* Just to use this function. */ + yyterminate(); + yy_fatal_error("Unexpected token"); + return -1; +} + +<*><> { + while(YYSTATE != INITIAL) + yy_pop_state(); + yyterminate(); + } + + +%% + +/* + * Very dirty but wonderful hack allowing to rule states from within .y file. + */ +void +asn1p_lexer_hack_push_opaque_state() { + yy_push_state(opaque); +} + +/* + * Another hack which disables recognizing some tokens when inside WITH SYNTAX. + */ +void +asn1p_lexer_hack_enable_with_syntax() { + yy_push_state(with_syntax); +} + +/* + * Check that a token does not end with dash and does not contain + * several dashes in succession. + * "Name", "Type-Id", "T-y-p-e-i-d" are OK + * "end-", "vustom--value" are INVALID + */ +static int +_check_dashes(char *ptr) { + int prev_dash = 0; + + assert(*ptr != '-'); + + for(;; ptr++) { + switch(*ptr) { + case '-': + if(prev_dash++) /* No double dashes */ + return -1; + continue; + case '\0': + if(prev_dash) /* No dashes at the end */ + return -1; + break; + default: + prev_dash = 0; + continue; + } + break; + } + + return 0; +} + +static asn1_integer_t +asn1p_atoi(char *ptr) { + asn1_integer_t value; + errno = 0; /* Clear the error code */ + + if(sizeof(value) <= sizeof(int)) { + value = strtol(ptr, 0, 10); + } else { +#ifdef HAVE_STRTOIMAX + value = strtoimax(ptr, 0, 10); +#elif HAVE_STRTOLL + value = strtoll(ptr, 0, 10); +#else + value = strtol(ptr, 0, 10); +#endif + } + + if(errno == ERANGE) { + fprintf(stderr, + "Value \"%s\" at line %d is too large " + "for this compiler! Please contact the vendor.", + ptr, yylineno); + errno = ERANGE; /* Restore potentially clobbered errno */ + } + + return value; +} + diff --git a/libasn1parser/asn1p_list.h b/libasn1parser/asn1p_list.h new file mode 100644 index 00000000..1f808780 --- /dev/null +++ b/libasn1parser/asn1p_list.h @@ -0,0 +1,57 @@ +/* + * Singly linked tail queue support. + */ +#ifndef ASN1_PARSER_LIST_H +#define ASN1_PARSER_LIST_H + +#define TQ_HEAD(type) \ + struct { \ + type *tq_head; \ + type**tq_tail; \ + } + +#define TQ_HEAD_COPY(to, from) \ + do { (to)->tq_head = (from)->tq_head; \ + (to)->tq_tail = (from)->tq_tail; } while(0) + +#define TQ_ENTRY(type) \ + struct { \ + type *tq_next; \ + } + +#define TQ_FIRST(headp) ((headp)->tq_head) +#define TQ_NEXT(el, field) ((el)->field.tq_next) + +#define TQ_INIT(head) do { \ + TQ_FIRST((head)) = 0; \ + (head)->tq_tail = &TQ_FIRST((head)); \ + } while(0) + +#define TQ_FOR(var, head, field) \ + for((var) = TQ_FIRST((head)); \ + (var); (var) = TQ_NEXT((var), field)) + +#define TQ_ADD(head, xel, field) do { \ + typeof(xel) __el = xel; \ + assert(TQ_NEXT((__el), field) == 0); \ + *(head)->tq_tail = (__el); \ + (head)->tq_tail = &TQ_NEXT((__el), field); \ + } while(0) + +/* + * Remove the first element and return it. + */ +#define TQ_REMOVE(head, field) ({ \ + typeof(TQ_FIRST((head))) __fel; \ + __fel = TQ_FIRST((head)); \ + if(__fel == 0 \ + || (TQ_FIRST((head)) = TQ_NEXT(__fel, field)) \ + == 0) { \ + (head)->tq_tail = &TQ_FIRST((head)); \ + } else { \ + TQ_NEXT(__fel, field) = 0; \ + } \ + __fel; }) + + +#endif /* ASN1_PARSER_LIST_H */ diff --git a/libasn1parser/asn1p_module.c b/libasn1parser/asn1p_module.c new file mode 100644 index 00000000..d430844e --- /dev/null +++ b/libasn1parser/asn1p_module.c @@ -0,0 +1,62 @@ +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty module. + */ +asn1p_module_t * +asn1p_module_new() { + asn1p_module_t *mod; + + mod = calloc(1, sizeof *mod); + if(mod) { + TQ_INIT(&(mod->imports)); + TQ_INIT(&(mod->exports)); + TQ_INIT(&(mod->members)); + } + return mod; +} + +/* + * Destroy the module. + */ +void +asn1p_module_free(asn1p_module_t *mod) { + if(mod) { + asn1p_expr_t *expr; + + if(mod->Identifier) + free(mod->Identifier); + + if(mod->module_oid) + asn1p_oid_free(mod->module_oid); + + while((expr = TQ_REMOVE(&(mod->members), next))) + asn1p_expr_free(expr); + + free(mod); + } +} + +asn1p_t * +asn1p_new() { + asn1p_t *asn; + asn = calloc(1, sizeof(*asn)); + if(asn) { + TQ_INIT(&(asn->modules)); + } + return asn; +} + + +void +asn1p_free(asn1p_t *asn) { + if(asn) { + asn1p_module_t *mod; + while((mod = TQ_REMOVE(&(asn->modules), mod_next))) + asn1p_module_free(mod); + free(asn); + } +} diff --git a/libasn1parser/asn1p_module.h b/libasn1parser/asn1p_module.h new file mode 100644 index 00000000..906c784a --- /dev/null +++ b/libasn1parser/asn1p_module.h @@ -0,0 +1,88 @@ +/* + * A Module definition structure used by the ASN.1 parser. + */ +#ifndef ASN1_PARSER_MODULE_H +#define ASN1_PARSER_MODULE_H + +/* + * Flags specific to a module. + */ +typedef enum asn1p_module_flags { + MSF_NOFLAGS, + MSF_EXPLICIT_TAGS = 0x1, + MSF_IMPLICIT_TAGS = 0x2, + MSF_AUTOMATIC_TAGS = 0x4, + MSF_EXTENSIBILITY_IMPLIED = 0x8, +} asn1p_module_flags_e; + +/* + * === EXAMPLE === + * MySyntax DEFINITIONS AUTOMATIC TAGS ::= + * BEGIN + * ... + * END + * === EOF === + */ +typedef struct asn1p_module_s { + + /* + * Name of the source file. + */ + char *source_file_name; + + /* + * Human-readable module identifier. + */ + char *Identifier; /* Module name */ + + /* + * Unique module identifier, OID. + */ + asn1p_oid_t *module_oid; /* Optional OID of the module */ + + /* + * Module flags. + */ + asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */ + + /* + * List of everything that this module IMPORTS. + */ + TQ_HEAD(struct asn1p_xports_s) imports; + + /* + * List of everything that this module EXPORTS. + */ + TQ_HEAD(struct asn1p_xports_s) exports; + + /* + * List of everything that this module defines itself. + */ + TQ_HEAD(struct asn1p_expr_s) members; + + /* + * Next module in the list. + */ + TQ_ENTRY(struct asn1p_module_s) + mod_next; + +} asn1p_module_t; + +/* + * Constructor and destructor. + */ +asn1p_module_t *asn1p_module_new(void); +void asn1p_module_free(asn1p_module_t *mod); + +/* + * No more than a container for several modules. + */ +typedef struct asn1p_s { + TQ_HEAD(struct asn1p_module_s) modules; +} asn1p_t; + +asn1p_t *asn1p_new(void); +void asn1p_free(asn1p_t *asn); + + +#endif /* ASN1_PARSER_MODULE_H */ diff --git a/libasn1parser/asn1p_oid.c b/libasn1parser/asn1p_oid.c new file mode 100644 index 00000000..2c22b0fd --- /dev/null +++ b/libasn1parser/asn1p_oid.c @@ -0,0 +1,95 @@ +#include +#include +#include + +#include "asn1parser.h" + +asn1p_oid_t * +asn1p_oid_new() { + return calloc(1, sizeof(asn1p_oid_t)); +} + +int +asn1p_oid_add_arc(asn1p_oid_t *oid, asn1p_oid_arc_t *template) { + void *p; + p = realloc(oid->arcs, (oid->arcs_count + 1) * sizeof(oid->arcs[0])); + if(p) { + oid->arcs = p; + oid->arcs[oid->arcs_count].name + = template->name?strdup(template->name):0; + oid->arcs[oid->arcs_count].number = template->number; + oid->arcs_count++; + return 0; + } else { + return -1; + } +} + +void +asn1p_oid_free(asn1p_oid_t *oid) { + if(oid) { + if(oid->arcs) { + while(oid->arcs_count--) { + if(oid->arcs[oid->arcs_count].name) + free(oid->arcs[oid->arcs_count].name); + } + } + free(oid); + } +} + +asn1p_oid_arc_t * +asn1p_oid_arc_new(const char *optName, asn1_integer_t optNumber /* = -1 */) { + asn1p_oid_arc_t *arc; + + arc = calloc(1, sizeof *arc); + if(arc) { + if(optName) + arc->name = strdup(optName); + arc->number = optNumber; + } + + return arc; +} + +void +asn1p_oid_arc_free(asn1p_oid_arc_t *arc) { + if(arc) { + if(arc->name) + free(arc->name); + free(arc); + } +} + +int +asn1p_oid_compare(asn1p_oid_t *a, asn1p_oid_t *b) { + int i; + + for(i = 0; ; i++) { + asn1_integer_t cmp; + + if(b->arcs_count > i) { + if(a->arcs_count <= i) + return -1; + } else if(a->arcs_count > i) { + if(b->arcs_count <= i) + return 1; + } else if(b->arcs_count <= i && a->arcs_count <= i) { + cmp = b->arcs_count - a->arcs_count; + if(cmp < 0) + return -1; + else if(cmp > 0) + return 1; + return 0; + } + + cmp = b->arcs[i].number - a->arcs[i].number; + if(cmp < 0) + return -1; + else if(cmp > 0) + return 1; + } + +} + + diff --git a/libasn1parser/asn1p_oid.h b/libasn1parser/asn1p_oid.h new file mode 100644 index 00000000..cbb6b079 --- /dev/null +++ b/libasn1parser/asn1p_oid.h @@ -0,0 +1,66 @@ +/* + * Object Identifier definition. + */ +#ifndef ASN1_PARSER_OID_H +#define ASN1_PARSER_OID_H + +/******************************** + * Single Object Identifier Arc * + ********************************/ + +/* + * Object identifier arc (one number in the hierarchy). + */ +typedef struct asn1p_oid_arc_s { + asn1_integer_t number; /* -1 if not yet defined */ + char *name; /* 0 if not defined */ +} asn1p_oid_arc_t; + + +/* + * Arc constructor. + */ +asn1p_oid_arc_t *asn1p_oid_arc_new( + const char *optName, asn1_integer_t optNumber /* = -1 */); +/* + * Arc destructor. + */ +void asn1p_oid_arc_free(asn1p_oid_arc_t *); + + +/************************************************** + * Object Identifier itself, a collection of arcs * + **************************************************/ + +/* + * Object Identifier as a collection of arcs. + */ +typedef struct asn1p_oid_s { + asn1p_oid_arc_t *arcs; + int arcs_count; +} asn1p_oid_t; + +/* + * OID constructor. + */ +asn1p_oid_t *asn1p_oid_new(void); + +/* + * Add another arc using given one as a template + */ +int asn1p_oid_add_arc(asn1p_oid_t *, asn1p_oid_arc_t *template); + +/* + * OID destructor. + */ +void asn1p_oid_free(asn1p_oid_t *); + +/* + * RETURN VALUES: + * 0: The specified OIDs are equal. + * -1 or 1 otherwise. + */ +int asn1p_oid_compare(asn1p_oid_t *a, asn1p_oid_t *b); + + +#endif /* ASN1_PARSER_OID_H */ diff --git a/libasn1parser/asn1p_param.c b/libasn1parser/asn1p_param.c new file mode 100644 index 00000000..f7082241 --- /dev/null +++ b/libasn1parser/asn1p_param.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty parameters list. + */ +asn1p_paramlist_t * +asn1p_paramlist_new(int _lineno) { + asn1p_paramlist_t *pl; + + pl = calloc(1, sizeof *pl); + if(pl) { + pl->_lineno = _lineno; + } + + return pl; +} + +void +asn1p_paramlist_free(asn1p_paramlist_t *pl) { + if(pl) { + if(pl->params) { + int i = pl->params_count; + while(i--) { + if(pl->params[i].governor) + asn1p_ref_free(pl->params[i].governor); + if(pl->params[i].argument) + free(pl->params[i].argument); + pl->params[i].governor = 0; + pl->params[i].argument = 0; + } + free(pl->params); + pl->params = 0; + } + + free(pl); + } +} + +int +asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) { + + if(!pl || !arg) { + errno = EINVAL; + return -1; + } + + /* + * Make sure there's enough space to insert a new element. + */ + if(pl->params_count == pl->params_size) { + int newsize = pl->params_size?pl->params_size<<2:4; + void *p; + p = realloc(pl->params, + newsize * sizeof(pl->params[0])); + if(p) { + pl->params = p; + pl->params_size = newsize; + } else { + return -1; + } + + } + + if(gov) { + pl->params[pl->params_count].governor = asn1p_ref_clone(gov); + if(pl->params[pl->params_count].governor == NULL) { + return -1; + } + } else { + pl->params[pl->params_count].governor = 0; + } + + pl->params[pl->params_count].argument = strdup(arg); + if(pl->params[pl->params_count].argument) { + pl->params_count++; + return 0; + } else { + if(pl->params[pl->params_count].governor) + asn1p_ref_free(pl->params[pl->params_count].governor); + return -1; + } +} + +asn1p_paramlist_t * +asn1p_paramlist_clone(asn1p_paramlist_t *pl) { + asn1p_paramlist_t *newpl; + + newpl = asn1p_paramlist_new(pl->_lineno); + if(newpl) { + int i; + for(i = 0; i < pl->params_count; i++) { + if(asn1p_paramlist_add_param(newpl, + pl->params[i].governor, + pl->params[i].argument + )) { + asn1p_paramlist_free(newpl); + newpl = NULL; + break; + } + } + } + + return newpl; +} + diff --git a/libasn1parser/asn1p_param.h b/libasn1parser/asn1p_param.h new file mode 100644 index 00000000..c9c20c23 --- /dev/null +++ b/libasn1parser/asn1p_param.h @@ -0,0 +1,30 @@ +/* + * Structures and prototypes related to parametrization + */ +#ifndef ASN1_PARSER_PARAMETRIZATION_H +#define ASN1_PARSER_PARAMETRIZATION_H + +typedef struct asn1p_paramlist_s { + struct asn1p_param_s { + asn1p_ref_t *governor; + char *argument; + } *params; + int params_count; + int params_size; + + int _lineno; +} asn1p_paramlist_t; + +/* + * Constructor and destructor. + */ +asn1p_paramlist_t *asn1p_paramlist_new(int _lineno); +void asn1p_paramlist_free(asn1p_paramlist_t *); + +asn1p_paramlist_t *asn1p_paramlist_clone(asn1p_paramlist_t *ref); + +int asn1p_paramlist_add_param(asn1p_paramlist_t *, + asn1p_ref_t *opt_gov, char *arg); + + +#endif /* ASN1_PARSER_PARAMETRIZATION_H */ diff --git a/libasn1parser/asn1p_ref.c b/libasn1parser/asn1p_ref.c new file mode 100644 index 00000000..4ac2b32d --- /dev/null +++ b/libasn1parser/asn1p_ref.c @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty reference. + */ +asn1p_ref_t * +asn1p_ref_new(int _lineno) { + asn1p_ref_t *ref; + + ref = calloc(1, sizeof *ref); + if(ref) { + ref->_lineno = _lineno; + } + + return ref; +} + +void +asn1p_ref_free(asn1p_ref_t *ref) { + if(ref) { + if(ref->components) { + int i = ref->comp_count; + while(i--) { + if(ref->components[i].name) + free(ref->components[i].name); + ref->components[i].name = 0; + } + free(ref->components); + ref->components = 0; + } + + free(ref); + } +} + +static enum asn1p_ref_lex_type_e +asn1p_ref_name2lextype(char *name) { + enum asn1p_ref_lex_type_e lex_type; + int has_lowercase = 0; + + if(*name == '&') { + if(name[1] >= 'A' && name[1] <= 'Z') { + lex_type = RLT_AmpUppercase; + } else { + lex_type = RLT_Amplowercase; + } + } else if(*name >= 'A' && *name <= 'Z') { + char *p; + + for(p = name; *p; p++) { + if(*p >= 'a' && *p <= 'z') { + has_lowercase = 1; + break; + } + } + + if(has_lowercase) { + lex_type = RLT_Uppercase; + } else { + lex_type = RLT_CAPITALS; + } + } else if(*name == '@') { + if(name[1] == '.') + lex_type = RLT_AtDotlowercase; + else + lex_type = RLT_Atlowercase; + } else { + lex_type = RLT_lowercase; + } + + return lex_type; +} + +int +asn1p_ref_add_component(asn1p_ref_t *ref, char *name, enum asn1p_ref_lex_type_e lex_type) { + + if(!ref || !name || lex_type < RLT_UNKNOWN || lex_type >= RLT_MAX) { + errno = EINVAL; + return -1; + } + + if(ref->comp_count == ref->comp_size) { + int newsize = ref->comp_size?(ref->comp_size<<2):4; + void *p = realloc(ref->components, + newsize * sizeof(ref->components[0])); + if(p) { + ref->components = p; + ref->comp_size = newsize; + } else { + return -1; + } + + } + + if(lex_type == RLT_UNKNOWN) { + lex_type = asn1p_ref_name2lextype(name); + } else { + assert(lex_type == asn1p_ref_name2lextype(name)); + } + + ref->components[ref->comp_count].name = strdup(name); + ref->components[ref->comp_count].lex_type = lex_type; + if(ref->components[ref->comp_count].name) { + ref->comp_count++; + return 0; + } else { + return -1; + } +} + +asn1p_ref_t * +asn1p_ref_clone(asn1p_ref_t *ref) { + asn1p_ref_t *newref; + + newref = asn1p_ref_new(ref->_lineno); + if(newref) { + int i; + for(i = 0; i < ref->comp_count; i++) { + if(asn1p_ref_add_component(newref, + ref->components[i].name, + ref->components[i].lex_type + )) { + asn1p_ref_free(newref); + newref = NULL; + break; + } + } + } + + return newref; +} diff --git a/libasn1parser/asn1p_ref.h b/libasn1parser/asn1p_ref.h new file mode 100644 index 00000000..dc7a7165 --- /dev/null +++ b/libasn1parser/asn1p_ref.h @@ -0,0 +1,62 @@ +/* + * Generic reference to the yet unknown type defined elsewhere. + */ +#ifndef ASN1_PARSER_REFERENCE_H +#define ASN1_PARSER_REFERENCE_H + +typedef struct asn1p_ref_s { + + /* + * A set of reference name components. + * A reference name consists of several components separated by dots: + * "OBJECT-CLASS.&Algorithm.&id" + */ + struct asn1p_ref_component_s { + enum asn1p_ref_lex_type_e { + RLT_UNKNOWN, /* Invalid? */ + /* + * Object class reference "OCLASS1", + * type reference "Type1", + * value reference "id", + * type field reference "&Type1", + * value field reference "&id", + * "OBJECT-CLASS" + */ + RLT_CAPITALS, + RLT_Uppercase, + RLT_lowercase, + RLT_AmpUppercase, + RLT_Amplowercase, + RLT_Atlowercase, + RLT_AtDotlowercase, + RLT_MAX + } lex_type; /* Inferred lexical type of the identifier */ + char *name; /* An identifier */ + } *components; + + int comp_count; /* Number of the components in the reference name. */ + int comp_size; /* Number of allocated structures */ + + int _lineno; /* Number of line in the file */ +} asn1p_ref_t; + +/* + * Constructor and destructor. + */ +asn1p_ref_t *asn1p_ref_new(int _lineno); +void asn1p_ref_free(asn1p_ref_t *); + +asn1p_ref_t *asn1p_ref_clone(asn1p_ref_t *ref); + +/* + * Add a new reference component to the existing reference structure. + * + * RETURN VALUES: + * 0: All clear. + * -1/EINVAL: Invalid arguments + * -1/ENOMEM: Memory allocation failed + */ +int asn1p_ref_add_component(asn1p_ref_t *, + char *name, enum asn1p_ref_lex_type_e); + +#endif /* ASN1_PARSER_REFERENCE_H */ diff --git a/libasn1parser/asn1p_value.c b/libasn1parser/asn1p_value.c new file mode 100644 index 00000000..fb3a9453 --- /dev/null +++ b/libasn1parser/asn1p_value.c @@ -0,0 +1,178 @@ +#include +#include +#include +#include + +#include "asn1parser.h" + + +asn1p_value_t * +asn1p_value_fromref(asn1p_ref_t *ref, int do_copy) { + if(ref) { + asn1p_value_t *v = calloc(1, sizeof *v); + if(v) { + if(do_copy) { + v->value.reference = asn1p_ref_clone(ref); + if(v->value.reference == NULL) { + free(v); + return NULL; + } + } else { + v->value.reference = ref; + } + v->type = ATV_REFERENCED; + } + return v; + } else { + errno = EINVAL; + return NULL; + } +} + +asn1p_value_t * +asn1p_value_frombits(uint8_t *bits, int size_in_bits, int do_copy) { + if(bits) { + asn1p_value_t *v = calloc(1, sizeof *v); + assert(size_in_bits >= 0); + if(v) { + if(do_copy) { + int size = ((size_in_bits + 7) >> 3); + void *p; + p = malloc(size + 1); + if(p) { + memcpy(p, bits, size); + ((char *)p)[size] = '\0'; /* JIC */ + } else { + free(v); + return NULL; + } + v->value.binary_vector.bits = p; + } else { + v->value.binary_vector.bits = (void *)bits; + } + v->value.binary_vector.size_in_bits = size_in_bits; + v->type = ATV_BITVECTOR; + } + return v; + } else { + errno = EINVAL; + return NULL; + } +} +asn1p_value_t * +asn1p_value_frombuf(char *buffer, int size, int do_copy) { + if(buffer) { + asn1p_value_t *v = calloc(1, sizeof *v); + assert(size >= 0); + if(v) { + if(do_copy) { + void *p = malloc(size + 1); + if(p) { + memcpy(p, buffer, size); + ((char *)p)[size] = '\0'; /* JIC */ + } else { + free(v); + return NULL; + } + v->value.string.buf = p; + } else { + v->value.string.buf = buffer; + } + v->value.string.size = size; + v->type = ATV_STRING; + } + return v; + } else { + errno = EINVAL; + return NULL; + } +} + +asn1p_value_t * +asn1p_value_fromdouble(double d) { + asn1p_value_t *v = calloc(1, sizeof *v); + if(v) { + v->value.v_double = d; + v->type = ATV_REAL; + } + return v; +} + +asn1p_value_t * +asn1p_value_fromint(asn1_integer_t i) { + asn1p_value_t *v = calloc(1, sizeof *v); + if(v) { + v->value.v_integer = i; + v->type = ATV_INTEGER; + } + return v; +} + +asn1p_value_t * +asn1p_value_clone(asn1p_value_t *v) { + asn1p_value_t *clone; + if(v) { + switch(v->type) { + case ATV_NOVALUE: + return calloc(1, sizeof(*v)); + case ATV_REFERENCED: + return asn1p_value_fromref(v->value.reference, 1); + case ATV_REAL: + return asn1p_value_fromdouble(v->value.v_double); + case ATV_INTEGER: + case ATV_MIN: + case ATV_MAX: + case ATV_FALSE: + case ATV_TRUE: + clone = asn1p_value_fromint(v->value.v_integer); + if(clone) clone->type = v->type; + return clone; + case ATV_STRING: + clone = asn1p_value_frombuf(v->value.string.buf, + v->value.string.size, 1); + if(clone) clone->type = v->type; + return clone; + case ATV_UNPARSED: + clone = asn1p_value_frombuf(v->value.string.buf, + v->value.string.size, 1); + if(clone) clone->type = ATV_UNPARSED; + return clone; + case ATV_BITVECTOR: + return asn1p_value_frombuf(v->value.binary_vector.bits, + v->value.binary_vector.size_in_bits, 1); + } + } + return v; +} + +void +asn1p_value_free(asn1p_value_t *v) { + if(v) { + switch(v->type) { + case ATV_NOVALUE: + break; + case ATV_REFERENCED: + asn1p_ref_free(v->value.reference); + break; + case ATV_INTEGER: + case ATV_MIN: + case ATV_MAX: + case ATV_FALSE: + case ATV_TRUE: + case ATV_REAL: + /* No freeing necessary */ + break; + case ATV_STRING: + case ATV_UNPARSED: + assert(v->value.string.buf); + free(v->value.string.buf); + break; + case ATV_BITVECTOR: + assert(v->value.binary_vector.bits); + free(v->value.binary_vector.bits); + break; + } + free(v); + } +} + diff --git a/libasn1parser/asn1p_value.h b/libasn1parser/asn1p_value.h new file mode 100644 index 00000000..c9dabfcd --- /dev/null +++ b/libasn1parser/asn1p_value.h @@ -0,0 +1,60 @@ +/* + * A generic value of different syntaxes. + */ +#ifndef ASN1_PARSER_VALUE_H +#define ASN1_PARSER_VALUE_H + +/* + * A wrapper around various kinds of values. + */ +typedef struct asn1p_value_s { + /* + * The value of the element. + */ + enum { + ATV_NOVALUE, + ATV_REFERENCED, + ATV_REAL, + ATV_INTEGER, + ATV_MIN, + ATV_MAX, + ATV_FALSE, + ATV_TRUE, + ATV_STRING, + ATV_UNPARSED, + ATV_BITVECTOR, + } type; /* Value type and location */ + + union { + asn1p_ref_t *reference; + asn1_integer_t v_integer; + double v_double; + /* + * Binary bits vector. + */ + struct { + uint8_t *buf; + int size; + } string; + struct { + uint8_t *bits; + int size_in_bits; + } binary_vector; + } value; +} asn1p_value_t; + +/* + * Constructors and destructor for value. + * If ref, bits or buffer are omitted, the corresponding function returns + * (asn1p_value_t *)0 with errno = EINVAL. + * Allocated value (where applicable) is guaranteed to be NUL-terminated. + */ +asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy); +asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc); +asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy); +asn1p_value_t *asn1p_value_fromdouble(double); +asn1p_value_t *asn1p_value_fromint(asn1_integer_t); +asn1p_value_t *asn1p_value_clone(asn1p_value_t *); +void asn1p_value_free(asn1p_value_t *); + +#endif /* ASN1_PARSER_VALUE_H */ diff --git a/libasn1parser/asn1p_xports.c b/libasn1parser/asn1p_xports.c new file mode 100644 index 00000000..cfc9fa4f --- /dev/null +++ b/libasn1parser/asn1p_xports.c @@ -0,0 +1,34 @@ +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new structure that would hold the EXPORTS or IMPORTS + * clause data. + */ +asn1p_xports_t * +asn1p_xports_new() { + asn1p_xports_t *xp; + + xp = calloc(1, sizeof *xp); + if(xp) { + TQ_INIT(&(xp->members)); + } + + return xp; +} + +/* + * Destroy the xports structure. + */ +void +asn1p_xports_free(asn1p_xports_t *xp) { + if(xp) { + if(xp->from) + free(xp->from); + if(xp->from_oid) + asn1p_oid_free(xp->from_oid); + free(xp); + } +} diff --git a/libasn1parser/asn1p_xports.h b/libasn1parser/asn1p_xports.h new file mode 100644 index 00000000..8f4fade3 --- /dev/null +++ b/libasn1parser/asn1p_xports.h @@ -0,0 +1,40 @@ +/* + * Imports and exports structure. + */ +#ifndef ASN1_PARSE_XPORTS_H +#define ASN1_PARSE_XPORTS_H + + +typedef struct asn1p_xports_s { + /* + * Type of the xports structure. + */ + enum asn1p_xports { + XPT_IMPORTS, + XPT_EXPORTS, + } xports_type; + + /* + * Module name and optional OID, occur after FROM. + */ + char *from; /* Name of the module */ + asn1p_oid_t *from_oid; /* Optional OID of the module */ + + /* + * Number of entities to import. + */ + TQ_HEAD(struct asn1p_expr_s) members; + + /* + * Pointer to the next xports structure in whatever list. + */ + TQ_ENTRY(struct asn1p_xports_s) xp_next; +} asn1p_xports_t; + +/* + * Constructor and destructor. + */ +asn1p_xports_t *asn1p_xports_new(void); +void asn1p_xports_free(asn1p_xports_t *); + +#endif /* ASN1_PARSE_XPORTS_H */ diff --git a/libasn1parser/asn1p_y.c b/libasn1parser/asn1p_y.c new file mode 100644 index 00000000..095c9041 --- /dev/null +++ b/libasn1parser/asn1p_y.c @@ -0,0 +1,3484 @@ + +/* A Bison parser, made from asn1p_y.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define yyparse asn1p_parse +#define yylex asn1p_lex +#define yyerror asn1p_error +#define yylval asn1p_lval +#define yychar asn1p_char +#define yydebug asn1p_debug +#define yynerrs asn1p_nerrs +#define TOK_PPEQ 257 +#define TOK_opaque 258 +#define TOK_bstring 259 +#define TOK_cstring 260 +#define TOK_hstring 261 +#define TOK_identifier 262 +#define TOK_number 263 +#define TOK_number_negative 264 +#define TOK_typereference 265 +#define TOK_objectclassreference 266 +#define TOK_typefieldreference 267 +#define TOK_valuefieldreference 268 +#define TOK_ABSENT 269 +#define TOK_ABSTRACT_SYNTAX 270 +#define TOK_ALL 271 +#define TOK_ANY 272 +#define TOK_APPLICATION 273 +#define TOK_AUTOMATIC 274 +#define TOK_BEGIN 275 +#define TOK_BIT 276 +#define TOK_BMPString 277 +#define TOK_BOOLEAN 278 +#define TOK_BY 279 +#define TOK_CHARACTER 280 +#define TOK_CHOICE 281 +#define TOK_CLASS 282 +#define TOK_COMPONENT 283 +#define TOK_COMPONENTS 284 +#define TOK_CONSTRAINED 285 +#define TOK_CONTAINING 286 +#define TOK_DEFAULT 287 +#define TOK_DEFINITIONS 288 +#define TOK_DEFINED 289 +#define TOK_EMBEDDED 290 +#define TOK_ENCODED 291 +#define TOK_END 292 +#define TOK_ENUMERATED 293 +#define TOK_EXPLICIT 294 +#define TOK_EXPORTS 295 +#define TOK_EXTENSIBILITY 296 +#define TOK_EXTERNAL 297 +#define TOK_FALSE 298 +#define TOK_FROM 299 +#define TOK_GeneralizedTime 300 +#define TOK_GeneralString 301 +#define TOK_GraphicString 302 +#define TOK_IA5String 303 +#define TOK_IDENTIFIER 304 +#define TOK_IMPLICIT 305 +#define TOK_IMPLIED 306 +#define TOK_IMPORTS 307 +#define TOK_INCLUDES 308 +#define TOK_INSTANCE 309 +#define TOK_INTEGER 310 +#define TOK_ISO646String 311 +#define TOK_MAX 312 +#define TOK_MIN 313 +#define TOK_MINUS_INFINITY 314 +#define TOK_NULL 315 +#define TOK_NumericString 316 +#define TOK_OBJECT 317 +#define TOK_ObjectDescriptor 318 +#define TOK_OCTET 319 +#define TOK_OF 320 +#define TOK_OPTIONAL 321 +#define TOK_PATTERN 322 +#define TOK_PDV 323 +#define TOK_PLUS_INFINITY 324 +#define TOK_PRESENT 325 +#define TOK_PrintableString 326 +#define TOK_PRIVATE 327 +#define TOK_REAL 328 +#define TOK_RELATIVE_OID 329 +#define TOK_SEQUENCE 330 +#define TOK_SET 331 +#define TOK_SIZE 332 +#define TOK_STRING 333 +#define TOK_SYNTAX 334 +#define TOK_T61String 335 +#define TOK_TAGS 336 +#define TOK_TeletexString 337 +#define TOK_TRUE 338 +#define TOK_TYPE_IDENTIFIER 339 +#define TOK_UNIQUE 340 +#define TOK_UNIVERSAL 341 +#define TOK_UniversalString 342 +#define TOK_UTCTime 343 +#define TOK_UTF8String 344 +#define TOK_VideotexString 345 +#define TOK_VisibleString 346 +#define TOK_WITH 347 +#define TOK_UNION 348 +#define TOK_INTERSECTION 349 +#define TOK_EXCEPT 350 +#define TOK_TwoDots 351 +#define TOK_ThreeDots 352 +#define TOK_tag 353 + +#line 1 "asn1p_y.y" + + +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +#define YYPARSE_PARAM param +#define YYERROR_VERBOSE + +int yylex(void); +int yyerror(const char *msg); +void asn1p_lexer_hack_push_opaque_state(void); +void asn1p_lexer_hack_enable_with_syntax(void); +#define yylineno asn1p_lineno +extern int asn1p_lineno; + + +static asn1p_value_t * + _convert_bitstring2binary(char *str, int base); + +#define checkmem(ptr) do { \ + if(!(ptr)) \ + return yyerror("Memory failure"); \ + } while(0) + +#define CONSTRAINT_INSERT(root, constr_type, arg1, arg2) do { \ + if(arg1->type != constr_type) { \ + int __ret; \ + root = asn1p_constraint_new(yylineno); \ + checkmem(root); \ + root->type = constr_type; \ + __ret = asn1p_constraint_insert(root, \ + arg1); \ + checkmem(__ret == 0); \ + } else { \ + root = arg1; \ + } \ + if(arg2) { \ + int __ret \ + = asn1p_constraint_insert(root, arg2); \ + checkmem(__ret == 0); \ + } \ + } while(0) + + +#line 57 "asn1p_y.y" +typedef union { + asn1p_t *a_grammar; + asn1p_module_flags_e a_module_flags; + asn1p_module_t *a_module; + asn1p_expr_type_e a_type; /* ASN.1 Type */ + asn1p_expr_t *a_expr; /* Constructed collection */ + asn1p_constraint_t *a_constr; /* Constraint */ + enum asn1p_constraint_type_e a_ctype;/* Constraint type */ + asn1p_xports_t *a_xports; /* IMports/EXports */ + asn1p_oid_t *a_oid; /* Object Identifier */ + asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ + struct asn1p_type_tag_s a_tag; /* A tag */ + asn1p_ref_t *a_ref; /* Reference to custom type */ + asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ + asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ + struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ + asn1p_value_t *a_value; /* Number, DefinedValue, etc */ + struct asn1p_param_s a_parg; /* A parameter argument */ + asn1p_paramlist_t *a_plist; /* A pargs list */ + enum asn1p_expr_marker_e a_marker; /* OPTIONAL/DEFAULT */ + enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ + asn1_integer_t a_int; + char *tv_str; + struct { + char *buf; + int len; + } tv_opaque; + struct { + char *name; + struct asn1p_type_tag_s tag; + } tv_nametag; +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 375 +#define YYFLAG -32768 +#define YYNTBASE 113 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 353 ? yytranslate[x] : 211) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 109, 2, 2, 2, 2, 2, 2, 104, + 105, 2, 2, 107, 2, 110, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 108, 106, 111, + 2, 2, 2, 112, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 96, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 102, 94, 103, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 95, 97, 98, + 99, 100, 101 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 7, 16, 17, 19, 23, 26, 28, + 31, 33, 38, 40, 41, 43, 45, 48, 51, 54, + 57, 60, 61, 63, 65, 68, 70, 72, 74, 76, + 78, 80, 84, 87, 89, 92, 97, 99, 103, 105, + 107, 111, 115, 118, 120, 124, 126, 128, 135, 137, + 139, 140, 142, 147, 152, 156, 163, 165, 169, 171, + 175, 179, 181, 185, 187, 189, 191, 195, 201, 202, + 204, 206, 210, 213, 217, 222, 223, 225, 226, 233, + 235, 238, 240, 242, 245, 247, 251, 253, 257, 261, + 263, 265, 267, 272, 274, 278, 280, 284, 288, 290, + 294, 296, 300, 302, 304, 306, 308, 313, 314, 318, + 320, 322, 324, 326, 328, 330, 334, 336, 339, 341, + 343, 345, 347, 350, 353, 355, 357, 360, 363, 365, + 367, 369, 371, 374, 376, 379, 381, 383, 385, 387, + 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, + 412, 417, 422, 427, 432, 434, 439, 440, 442, 444, + 446, 448, 450, 452, 457, 459, 462, 466, 468, 472, + 478, 480, 484, 486, 488, 492, 494, 498, 500, 504, + 506, 510, 515, 517, 519, 521, 524, 527, 531, 533, + 535, 537, 539, 541, 543, 545, 547, 549, 555, 557, + 561, 563, 567, 568, 570, 572, 574, 576, 578, 580, + 584, 589, 591, 595, 598, 602, 604, 608, 609, 611, + 613, 616, 618, 620, 621, 625, 628, 632, 634, 638, + 640, 645, 650, 652, 654, 656, 658, 659, 661, 663, + 666, 669, 671, 673, 675, 677, 679 +}; + +static const short yyrhs[] = { 114, + 0, 115, 0, 114, 115, 0, 207, 116, 34, 120, + 3, 21, 123, 38, 0, 0, 117, 0, 102, 118, + 103, 0, 102, 103, 0, 119, 0, 118, 119, 0, + 209, 0, 209, 104, 9, 105, 0, 9, 0, 0, + 121, 0, 122, 0, 121, 122, 0, 40, 82, 0, + 51, 82, 0, 20, 82, 0, 42, 52, 0, 0, + 124, 0, 125, 0, 124, 125, 0, 126, 0, 131, + 0, 137, 0, 161, 0, 134, 0, 169, 0, 53, + 127, 106, 0, 53, 45, 0, 128, 0, 127, 128, + 0, 129, 45, 207, 116, 0, 130, 0, 129, 107, + 130, 0, 207, 0, 209, 0, 41, 132, 106, 0, + 41, 17, 106, 0, 41, 106, 0, 133, 0, 132, + 107, 133, 0, 207, 0, 209, 0, 207, 135, 3, + 102, 136, 103, 0, 156, 0, 166, 0, 0, 177, + 0, 207, 3, 205, 85, 0, 207, 3, 205, 153, + 0, 207, 3, 143, 0, 207, 102, 138, 103, 3, + 153, 0, 139, 0, 138, 107, 139, 0, 207, 0, + 207, 108, 209, 0, 166, 108, 209, 0, 141, 0, + 140, 107, 141, 0, 155, 0, 209, 0, 152, 0, + 142, 107, 152, 0, 28, 102, 145, 103, 147, 0, + 0, 86, 0, 146, 0, 145, 107, 146, 0, 159, + 197, 0, 159, 153, 144, 0, 159, 159, 197, 144, + 0, 0, 148, 0, 0, 93, 80, 102, 149, 150, + 103, 0, 151, 0, 150, 151, 0, 4, 0, 159, + 0, 210, 153, 0, 154, 0, 155, 171, 197, 0, + 100, 0, 100, 109, 164, 0, 100, 109, 204, 0, + 168, 0, 169, 0, 170, 0, 207, 102, 140, 103, + 0, 156, 0, 55, 66, 156, 0, 11, 0, 11, + 110, 207, 0, 11, 110, 209, 0, 208, 0, 208, + 110, 157, 0, 158, 0, 157, 110, 158, 0, 160, + 0, 160, 0, 13, 0, 14, 0, 209, 135, 3, + 162, 0, 0, 102, 163, 165, 0, 5, 0, 7, + 0, 6, 0, 204, 0, 164, 0, 209, 0, 207, + 110, 209, 0, 4, 0, 165, 4, 0, 24, 0, + 61, 0, 74, 0, 167, 0, 65, 79, 0, 63, + 50, 0, 75, 0, 43, 0, 36, 69, 0, 26, + 79, 0, 89, 0, 46, 0, 56, 0, 39, 0, + 22, 79, 0, 166, 0, 167, 201, 0, 23, 0, + 47, 0, 48, 0, 49, 0, 57, 0, 62, 0, + 72, 0, 81, 0, 83, 0, 88, 0, 90, 0, + 91, 0, 92, 0, 64, 0, 27, 102, 142, 103, + 0, 76, 102, 142, 103, 0, 77, 102, 142, 103, + 0, 76, 171, 66, 155, 0, 77, 171, 66, 155, + 0, 18, 0, 18, 35, 25, 209, 0, 0, 175, + 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, + 0, 78, 104, 177, 105, 0, 176, 0, 175, 176, + 0, 104, 177, 105, 0, 178, 0, 178, 107, 100, + 0, 178, 107, 100, 107, 178, 0, 100, 0, 100, + 107, 178, 0, 179, 0, 180, 0, 179, 172, 180, + 0, 181, 0, 180, 173, 181, 0, 182, 0, 181, + 174, 182, 0, 185, 0, 185, 183, 185, 0, 184, + 104, 177, 105, 0, 191, 0, 186, 0, 99, 0, + 99, 111, 0, 111, 99, 0, 111, 99, 111, 0, + 78, 0, 45, 0, 204, 0, 209, 0, 6, 0, + 59, 0, 58, 0, 44, 0, 84, 0, 93, 30, + 102, 187, 103, 0, 188, 0, 187, 107, 188, 0, + 100, 0, 209, 171, 189, 0, 0, 190, 0, 71, + 0, 15, 0, 67, 0, 192, 0, 193, 0, 102, + 207, 103, 0, 192, 102, 194, 103, 0, 195, 0, + 194, 107, 195, 0, 112, 196, 0, 112, 110, 196, + 0, 209, 0, 196, 110, 209, 0, 0, 198, 0, + 67, 0, 33, 199, 0, 185, 0, 166, 0, 0, + 102, 200, 165, 0, 102, 103, 0, 102, 202, 103, + 0, 203, 0, 202, 107, 203, 0, 209, 0, 209, + 104, 204, 105, 0, 209, 104, 164, 105, 0, 204, + 0, 100, 0, 9, 0, 10, 0, 0, 206, 0, + 101, 0, 101, 51, 0, 101, 40, 0, 11, 0, + 12, 0, 12, 0, 8, 0, 209, 0, 209, 206, + 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 297, 303, 309, 325, 350, 352, 355, 359, 364, 371, + 379, 384, 388, 397, 399, 407, 411, 419, 423, 426, + 429, 437, 439, 448, 452, 477, 481, 490, 497, 510, + 521, 534, 541, 546, 552, 558, 567, 573, 579, 586, + 594, 598, 601, 608, 614, 620, 627, 636, 646, 654, + 662, 664, 676, 688, 695, 711, 721, 731, 741, 746, + 753, 763, 769, 775, 779, 791, 797, 803, 813, 815, + 818, 826, 832, 841, 846, 863, 865, 870, 874, 879, + 884, 890, 894, 919, 926, 931, 939, 948, 957, 968, + 972, 978, 986, 1010, 1017, 1031, 1040, 1050, 1060, 1068, + 1089, 1098, 1107, 1108, 1110, 1117, 1129, 1139, 1141, 1146, + 1150, 1154, 1158, 1161, 1166, 1178, 1194, 1205, 1219, 1221, + 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, + 1237, 1239, 1240, 1243, 1250, 1262, 1264, 1268, 1272, 1273, + 1274, 1275, 1276, 1280, 1281, 1282, 1283, 1287, 1288, 1291, + 1298, 1304, 1310, 1318, 1326, 1332, 1348, 1350, 1353, 1353, + 1354, 1354, 1355, 1357, 1370, 1373, 1378, 1384, 1388, 1395, + 1403, 1408, 1417, 1419, 1421, 1426, 1428, 1434, 1436, 1441, + 1448, 1455, 1463, 1466, 1471, 1473, 1474, 1475, 1478, 1482, + 1487, 1491, 1502, 1506, 1511, 1516, 1521, 1528, 1534, 1538, + 1543, 1549, 1561, 1563, 1566, 1570, 1573, 1578, 1582, 1590, + 1605, 1611, 1618, 1631, 1643, 1658, 1662, 1679, 1681, 1684, + 1688, 1694, 1697, 1699, 1699, 1719, 1724, 1729, 1735, 1741, + 1749, 1757, 1765, 1772, 1782, 1787, 1817, 1819, 1822, 1827, + 1831, 1837, 1842, 1848, 1855, 1862, 1867 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","TOK_PPEQ", +"TOK_opaque","TOK_bstring","TOK_cstring","TOK_hstring","TOK_identifier","TOK_number", +"TOK_number_negative","TOK_typereference","TOK_objectclassreference","TOK_typefieldreference", +"TOK_valuefieldreference","TOK_ABSENT","TOK_ABSTRACT_SYNTAX","TOK_ALL","TOK_ANY", +"TOK_APPLICATION","TOK_AUTOMATIC","TOK_BEGIN","TOK_BIT","TOK_BMPString","TOK_BOOLEAN", +"TOK_BY","TOK_CHARACTER","TOK_CHOICE","TOK_CLASS","TOK_COMPONENT","TOK_COMPONENTS", +"TOK_CONSTRAINED","TOK_CONTAINING","TOK_DEFAULT","TOK_DEFINITIONS","TOK_DEFINED", +"TOK_EMBEDDED","TOK_ENCODED","TOK_END","TOK_ENUMERATED","TOK_EXPLICIT","TOK_EXPORTS", +"TOK_EXTENSIBILITY","TOK_EXTERNAL","TOK_FALSE","TOK_FROM","TOK_GeneralizedTime", +"TOK_GeneralString","TOK_GraphicString","TOK_IA5String","TOK_IDENTIFIER","TOK_IMPLICIT", +"TOK_IMPLIED","TOK_IMPORTS","TOK_INCLUDES","TOK_INSTANCE","TOK_INTEGER","TOK_ISO646String", +"TOK_MAX","TOK_MIN","TOK_MINUS_INFINITY","TOK_NULL","TOK_NumericString","TOK_OBJECT", +"TOK_ObjectDescriptor","TOK_OCTET","TOK_OF","TOK_OPTIONAL","TOK_PATTERN","TOK_PDV", +"TOK_PLUS_INFINITY","TOK_PRESENT","TOK_PrintableString","TOK_PRIVATE","TOK_REAL", +"TOK_RELATIVE_OID","TOK_SEQUENCE","TOK_SET","TOK_SIZE","TOK_STRING","TOK_SYNTAX", +"TOK_T61String","TOK_TAGS","TOK_TeletexString","TOK_TRUE","TOK_TYPE_IDENTIFIER", +"TOK_UNIQUE","TOK_UNIVERSAL","TOK_UniversalString","TOK_UTCTime","TOK_UTF8String", +"TOK_VideotexString","TOK_VisibleString","TOK_WITH","'|'","TOK_UNION","'^'", +"TOK_INTERSECTION","TOK_EXCEPT","TOK_TwoDots","TOK_ThreeDots","TOK_tag","'{'", +"'}'","'('","')'","';'","','","':'","'!'","'.'","'<'","'@'","ParsedGrammar", +"ModuleList","ModuleSpecification","optObjectIdentifier","ObjectIdentifier", +"ObjectIdentifierBody","ObjectIdentifierElement","optModuleSpecificationFlags", +"ModuleSpecificationFlags","ModuleSpecificationFlag","optModuleSpecificationBody", +"ModuleSpecificationBody","ModuleSpecificationElement","ImportsDefinition","ImportsBundleSet", +"ImportsBundle","ImportsList","ImportsElement","ExportsDefinition","ExportsBody", +"ExportsElement","ValueSetDefinition","DefinedTypeRef","optValueSetBody","DataTypeReference", +"ParameterArgumentList","ParameterArgumentName","ActualParameterList","ActualParameter", +"ConstructedDataTypeDefinition","ClassDeclaration","optUnique","ClassFieldList", +"ClassField","optWithSyntax","WithSyntax","@1","WithSyntaxFormat","WithSyntaxFormatToken", +"DataTypeMember","ConstrainedTypeDeclaration","ExtensionAndException","TypeDeclaration", +"ComplexTypeReference","ComplexTypeReferenceAmpList","ComplexTypeReferenceElement", +"ClassFieldIdentifier","ClassFieldName","ValueDefinition","InlineOrDefinedValue", +"@2","DefinedValue","Opaque","BasicTypeId","BasicTypeId_UniverationCompatible", +"BasicType","BasicString","ConstructedType","optConstraints","Union","Intersection", +"Except","Constraints","SingleConstraint","ConstraintElementSet","ConstraintElement", +"ConstraintElementUnion","ConstraintElementIntersection","ConstraintElementException", +"ConstraintSubtypeElement","ConstraintRangeSpec","ConstraintSpec","ConstraintValue", +"WithComponents","WithComponentsList","WithComponentsElement","optPresenceConstraint", +"PresenceConstraint","TableConstraint","SimpleTableConstraint","ComponentRelationConstraint", +"AtNotationList","AtNotationElement","ComponentIdList","optMarker","Marker", +"DefaultValue","@3","UniverationDefinition","UniverationList","UniverationElement", +"SignedNumber","optTag","Tag","TypeRefName","ObjectClassReference","Identifier", +"TaggedIdentifier", NULL +}; +#endif + +static const short yyr1[] = { 0, + 113, 114, 114, 115, 116, 116, 117, 117, 118, 118, + 119, 119, 119, 120, 120, 121, 121, 122, 122, 122, + 122, 123, 123, 124, 124, 125, 125, 125, 125, 125, + 125, 126, 126, 127, 127, 128, 129, 129, 130, 130, + 131, 131, 131, 132, 132, 133, 133, 134, 135, 135, + 136, 136, 137, 137, 137, 137, 138, 138, 139, 139, + 139, 140, 140, 141, 141, 142, 142, 143, 144, 144, + 145, 145, 146, 146, 146, 147, 147, 149, 148, 150, + 150, 151, 151, 152, 152, 153, 154, 154, 154, 155, + 155, 155, 155, 155, 155, 156, 156, 156, 156, 156, + 157, 157, 158, 159, 160, 160, 161, 163, 162, 162, + 162, 162, 162, 162, 164, 164, 165, 165, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, + 167, 167, 167, 168, 168, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 170, + 170, 170, 170, 170, 170, 170, 171, 171, 172, 172, + 173, 173, 174, 175, 175, 175, 176, 177, 177, 177, + 177, 177, 178, 179, 179, 180, 180, 181, 181, 182, + 182, 182, 182, 182, 183, 183, 183, 183, 184, 184, + 185, 185, 185, 185, 185, 185, 185, 186, 187, 187, + 188, 188, 189, 189, 190, 190, 190, 191, 191, 192, + 193, 194, 194, 195, 195, 196, 196, 197, 197, 198, + 198, 199, 199, 200, 199, 201, 201, 202, 202, 203, + 203, 203, 203, 203, 204, 204, 205, 205, 206, 206, + 206, 207, 207, 208, 209, 210, 210 +}; + +static const short yyr2[] = { 0, + 1, 1, 2, 8, 0, 1, 3, 2, 1, 2, + 1, 4, 1, 0, 1, 1, 2, 2, 2, 2, + 2, 0, 1, 1, 2, 1, 1, 1, 1, 1, + 1, 3, 2, 1, 2, 4, 1, 3, 1, 1, + 3, 3, 2, 1, 3, 1, 1, 6, 1, 1, + 0, 1, 4, 4, 3, 6, 1, 3, 1, 3, + 3, 1, 3, 1, 1, 1, 3, 5, 0, 1, + 1, 3, 2, 3, 4, 0, 1, 0, 6, 1, + 2, 1, 1, 2, 1, 3, 1, 3, 3, 1, + 1, 1, 4, 1, 3, 1, 3, 3, 1, 3, + 1, 3, 1, 1, 1, 1, 4, 0, 3, 1, + 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, + 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, + 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 1, 4, 0, 1, 1, 1, + 1, 1, 1, 4, 1, 2, 3, 1, 3, 5, + 1, 3, 1, 1, 3, 1, 3, 1, 3, 1, + 3, 4, 1, 1, 1, 2, 2, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 5, 1, 3, + 1, 3, 0, 1, 1, 1, 1, 1, 1, 3, + 4, 1, 3, 2, 3, 1, 3, 0, 1, 1, + 2, 1, 1, 0, 3, 2, 3, 1, 3, 1, + 4, 4, 1, 1, 1, 1, 0, 1, 1, 2, + 2, 1, 1, 1, 1, 1, 2 +}; + +static const short yydefact[] = { 0, + 242, 243, 1, 2, 5, 3, 0, 0, 6, 245, + 13, 8, 0, 9, 11, 14, 7, 10, 0, 0, + 0, 0, 0, 0, 15, 16, 0, 20, 18, 21, + 19, 0, 17, 12, 22, 136, 0, 137, 138, 139, + 0, 140, 141, 149, 142, 143, 144, 145, 146, 147, + 148, 0, 23, 24, 26, 27, 30, 28, 29, 31, + 0, 0, 0, 43, 0, 44, 46, 47, 33, 0, + 34, 0, 37, 39, 40, 4, 25, 237, 96, 244, + 0, 119, 0, 0, 132, 126, 130, 131, 120, 0, + 0, 121, 125, 129, 0, 0, 49, 50, 122, 99, + 0, 42, 41, 0, 32, 35, 0, 0, 0, 239, + 55, 0, 238, 0, 133, 128, 127, 124, 123, 0, + 57, 0, 59, 0, 0, 0, 45, 5, 38, 0, + 241, 240, 96, 244, 155, 0, 0, 157, 157, 53, + 54, 157, 94, 134, 122, 90, 91, 92, 0, 97, + 98, 0, 0, 0, 0, 51, 105, 106, 100, 101, + 103, 110, 112, 111, 235, 236, 108, 107, 114, 113, + 0, 115, 36, 0, 71, 218, 104, 0, 0, 0, + 0, 0, 0, 0, 158, 165, 0, 0, 218, 0, + 135, 0, 0, 58, 61, 60, 193, 196, 190, 195, + 194, 189, 197, 0, 171, 0, 0, 52, 168, 173, + 174, 176, 178, 0, 180, 184, 183, 208, 209, 191, + 192, 0, 0, 0, 76, 0, 0, 220, 69, 218, + 73, 219, 0, 87, 0, 66, 85, 246, 0, 95, + 0, 0, 0, 0, 166, 0, 0, 86, 234, 226, + 0, 228, 233, 230, 0, 62, 64, 65, 56, 0, + 0, 0, 48, 0, 159, 160, 0, 161, 162, 0, + 163, 0, 0, 185, 0, 0, 0, 102, 117, 109, + 116, 0, 68, 77, 72, 224, 223, 222, 221, 70, + 74, 69, 156, 0, 150, 0, 247, 84, 0, 151, + 167, 153, 152, 154, 227, 0, 0, 93, 0, 0, + 172, 210, 169, 175, 177, 179, 0, 186, 187, 181, + 0, 0, 212, 118, 0, 0, 75, 88, 89, 67, + 164, 229, 0, 0, 63, 201, 0, 199, 157, 0, + 182, 188, 0, 214, 216, 211, 0, 78, 225, 232, + 231, 198, 0, 203, 170, 215, 0, 213, 0, 200, + 206, 207, 205, 202, 204, 217, 82, 0, 80, 83, + 79, 81, 0, 0, 0 +}; + +static const short yydefgoto[] = { 373, + 3, 4, 8, 9, 13, 14, 24, 25, 26, 52, + 53, 54, 55, 70, 71, 72, 73, 56, 65, 66, + 57, 96, 207, 58, 120, 121, 255, 256, 235, 111, + 291, 174, 175, 283, 284, 359, 368, 369, 236, 141, + 237, 142, 143, 159, 160, 176, 177, 59, 168, 223, + 169, 280, 144, 145, 146, 147, 148, 184, 267, 270, + 272, 185, 186, 208, 209, 210, 211, 212, 213, 276, + 214, 215, 216, 337, 338, 364, 365, 217, 218, 219, + 322, 323, 344, 231, 232, 289, 326, 191, 251, 252, + 220, 112, 113, 149, 100, 221, 239 +}; + +static const short yypact[] = { 81, +-32768,-32768, 81,-32768, -45,-32768, 23, 70,-32768,-32768, +-32768,-32768, 47,-32768, 31, 190,-32768,-32768, 132, 61, + 69, 108, 86, 176, 190,-32768, 76,-32768,-32768,-32768, +-32768, 166,-32768,-32768, 442,-32768, 32,-32768,-32768,-32768, + 121,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 168, 442,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 179, 732, 103,-32768, 52,-32768,-32768,-32768,-32768, 39, +-32768, 16,-32768,-32768,-32768,-32768,-32768, -11, 111,-32768, + 150,-32768, 152, 142,-32768,-32768,-32768,-32768,-32768, 184, + 159,-32768,-32768,-32768, 748, 240,-32768,-32768,-32768, 135, + 243,-32768,-32768, 141,-32768,-32768, 81, 141, 145, 60, +-32768, 599,-32768, 141,-32768,-32768,-32768,-32768,-32768, -1, +-32768, 143, 144, 147, 206, 68,-32768, -45,-32768, 206, +-32768,-32768, -42, 148, 221, 161, 198, 40, 53,-32768, +-32768, -37,-32768,-32768, 163,-32768,-32768,-32768, 164,-32768, +-32768, 264, 748, 261, 261, 155,-32768,-32768, 160,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 162,-32768,-32768, 64,-32768, 524,-32768, 246, 21, 212, + 169, 21, 155, 208, 171,-32768, 21, 210, 2, 17, +-32768, 383, 674,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768, 247, 172, 81, 175,-32768, 173, 133, + 140, 185,-32768, 178, 35,-32768,-32768, 182,-32768,-32768, +-32768, 206, 281, 261, 193, 206, 301,-32768, 202, 2, +-32768,-32768, 261, 181, 66,-32768,-32768, 191, 674,-32768, + 155, 71, 186, 674,-32768, 89, 674,-32768,-32768,-32768, + 90,-32768,-32768, 189, 91,-32768,-32768,-32768,-32768, 192, + 309, 194,-32768, 196,-32768,-32768, 309,-32768,-32768, 309, +-32768, 309, 155, 187, 205, 78, 200,-32768,-32768, 297, +-32768, 225,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 202,-32768, 250,-32768, 21,-32768,-32768, 201,-32768, +-32768,-32768,-32768,-32768,-32768, 56, 250,-32768, 383, 25, +-32768,-32768, 209, 140, 185,-32768, 215,-32768, 211,-32768, + 6, 101,-32768,-32768, 219, 281,-32768,-32768,-32768,-32768, +-32768,-32768, 223, 224,-32768,-32768, 109,-32768, -37, 309, +-32768,-32768, 261, 203,-32768,-32768, 200,-32768, 297,-32768, +-32768,-32768, 25, 24,-32768, 203, 261,-32768, 126,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 9,-32768,-32768, +-32768,-32768, 324, 326,-32768 +}; + +static const short yypgoto[] = {-32768, +-32768, 327, 204,-32768,-32768, 318,-32768,-32768, 308,-32768, +-32768, 282,-32768,-32768, 268,-32768, 226,-32768,-32768, 235, +-32768, 279,-32768,-32768,-32768, 195,-32768, 33, -129,-32768, + 51,-32768, 123,-32768,-32768,-32768,-32768, -17, 59, -156, +-32768, -185, -52,-32768, 130, -173, -109,-32768,-32768,-32768, + -209, 30, -50, -43,-32768, 46,-32768, -137,-32768,-32768, +-32768,-32768, 180, -159, -246,-32768, 94, 88, 97,-32768, +-32768, -206,-32768,-32768, 10,-32768,-32768,-32768,-32768,-32768, +-32768, 26, 27, -141,-32768,-32768,-32768,-32768,-32768, 65, + -118,-32768, 134, 1,-32768, -7,-32768 +}; + + +#define YYLAST 837 + + +static const short yytable[] = { 15, + 5, 188, 230, 5, 189, 15, 257, 170, 97, 97, + 98, 98, 367, 10, 311, 161, 109, 99, 99, 229, + 288, 157, 158, 243, 10, 165, 166, 62, 10, 68, + 10, 11, 10, 75, 227, 61, 259, 67, 361, 10, + 181, 74, 1, 2, 122, 62, 10, 248, 63, 1, + 2, 99, 242, 61, 10, 11, 7, 246, 302, -242, + 107, 304, 75, 10, 165, 166, 183, 114, 228, 320, + 74, 253, 162, 163, 164, 10, 165, 166, 1, 2, + 60, 299, 298, 197, 328, 10, 165, 166, 292, 110, + 362, 1, 2, 355, 363, 123, 68, 333, 60, 131, + 75, 152, 122, 16, 67, 153, 151, 128, 74, 99, + 132, 371, 161, 317, 150, 343, 249, 181, 172, 250, + 234, 198, 108, 257, 336, 12, 171, 240, 10, 367, + 181, 1, 2, 274, 19, 200, 201, 64, 157, 158, + 27, 182, 28, 183, 105, 275, 195, 196, 10, 17, + 29, 1, 2, 123, 187, 249, 183, 103, 104, 30, + 197, 203, 10, 165, 166, 69, 225, 31, 295, 167, + 226, 238, 296, 300, 238, 329, 287, 296, 32, 238, + 34, 78, 254, 99, 258, 370, 35, 253, 334, 79, + 80, 303, 305, 308, 370, 296, 306, 309, 198, 199, + 81, 354, 82, 346, 83, 76, 262, 347, 102, 20, + 117, 352, 200, 201, 84, 353, 281, 85, 157, 158, + 114, 86, 79, 80, 87, 293, 265, 266, 115, 21, + 116, 22, 202, 118, 88, 268, 269, 119, 203, 89, + 23, 90, 124, 91, 125, 126, 130, 204, 156, -243, + 154, 155, 92, 93, 205, 178, 206, 10, 165, 166, + 1, 2, 179, 180, 190, 192, 193, 94, 10, 222, + 233, 224, 241, 244, 183, 247, 260, 263, 261, 264, + 95, 273, 271, 277, 279, 282, 172, 290, 238, 294, + 301, 110, 307, 310, 171, 313, 312, 318, 254, 172, + 324, 258, 339, 319, 325, 331, 197, 171, 10, 165, + 166, 321, 357, 345, 197, 340, 10, 165, 166, 341, + 348, 342, 81, 374, 82, 375, 83, 350, 351, 6, + 18, 173, 33, 129, 77, 345, 84, 106, 127, 85, + 101, 335, 327, 86, 198, 339, 87, 194, 285, 366, + 372, 278, 198, 199, 330, 349, 88, 315, 200, 201, + 314, 89, 360, 90, 245, 91, 200, 201, 316, 356, + 332, 297, 358, 0, 92, 93, 0, 0, 0, 0, + 0, 0, 0, 0, 203, 0, 202, 0, 0, 94, + 10, 0, 203, 133, 134, 0, 0, 0, 0, 0, + 135, 204, 286, 0, 81, 36, 82, 0, 83, 136, + 206, 0, 0, 0, 0, 0, 0, 0, 84, 0, + 0, 85, 0, 0, 0, 86, 0, 0, 87, 38, + 39, 40, 0, 0, 0, 0, 0, 137, 88, 42, + 0, 0, 0, 89, 43, 90, 44, 91, 0, 10, + 0, 0, 1, 2, 45, 0, 92, 93, 138, 139, + 0, 0, 0, 46, 36, 47, 0, 0, 0, 0, + 48, 94, 49, 50, 51, 0, 0, 0, 0, 0, + 0, 0, 37, 0, 0, 0, 0, 0, 38, 39, + 40, 0, 0, 0, 41, 0, 0, 0, 42, 0, + 0, 0, 0, 43, 0, 44, 0, 0, 0, 0, + 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, + 0, 0, 46, 0, 47, 0, 0, 0, 0, 48, + 0, 49, 50, 51, 133, 134, 157, 158, 0, 0, + 0, 135, 0, 0, 0, 81, 36, 82, 0, 83, + 136, 0, 0, 0, 0, 0, 227, 0, 0, 84, + 0, 0, 85, 0, 0, 0, 86, 0, 0, 87, + 38, 39, 40, 0, 0, 0, 0, 0, 137, 88, + 42, 0, 0, 0, 89, 43, 90, 44, 91, 0, + 228, 0, 0, 0, 0, 45, 0, 92, 93, 138, + 139, 0, 0, 0, 46, 0, 47, 0, 0, 133, + 134, 48, 94, 49, 50, 51, 135, 0, 0, 0, + 81, 36, 82, 0, 83, 136, 0, 0, 0, 0, + 0, 0, 0, 0, 84, 0, 0, 85, 0, 0, + 0, 86, 0, 0, 87, 38, 39, 40, 0, 0, + 0, 0, 0, 137, 88, 42, 0, 0, 0, 89, + 43, 90, 44, 91, 0, 0, 0, 0, 0, 0, + 45, 0, 92, 93, 138, 139, 0, 0, 0, 46, + 0, 47, 0, 140, 133, 134, 48, 94, 49, 50, + 51, 135, 0, 0, 0, 81, 36, 82, 0, 83, + 136, 0, 0, 0, 0, 0, 0, 0, 0, 84, + 0, 0, 85, 0, 0, 0, 86, 0, 0, 87, + 38, 39, 40, 0, 0, 0, 0, 0, 137, 88, + 42, 0, 0, 0, 89, 43, 90, 44, 91, 0, + 0, 0, 79, 80, 0, 45, 0, 92, 93, 138, + 139, 0, 0, 81, 46, 82, 47, 83, 1, 2, + 0, 48, 94, 49, 50, 51, 0, 84, 0, 81, + 85, 82, 0, 83, 86, 0, 0, 87, 0, 0, + 0, 0, 0, 84, 0, 0, 85, 88, 0, 0, + 86, 0, 89, 87, 90, 0, 91, 0, 0, 0, + 0, 0, 0, 88, 0, 92, 93, 0, 89, 0, + 90, 0, 91, 0, 0, 0, 0, 0, 0, 0, + 94, 92, 93, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 94 +}; + +static const short yycheck[] = { 7, + 0, 139, 176, 3, 142, 13, 192, 126, 61, 62, + 61, 62, 4, 8, 261, 125, 28, 61, 62, 176, + 227, 13, 14, 183, 8, 9, 10, 35, 8, 37, + 8, 9, 8, 41, 33, 35, 193, 37, 15, 8, + 78, 41, 11, 12, 95, 53, 8, 189, 17, 11, + 12, 95, 182, 53, 8, 9, 102, 187, 244, 102, + 45, 247, 70, 8, 9, 10, 104, 110, 67, 276, + 70, 190, 5, 6, 7, 8, 9, 10, 11, 12, + 35, 241, 239, 6, 294, 8, 9, 10, 230, 101, + 67, 11, 12, 340, 71, 95, 104, 307, 53, 40, + 108, 103, 153, 34, 104, 107, 114, 107, 108, 153, + 51, 103, 222, 273, 114, 110, 100, 78, 126, 103, + 100, 44, 107, 309, 100, 103, 126, 180, 8, 4, + 78, 11, 12, 99, 104, 58, 59, 106, 13, 14, + 9, 102, 82, 104, 106, 111, 154, 155, 8, 103, + 82, 11, 12, 153, 102, 100, 104, 106, 107, 52, + 6, 84, 8, 9, 10, 45, 103, 82, 103, 102, + 107, 179, 107, 103, 182, 294, 227, 107, 3, 187, + 105, 3, 190, 227, 192, 359, 21, 306, 307, 11, + 12, 103, 103, 103, 368, 107, 107, 107, 44, 45, + 22, 339, 24, 103, 26, 38, 206, 107, 106, 20, + 69, 103, 58, 59, 36, 107, 224, 39, 13, 14, + 110, 43, 11, 12, 46, 233, 94, 95, 79, 40, + 79, 42, 78, 50, 56, 96, 97, 79, 84, 61, + 51, 63, 3, 65, 110, 3, 102, 93, 102, 102, + 108, 108, 74, 75, 100, 35, 102, 8, 9, 10, + 11, 12, 102, 66, 102, 102, 3, 89, 8, 110, + 25, 110, 104, 66, 104, 66, 30, 103, 107, 107, + 102, 104, 98, 102, 4, 93, 294, 86, 296, 109, + 105, 101, 104, 102, 294, 100, 103, 111, 306, 307, + 4, 309, 310, 99, 80, 105, 6, 307, 8, 9, + 10, 112, 110, 321, 6, 107, 8, 9, 10, 105, + 102, 111, 22, 0, 24, 0, 26, 105, 105, 3, + 13, 128, 25, 108, 53, 343, 36, 70, 104, 39, + 62, 309, 292, 43, 44, 353, 46, 153, 226, 357, + 368, 222, 44, 45, 296, 326, 56, 270, 58, 59, + 267, 61, 353, 63, 185, 65, 58, 59, 272, 343, + 306, 238, 347, -1, 74, 75, -1, -1, -1, -1, + -1, -1, -1, -1, 84, -1, 78, -1, -1, 89, + 8, -1, 84, 11, 12, -1, -1, -1, -1, -1, + 18, 93, 102, -1, 22, 23, 24, -1, 26, 27, + 102, -1, -1, -1, -1, -1, -1, -1, 36, -1, + -1, 39, -1, -1, -1, 43, -1, -1, 46, 47, + 48, 49, -1, -1, -1, -1, -1, 55, 56, 57, + -1, -1, -1, 61, 62, 63, 64, 65, -1, 8, + -1, -1, 11, 12, 72, -1, 74, 75, 76, 77, + -1, -1, -1, 81, 23, 83, -1, -1, -1, -1, + 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, + -1, -1, 41, -1, -1, -1, -1, -1, 47, 48, + 49, -1, -1, -1, 53, -1, -1, -1, 57, -1, + -1, -1, -1, 62, -1, 64, -1, -1, -1, -1, + -1, -1, -1, 72, -1, -1, -1, -1, -1, -1, + -1, -1, 81, -1, 83, -1, -1, -1, -1, 88, + -1, 90, 91, 92, 11, 12, 13, 14, -1, -1, + -1, 18, -1, -1, -1, 22, 23, 24, -1, 26, + 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, + -1, -1, 39, -1, -1, -1, 43, -1, -1, 46, + 47, 48, 49, -1, -1, -1, -1, -1, 55, 56, + 57, -1, -1, -1, 61, 62, 63, 64, 65, -1, + 67, -1, -1, -1, -1, 72, -1, 74, 75, 76, + 77, -1, -1, -1, 81, -1, 83, -1, -1, 11, + 12, 88, 89, 90, 91, 92, 18, -1, -1, -1, + 22, 23, 24, -1, 26, 27, -1, -1, -1, -1, + -1, -1, -1, -1, 36, -1, -1, 39, -1, -1, + -1, 43, -1, -1, 46, 47, 48, 49, -1, -1, + -1, -1, -1, 55, 56, 57, -1, -1, -1, 61, + 62, 63, 64, 65, -1, -1, -1, -1, -1, -1, + 72, -1, 74, 75, 76, 77, -1, -1, -1, 81, + -1, 83, -1, 85, 11, 12, 88, 89, 90, 91, + 92, 18, -1, -1, -1, 22, 23, 24, -1, 26, + 27, -1, -1, -1, -1, -1, -1, -1, -1, 36, + -1, -1, 39, -1, -1, -1, 43, -1, -1, 46, + 47, 48, 49, -1, -1, -1, -1, -1, 55, 56, + 57, -1, -1, -1, 61, 62, 63, 64, 65, -1, + -1, -1, 11, 12, -1, 72, -1, 74, 75, 76, + 77, -1, -1, 22, 81, 24, 83, 26, 11, 12, + -1, 88, 89, 90, 91, 92, -1, 36, -1, 22, + 39, 24, -1, 26, 43, -1, -1, 46, -1, -1, + -1, -1, -1, 36, -1, -1, 39, 56, -1, -1, + 43, -1, 61, 46, 63, -1, 65, -1, -1, -1, + -1, -1, -1, 56, -1, 74, 75, -1, 61, -1, + 63, -1, 65, -1, -1, -1, -1, -1, -1, -1, + 89, 74, 75, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 89 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/share/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 1: +#line 298 "asn1p_y.y" +{ + *(void **)param = yyvsp[0].a_grammar; + ; + break;} +case 2: +#line 304 "asn1p_y.y" +{ + yyval.a_grammar = asn1p_new(); + checkmem(yyval.a_grammar); + TQ_ADD(&(yyval.a_grammar->modules), yyvsp[0].a_module, mod_next); + ; + break;} +case 3: +#line 309 "asn1p_y.y" +{ + yyval.a_grammar = yyvsp[-1].a_grammar; + TQ_ADD(&(yyval.a_grammar->modules), yyvsp[0].a_module, mod_next); + ; + break;} +case 4: +#line 330 "asn1p_y.y" +{ + + if(yyvsp[-1].a_module) { + yyval.a_module = yyvsp[-1].a_module; + } else { + /* There's a chance that a module is just plain empty */ + yyval.a_module = asn1p_module_new(); + } + checkmem(yyval.a_module); + + yyval.a_module->Identifier = yyvsp[-7].tv_str; + yyval.a_module->module_oid = yyvsp[-6].a_oid; + yyval.a_module->module_flags = yyvsp[-4].a_module_flags; + ; + break;} +case 5: +#line 351 "asn1p_y.y" +{ yyval.a_oid = 0; ; + break;} +case 6: +#line 352 "asn1p_y.y" +{ yyval.a_oid = yyvsp[0].a_oid; ; + break;} +case 7: +#line 356 "asn1p_y.y" +{ + yyval.a_oid = yyvsp[-1].a_oid; + ; + break;} +case 8: +#line 359 "asn1p_y.y" +{ + yyval.a_oid = 0; + ; + break;} +case 9: +#line 365 "asn1p_y.y" +{ + yyval.a_oid = asn1p_oid_new(); + asn1p_oid_add_arc(yyval.a_oid, &yyvsp[0].a_oid_arc); + if(yyvsp[0].a_oid_arc.name) + free(yyvsp[0].a_oid_arc.name); + ; + break;} +case 10: +#line 371 "asn1p_y.y" +{ + yyval.a_oid = yyvsp[-1].a_oid; + asn1p_oid_add_arc(yyval.a_oid, &yyvsp[0].a_oid_arc); + if(yyvsp[0].a_oid_arc.name) + free(yyvsp[0].a_oid_arc.name); + ; + break;} +case 11: +#line 380 "asn1p_y.y" +{ /* iso */ + yyval.a_oid_arc.name = yyvsp[0].tv_str; + yyval.a_oid_arc.number = -1; + ; + break;} +case 12: +#line 384 "asn1p_y.y" +{ /* iso(1) */ + yyval.a_oid_arc.name = yyvsp[-3].tv_str; + yyval.a_oid_arc.number = yyvsp[-1].a_int; + ; + break;} +case 13: +#line 388 "asn1p_y.y" +{ /* 1 */ + yyval.a_oid_arc.name = 0; + yyval.a_oid_arc.number = yyvsp[0].a_int; + ; + break;} +case 14: +#line 398 "asn1p_y.y" +{ yyval.a_module_flags = MSF_NOFLAGS; ; + break;} +case 15: +#line 399 "asn1p_y.y" +{ + yyval.a_module_flags = yyvsp[0].a_module_flags; + ; + break;} +case 16: +#line 408 "asn1p_y.y" +{ + yyval.a_module_flags = yyvsp[0].a_module_flags; + ; + break;} +case 17: +#line 411 "asn1p_y.y" +{ + yyval.a_module_flags = yyvsp[-1].a_module_flags | yyvsp[0].a_module_flags; + ; + break;} +case 18: +#line 420 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_EXPLICIT_TAGS; + ; + break;} +case 19: +#line 423 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_IMPLICIT_TAGS; + ; + break;} +case 20: +#line 426 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_AUTOMATIC_TAGS; + ; + break;} +case 21: +#line 429 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_EXTENSIBILITY_IMPLIED; + ; + break;} +case 22: +#line 438 "asn1p_y.y" +{ yyval.a_module = 0; ; + break;} +case 23: +#line 439 "asn1p_y.y" +{ + assert(yyvsp[0].a_module); + yyval.a_module = yyvsp[0].a_module; + ; + break;} +case 24: +#line 449 "asn1p_y.y" +{ + yyval.a_module = yyvsp[0].a_module; + ; + break;} +case 25: +#line 452 "asn1p_y.y" +{ + yyval.a_module = yyvsp[-1].a_module; + +#ifdef MY_IMPORT +#error MY_IMPORT DEFINED ELSEWHERE! +#endif +#define MY_IMPORT(foo,field) do { \ + if(TQ_FIRST(&(yyvsp[0].a_module->foo))) { \ + TQ_ADD(&(yyval.a_module->foo), \ + TQ_REMOVE(&(yyvsp[0].a_module->foo), field), \ + field); \ + assert(TQ_FIRST(&(yyvsp[0].a_module->foo)) == 0); \ + } } while(0) + + MY_IMPORT(imports, xp_next); + MY_IMPORT(exports, xp_next); + MY_IMPORT(members, next); +#undef MY_IMPORT + + ; + break;} +case 26: +#line 478 "asn1p_y.y" +{ + yyval.a_module = yyvsp[0].a_module; + ; + break;} +case 27: +#line 481 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + if(yyvsp[0].a_xports) { + TQ_ADD(&(yyval.a_module->exports), yyvsp[0].a_xports, xp_next); + } else { + /* "EXPORTS ALL;" ? */ + } + ; + break;} +case 28: +#line 490 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + assert(yyvsp[0].a_expr->expr_type != A1TC_INVALID); + assert(yyvsp[0].a_expr->meta_type != AMT_INVALID); + TQ_ADD(&(yyval.a_module->members), yyvsp[0].a_expr, next); + ; + break;} +case 29: +#line 497 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + assert(yyvsp[0].a_expr->expr_type != A1TC_INVALID); + assert(yyvsp[0].a_expr->meta_type != AMT_INVALID); + TQ_ADD(&(yyval.a_module->members), yyvsp[0].a_expr, next); + ; + break;} +case 30: +#line 510 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + assert(yyvsp[0].a_expr->expr_type != A1TC_INVALID); + assert(yyvsp[0].a_expr->meta_type != AMT_INVALID); + TQ_ADD(&(yyval.a_module->members), yyvsp[0].a_expr, next); + ; + break;} +case 31: +#line 521 "asn1p_y.y" +{ + return yyerror( + "Attempt to redefine a standard basic type, " + "use -ftypesXY to switch back " + "to older version of ASN.1 standard"); + ; + break;} +case 32: +#line 535 "asn1p_y.y" +{ + yyval.a_module = yyvsp[-1].a_module; + ; + break;} +case 33: +#line 541 "asn1p_y.y" +{ + return yyerror("Empty IMPORTS list"); + ; + break;} +case 34: +#line 547 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + TQ_ADD(&(yyval.a_module->imports), yyvsp[0].a_xports, xp_next); + ; + break;} +case 35: +#line 552 "asn1p_y.y" +{ + yyval.a_module = yyvsp[-1].a_module; + TQ_ADD(&(yyval.a_module->imports), yyvsp[0].a_xports, xp_next); + ; + break;} +case 36: +#line 559 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-3].a_xports; + yyval.a_xports->from = yyvsp[-1].tv_str; + yyval.a_xports->from_oid = yyvsp[0].a_oid; + checkmem(yyval.a_xports); + ; + break;} +case 37: +#line 568 "asn1p_y.y" +{ + yyval.a_xports = asn1p_xports_new(); + checkmem(yyval.a_xports); + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 38: +#line 573 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-2].a_xports; + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 39: +#line 580 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_REFERENCE; + ; + break;} +case 40: +#line 586 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_REFERENCE; + ; + break;} +case 41: +#line 595 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-1].a_xports; + ; + break;} +case 42: +#line 598 "asn1p_y.y" +{ + yyval.a_xports = 0; + ; + break;} +case 43: +#line 601 "asn1p_y.y" +{ + /* Empty EXPORTS clause effectively prohibits export. */ + yyval.a_xports = asn1p_xports_new(); + checkmem(yyval.a_xports); + ; + break;} +case 44: +#line 609 "asn1p_y.y" +{ + yyval.a_xports = asn1p_xports_new(); + assert(yyval.a_xports); + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 45: +#line 614 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-2].a_xports; + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 46: +#line 621 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_EXPORTVAR; + ; + break;} +case 47: +#line 627 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_EXPORTVAR; + ; + break;} +case 48: +#line 637 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-4].a_expr; + assert(yyval.a_expr->Identifier == 0); + yyval.a_expr->Identifier = yyvsp[-5].tv_str; + yyval.a_expr->meta_type = AMT_VALUESET; + // take care of optValueSetBody + ; + break;} +case 49: +#line 647 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = yyvsp[0].a_ref; + yyval.a_expr->expr_type = A1TC_REFERENCE; + yyval.a_expr->meta_type = AMT_TYPEREF; + ; + break;} +case 50: +#line 654 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = yyvsp[0].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 51: +#line 663 "asn1p_y.y" +{ ; + break;} +case 52: +#line 664 "asn1p_y.y" +{ + ; + break;} +case 53: +#line 680 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->tag = yyvsp[-1].a_tag; + yyval.a_expr->expr_type = A1TC_TYPEID; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 54: +#line 688 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->tag = yyvsp[-1].a_tag; + assert(yyval.a_expr->expr_type); + assert(yyval.a_expr->meta_type); + ; + break;} +case 55: +#line 695 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + yyval.a_expr->Identifier = yyvsp[-2].tv_str; + assert(yyval.a_expr->expr_type == A1TC_CLASSDEF); + assert(yyval.a_expr->meta_type == AMT_OBJECT); + ; + break;} +case 56: +#line 712 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + assert(yyval.a_expr->Identifier == 0); + yyval.a_expr->Identifier = yyvsp[-5].tv_str; + yyval.a_expr->params = yyvsp[-3].a_plist; + yyval.a_expr->meta_type = AMT_PARAMTYPE; + ; + break;} +case 57: +#line 722 "asn1p_y.y" +{ + int ret; + yyval.a_plist = asn1p_paramlist_new(yylineno); + checkmem(yyval.a_plist); + ret = asn1p_paramlist_add_param(yyval.a_plist, yyvsp[0].a_parg.governor, yyvsp[0].a_parg.argument); + checkmem(ret == 0); + if(yyvsp[0].a_parg.governor) asn1p_ref_free(yyvsp[0].a_parg.governor); + if(yyvsp[0].a_parg.argument) free(yyvsp[0].a_parg.argument); + ; + break;} +case 58: +#line 731 "asn1p_y.y" +{ + int ret; + yyval.a_plist = yyvsp[-2].a_plist; + ret = asn1p_paramlist_add_param(yyval.a_plist, yyvsp[0].a_parg.governor, yyvsp[0].a_parg.argument); + checkmem(ret == 0); + if(yyvsp[0].a_parg.governor) asn1p_ref_free(yyvsp[0].a_parg.governor); + if(yyvsp[0].a_parg.argument) free(yyvsp[0].a_parg.argument); + ; + break;} +case 59: +#line 742 "asn1p_y.y" +{ + yyval.a_parg.governor = NULL; + yyval.a_parg.argument = yyvsp[0].tv_str; + ; + break;} +case 60: +#line 746 "asn1p_y.y" +{ + int ret; + yyval.a_parg.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_parg.governor, yyvsp[-2].tv_str, 0); + checkmem(ret == 0); + yyval.a_parg.argument = yyvsp[0].tv_str; + ; + break;} +case 61: +#line 753 "asn1p_y.y" +{ + int ret; + yyval.a_parg.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_parg.governor, + ASN_EXPR_TYPE2STR(yyvsp[-2].a_type), 1); + checkmem(ret == 0); + yyval.a_parg.argument = yyvsp[0].tv_str; + ; + break;} +case 62: +#line 764 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 63: +#line 769 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 64: +#line 776 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + ; + break;} +case 65: +#line 779 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_REFERENCE; + yyval.a_expr->meta_type = AMT_VALUE; + ; + break;} +case 66: +#line 792 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 67: +#line 797 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 68: +#line 804 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + checkmem(yyval.a_expr); + yyval.a_expr->with_syntax = yyvsp[0].a_wsynt; + assert(yyval.a_expr->expr_type == A1TC_CLASSDEF); + assert(yyval.a_expr->meta_type == AMT_OBJECT); + ; + break;} +case 69: +#line 814 "asn1p_y.y" +{ yyval.a_int = 0; ; + break;} +case 70: +#line 815 "asn1p_y.y" +{ yyval.a_int = 1; ; + break;} +case 71: +#line 819 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_CLASSDEF; + yyval.a_expr->meta_type = AMT_OBJECT; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 72: +#line 826 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 73: +#line 833 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[-1].a_refcomp.name; + yyval.a_expr->expr_type = A1TC_CLASSFIELD; + yyval.a_expr->meta_type = AMT_OBJECTFIELD; + yyval.a_expr->marker = yyvsp[0].a_marker; + ; + break;} +case 74: +#line 841 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + yyval.a_expr->Identifier = yyvsp[-2].a_refcomp.name; + yyval.a_expr->unique = yyvsp[0].a_int; + ; + break;} +case 75: +#line 846 "asn1p_y.y" +{ + int ret; + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[-3].a_refcomp.name; + yyval.a_expr->reference = asn1p_ref_new(yylineno); + checkmem(yyval.a_expr->reference); + ret = asn1p_ref_add_component(yyval.a_expr->reference, + yyvsp[-2].a_refcomp.name, yyvsp[-2].a_refcomp.lex_type); + checkmem(ret == 0); + yyval.a_expr->expr_type = A1TC_CLASSFIELD; + yyval.a_expr->meta_type = AMT_OBJECTFIELD; + yyval.a_expr->marker = yyvsp[-1].a_marker; + yyval.a_expr->unique = yyvsp[0].a_int; + ; + break;} +case 76: +#line 864 "asn1p_y.y" +{ yyval.a_wsynt = 0; ; + break;} +case 77: +#line 865 "asn1p_y.y" +{ + yyval.a_wsynt = yyvsp[0].a_wsynt; + ; + break;} +case 78: +#line 872 "asn1p_y.y" +{ asn1p_lexer_hack_enable_with_syntax(); ; + break;} +case 79: +#line 874 "asn1p_y.y" +{ + yyval.a_wsynt = yyvsp[-1].a_wsynt; + ; + break;} +case 80: +#line 880 "asn1p_y.y" +{ + yyval.a_wsynt = asn1p_wsyntx_new(); + TQ_ADD(&(yyval.a_wsynt->chunks), yyvsp[0].a_wchunk, next); + ; + break;} +case 81: +#line 884 "asn1p_y.y" +{ + yyval.a_wsynt = yyvsp[-1].a_wsynt; + TQ_ADD(&(yyval.a_wsynt->chunks), yyvsp[0].a_wchunk, next); + ; + break;} +case 82: +#line 891 "asn1p_y.y" +{ + yyval.a_wchunk = asn1p_wsyntx_chunk_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + ; + break;} +case 83: +#line 894 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[0].a_refcomp.name, yyvsp[0].a_refcomp.lex_type); + checkmem(ret == 0); + yyval.a_wchunk = asn1p_wsyntx_chunk_fromref(ref, 0); + ; + break;} +case 84: +#line 920 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + assert(yyval.a_expr->Identifier == 0); + yyval.a_expr->Identifier = yyvsp[-1].tv_nametag.name; + yyval.a_expr->tag = yyvsp[-1].tv_nametag.tag; + ; + break;} +case 85: +#line 926 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + ; + break;} +case 86: +#line 932 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + yyval.a_expr->constraints = yyvsp[-1].a_constr; + yyval.a_expr->marker = yyvsp[0].a_marker; + ; + break;} +case 87: +#line 940 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 88: +#line 948 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->value = yyvsp[0].a_value; + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 89: +#line 957 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + yyval.a_expr->value = yyvsp[0].a_value; + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 90: +#line 969 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + ; + break;} +case 91: +#line 972 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = yyvsp[0].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 92: +#line 978 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + checkmem(yyval.a_expr); + assert(yyval.a_expr->meta_type); + ; + break;} +case 93: +#line 986 "asn1p_y.y" +{ + int ret; + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == 0); + assert(yyval.a_expr->meta_type == 0); + assert(yyval.a_expr->reference == 0); + yyval.a_expr->reference = asn1p_ref_new(yylineno); + checkmem(yyval.a_expr->reference); + ret = asn1p_ref_add_component(yyval.a_expr->reference, yyvsp[-3].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + free(yyvsp[-3].tv_str); + yyval.a_expr->expr_type = A1TC_PARAMETRIZED; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 94: +#line 1010 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = yyvsp[0].a_ref; + yyval.a_expr->expr_type = A1TC_REFERENCE; + yyval.a_expr->meta_type = AMT_TYPEREF; + ; + break;} +case 95: +#line 1017 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = yyvsp[0].a_ref; + yyval.a_expr->expr_type = A1TC_INSTANCE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 96: +#line 1032 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + free(yyvsp[0].tv_str); + ; + break;} +case 97: +#line 1040 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[-2].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + free(yyvsp[-2].tv_str); + ; + break;} +case 98: +#line 1050 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[-2].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + free(yyvsp[-2].tv_str); + ; + break;} +case 99: +#line 1060 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_CAPITALS); + free(yyvsp[0].tv_str); + checkmem(ret == 0); + ; + break;} +case 100: +#line 1068 "asn1p_y.y" +{ + int ret; + yyval.a_ref = yyvsp[0].a_ref; + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[-2].tv_str, RLT_CAPITALS); + free(yyvsp[-2].tv_str); + checkmem(ret == 0); + /* + * Move the last element infront. + */ + { + struct asn1p_ref_component_s tmp_comp; + tmp_comp = yyval.a_ref->components[yyval.a_ref->comp_count-1]; + memmove(&yyval.a_ref->components[1], + &yyval.a_ref->components[0], + sizeof(yyval.a_ref->components[0]) + * (yyval.a_ref->comp_count - 1)); + yyval.a_ref->components[0] = tmp_comp; + } + ; + break;} +case 101: +#line 1090 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].a_refcomp.name, yyvsp[0].a_refcomp.lex_type); + free(yyvsp[0].a_refcomp.name); + checkmem(ret == 0); + ; + break;} +case 102: +#line 1098 "asn1p_y.y" +{ + int ret; + yyval.a_ref = yyvsp[-2].a_ref; + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].a_refcomp.name, yyvsp[0].a_refcomp.lex_type); + free(yyvsp[0].a_refcomp.name); + checkmem(ret == 0); + ; + break;} +case 105: +#line 1112 "asn1p_y.y" +{ + yyval.a_refcomp.lex_type = RLT_AmpUppercase; + yyval.a_refcomp.name = yyvsp[0].tv_str; + ; + break;} +case 106: +#line 1117 "asn1p_y.y" +{ + yyval.a_refcomp.lex_type = RLT_Amplowercase; + yyval.a_refcomp.name = yyvsp[0].tv_str; + ; + break;} +case 107: +#line 1130 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + assert(yyval.a_expr->Identifier == NULL); + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->value = yyvsp[0].a_value; + ; + break;} +case 108: +#line 1140 "asn1p_y.y" +{ asn1p_lexer_hack_push_opaque_state(); ; + break;} +case 109: +#line 1141 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_UNPARSED; + ; + break;} +case 110: +#line 1146 "asn1p_y.y" +{ + yyval.a_value = _convert_bitstring2binary(yyvsp[0].tv_str, 'B'); + checkmem(yyval.a_value); + ; + break;} +case 111: +#line 1150 "asn1p_y.y" +{ + yyval.a_value = _convert_bitstring2binary(yyvsp[0].tv_str, 'H'); + checkmem(yyval.a_value); + ; + break;} +case 112: +#line 1154 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + checkmem(yyval.a_value); + ; + break;} +case 113: +#line 1158 "asn1p_y.y" +{ + yyval.a_value = yyvsp[0].a_value; + ; + break;} +case 114: +#line 1161 "asn1p_y.y" +{ + yyval.a_value = yyvsp[0].a_value; + ; + break;} +case 115: +#line 1167 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_value = asn1p_value_fromref(ref, 0); + checkmem(yyval.a_value); + free(yyvsp[0].tv_str); + ; + break;} +case 116: +#line 1178 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[-2].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_value = asn1p_value_fromref(ref, 0); + checkmem(yyval.a_value); + free(yyvsp[-2].tv_str); + free(yyvsp[0].tv_str); + ; + break;} +case 117: +#line 1195 "asn1p_y.y" +{ + yyval.tv_opaque.len = yyvsp[0].tv_opaque.len + 2; + yyval.tv_opaque.buf = malloc(yyval.tv_opaque.len + 1); + checkmem(yyval.tv_opaque.buf); + yyval.tv_opaque.buf[0] = '{'; + yyval.tv_opaque.buf[1] = ' '; + memcpy(yyval.tv_opaque.buf + 2, yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len); + yyval.tv_opaque.buf[yyval.tv_opaque.len] = '\0'; + free(yyvsp[0].tv_opaque.buf); + ; + break;} +case 118: +#line 1205 "asn1p_y.y" +{ + int newsize = yyvsp[-1].tv_opaque.len + yyvsp[0].tv_opaque.len; + char *p = malloc(newsize + 1); + checkmem(p); + memcpy(p , yyvsp[-1].tv_opaque.buf, yyvsp[-1].tv_opaque.len); + memcpy(p + yyvsp[-1].tv_opaque.len, yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len); + p[newsize] = '\0'; + free(yyvsp[-1].tv_opaque.buf); + free(yyvsp[0].tv_opaque.buf); + yyval.tv_opaque.buf = p; + yyval.tv_opaque.len = newsize; + ; + break;} +case 119: +#line 1220 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_BOOLEAN; ; + break;} +case 120: +#line 1221 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_NULL; ; + break;} +case 121: +#line 1222 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_REAL; ; + break;} +case 122: +#line 1223 "asn1p_y.y" +{ yyval.a_type = yyvsp[0].a_type; ; + break;} +case 123: +#line 1224 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_OCTET_STRING; ; + break;} +case 124: +#line 1225 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_OBJECT_IDENTIFIER; ; + break;} +case 125: +#line 1226 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_RELATIVE_OID; ; + break;} +case 126: +#line 1227 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_EXTERNAL; ; + break;} +case 127: +#line 1228 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_EMBEDDED_PDV; ; + break;} +case 128: +#line 1229 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_CHARACTER_STRING; ; + break;} +case 129: +#line 1230 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_UTCTime; ; + break;} +case 130: +#line 1231 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_GeneralizedTime; ; + break;} +case 131: +#line 1238 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_INTEGER; ; + break;} +case 132: +#line 1239 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_ENUMERATED; ; + break;} +case 133: +#line 1240 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_BIT_STRING; ; + break;} +case 134: +#line 1244 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = yyvsp[0].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 135: +#line 1250 "asn1p_y.y" +{ + if(yyvsp[0].a_expr) { + yyval.a_expr = yyvsp[0].a_expr; + } else { + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + } + yyval.a_expr->expr_type = yyvsp[-1].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 136: +#line 1263 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_BMPString; ; + break;} +case 137: +#line 1264 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_GeneralString; + return yyerror("GeneralString is not supported"); + ; + break;} +case 138: +#line 1268 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_GraphicString; + return yyerror("GraphicString is not supported"); + ; + break;} +case 139: +#line 1272 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_IA5String; ; + break;} +case 140: +#line 1273 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_ISO646String; ; + break;} +case 141: +#line 1274 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_NumericString; ; + break;} +case 142: +#line 1275 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_PrintableString; ; + break;} +case 143: +#line 1276 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_T61String; + return yyerror("T61String not implemented yet"); + ; + break;} +case 144: +#line 1280 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_TeletexString; ; + break;} +case 145: +#line 1281 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_UniversalString; ; + break;} +case 146: +#line 1282 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_UTF8String; ; + break;} +case 147: +#line 1283 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_VideotexString; + return yyerror("VideotexString is no longer supported"); + ; + break;} +case 148: +#line 1287 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_VisibleString; ; + break;} +case 149: +#line 1288 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_ObjectDescriptor; ; + break;} +case 150: +#line 1292 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == A1TC_INVALID); + yyval.a_expr->expr_type = ASN_CONSTR_CHOICE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 151: +#line 1298 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == A1TC_INVALID); + yyval.a_expr->expr_type = ASN_CONSTR_SEQUENCE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 152: +#line 1304 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == A1TC_INVALID); + yyval.a_expr->expr_type = ASN_CONSTR_SET; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 153: +#line 1310 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->constraints = yyvsp[-2].a_constr; + yyval.a_expr->expr_type = ASN_CONSTR_SEQUENCE_OF; + yyval.a_expr->meta_type = AMT_TYPE; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 154: +#line 1318 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->constraints = yyvsp[-2].a_constr; + yyval.a_expr->expr_type = ASN_CONSTR_SET_OF; + yyval.a_expr->meta_type = AMT_TYPE; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 155: +#line 1326 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = ASN_CONSTR_ANY; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 156: +#line 1332 "asn1p_y.y" +{ + int ret; + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_expr->reference, + yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_expr->expr_type = ASN_CONSTR_ANY; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 157: +#line 1349 "asn1p_y.y" +{ yyval.a_constr = 0; ; + break;} +case 158: +#line 1350 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 164: +#line 1358 "asn1p_y.y" +{ + /* + * This is a special case, for compatibility purposes. + * It goes without parenthesis. + */ + int ret; + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_CT_SIZE; + ret = asn1p_constraint_insert(yyval.a_constr, yyvsp[-1].a_constr); + checkmem(ret == 0); + ; + break;} +case 165: +#line 1370 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_SET, yyvsp[0].a_constr, 0); + ; + break;} +case 166: +#line 1373 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_SET, yyvsp[-1].a_constr, yyvsp[0].a_constr); + ; + break;} +case 167: +#line 1379 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[-1].a_constr; + ; + break;} +case 168: +#line 1385 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 169: +#line 1388 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-2].a_constr, ct); + ; + break;} +case 170: +#line 1395 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-4].a_constr, ct); + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-4].a_constr, yyvsp[0].a_constr); + ; + break;} +case 171: +#line 1403 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_EXT; + ; + break;} +case 172: +#line 1408 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, ct, yyvsp[0].a_constr); + ; + break;} +case 173: +#line 1417 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 174: +#line 1420 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 175: +#line 1421 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_UNI, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 176: +#line 1427 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 177: +#line 1429 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_INT, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 178: +#line 1435 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 179: +#line 1436 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_EXC, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 180: +#line 1442 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_VALUE; + yyval.a_constr->value = yyvsp[0].a_value; + ; + break;} +case 181: +#line 1448 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = yyvsp[-1].a_ctype; + yyval.a_constr->range_start = yyvsp[-2].a_value; + yyval.a_constr->range_stop = yyvsp[0].a_value; + ; + break;} +case 182: +#line 1455 "asn1p_y.y" +{ + int ret; + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = yyvsp[-3].a_ctype; + ret = asn1p_constraint_insert(yyval.a_constr, yyvsp[-1].a_constr); + checkmem(ret == 0); + ; + break;} +case 183: +#line 1463 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 184: +#line 1466 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 185: +#line 1472 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_RANGE; ; + break;} +case 186: +#line 1473 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_RLRANGE; ; + break;} +case 187: +#line 1474 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_LLRANGE; ; + break;} +case 188: +#line 1475 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_ULRANGE; ; + break;} +case 189: +#line 1479 "asn1p_y.y" +{ + yyval.a_ctype = ACT_CT_SIZE; + ; + break;} +case 190: +#line 1482 "asn1p_y.y" +{ + yyval.a_ctype = ACT_CT_FROM; + ; + break;} +case 191: +#line 1488 "asn1p_y.y" +{ + yyval.a_value = yyvsp[0].a_value; + ; + break;} +case 192: +#line 1491 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_value = asn1p_value_fromref(ref, 0); + checkmem(yyval.a_value); + free(yyvsp[0].tv_str); + ; + break;} +case 193: +#line 1502 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + checkmem(yyval.a_value); + ; + break;} +case 194: +#line 1506 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(123); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_MIN; + ; + break;} +case 195: +#line 1511 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(321); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_MAX; + ; + break;} +case 196: +#line 1516 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(0); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_FALSE; + ; + break;} +case 197: +#line 1521 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(1); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_TRUE; + ; + break;} +case 198: +#line 1529 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CT_WCOMPS, yyvsp[-1].a_constr, 0); + ; + break;} +case 199: +#line 1535 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 200: +#line 1538 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CT_WCOMPS, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 201: +#line 1544 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_EXT; + ; + break;} +case 202: +#line 1549 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_VALUE; + yyval.a_constr->value = asn1p_value_frombuf(yyvsp[-2].tv_str, strlen(yyvsp[-2].tv_str), 0); + yyval.a_constr->presence = yyvsp[0].a_pres; + ; + break;} +case 203: +#line 1562 "asn1p_y.y" +{ yyval.a_pres = ACPRES_DEFAULT; ; + break;} +case 204: +#line 1563 "asn1p_y.y" +{ yyval.a_pres = yyvsp[0].a_pres; ; + break;} +case 205: +#line 1567 "asn1p_y.y" +{ + yyval.a_pres = ACPRES_PRESENT; + ; + break;} +case 206: +#line 1570 "asn1p_y.y" +{ + yyval.a_pres = ACPRES_ABSENT; + ; + break;} +case 207: +#line 1573 "asn1p_y.y" +{ + yyval.a_pres = ACPRES_OPTIONAL; + ; + break;} +case 208: +#line 1579 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 209: +#line 1582 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 210: +#line 1591 "asn1p_y.y" +{ + asn1p_ref_t *ref = asn1p_ref_new(yylineno); + asn1p_constraint_t *ct; + int ret; + ret = asn1p_ref_add_component(ref, yyvsp[-1].tv_str, 0); + checkmem(ret == 0); + ct = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref(ref, 0); + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CRC, ct, 0); + ; + break;} +case 211: +#line 1606 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CRC, yyvsp[-3].a_constr, yyvsp[-1].a_constr); + ; + break;} +case 212: +#line 1612 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_VALUE; + yyval.a_constr->value = asn1p_value_fromref(yyvsp[0].a_ref, 0); + ; + break;} +case 213: +#line 1618 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref(yyvsp[0].a_ref, 0); + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-2].a_constr, ct); + ; + break;} +case 214: +#line 1632 "asn1p_y.y" +{ + char *p = malloc(strlen(yyvsp[0].tv_str) + 2); + int ret; + *p = '@'; + strcpy(p + 1, yyvsp[0].tv_str); + yyval.a_ref = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_ref, p, 0); + checkmem(ret == 0); + free(p); + free(yyvsp[0].tv_str); + ; + break;} +case 215: +#line 1643 "asn1p_y.y" +{ + char *p = malloc(strlen(yyvsp[0].tv_str) + 3); + int ret; + p[0] = '@'; + p[1] = '.'; + strcpy(p + 2, yyvsp[0].tv_str); + yyval.a_ref = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_ref, p, 0); + checkmem(ret == 0); + free(p); + free(yyvsp[0].tv_str); + ; + break;} +case 216: +#line 1659 "asn1p_y.y" +{ + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 217: +#line 1662 "asn1p_y.y" +{ + int l1 = strlen(yyvsp[-2].tv_str); + int l3 = strlen(yyvsp[0].tv_str); + yyval.tv_str = malloc(l1 + 1 + l3 + 1); + memcpy(yyval.tv_str, yyvsp[-2].tv_str, l1); + yyval.tv_str[l1] = '.'; + memcpy(yyval.tv_str + l1 + 1, yyvsp[0].tv_str, l3); + yyval.tv_str[l1 + 1 + l3] = '\0'; + ; + break;} +case 218: +#line 1680 "asn1p_y.y" +{ yyval.a_marker = EM_NOMARK; ; + break;} +case 219: +#line 1681 "asn1p_y.y" +{ yyval.a_marker = yyvsp[0].a_marker; ; + break;} +case 220: +#line 1685 "asn1p_y.y" +{ + yyval.a_marker = EM_OPTIONAL; + ; + break;} +case 221: +#line 1688 "asn1p_y.y" +{ + yyval.a_marker = EM_DEFAULT; + /* FIXME: store DefaultValue somewhere */ + ; + break;} +case 222: +#line 1695 "asn1p_y.y" +{ + ; + break;} +case 223: +#line 1697 "asn1p_y.y" +{ + ; + break;} +case 224: +#line 1699 "asn1p_y.y" +{ asn1p_lexer_hack_push_opaque_state(); ; + break;} +case 225: +#line 1699 "asn1p_y.y" +{ + ; + break;} +case 226: +#line 1720 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + ; + break;} +case 227: +#line 1724 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + ; + break;} +case 228: +#line 1730 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 229: +#line 1735 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 230: +#line 1742 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->Identifier = yyvsp[0].tv_str; + ; + break;} +case 231: +#line 1749 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->value = yyvsp[-1].a_value; + ; + break;} +case 232: +#line 1757 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->value = yyvsp[-1].a_value; + ; + break;} +case 233: +#line 1765 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->value = yyvsp[0].a_value; + ; + break;} +case 234: +#line 1772 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_VALUE; + ; + break;} +case 235: +#line 1783 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(yyvsp[0].a_int); + checkmem(yyval.a_value); + ; + break;} +case 236: +#line 1787 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(yyvsp[0].a_int); + checkmem(yyval.a_value); + ; + break;} +case 237: +#line 1818 "asn1p_y.y" +{ memset(&yyval.a_tag, 0, sizeof(yyval.a_tag)); ; + break;} +case 238: +#line 1819 "asn1p_y.y" +{ yyval.a_tag = yyvsp[0].a_tag; ; + break;} +case 239: +#line 1823 "asn1p_y.y" +{ + yyval.a_tag = yyvsp[0].a_tag; + yyval.a_tag.tag_mode = TM_DEFAULT; + ; + break;} +case 240: +#line 1827 "asn1p_y.y" +{ + yyval.a_tag = yyvsp[-1].a_tag; + yyval.a_tag.tag_mode = TM_IMPLICIT; + ; + break;} +case 241: +#line 1831 "asn1p_y.y" +{ + yyval.a_tag = yyvsp[-1].a_tag; + yyval.a_tag.tag_mode = TM_EXPLICIT; + ; + break;} +case 242: +#line 1838 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 243: +#line 1842 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 244: +#line 1849 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 245: +#line 1856 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 246: +#line 1863 "asn1p_y.y" +{ + memset(&yyval.tv_nametag, 0, sizeof(yyval.tv_nametag)); + yyval.tv_nametag.name = yyvsp[0].tv_str; + ; + break;} +case 247: +#line 1867 "asn1p_y.y" +{ + yyval.tv_nametag.name = yyvsp[-1].tv_str; + yyval.tv_nametag.tag = yyvsp[0].a_tag; + ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/share/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 1874 "asn1p_y.y" + + + +/* + * Convert Xstring ('0101'B or '5'H) to the binary vector. + */ +static asn1p_value_t * +_convert_bitstring2binary(char *str, int base) { + asn1p_value_t *val; + int slen; + int memlen; + int baselen; + int bits; + uint8_t *binary_vector; + uint8_t *bv_ptr; + uint8_t cur_val; + + assert(str); + assert(str[0] == '\''); + + switch(base) { + case 'B': + baselen = 1; + break; + case 'H': + baselen = 4; + break; + default: + assert(base == 'B' || base == 'H'); + errno = EINVAL; + return NULL; + } + + slen = strlen(str); + assert(str[slen - 1] == base); + assert(str[slen - 2] == '\''); + + memlen = slen / (8 / baselen); /* Conservative estimate */ + + bv_ptr = binary_vector = malloc(memlen + 1); + if(bv_ptr == NULL) + /* ENOMEM */ + return NULL; + + cur_val = 0; + bits = 0; + while(*(++str) != '\'') { + switch(baselen) { + case 1: + switch(*str) { + case '1': + cur_val |= 1 << (7 - (bits % 8)); + case '0': + break; + default: + assert(!"_y UNREACH1"); + case ' ': case '\r': case '\n': + continue; + } + break; + case 4: + switch(*str) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + cur_val |= (*str - '0') << (4 - (bits % 8)); + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + cur_val |= ((*str - 'A') + 10) + << (4 - (bits % 8)); + break; + default: + assert(!"_y UNREACH2"); + case ' ': case '\r': case '\n': + continue; + } + break; + } + + bits += baselen; + if((bits % 8) == 0) { + *bv_ptr++ = cur_val; + cur_val = 0; + } + } + + *bv_ptr = cur_val; + assert((bv_ptr - binary_vector) <= memlen); + + val = asn1p_value_frombits(binary_vector, bits, 0); + if(val == NULL) { + free(binary_vector); + } + + return val; +} + +extern char *asn1p_text; + +int +yyerror(const char *msg) { + fprintf(stderr, + "ASN.1 grammar parse error " + "near line %d (token \"%s\"): %s\n", + asn1p_lineno, asn1p_text, msg); + return -1; +} + + diff --git a/libasn1parser/asn1p_y.h b/libasn1parser/asn1p_y.h new file mode 100644 index 00000000..61679e3d --- /dev/null +++ b/libasn1parser/asn1p_y.h @@ -0,0 +1,132 @@ +typedef union { + asn1p_t *a_grammar; + asn1p_module_flags_e a_module_flags; + asn1p_module_t *a_module; + asn1p_expr_type_e a_type; /* ASN.1 Type */ + asn1p_expr_t *a_expr; /* Constructed collection */ + asn1p_constraint_t *a_constr; /* Constraint */ + enum asn1p_constraint_type_e a_ctype;/* Constraint type */ + asn1p_xports_t *a_xports; /* IMports/EXports */ + asn1p_oid_t *a_oid; /* Object Identifier */ + asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ + struct asn1p_type_tag_s a_tag; /* A tag */ + asn1p_ref_t *a_ref; /* Reference to custom type */ + asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ + asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ + struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ + asn1p_value_t *a_value; /* Number, DefinedValue, etc */ + struct asn1p_param_s a_parg; /* A parameter argument */ + asn1p_paramlist_t *a_plist; /* A pargs list */ + enum asn1p_expr_marker_e a_marker; /* OPTIONAL/DEFAULT */ + enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ + asn1_integer_t a_int; + char *tv_str; + struct { + char *buf; + int len; + } tv_opaque; + struct { + char *name; + struct asn1p_type_tag_s tag; + } tv_nametag; +} YYSTYPE; +#define TOK_PPEQ 257 +#define TOK_opaque 258 +#define TOK_bstring 259 +#define TOK_cstring 260 +#define TOK_hstring 261 +#define TOK_identifier 262 +#define TOK_number 263 +#define TOK_number_negative 264 +#define TOK_typereference 265 +#define TOK_objectclassreference 266 +#define TOK_typefieldreference 267 +#define TOK_valuefieldreference 268 +#define TOK_ABSENT 269 +#define TOK_ABSTRACT_SYNTAX 270 +#define TOK_ALL 271 +#define TOK_ANY 272 +#define TOK_APPLICATION 273 +#define TOK_AUTOMATIC 274 +#define TOK_BEGIN 275 +#define TOK_BIT 276 +#define TOK_BMPString 277 +#define TOK_BOOLEAN 278 +#define TOK_BY 279 +#define TOK_CHARACTER 280 +#define TOK_CHOICE 281 +#define TOK_CLASS 282 +#define TOK_COMPONENT 283 +#define TOK_COMPONENTS 284 +#define TOK_CONSTRAINED 285 +#define TOK_CONTAINING 286 +#define TOK_DEFAULT 287 +#define TOK_DEFINITIONS 288 +#define TOK_DEFINED 289 +#define TOK_EMBEDDED 290 +#define TOK_ENCODED 291 +#define TOK_END 292 +#define TOK_ENUMERATED 293 +#define TOK_EXPLICIT 294 +#define TOK_EXPORTS 295 +#define TOK_EXTENSIBILITY 296 +#define TOK_EXTERNAL 297 +#define TOK_FALSE 298 +#define TOK_FROM 299 +#define TOK_GeneralizedTime 300 +#define TOK_GeneralString 301 +#define TOK_GraphicString 302 +#define TOK_IA5String 303 +#define TOK_IDENTIFIER 304 +#define TOK_IMPLICIT 305 +#define TOK_IMPLIED 306 +#define TOK_IMPORTS 307 +#define TOK_INCLUDES 308 +#define TOK_INSTANCE 309 +#define TOK_INTEGER 310 +#define TOK_ISO646String 311 +#define TOK_MAX 312 +#define TOK_MIN 313 +#define TOK_MINUS_INFINITY 314 +#define TOK_NULL 315 +#define TOK_NumericString 316 +#define TOK_OBJECT 317 +#define TOK_ObjectDescriptor 318 +#define TOK_OCTET 319 +#define TOK_OF 320 +#define TOK_OPTIONAL 321 +#define TOK_PATTERN 322 +#define TOK_PDV 323 +#define TOK_PLUS_INFINITY 324 +#define TOK_PRESENT 325 +#define TOK_PrintableString 326 +#define TOK_PRIVATE 327 +#define TOK_REAL 328 +#define TOK_RELATIVE_OID 329 +#define TOK_SEQUENCE 330 +#define TOK_SET 331 +#define TOK_SIZE 332 +#define TOK_STRING 333 +#define TOK_SYNTAX 334 +#define TOK_T61String 335 +#define TOK_TAGS 336 +#define TOK_TeletexString 337 +#define TOK_TRUE 338 +#define TOK_TYPE_IDENTIFIER 339 +#define TOK_UNIQUE 340 +#define TOK_UNIVERSAL 341 +#define TOK_UniversalString 342 +#define TOK_UTCTime 343 +#define TOK_UTF8String 344 +#define TOK_VideotexString 345 +#define TOK_VisibleString 346 +#define TOK_WITH 347 +#define TOK_UNION 348 +#define TOK_INTERSECTION 349 +#define TOK_EXCEPT 350 +#define TOK_TwoDots 351 +#define TOK_ThreeDots 352 +#define TOK_tag 353 + + +extern YYSTYPE asn1p_lval; diff --git a/libasn1parser/asn1p_y.y b/libasn1parser/asn1p_y.y new file mode 100644 index 00000000..822a8efb --- /dev/null +++ b/libasn1parser/asn1p_y.y @@ -0,0 +1,1982 @@ +%{ + +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +#define YYPARSE_PARAM param +#define YYERROR_VERBOSE + +int yylex(void); +int yyerror(const char *msg); +void asn1p_lexer_hack_push_opaque_state(void); +void asn1p_lexer_hack_enable_with_syntax(void); +#define yylineno asn1p_lineno +extern int asn1p_lineno; + + +static asn1p_value_t * + _convert_bitstring2binary(char *str, int base); + +#define checkmem(ptr) do { \ + if(!(ptr)) \ + return yyerror("Memory failure"); \ + } while(0) + +#define CONSTRAINT_INSERT(root, constr_type, arg1, arg2) do { \ + if(arg1->type != constr_type) { \ + int __ret; \ + root = asn1p_constraint_new(yylineno); \ + checkmem(root); \ + root->type = constr_type; \ + __ret = asn1p_constraint_insert(root, \ + arg1); \ + checkmem(__ret == 0); \ + } else { \ + root = arg1; \ + } \ + if(arg2) { \ + int __ret \ + = asn1p_constraint_insert(root, arg2); \ + checkmem(__ret == 0); \ + } \ + } while(0) + +%} + + +/* + * Token value definition. + * a_*: ASN-specific types. + * tv_*: Locally meaningful types. + */ +%union { + asn1p_t *a_grammar; + asn1p_module_flags_e a_module_flags; + asn1p_module_t *a_module; + asn1p_expr_type_e a_type; /* ASN.1 Type */ + asn1p_expr_t *a_expr; /* Constructed collection */ + asn1p_constraint_t *a_constr; /* Constraint */ + enum asn1p_constraint_type_e a_ctype;/* Constraint type */ + asn1p_xports_t *a_xports; /* IMports/EXports */ + asn1p_oid_t *a_oid; /* Object Identifier */ + asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ + struct asn1p_type_tag_s a_tag; /* A tag */ + asn1p_ref_t *a_ref; /* Reference to custom type */ + asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ + asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ + struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ + asn1p_value_t *a_value; /* Number, DefinedValue, etc */ + struct asn1p_param_s a_parg; /* A parameter argument */ + asn1p_paramlist_t *a_plist; /* A pargs list */ + enum asn1p_expr_marker_e a_marker; /* OPTIONAL/DEFAULT */ + enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ + asn1_integer_t a_int; + char *tv_str; + struct { + char *buf; + int len; + } tv_opaque; + struct { + char *name; + struct asn1p_type_tag_s tag; + } tv_nametag; +}; + +/* + * Token types returned by scanner. + */ +%token TOK_PPEQ /* "::=", Pseudo Pascal EQuality */ +%token TOK_opaque /* opaque data (driven from .y) */ +%token TOK_bstring +%token TOK_cstring +%token TOK_hstring +%token TOK_identifier +%token TOK_number +%token TOK_number_negative +%token TOK_typereference +%token TOK_objectclassreference /* "CLASS1" */ +%token TOK_typefieldreference /* "&Pork" */ +%token TOK_valuefieldreference /* "&id" */ + +/* + * Token types representing ASN.1 standard keywords. + */ +%token TOK_ABSENT +%token TOK_ABSTRACT_SYNTAX +%token TOK_ALL +%token TOK_ANY +%token TOK_APPLICATION +%token TOK_AUTOMATIC +%token TOK_BEGIN +%token TOK_BIT +%token TOK_BMPString +%token TOK_BOOLEAN +%token TOK_BY +%token TOK_CHARACTER +%token TOK_CHOICE +%token TOK_CLASS +%token TOK_COMPONENT +%token TOK_COMPONENTS +%token TOK_CONSTRAINED +%token TOK_CONTAINING +%token TOK_DEFAULT +%token TOK_DEFINITIONS +%token TOK_DEFINED +%token TOK_EMBEDDED +%token TOK_ENCODED +%token TOK_END +%token TOK_ENUMERATED +%token TOK_EXPLICIT +%token TOK_EXPORTS +%token TOK_EXTENSIBILITY +%token TOK_EXTERNAL +%token TOK_FALSE +%token TOK_FROM +%token TOK_GeneralizedTime +%token TOK_GeneralString +%token TOK_GraphicString +%token TOK_IA5String +%token TOK_IDENTIFIER +%token TOK_IMPLICIT +%token TOK_IMPLIED +%token TOK_IMPORTS +%token TOK_INCLUDES +%token TOK_INSTANCE +%token TOK_INTEGER +%token TOK_ISO646String +%token TOK_MAX +%token TOK_MIN +%token TOK_MINUS_INFINITY +%token TOK_NULL +%token TOK_NumericString +%token TOK_OBJECT +%token TOK_ObjectDescriptor +%token TOK_OCTET +%token TOK_OF +%token TOK_OPTIONAL +%token TOK_PATTERN +%token TOK_PDV +%token TOK_PLUS_INFINITY +%token TOK_PRESENT +%token TOK_PrintableString +%token TOK_PRIVATE +%token TOK_REAL +%token TOK_RELATIVE_OID +%token TOK_SEQUENCE +%token TOK_SET +%token TOK_SIZE +%token TOK_STRING +%token TOK_SYNTAX +%token TOK_T61String +%token TOK_TAGS +%token TOK_TeletexString +%token TOK_TRUE +%token TOK_TYPE_IDENTIFIER +%token TOK_UNIQUE +%token TOK_UNIVERSAL +%token TOK_UniversalString +%token TOK_UTCTime +%token TOK_UTF8String +%token TOK_VideotexString +%token TOK_VisibleString +%token TOK_WITH + +%left '|' TOK_UNION +%left '^' TOK_INTERSECTION +%left TOK_EXCEPT + +/* Misc tags */ +%token TOK_TwoDots /* .. */ +%token TOK_ThreeDots /* ... */ +%token TOK_tag /* [0] */ + + +/* + * Types defined herein. + */ +%type ModuleList +%type ModuleSpecification +%type ModuleSpecificationBody +%type ModuleSpecificationElement +%type optModuleSpecificationBody /* Optional */ +%type optModuleSpecificationFlags +%type ModuleSpecificationFlags /* Set of FL */ +%type ModuleSpecificationFlag /* Single FL */ +%type ImportsDefinition +%type ImportsBundleSet +%type ImportsBundle +%type ImportsList +%type ExportsDefinition +%type ExportsBody +%type ImportsElement +%type ExportsElement +%type DataTypeMember +%type ExtensionAndException +%type TypeDeclaration +%type ComplexTypeReference +%type ComplexTypeReferenceAmpList +%type ComplexTypeReferenceElement +%type ClassFieldIdentifier +%type ClassFieldName +%type ClassFieldList +%type ClassField +%type ClassDeclaration +%type ConstrainedTypeDeclaration +%type DataTypeReference /* Type1 ::= Type2 */ +%type DefinedTypeRef +%type ValueSetDefinition /* Val INTEGER ::= {1|2} */ +%type ValueDefinition /* val INTEGER ::= 1*/ +%type optValueSetBody +%type InlineOrDefinedValue +%type DefinedValue +%type SignedNumber +%type ConstructedType +%type ConstructedDataTypeDefinition +//%type optUniverationDefinition +%type UniverationDefinition +%type UniverationList +%type UniverationElement +%type TypeRefName +%type ObjectClassReference +%type TaggedIdentifier +%type Identifier +%type ParameterArgumentName +%type ParameterArgumentList +%type ActualParameter +%type ActualParameterList +%type ObjectIdentifier /* OID */ +%type optObjectIdentifier /* Optional OID */ +%type ObjectIdentifierBody +%type ObjectIdentifierElement +%type BasicType +%type BasicTypeId +%type BasicTypeId_UniverationCompatible +%type BasicString +%type Opaque +//%type StringValue +%type Tag /* [UNIVERSAL 0] IMPLICIT */ +%type optTag /* [UNIVERSAL 0] IMPLICIT */ +%type optConstraints +%type Constraints +%type SingleConstraint /* (SIZE(2)) */ +%type ConstraintElementSet /* 1..2,...,3 */ +%type ConstraintSubtypeElement /* 1..2 */ +%type ConstraintElementIntersection +%type ConstraintElementException +%type ConstraintElementUnion +%type ConstraintElement +%type SimpleTableConstraint +%type TableConstraint +%type WithComponents +%type WithComponentsList +%type WithComponentsElement +%type ComponentRelationConstraint +%type AtNotationList +%type AtNotationElement +%type ConstraintValue +%type ConstraintSpec +%type ConstraintRangeSpec +%type optWithSyntax +%type WithSyntax +%type WithSyntaxFormat +%type WithSyntaxFormatToken +%type optMarker Marker +%type optUnique +%type optPresenceConstraint PresenceConstraint +%type ComponentIdList + + +%% + + +ParsedGrammar: + ModuleList { + *(void **)param = $1; + } + ; + +ModuleList: + ModuleSpecification { + $$ = asn1p_new(); + checkmem($$); + TQ_ADD(&($$->modules), $1, mod_next); + } + | ModuleList ModuleSpecification { + $$ = $1; + TQ_ADD(&($$->modules), $2, mod_next); + } + ; + +/* + * ASN module definition. + * === EXAMPLE === + * MySyntax DEFINITIONS AUTOMATIC TAGS ::= + * BEGIN + * ... + * END + * === EOF === + */ + +ModuleSpecification: + TypeRefName optObjectIdentifier TOK_DEFINITIONS + optModuleSpecificationFlags + TOK_PPEQ TOK_BEGIN + optModuleSpecificationBody + TOK_END { + + if($7) { + $$ = $7; + } else { + /* There's a chance that a module is just plain empty */ + $$ = asn1p_module_new(); + } + checkmem($$); + + $$->Identifier = $1; + $$->module_oid = $2; + $$->module_flags = $4; + } + ; + +/* + * Object Identifier Definition + * { iso member-body(2) 3 } + */ +optObjectIdentifier: + { $$ = 0; } + | ObjectIdentifier { $$ = $1; } + ; + +ObjectIdentifier: + '{' ObjectIdentifierBody '}' { + $$ = $2; + } + | '{' '}' { + $$ = 0; + } + ; + +ObjectIdentifierBody: + ObjectIdentifierElement { + $$ = asn1p_oid_new(); + asn1p_oid_add_arc($$, &$1); + if($1.name) + free($1.name); + } + | ObjectIdentifierBody ObjectIdentifierElement { + $$ = $1; + asn1p_oid_add_arc($$, &$2); + if($2.name) + free($2.name); + } + ; + +ObjectIdentifierElement: + Identifier { /* iso */ + $$.name = $1; + $$.number = -1; + } + | Identifier '(' TOK_number ')' { /* iso(1) */ + $$.name = $1; + $$.number = $3; + } + | TOK_number { /* 1 */ + $$.name = 0; + $$.number = $1; + } + ; + +/* + * Optional module flags. + */ +optModuleSpecificationFlags: + { $$ = MSF_NOFLAGS; } + | ModuleSpecificationFlags { + $$ = $1; + } + ; + +/* + * Module flags. + */ +ModuleSpecificationFlags: + ModuleSpecificationFlag { + $$ = $1; + } + | ModuleSpecificationFlags ModuleSpecificationFlag { + $$ = $1 | $2; + } + ; + +/* + * Single module flag. + */ +ModuleSpecificationFlag: + TOK_EXPLICIT TOK_TAGS { + $$ = MSF_EXPLICIT_TAGS; + } + | TOK_IMPLICIT TOK_TAGS { + $$ = MSF_IMPLICIT_TAGS; + } + | TOK_AUTOMATIC TOK_TAGS { + $$ = MSF_AUTOMATIC_TAGS; + } + | TOK_EXTENSIBILITY TOK_IMPLIED { + $$ = MSF_EXTENSIBILITY_IMPLIED; + } + ; + +/* + * Optional module body. + */ +optModuleSpecificationBody: + { $$ = 0; } + | ModuleSpecificationBody { + assert($1); + $$ = $1; + } + ; + +/* + * ASN.1 Module body. + */ +ModuleSpecificationBody: + ModuleSpecificationElement { + $$ = $1; + } + | ModuleSpecificationBody ModuleSpecificationElement { + $$ = $1; + +#ifdef MY_IMPORT +#error MY_IMPORT DEFINED ELSEWHERE! +#endif +#define MY_IMPORT(foo,field) do { \ + if(TQ_FIRST(&($2->foo))) { \ + TQ_ADD(&($$->foo), \ + TQ_REMOVE(&($2->foo), field), \ + field); \ + assert(TQ_FIRST(&($2->foo)) == 0); \ + } } while(0) + + MY_IMPORT(imports, xp_next); + MY_IMPORT(exports, xp_next); + MY_IMPORT(members, next); +#undef MY_IMPORT + + } + ; + +/* + * One of the elements of ASN.1 module specification. + */ +ModuleSpecificationElement: + ImportsDefinition { + $$ = $1; + } + | ExportsDefinition { + $$ = asn1p_module_new(); + checkmem($$); + if($1) { + TQ_ADD(&($$->exports), $1, xp_next); + } else { + /* "EXPORTS ALL;" ? */ + } + } + | DataTypeReference { + $$ = asn1p_module_new(); + checkmem($$); + assert($1->expr_type != A1TC_INVALID); + assert($1->meta_type != AMT_INVALID); + TQ_ADD(&($$->members), $1, next); + } + | ValueDefinition { + $$ = asn1p_module_new(); + checkmem($$); + assert($1->expr_type != A1TC_INVALID); + assert($1->meta_type != AMT_INVALID); + TQ_ADD(&($$->members), $1, next); + } + /* + * Value set definition + * === EXAMPLE === + * EvenNumbers INTEGER ::= { 2 | 4 | 6 | 8 } + * === EOF === + */ + | ValueSetDefinition { + $$ = asn1p_module_new(); + checkmem($$); + assert($1->expr_type != A1TC_INVALID); + assert($1->meta_type != AMT_INVALID); + TQ_ADD(&($$->members), $1, next); + } + + /* + * Erroneous attemps + */ + | BasicString { + return yyerror( + "Attempt to redefine a standard basic type, " + "use -ftypesXY to switch back " + "to older version of ASN.1 standard"); + } + ; + +/* + * === EXAMPLE === + * IMPORTS Type1, value FROM Module { iso standard(0) } ; + * === EOF === + */ +ImportsDefinition: + TOK_IMPORTS ImportsBundleSet ';' { + $$ = $2; + } + /* + * Some error cases. + */ + | TOK_IMPORTS TOK_FROM /* ... */ { + return yyerror("Empty IMPORTS list"); + } + ; + +ImportsBundleSet: + ImportsBundle { + $$ = asn1p_module_new(); + checkmem($$); + TQ_ADD(&($$->imports), $1, xp_next); + } + | ImportsBundleSet ImportsBundle { + $$ = $1; + TQ_ADD(&($$->imports), $2, xp_next); + } + ; + +ImportsBundle: + ImportsList TOK_FROM TypeRefName optObjectIdentifier { + $$ = $1; + $$->from = $3; + $$->from_oid = $4; + checkmem($$); + } + ; + +ImportsList: + ImportsElement { + $$ = asn1p_xports_new(); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | ImportsList ',' ImportsElement { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ImportsElement: + TypeRefName { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_REFERENCE; + } + | Identifier { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_REFERENCE; + } + ; + +ExportsDefinition: + TOK_EXPORTS ExportsBody ';' { + $$ = $2; + } + | TOK_EXPORTS TOK_ALL ';' { + $$ = 0; + } + | TOK_EXPORTS ';' { + /* Empty EXPORTS clause effectively prohibits export. */ + $$ = asn1p_xports_new(); + checkmem($$); + } + ; + +ExportsBody: + ExportsElement { + $$ = asn1p_xports_new(); + assert($$); + TQ_ADD(&($$->members), $1, next); + } + | ExportsBody ',' ExportsElement { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ExportsElement: + TypeRefName { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_EXPORTVAR; + } + | Identifier { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_EXPORTVAR; + } + ; + + +ValueSetDefinition: + TypeRefName DefinedTypeRef TOK_PPEQ '{' optValueSetBody '}' { + $$ = $2; + assert($$->Identifier == 0); + $$->Identifier = $1; + $$->meta_type = AMT_VALUESET; + // take care of optValueSetBody + } + ; + +DefinedTypeRef: + ComplexTypeReference { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->reference = $1; + $$->expr_type = A1TC_REFERENCE; + $$->meta_type = AMT_TYPEREF; + } + | BasicTypeId { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + ; + +optValueSetBody: + { } + | ConstraintElementSet { + } + ; + + +/* + * Data Type Reference. + * === EXAMPLE === + * Type3 ::= CHOICE { a Type1, b Type 2 } + * === EOF === + */ + +DataTypeReference: + /* + * Optionally tagged type definition. + */ + TypeRefName TOK_PPEQ optTag TOK_TYPE_IDENTIFIER { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->tag = $3; + $$->expr_type = A1TC_TYPEID; + $$->meta_type = AMT_TYPE; + } + | TypeRefName TOK_PPEQ optTag ConstrainedTypeDeclaration { + $$ = $4; + $$->Identifier = $1; + $$->tag = $3; + assert($$->expr_type); + assert($$->meta_type); + } + | TypeRefName TOK_PPEQ ClassDeclaration { + $$ = $3; + $$->Identifier = $1; + assert($$->expr_type == A1TC_CLASSDEF); + assert($$->meta_type == AMT_OBJECT); + } + /* + * Parametrized declaration: + * === EXAMPLE === + * SIGNED { ToBeSigned } ::= SEQUENCE { + * toBeSigned ToBeSigned, + * algorithm AlgorithmIdentifier, + * signature BIT STRING + * } + * === EOF === + */ + | TypeRefName '{' ParameterArgumentList '}' + TOK_PPEQ ConstrainedTypeDeclaration { + $$ = $6; + assert($$->Identifier == 0); + $$->Identifier = $1; + $$->params = $3; + $$->meta_type = AMT_PARAMTYPE; + } + ; + +ParameterArgumentList: + ParameterArgumentName { + int ret; + $$ = asn1p_paramlist_new(yylineno); + checkmem($$); + ret = asn1p_paramlist_add_param($$, $1.governor, $1.argument); + checkmem(ret == 0); + if($1.governor) asn1p_ref_free($1.governor); + if($1.argument) free($1.argument); + } + | ParameterArgumentList ',' ParameterArgumentName { + int ret; + $$ = $1; + ret = asn1p_paramlist_add_param($$, $3.governor, $3.argument); + checkmem(ret == 0); + if($3.governor) asn1p_ref_free($3.governor); + if($3.argument) free($3.argument); + } + ; + +ParameterArgumentName: + TypeRefName { + $$.governor = NULL; + $$.argument = $1; + } + | TypeRefName ':' Identifier { + int ret; + $$.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$.governor, $1, 0); + checkmem(ret == 0); + $$.argument = $3; + } + | BasicTypeId ':' Identifier { + int ret; + $$.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$.governor, + ASN_EXPR_TYPE2STR($1), 1); + checkmem(ret == 0); + $$.argument = $3; + } + ; + +ActualParameterList: + ActualParameter { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | ActualParameterList ',' ActualParameter { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ActualParameter: + TypeDeclaration { + $$ = $1; + } + | Identifier { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_REFERENCE; + $$->meta_type = AMT_VALUE; + } + ; + +/* + * A collection of constructed data type members. + */ +ConstructedDataTypeDefinition: + DataTypeMember { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | ConstructedDataTypeDefinition ',' DataTypeMember { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ClassDeclaration: + TOK_CLASS '{' ClassFieldList '}' optWithSyntax { + $$ = $3; + checkmem($$); + $$->with_syntax = $5; + assert($$->expr_type == A1TC_CLASSDEF); + assert($$->meta_type == AMT_OBJECT); + } + ; + +optUnique: + { $$ = 0; } + | TOK_UNIQUE { $$ = 1; } + ; + +ClassFieldList: + ClassField { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->expr_type = A1TC_CLASSDEF; + $$->meta_type = AMT_OBJECT; + TQ_ADD(&($$->members), $1, next); + } + | ClassFieldList ',' ClassField { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ClassField: + ClassFieldIdentifier optMarker { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1.name; + $$->expr_type = A1TC_CLASSFIELD; + $$->meta_type = AMT_OBJECTFIELD; + $$->marker = $2; + } + | ClassFieldIdentifier ConstrainedTypeDeclaration optUnique { + $$ = $2; + $$->Identifier = $1.name; + $$->unique = $3; + } + | ClassFieldIdentifier ClassFieldIdentifier optMarker optUnique { + int ret; + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1.name; + $$->reference = asn1p_ref_new(yylineno); + checkmem($$->reference); + ret = asn1p_ref_add_component($$->reference, + $2.name, $2.lex_type); + checkmem(ret == 0); + $$->expr_type = A1TC_CLASSFIELD; + $$->meta_type = AMT_OBJECTFIELD; + $$->marker = $3; + $$->unique = $4; + } + ; + +optWithSyntax: + { $$ = 0; } + | WithSyntax { + $$ = $1; + } + ; + +WithSyntax: + TOK_WITH TOK_SYNTAX '{' + { asn1p_lexer_hack_enable_with_syntax(); } + WithSyntaxFormat + '}' { + $$ = $5; + } + ; + +WithSyntaxFormat: + WithSyntaxFormatToken { + $$ = asn1p_wsyntx_new(); + TQ_ADD(&($$->chunks), $1, next); + } + | WithSyntaxFormat WithSyntaxFormatToken { + $$ = $1; + TQ_ADD(&($$->chunks), $2, next); + } + ; + +WithSyntaxFormatToken: + TOK_opaque { + $$ = asn1p_wsyntx_chunk_frombuf($1.buf, $1.len, 0); + } + | ClassFieldIdentifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1.name, $1.lex_type); + checkmem(ret == 0); + $$ = asn1p_wsyntx_chunk_fromref(ref, 0); + } + ; + +/* + * A data type member goes like this + * === + * memb1 [0] Type1 { a(1), b(2) } (2) + * === + * Therefore, we propose a split. + * ^^^^^^^^^ ^^^^^^^^^^ + * ^TaggedIdentifier ^TypeDeclaration + * ^ConstrainedTypeDeclaration + */ + +/* + * A member of a constructed data type ("a" or "b" in above example). + */ +DataTypeMember: + TaggedIdentifier ConstrainedTypeDeclaration { + $$ = $2; + assert($$->Identifier == 0); + $$->Identifier = $1.name; + $$->tag = $1.tag; + } + | ExtensionAndException { + $$ = $1; + } + ; + +ConstrainedTypeDeclaration: + TypeDeclaration optConstraints optMarker { + $$ = $1; + $$->constraints = $2; + $$->marker = $3; + } + ; + +ExtensionAndException: + TOK_ThreeDots { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + checkmem($$->Identifier); + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_TYPE; + } + | TOK_ThreeDots '!' DefinedValue { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + checkmem($$->Identifier); + $$->value = $3; + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_TYPE; + } + | TOK_ThreeDots '!' SignedNumber { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + $$->value = $3; + checkmem($$->Identifier); + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_TYPE; + } + ; + +TypeDeclaration: + BasicType { + $$ = $1; + } + | BasicString { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + | ConstructedType { + $$ = $1; + checkmem($$); + assert($$->meta_type); + } + /* + * A parametrized assignment. + */ + | TypeRefName '{' ActualParameterList '}' { + int ret; + $$ = $3; + assert($$->expr_type == 0); + assert($$->meta_type == 0); + assert($$->reference == 0); + $$->reference = asn1p_ref_new(yylineno); + checkmem($$->reference); + ret = asn1p_ref_add_component($$->reference, $1, RLT_UNKNOWN); + checkmem(ret == 0); + free($1); + $$->expr_type = A1TC_PARAMETRIZED; + $$->meta_type = AMT_TYPE; + } + /* + * A DefinedType reference. + * "CLASS1.&id.&id2" + * or + * "Module.Type" + * or + * "Module.identifier" + * or + * "Type" + */ + | ComplexTypeReference { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->reference = $1; + $$->expr_type = A1TC_REFERENCE; + $$->meta_type = AMT_TYPEREF; + } + | TOK_INSTANCE TOK_OF ComplexTypeReference { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->reference = $3; + $$->expr_type = A1TC_INSTANCE; + $$->meta_type = AMT_TYPE; + } + ; + +/* + * A type name consisting of several components. + * === EXAMPLE === + * === EOF === + */ +ComplexTypeReference: + TOK_typereference { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); + checkmem(ret == 0); + free($1); + } + | TOK_typereference '.' TypeRefName { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component($$, $3, RLT_UNKNOWN); + checkmem(ret == 0); + free($1); + } + | TOK_typereference '.' Identifier { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component($$, $3, RLT_lowercase); + checkmem(ret == 0); + free($1); + } + | ObjectClassReference { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_CAPITALS); + free($1); + checkmem(ret == 0); + } + | ObjectClassReference '.' ComplexTypeReferenceAmpList { + int ret; + $$ = $3; + ret = asn1p_ref_add_component($$, $1, RLT_CAPITALS); + free($1); + checkmem(ret == 0); + /* + * Move the last element infront. + */ + { + struct asn1p_ref_component_s tmp_comp; + tmp_comp = $$->components[$$->comp_count-1]; + memmove(&$$->components[1], + &$$->components[0], + sizeof($$->components[0]) + * ($$->comp_count - 1)); + $$->components[0] = tmp_comp; + } + } + ; + +ComplexTypeReferenceAmpList: + ComplexTypeReferenceElement { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1.name, $1.lex_type); + free($1.name); + checkmem(ret == 0); + } + | ComplexTypeReferenceAmpList '.' ComplexTypeReferenceElement { + int ret; + $$ = $1; + ret = asn1p_ref_add_component($$, $3.name, $3.lex_type); + free($3.name); + checkmem(ret == 0); + } + ; + +ComplexTypeReferenceElement: ClassFieldName; +ClassFieldIdentifier: ClassFieldName; + +ClassFieldName: + /* "&Type1" */ + TOK_typefieldreference { + $$.lex_type = RLT_AmpUppercase; + $$.name = $1; + } + /* "&id" */ + | TOK_valuefieldreference { + $$.lex_type = RLT_Amplowercase; + $$.name = $1; + } + ; + + +/* + * === EXAMPLE === + * value INTEGER ::= 1 + * === EOF === + */ +ValueDefinition: + Identifier DefinedTypeRef TOK_PPEQ InlineOrDefinedValue { + $$ = $2; + assert($$->Identifier == NULL); + $$->Identifier = $1; + $$->meta_type = AMT_VALUE; + $$->value = $4; + } + ; + +InlineOrDefinedValue: + '{' { asn1p_lexer_hack_push_opaque_state(); } + Opaque /* '}' */ { + $$ = asn1p_value_frombuf($3.buf, $3.len, 0); + checkmem($$); + $$->type = ATV_UNPARSED; + } + | TOK_bstring { + $$ = _convert_bitstring2binary($1, 'B'); + checkmem($$); + } + | TOK_hstring { + $$ = _convert_bitstring2binary($1, 'H'); + checkmem($$); + } + | TOK_cstring { + $$ = asn1p_value_frombuf($1.buf, $1.len, 0); + checkmem($$); + } + | SignedNumber { + $$ = $1; + } + | DefinedValue { + $$ = $1; + } + ; + +DefinedValue: + Identifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1, RLT_lowercase); + checkmem(ret == 0); + $$ = asn1p_value_fromref(ref, 0); + checkmem($$); + free($1); + } + | TypeRefName '.' Identifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(ref, $3, RLT_lowercase); + checkmem(ret == 0); + $$ = asn1p_value_fromref(ref, 0); + checkmem($$); + free($1); + free($3); + } + ; + +Opaque: + TOK_opaque { + $$.len = $1.len + 2; + $$.buf = malloc($$.len + 1); + checkmem($$.buf); + $$.buf[0] = '{'; + $$.buf[1] = ' '; + memcpy($$.buf + 2, $1.buf, $1.len); + $$.buf[$$.len] = '\0'; + free($1.buf); + } + | Opaque TOK_opaque { + int newsize = $1.len + $2.len; + char *p = malloc(newsize + 1); + checkmem(p); + memcpy(p , $1.buf, $1.len); + memcpy(p + $1.len, $2.buf, $2.len); + p[newsize] = '\0'; + free($1.buf); + free($2.buf); + $$.buf = p; + $$.len = newsize; + } + ; + +BasicTypeId: + TOK_BOOLEAN { $$ = ASN_BASIC_BOOLEAN; } + | TOK_NULL { $$ = ASN_BASIC_NULL; } + | TOK_REAL { $$ = ASN_BASIC_REAL; } + | BasicTypeId_UniverationCompatible { $$ = $1; } + | TOK_OCTET TOK_STRING { $$ = ASN_BASIC_OCTET_STRING; } + | TOK_OBJECT TOK_IDENTIFIER { $$ = ASN_BASIC_OBJECT_IDENTIFIER; } + | TOK_RELATIVE_OID { $$ = ASN_BASIC_RELATIVE_OID; } + | TOK_EXTERNAL { $$ = ASN_BASIC_EXTERNAL; } + | TOK_EMBEDDED TOK_PDV { $$ = ASN_BASIC_EMBEDDED_PDV; } + | TOK_CHARACTER TOK_STRING { $$ = ASN_BASIC_CHARACTER_STRING; } + | TOK_UTCTime { $$ = ASN_BASIC_UTCTime; } + | TOK_GeneralizedTime { $$ = ASN_BASIC_GeneralizedTime; } + ; + +/* + * A type identifier which may be used with "{ a(1), b(2) }" clause. + */ +BasicTypeId_UniverationCompatible: + TOK_INTEGER { $$ = ASN_BASIC_INTEGER; } + | TOK_ENUMERATED { $$ = ASN_BASIC_ENUMERATED; } + | TOK_BIT TOK_STRING { $$ = ASN_BASIC_BIT_STRING; } + ; + +BasicType: + BasicTypeId { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + | BasicTypeId_UniverationCompatible UniverationDefinition { + if($2) { + $$ = $2; + } else { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + } + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + ; + +BasicString: + TOK_BMPString { $$ = ASN_STRING_BMPString; } + | TOK_GeneralString { + $$ = ASN_STRING_GeneralString; + return yyerror("GeneralString is not supported"); + } + | TOK_GraphicString { + $$ = ASN_STRING_GraphicString; + return yyerror("GraphicString is not supported"); + } + | TOK_IA5String { $$ = ASN_STRING_IA5String; } + | TOK_ISO646String { $$ = ASN_STRING_ISO646String; } + | TOK_NumericString { $$ = ASN_STRING_NumericString; } + | TOK_PrintableString { $$ = ASN_STRING_PrintableString; } + | TOK_T61String { + $$ = ASN_STRING_T61String; + return yyerror("T61String not implemented yet"); + } + | TOK_TeletexString { $$ = ASN_STRING_TeletexString; } + | TOK_UniversalString { $$ = ASN_STRING_UniversalString; } + | TOK_UTF8String { $$ = ASN_STRING_UTF8String; } + | TOK_VideotexString { + $$ = ASN_STRING_VideotexString; + return yyerror("VideotexString is no longer supported"); + } + | TOK_VisibleString { $$ = ASN_STRING_VisibleString; } + | TOK_ObjectDescriptor { $$ = ASN_STRING_ObjectDescriptor; } + ; + +ConstructedType: + TOK_CHOICE '{' ConstructedDataTypeDefinition '}' { + $$ = $3; + assert($$->expr_type == A1TC_INVALID); + $$->expr_type = ASN_CONSTR_CHOICE; + $$->meta_type = AMT_TYPE; + } + | TOK_SEQUENCE '{' ConstructedDataTypeDefinition '}' { + $$ = $3; + assert($$->expr_type == A1TC_INVALID); + $$->expr_type = ASN_CONSTR_SEQUENCE; + $$->meta_type = AMT_TYPE; + } + | TOK_SET '{' ConstructedDataTypeDefinition '}' { + $$ = $3; + assert($$->expr_type == A1TC_INVALID); + $$->expr_type = ASN_CONSTR_SET; + $$->meta_type = AMT_TYPE; + } + | TOK_SEQUENCE optConstraints TOK_OF TypeDeclaration { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->constraints = $2; + $$->expr_type = ASN_CONSTR_SEQUENCE_OF; + $$->meta_type = AMT_TYPE; + TQ_ADD(&($$->members), $4, next); + } + | TOK_SET optConstraints TOK_OF TypeDeclaration { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->constraints = $2; + $$->expr_type = ASN_CONSTR_SET_OF; + $$->meta_type = AMT_TYPE; + TQ_ADD(&($$->members), $4, next); + } + | TOK_ANY { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = ASN_CONSTR_ANY; + $$->meta_type = AMT_TYPE; + } + | TOK_ANY TOK_DEFINED TOK_BY Identifier { + int ret; + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->reference = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$->reference, + $4, RLT_lowercase); + checkmem(ret == 0); + $$->expr_type = ASN_CONSTR_ANY; + $$->meta_type = AMT_TYPE; + } + ; + +/* + * Data type constraints. + */ +optConstraints: + { $$ = 0; } + | Constraints { $$ = $1; } + ; + +Union: '|' | TOK_UNION; +Intersection: '^' | TOK_INTERSECTION; +Except: TOK_EXCEPT; + +Constraints: + TOK_SIZE '(' ConstraintElementSet ')' { + /* + * This is a special case, for compatibility purposes. + * It goes without parenthesis. + */ + int ret; + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_CT_SIZE; + ret = asn1p_constraint_insert($$, $3); + checkmem(ret == 0); + } + | SingleConstraint { + CONSTRAINT_INSERT($$, ACT_CA_SET, $1, 0); + } + | Constraints SingleConstraint { + CONSTRAINT_INSERT($$, ACT_CA_SET, $1, $2); + } + ; + +SingleConstraint: + '(' ConstraintElementSet ')' { + $$ = $2; + } + ; + +ConstraintElementSet: + ConstraintElement { + $$ = $1; + } + | ConstraintElement ',' TOK_ThreeDots { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); + } + | ConstraintElement ',' TOK_ThreeDots ',' ConstraintElement { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, $5); + } + | TOK_ThreeDots { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_EXT; + } + | TOK_ThreeDots ',' ConstraintElement { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT($$, ACT_CA_CSV, ct, $3); + } + ; + +ConstraintElement: ConstraintElementUnion { $$ = $1; } ; + +ConstraintElementUnion: + ConstraintElementIntersection { $$ = $1; } + | ConstraintElementUnion Union ConstraintElementIntersection { + CONSTRAINT_INSERT($$, ACT_CA_UNI, $1, $3); + } + ; + +ConstraintElementIntersection: + ConstraintElementException { $$ = $1; } + | ConstraintElementIntersection Intersection + ConstraintElementException { + CONSTRAINT_INSERT($$, ACT_CA_INT, $1, $3); + } + ; + +ConstraintElementException: + ConstraintSubtypeElement { $$ = $1; } + | ConstraintElementException Except ConstraintSubtypeElement { + CONSTRAINT_INSERT($$, ACT_CA_EXC, $1, $3); + } + ; + +ConstraintSubtypeElement: + ConstraintValue { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_VALUE; + $$->value = $1; + } + | ConstraintValue ConstraintRangeSpec ConstraintValue { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = $2; + $$->range_start = $1; + $$->range_stop = $3; + } + | ConstraintSpec '(' ConstraintElementSet ')' { + int ret; + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = $1; + ret = asn1p_constraint_insert($$, $3); + checkmem(ret == 0); + } + | TableConstraint { + $$ = $1; + } + | WithComponents { + $$ = $1; + } + ; + +ConstraintRangeSpec: + TOK_TwoDots { $$ = ACT_EL_RANGE; } + | TOK_TwoDots '<' { $$ = ACT_EL_RLRANGE; } + | '<' TOK_TwoDots { $$ = ACT_EL_LLRANGE; } + | '<' TOK_TwoDots '<' { $$ = ACT_EL_ULRANGE; } + ; + +ConstraintSpec: + TOK_SIZE { + $$ = ACT_CT_SIZE; + } + | TOK_FROM { + $$ = ACT_CT_FROM; + } + ; + +ConstraintValue: + SignedNumber { + $$ = $1; + } + | Identifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1, RLT_lowercase); + checkmem(ret == 0); + $$ = asn1p_value_fromref(ref, 0); + checkmem($$); + free($1); + } + | TOK_cstring { + $$ = asn1p_value_frombuf($1.buf, $1.len, 0); + checkmem($$); + } + | TOK_MIN { + $$ = asn1p_value_fromint(123); + checkmem($$); + $$->type = ATV_MIN; + } + | TOK_MAX { + $$ = asn1p_value_fromint(321); + checkmem($$); + $$->type = ATV_MAX; + } + | TOK_FALSE { + $$ = asn1p_value_fromint(0); + checkmem($$); + $$->type = ATV_FALSE; + } + | TOK_TRUE { + $$ = asn1p_value_fromint(1); + checkmem($$); + $$->type = ATV_TRUE; + } + ; + +WithComponents: + TOK_WITH TOK_COMPONENTS '{' WithComponentsList '}' { + CONSTRAINT_INSERT($$, ACT_CT_WCOMPS, $4, 0); + } + ; + +WithComponentsList: + WithComponentsElement { + $$ = $1; + } + | WithComponentsList ',' WithComponentsElement { + CONSTRAINT_INSERT($$, ACT_CT_WCOMPS, $1, $3); + } + ; + +WithComponentsElement: + TOK_ThreeDots { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_EXT; + } + | Identifier optConstraints optPresenceConstraint { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_VALUE; + $$->value = asn1p_value_frombuf($1, strlen($1), 0); + $$->presence = $3; + } + ; + +/* + * presence constraint for WithComponents + */ +optPresenceConstraint: + { $$ = ACPRES_DEFAULT; } + | PresenceConstraint { $$ = $1; } + ; + +PresenceConstraint: + TOK_PRESENT { + $$ = ACPRES_PRESENT; + } + | TOK_ABSENT { + $$ = ACPRES_ABSENT; + } + | TOK_OPTIONAL { + $$ = ACPRES_OPTIONAL; + } + ; + +TableConstraint: + SimpleTableConstraint { + $$ = $1; + } + | ComponentRelationConstraint { + $$ = $1; + } + ; + +/* + * "{ExtensionSet}" + */ +SimpleTableConstraint: + '{' TypeRefName '}' { + asn1p_ref_t *ref = asn1p_ref_new(yylineno); + asn1p_constraint_t *ct; + int ret; + ret = asn1p_ref_add_component(ref, $2, 0); + checkmem(ret == 0); + ct = asn1p_constraint_new(yylineno); + checkmem($$); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref(ref, 0); + CONSTRAINT_INSERT($$, ACT_CA_CRC, ct, 0); + } + ; + +ComponentRelationConstraint: + SimpleTableConstraint '{' AtNotationList '}' { + CONSTRAINT_INSERT($$, ACT_CA_CRC, $1, $3); + } + ; + +AtNotationList: + AtNotationElement { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_VALUE; + $$->value = asn1p_value_fromref($1, 0); + } + | AtNotationList ',' AtNotationElement { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref($3, 0); + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); + } + ; + +/* + * @blah + */ +AtNotationElement: + '@' ComponentIdList { + char *p = malloc(strlen($2) + 2); + int ret; + *p = '@'; + strcpy(p + 1, $2); + $$ = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$, p, 0); + checkmem(ret == 0); + free(p); + free($2); + } + | '@' '.' ComponentIdList { + char *p = malloc(strlen($3) + 3); + int ret; + p[0] = '@'; + p[1] = '.'; + strcpy(p + 2, $3); + $$ = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$, p, 0); + checkmem(ret == 0); + free(p); + free($3); + } + ; + +/* identifier "." ... */ +ComponentIdList: + Identifier { + $$ = $1; + } + | ComponentIdList '.' Identifier { + int l1 = strlen($1); + int l3 = strlen($3); + $$ = malloc(l1 + 1 + l3 + 1); + memcpy($$, $1, l1); + $$[l1] = '.'; + memcpy($$ + l1 + 1, $3, l3); + $$[l1 + 1 + l3] = '\0'; + } + ; + + + +/* + * MARKERS + */ + +optMarker: + { $$ = EM_NOMARK; } + | Marker { $$ = $1; } + ; + +Marker: + TOK_OPTIONAL { + $$ = EM_OPTIONAL; + } + | TOK_DEFAULT DefaultValue { + $$ = EM_DEFAULT; + /* FIXME: store DefaultValue somewhere */ + } + ; + +DefaultValue: + ConstraintValue { + } + | BasicTypeId { + } + | '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ { + } + ; + +/* + * Universal enumeration definition to use in INTEGER and ENUMERATED. + * === EXAMPLE === + * Gender ::= ENUMERATED { unknown(0), male(1), female(2) } + * Temperature ::= INTEGER { absolute-zero(-273), freezing(0), boiling(100) } + * === EOF === + */ +/* +optUniverationDefinition: + { $$ = 0; } + | UniverationDefinition { + $$ = $1; + } + ; +*/ + +UniverationDefinition: + '{' '}' { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + } + | '{' UniverationList '}' { + $$ = $2; + } + ; + +UniverationList: + UniverationElement { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | UniverationList ',' UniverationElement { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +UniverationElement: + Identifier { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->Identifier = $1; + } + | Identifier '(' SignedNumber ')' { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->Identifier = $1; + $$->value = $3; + } + | Identifier '(' DefinedValue ')' { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->Identifier = $1; + $$->value = $3; + } + | SignedNumber { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->value = $1; + } + | TOK_ThreeDots { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + checkmem($$->Identifier); + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_VALUE; + } + ; + +SignedNumber: + TOK_number { + $$ = asn1p_value_fromint($1); + checkmem($$); + } + | TOK_number_negative { + $$ = asn1p_value_fromint($1); + checkmem($$); + } + ; + +/* + * SEQUENCE definition. + * === EXAMPLE === + * Struct1 ::= SEQUENCE { + * memb1 Struct2, + * memb2 SEQUENCE OF { + * memb2-1 Struct 3 + * } + * } + * === EOF === + */ + + + +/* + * SET definition. + * === EXAMPLE === + * Person ::= SET { + * name [0] PrintableString (SIZE(1..20)), + * country [1] PrintableString (SIZE(1..20)) DEFAULT default-country, + * } + * === EOF === + */ + +optTag: + { memset(&$$, 0, sizeof($$)); } + | Tag { $$ = $1; } + ; + +Tag: + TOK_tag { + $$ = $1; + $$.tag_mode = TM_DEFAULT; + } + | TOK_tag TOK_IMPLICIT { + $$ = $1; + $$.tag_mode = TM_IMPLICIT; + } + | TOK_tag TOK_EXPLICIT { + $$ = $1; + $$.tag_mode = TM_EXPLICIT; + } + ; + +TypeRefName: + TOK_typereference { + checkmem($1); + $$ = $1; + } + | TOK_objectclassreference { + checkmem($1); + $$ = $1; + } + ; + +ObjectClassReference: + TOK_objectclassreference { + checkmem($1); + $$ = $1; + } + ; + +Identifier: + TOK_identifier { + checkmem($1); + $$ = $1; + } + ; + +TaggedIdentifier: + Identifier { + memset(&$$, 0, sizeof($$)); + $$.name = $1; + } + | Identifier Tag { + $$.name = $1; + $$.tag = $2; + } + ; + + +%% + + +/* + * Convert Xstring ('0101'B or '5'H) to the binary vector. + */ +static asn1p_value_t * +_convert_bitstring2binary(char *str, int base) { + asn1p_value_t *val; + int slen; + int memlen; + int baselen; + int bits; + uint8_t *binary_vector; + uint8_t *bv_ptr; + uint8_t cur_val; + + assert(str); + assert(str[0] == '\''); + + switch(base) { + case 'B': + baselen = 1; + break; + case 'H': + baselen = 4; + break; + default: + assert(base == 'B' || base == 'H'); + errno = EINVAL; + return NULL; + } + + slen = strlen(str); + assert(str[slen - 1] == base); + assert(str[slen - 2] == '\''); + + memlen = slen / (8 / baselen); /* Conservative estimate */ + + bv_ptr = binary_vector = malloc(memlen + 1); + if(bv_ptr == NULL) + /* ENOMEM */ + return NULL; + + cur_val = 0; + bits = 0; + while(*(++str) != '\'') { + switch(baselen) { + case 1: + switch(*str) { + case '1': + cur_val |= 1 << (7 - (bits % 8)); + case '0': + break; + default: + assert(!"_y UNREACH1"); + case ' ': case '\r': case '\n': + continue; + } + break; + case 4: + switch(*str) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + cur_val |= (*str - '0') << (4 - (bits % 8)); + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + cur_val |= ((*str - 'A') + 10) + << (4 - (bits % 8)); + break; + default: + assert(!"_y UNREACH2"); + case ' ': case '\r': case '\n': + continue; + } + break; + } + + bits += baselen; + if((bits % 8) == 0) { + *bv_ptr++ = cur_val; + cur_val = 0; + } + } + + *bv_ptr = cur_val; + assert((bv_ptr - binary_vector) <= memlen); + + val = asn1p_value_frombits(binary_vector, bits, 0); + if(val == NULL) { + free(binary_vector); + } + + return val; +} + +extern char *asn1p_text; + +int +yyerror(const char *msg) { + fprintf(stderr, + "ASN.1 grammar parse error " + "near line %d (token \"%s\"): %s\n", + asn1p_lineno, asn1p_text, msg); + return -1; +} + + diff --git a/libasn1parser/asn1parser.c b/libasn1parser/asn1parser.c new file mode 100644 index 00000000..b5d9e1e4 --- /dev/null +++ b/libasn1parser/asn1parser.c @@ -0,0 +1,171 @@ +#include +#include +#include +#include +#include +#include + +#include "asn1parser.h" +#include "asn1p_list.h" + +int asn1p_parse(void **param); + +void *asn1p__scan_bytes(const char *, int len); +void *asn1p__delete_buffer(void *); +void *asn1p_restart(FILE *); + +extern int asn1p_lineno; + +static int _asn1p_set_flags(enum asn1p_flags flags); +static int _asn1p_assign_filename(asn1p_t *a, const char *fname); + +/* + * Parse the given buffer. + */ +asn1p_t * +asn1p_parse_buffer(const char *buffer, int size /* = -1 */, enum asn1p_flags flags) { + asn1p_t *a = 0; + void *ap; + void *ybuf; + int ret; + + if(_asn1p_set_flags(flags)) { + /* EINVAL */ + return 0; + } + + if(size < 0) + size = strlen(buffer); + + ybuf = asn1p__scan_bytes(buffer, size); + if(!ybuf) { + assert(ybuf); + return 0; + } + + asn1p_lineno = 1; + + ap = (void *)&a; + ret = asn1p_parse(ap); + + asn1p__delete_buffer(ybuf); + + if(ret == 0) { + assert(a); + if(_asn1p_assign_filename(a, "-")) + return NULL; /* FIXME: destroy (a) */ + } else { + assert(a == NULL); + } + + return a; +} + + +/* + * Parse the file identified by its name. + */ +asn1p_t * +asn1p_parse_file(const char *filename, enum asn1p_flags flags) { + struct stat sb; + asn1p_t *a = 0; + void *ap; + FILE *fp; + int ret; + + if(_asn1p_set_flags(flags)) { + /* EINVAL */ + return 0; + } + + fp = fopen(filename, "r"); + if(fp == NULL) { + perror(filename); + return NULL; + } + + if(fstat(fileno(fp), &sb) + || !S_ISREG(sb.st_mode)) { + fclose(fp); + fprintf(stderr, "%s file not recognized: Bad file format\n", + filename); + errno = EINVAL; + return NULL; + } + + asn1p_lineno = 1; + + asn1p_restart(fp); + + ap = (void *)&a; + ret = asn1p_parse(ap); + + fclose(fp); + + if(ret == 0) { + assert(a); + if(_asn1p_assign_filename(a, filename)) + return NULL; /* FIXME: destroy (a) */ + } else { + assert(a == NULL); + } + + return a; +} + +extern int asn1p_lexer_types_year; +extern int asn1p_lexer_constructs_year; +extern int asn1p__flex_debug; + +static int +_asn1p_set_flags(enum asn1p_flags flags) { + + asn1p_lexer_types_year = 0; + asn1p_lexer_constructs_year = 0; + asn1p__flex_debug = 0; + + /* + * Enable debugging in lexer. + */ + if(flags & A1P_LEXER_DEBUG) { + flags &= ~A1P_LEXER_DEBUG; + asn1p__flex_debug = 1; + } + + /* + * Restrict embedded types to ASN.1:1988 version of standard. + */ + if(flags & A1P_TYPES_RESTRICT_TO_1988) { + flags &= ~A1P_TYPES_RESTRICT_TO_1988; + asn1p_lexer_types_year = 1988; + } + + /* + * Restrict embedded types to ASN.1:1988 version of standard. + */ + if(flags & A1P_TYPES_RESTRICT_TO_1988) { + flags &= ~A1P_TYPES_RESTRICT_TO_1988; + asn1p_lexer_types_year = 1988; + } + + /* + * Check that we haven't missed an unknown flag. + */ + if(flags) { + errno = EINVAL; + return -1; + } + + return 0; +} + +static int +_asn1p_assign_filename(asn1p_t *a, const char *fname) { + asn1p_module_t *mod; + TQ_FOR(mod, &(a->modules), mod_next) { + mod->source_file_name = strdup(fname); + if(mod->source_file_name == NULL) + return -1; + } + return 0; +} diff --git a/libasn1parser/asn1parser.h b/libasn1parser/asn1parser.h new file mode 100644 index 00000000..b4c72f8b --- /dev/null +++ b/libasn1parser/asn1parser.h @@ -0,0 +1,73 @@ +/* + * This is a parser of the ASN.1 grammar. + */ +#ifndef ASN1PARSER_H +#define ASN1PARSER_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif /* HAVE_SYS_TYPES_H */ +#ifdef HAVE_INTTYPES_H +#include /* POSIX 1003.1-2001, C99 */ +#else /* HAVE_INTTYPES_H */ +#ifdef HAVE_STDINT_H +#include /* SUSv2+ */ +#endif /* HAVE_STDINT_H */ +#endif /* HAVE_INTTYPES_H */ + +/* + * Basic integer type used in numerous places. + * ASN.1 does not define any limits on this number, so it must be sufficiently + * large to accomodate typical inputs. It does not have to be a dynamically + * allocated type with potentially unlimited width: consider the width of + * an integer defined here as one of the "compiler limitations". + * NOTE: this is NOT a type for ASN.1 "INTEGER" type representation, this + * type is used by the compiler itself to handle large integer values + * specified inside ASN.1 grammar. + */ +typedef intmax_t asn1_integer_t; + +#include +#include /* Object identifiers (OIDs) */ +#include /* References to custom types */ +#include /* Value definition */ +#include /* Parametrization */ +#include /* Type Constraints */ +#include /* IMports/EXports */ +#include /* ASN.1 definition module */ +#include /* CLASS-related stuff */ +#include /* A single ASN.1 expression */ + +/* + * Parser flags. + */ +enum asn1p_flags { + A1P_NOFLAGS, + /* + * Enable verbose debugging output from lexer. + */ + A1P_LEXER_DEBUG = 0x0001, + /* + * Embedded types restricted to ASN.1:1988 + */ + A1P_TYPES_RESTRICT_TO_1988 = 0x0010, + /* + * Embedded constructs (concepts) restricted to ASN.1:1990 + */ + A1P_CONSTRUCTS_RESTRICT_TO_1990 = 0x0020, +}; + +/* + * Perform low-level parsing of ASN.1 module[s] + * and return a list of module trees. + */ +asn1p_t *asn1p_parse_file(const char *filename, + enum asn1p_flags); +asn1p_t *asn1p_parse_buffer(const char *buffer, int size /* = -1 */, + enum asn1p_flags); + +#endif /* ASN1PARSER_H */ diff --git a/libasn1parser/expr-h.pl b/libasn1parser/expr-h.pl new file mode 100755 index 00000000..c00128a0 --- /dev/null +++ b/libasn1parser/expr-h.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + + +print<) { + chomp; + next if(/TYPE_MAX/); + next unless(/^[ \t]+(ASN_[A-Z]+_([A-Za-z0-9_]+))/); + + print "\t[ $1 ]\t = "; + + $_ = $2; + if($_ eq "RELATIVE_OID") { + print '"RELATIVE-OID"'; + } else { + s/_/ /; + print '"'.$_.'"'; + } + + print ",\n"; +} + +print<= sizeof(asn1p_expr_type2str) \\ + / sizeof(asn1p_expr_type2str[0])) \\ + ? (char *)0 \\ + : asn1p_expr_type2str[(type)] \\ + ) + +#endif /* ASN1_PARSER_EXPR_STR_H */ +EOM diff --git a/libasn1print/Makefile.am b/libasn1print/Makefile.am new file mode 100644 index 00000000..fb4861a4 --- /dev/null +++ b/libasn1print/Makefile.am @@ -0,0 +1,14 @@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1print.la + +libasn1print_la_LDFLAGS = -all-static +libasn1print_la_SOURCES = \ + asn1print.c asn1print.h + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS = ${check_PROGRAMS} diff --git a/libasn1print/Makefile.in b/libasn1print/Makefile.in new file mode 100644 index 00000000..e1e876e5 --- /dev/null +++ b/libasn1print/Makefile.in @@ -0,0 +1,382 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1print.la + +libasn1print_la_LDFLAGS = -all-static +libasn1print_la_SOURCES = \ + asn1print.c asn1print.h + + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS = ${check_PROGRAMS} +subdir = libasn1print +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1print_la_LIBADD = +am_libasn1print_la_OBJECTS = asn1print.lo +libasn1print_la_OBJECTS = $(am_libasn1print_la_OBJECTS) + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1print.Plo +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libasn1print_la_SOURCES) +DIST_COMMON = README Makefile.am Makefile.in +SOURCES = $(libasn1print_la_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1print/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +libasn1print.la: $(libasn1print_la_OBJECTS) $(libasn1print_la_DEPENDENCIES) + $(LINK) $(libasn1print_la_LDFLAGS) $(libasn1print_la_OBJECTS) $(libasn1print_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1print.Plo@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES distclean \ + distclean-compile distclean-depend distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1print/README b/libasn1print/README new file mode 100644 index 00000000..5c1071cf --- /dev/null +++ b/libasn1print/README @@ -0,0 +1,4 @@ + +Ad hoc ASN tree printing procedures. Use for debugging purposes, this library +isn't thought through enough to be universally useful or even accurate. + diff --git a/libasn1print/asn1print.c b/libasn1print/asn1print.c new file mode 100644 index 00000000..992dcfa0 --- /dev/null +++ b/libasn1print/asn1print.c @@ -0,0 +1,456 @@ +#include +#include +#include +#include + +#include + +#include "asn1print.h" + +#define INDENT(fmt, args...) do { \ + int __i = level; while(__i--) putchar(' '); \ + printf(fmt, ##args); \ + } while(0) + +static int asn1print_module(asn1p_module_t *mod, enum asn1print_flags_e flags); +static int asn1print_oid(asn1p_oid_t *oid, enum asn1print_flags_e flags); +static int asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags_e flags); +static int asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags_e flags); +static int asn1print_params(asn1p_paramlist_t *pl,enum asn1print_flags_e flags); +static int asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags_e flags); +static int asn1print_constraint(asn1p_constraint_t *, enum asn1print_flags_e); +static int asn1print_value(asn1p_value_t *val, enum asn1print_flags_e flags); +static int asn1print_expr(asn1p_expr_t *tc, enum asn1print_flags_e flags, + int level); + +/* + * Print the contents of the parsed ASN tree. + */ +int +asn1print(asn1p_t *asn, enum asn1print_flags_e flags) { + asn1p_module_t *mod; + + if(asn == NULL) { + errno = EINVAL; + return -1; + } + + TQ_FOR(mod, &(asn->modules), mod_next) { + asn1print_module(mod, flags); + } + + return 0; +} + +static int +asn1print_module(asn1p_module_t *mod, enum asn1print_flags_e flags) { + asn1p_expr_t *tc; + + if(!(flags & APF_NO_SOURCE_COMMENTS)) + printf("\n-- Contents of \"%s\"\n", mod->source_file_name); + + printf("\n%s ", mod->Identifier); + if(mod->module_oid) { + asn1print_oid(mod->module_oid, flags); + printf("\n"); + } + + printf("DEFINITIONS"); + + if(mod->module_flags & MSF_EXPLICIT_TAGS) + printf(" EXPLICIT TAGS"); + if(mod->module_flags & MSF_IMPLICIT_TAGS) + printf(" IMPLICIT TAGS"); + if(mod->module_flags & MSF_AUTOMATIC_TAGS) + printf(" AUTOMATIC TAGS"); + if(mod->module_flags & MSF_EXTENSIBILITY_IMPLIED) + printf(" EXTENSIBILITY IMPLIED"); + + printf(" ::=\n"); + printf("BEGIN\n\n"); + + TQ_FOR(tc, &(mod->members), next) { + asn1print_expr(tc, flags, 0); + printf("\n\n"); + } + + printf("END\n"); + + return 0; +} + +static int +asn1print_oid(asn1p_oid_t *oid, enum asn1print_flags_e flags) { + int ac; + int accum = 0; + + printf("{"); + for(ac = 0; ac < oid->arcs_count; ac++) { + if(accum + strlen(oid->arcs[ac].name?:"") > 50) { + printf("\n\t"); + accum = 0; + } else if(ac) printf(" "); + + if(oid->arcs[ac].name) { + printf("%s(%d)", + oid->arcs[ac].name, + (int)oid->arcs[ac].number); + accum += strlen(oid->arcs[ac].name); + } else { + printf("%d", + (int)oid->arcs[ac].number); + } + accum += 4; + } + printf(" }"); + + return 0; +} + +static int +asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags_e flags) { + int cc; + + for(cc = 0; cc < ref->comp_count; cc++) { + if(cc) printf("."); + printf("%s", ref->components[cc].name); + } + + return 0; +} + +static int +asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags_e flags) { + struct asn1p_type_tag_s *tag = &tc->tag; + + if(tag->tag_class == TC_NOCLASS) + return 0; + + printf("["); + switch(tag->tag_class) { + case TC_NOCLASS: + assert(tag->tag_class != TC_NOCLASS); + break; + case TC_UNIVERSAL: printf("UNIVERSAL "); break; + case TC_PRIVATE: printf("PRIVATE "); break; + case TC_APPLICATION: printf("APPLICATION "); break; + case TC_CONTEXT_SPECIFIC: + break; + } + printf("%lld]", (long long)tag->tag_value); + + switch(tag->tag_mode) { + case TM_DEFAULT: break; + case TM_IMPLICIT: printf(" IMPLICIT"); break; + case TM_EXPLICIT: printf(" EXPLICIT"); break; + } + + return 0; +} + +static int +asn1print_value(asn1p_value_t *val, enum asn1print_flags_e flags) { + + if(val == NULL) + return 0; + + switch(val->type) { + case ATV_NOVALUE: + break; + case ATV_REFERENCED: + return asn1print_ref(val->value.reference, flags); + case ATV_INTEGER: + printf("%lld", (long long)val->value.v_integer); + return 0; + case ATV_MIN: printf("MIN"); return 0; + case ATV_MAX: printf("MAX"); return 0; + case ATV_FALSE: printf("FALSE"); return 0; + case ATV_TRUE: printf("TRUE"); return 0; + case ATV_REAL: + printf("%f", val->value.v_double); + return 0; + case ATV_STRING: + { + char *p = val->value.string.buf; + putchar('"'); + if(strchr(p, '"')) { + /* Mask quotes */ + for(; *p; p++) { + if(*p == '"') + putchar(*p); + putchar(*p); + } + } else { + fputs(p, stdout); + } + putchar('"'); + } + return 0; + case ATV_UNPARSED: + fputs(val->value.string.buf, stdout); + return 0; + case ATV_BITVECTOR: + { + uint8_t *bitvector; + int bits; + int i; + + bitvector = val->value.binary_vector.bits; + bits = val->value.binary_vector.size_in_bits; + + printf("'"); + if(bits%8) { + for(i = 0; i < bits; i++) { + uint8_t uc; + uc = bitvector[i>>3]; + putchar(((uc >> (7-(i%8)))&1)?'1':'0'); + } + printf("'B"); + } else { + char hextable[16] = "0123456789ABCDEF"; + for(i = 0; i < (bits>>3); i++) { + putchar(hextable[bitvector[i] >> 4]); + putchar(hextable[bitvector[i] & 0x0f]); + } + printf("'H"); + } + } + } + + assert(val->type || !"Unknown"); + + return 0; +} + +static int +asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags_e flags) { + int symno = 0; + + if(ct == 0) return 0; + + if(ct->type == ACT_CA_SET) + printf("("); + + switch(ct->type) { + case ACT_EL_VALUE: + asn1print_value(ct->value, flags); + break; + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + asn1print_value(ct->range_start, flags); + switch(ct->type) { + case ACT_EL_RANGE: printf(".."); break; + case ACT_EL_LLRANGE: printf("<.."); break; + case ACT_EL_RLRANGE: printf("..<"); break; + case ACT_EL_ULRANGE: printf("<..<"); break; + default: printf("?..?"); break; + } + asn1print_value(ct->range_stop, flags); + break; + case ACT_EL_EXT: + printf("..."); + break; + case ACT_CT_SIZE: + case ACT_CT_FROM: + switch(ct->type) { + case ACT_CT_SIZE: printf("SIZE ("); break; + case ACT_CT_FROM: printf("FROM ("); break; + default: printf("??? ("); break; + } + assert(ct->el_count != 0); + assert(ct->el_count == 1); + asn1print_constraint(ct->elements[0], flags); + printf(")"); + break; + case ACT_CT_WCOMP: + case ACT_CT_WCOMPS: + printf("???"); + break; + case ACT_CA_SET: symno++; + case ACT_CA_CRC: symno++; + case ACT_CA_CSV: symno++; + case ACT_CA_UNI: symno++; + case ACT_CA_INT: symno++; + case ACT_CA_EXC: + { + char *symtable[] = { " EXCEPT ", "^", "|", ",", + "", "(" }; + int i; + for(i = 0; i < ct->el_count; i++) { + enum asn1print_flags_e nflags = flags; + if(i) fputs(symtable[symno], stdout); + if(ct->type == ACT_CA_CRC) fputs("{", stdout); + asn1print_constraint(ct->elements[i], nflags); + if(ct->type == ACT_CA_CRC) fputs("}", stdout); + if(i+1 < ct->el_count + && ct->type == ACT_CA_SET) + fputs(")", stdout); + } + } + break; + case ACT_INVALID: + assert(ct->type != ACT_INVALID); + break; + } + + if(ct->type == ACT_CA_SET) + printf(")"); + + return 0; +} + +static int +asn1print_params(asn1p_paramlist_t *pl, enum asn1print_flags_e flags) { + if(pl) { + int i; + printf("{"); + for(i = 0; i < pl->params_count; i++) { + if(i) printf(", "); + if(pl->params[i].governor) { + asn1print_ref(pl->params[i].governor, flags); + printf(":"); + } + printf("%s", pl->params[i].argument); + } + printf("}"); + } + + return 0; +} + +static int +asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags_e flags) { + if(wx) { + asn1p_wsyntx_chunk_t *wc; + printf(" WITH SYNTAX {"); + TQ_FOR(wc, &(wx->chunks), next) { + if(wc->ref) { + asn1print_ref(wc->ref, flags); + } else { + fwrite(wc->buf, 1, wc->len, stdout); + } + } + printf("}\n"); + } + + return 0; +} + +static int +asn1print_expr(asn1p_expr_t *tc, enum asn1print_flags_e flags, int level) { + + if(flags & APF_LINE_COMMENTS) + INDENT("-- #line %d\n", tc->_lineno); + if(tc->Identifier) + INDENT("%s", tc->Identifier); + + if(tc->params) { + asn1print_params(tc->params, flags); + } + + if(tc->meta_type != AMT_VALUE + && tc->expr_type != A1TC_EXTENSIBLE) { + if(level) { + if(tc->Identifier) + printf("\t"); + } else { + printf(" ::="); + } + } + + if(tc->tag.tag_class) { + printf(" "); + asn1print_tag(tc, flags); + } + + switch(tc->expr_type) { + case A1TC_EXTENSIBLE: + if(tc->value) { + printf("!"); + asn1print_value(tc->value, flags); + } + break; + case A1TC_REFERENCE: + case A1TC_UNIVERVAL: + case A1TC_PARAMETRIZED: + break; + case A1TC_CLASSDEF: + printf(" CLASS"); + break; + case A1TC_CLASSFIELD: + /* Nothing to print here */ + break; + default: + { + char *p = ASN_EXPR_TYPE2STR(tc->expr_type); + printf(" %s", p?p:""); + } + break; + } + + if(tc->reference) { + printf(" "); + asn1print_ref(tc->reference, flags); + } + + /* + * Display the descendants (children) of the current type. + */ + if(TQ_FIRST(&(tc->members))) { + asn1p_expr_t *se; /* SubExpression */ + + if((tc->expr_type != ASN_CONSTR_SEQUENCE_OF + && tc->expr_type != ASN_CONSTR_SET_OF) + || TQ_FIRST(&(tc->members))->expr_type & ASN_CONSTR_MASK) + printf(" {\n"); + + TQ_FOR(se, &(tc->members), next) { + /* + * Print the expression as it were stand-alone type. + */ + asn1print_expr(se, flags, level + 4); + switch(se->marker) { + case EM_NOMARK: break; + case EM_OPTIONAL: printf(" OPTIONAL"); break; + case EM_DEFAULT: printf(" DEFAULT "); break; + } + if(TQ_NEXT(se, next)) { + printf(","); + INDENT("\n"); + } + } + + if((tc->expr_type != ASN_CONSTR_SEQUENCE_OF + && tc->expr_type != ASN_CONSTR_SET_OF) + || TQ_FIRST(&(tc->members))->expr_type & ASN_CONSTR_MASK) { + printf("\n"); + INDENT("}"); + } + } + + if(tc->with_syntax) + asn1print_with_syntax(tc->with_syntax, flags); + + if(tc->constraints) { + printf(" "); + asn1print_constraint(tc->constraints, flags); + } + if(tc->unique) { + printf(" UNIQUE"); + } + + if(tc->meta_type == AMT_VALUE + && tc->expr_type != A1TC_EXTENSIBLE) { + if(tc->expr_type == A1TC_UNIVERVAL) + printf("("); + else + printf(" ::= "); + asn1print_value(tc->value, flags); + if(tc->expr_type == A1TC_UNIVERVAL) + printf(")"); + } + + return 0; +} diff --git a/libasn1print/asn1print.h b/libasn1print/asn1print.h new file mode 100644 index 00000000..73875fb1 --- /dev/null +++ b/libasn1print/asn1print.h @@ -0,0 +1,16 @@ +#ifndef _ASN1PRINT_H_ +#define _ASN1PRINT_H_ + +enum asn1print_flags_e { + APF_NOFLAGS = 0x00, + APF_LINE_COMMENTS = 0x01, + APF_NO_SOURCE_COMMENTS = 0x02, +}; + +/* + * Print the contents of the parsed ASN.1 syntax tree. + */ +int asn1print(asn1p_t *asn, enum asn1print_flags_e flags); + + +#endif /* _ASN1PRINT_H_ */ diff --git a/ltconfig b/ltconfig new file mode 100755 index 00000000..bad848d6 --- /dev/null +++ b/ltconfig @@ -0,0 +1,3096 @@ +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} +echo=echo +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec "$SHELL" "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null`} + case X$UNAME in + *-DOS) PATH_SEPARATOR=';' ;; + *) PATH_SEPARATOR=':' ;; + esac +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" != 'X\t' || + test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running ltconfig again with it. + ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}" + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf "%s\n"' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # Cool, printf works + : + elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL" + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# The name of this program. +progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.3.4-freebsd-ports +TIMESTAMP=" (1.385.2.196 1999/12/07 21:47:57)" +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +default_ofile=libtool +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +enable_static=yes +enable_fast_install=yes +install_ltlibs=yes +release_suffix=yes +enable_dlopen=unknown +enable_win32_dll=no +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +nonopt= +ofile="$default_ofile" +verify_host=yes +with_gcc=no +with_gnu_ld=no +need_locks=yes +ac_ext=c +objext=o +libext=a +exeext= +cache_file= + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LDFLAGS="$LDFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_LIBS="$LIBS" +old_NM="$NM" +old_RANLIB="$RANLIB" +old_DLLTOOL="$DLLTOOL" +old_OBJDUMP="$OBJDUMP" +old_AS="$AS" + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test ! -f "$ltmain"; then + echo "$progname: \`$ltmain' does not exist" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi +if test "X${LANG+set}" = Xset; then LANG=C; export LANG; fi + +if test -n "$cache_file" && test -r "$cache_file"; then + echo "loading cache $cache_file within ltconfig" + . $cache_file +fi + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to LTMAIN. + srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +trap "$rm conftest*; exit 1" 1 2 15 +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$SHELL $ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$SHELL $ac_config_sub $host_alias` + echo "$ac_t$host" 1>&6 + + # Make sure the host verified. + test -z "$host" && exit 1 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case "$host_os" in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +case "$host_os" in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + +# Set a sane default for `OBJDUMP'. +test -z "$OBJDUMP" && OBJDUMP=objdump + +# If RANLIB is not set, then run the test. +if test "${RANLIB+set}" != "set"; then + result=no + + echo $ac_n "checking for ranlib... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then + RANLIB="ranlib" + result="ranlib" + break + fi + done + IFS="$save_ifs" + + echo "$ac_t$result" 1>&6 +fi + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" +fi + +# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin. +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$AS" && AS=as + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc || test -f $dir/cc$ac_exeext; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + echo "$progname:581: checking whether we are using GNU C" >&5 + + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo "$ac_t$with_gcc" 1>&6 +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +echo $ac_n "checking for object suffix... $ac_c" 1>&6 +$rm conftest* +echo 'int i = 1;' > conftest.c +echo "$progname:603: checking for object suffix" >& 5 +if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c) ;; + *) objext=`echo $ac_file | sed -e s/conftest.//` ;; + esac + done +else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 +fi +$rm conftest* +echo "$ac_t$objext" 1>&6 + +echo $ac_n "checking for executable suffix... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_exeext="no" + $rm conftest* + echo 'main () { return 0; }' > conftest.c + echo "$progname:629: checking for executable suffix" >& 5 + if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c | *.err | *.$objext ) ;; + *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;; + esac + done + else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* +fi +if test "X$ac_cv_exeext" = Xno; then + exeext="" +else + exeext="$ac_cv_exeext" +fi +echo "$ac_t$ac_cv_exeext" 1>&6 + +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +pic_flag= +special_shlib_compile_flags= +wl= +link_static_flag= +no_builtin_flag= + +if test "$with_gcc" = yes; then + wl='-Wl,' + link_static_flag='-static' + + case "$host_os" in + beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # we not sure about C++ programs. + link_static_flag="$link_static_flag ${wl}-lC" + ;; + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + pic_flag='-m68020 -resident32 -malways-restore-a4' + ;; + sysv4*MP*) + if test -d /usr/nec; then + pic_flag=-Kconform_pic + fi + ;; + *) + pic_flag='-fPIC' + ;; + esac +else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # All AIX code is PIC. + link_static_flag='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better link_static_flag that works with the bundled CC? + wl='-Wl,' + link_static_flag="${wl}-a ${wl}archive" + pic_flag='+Z' + ;; + + irix5* | irix6*) + wl='-Wl,' + link_static_flag='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + wl='-Wl,' + link_static_flag='-non_shared' + ;; + + sco3.2v5*) + pic_flag='-Kpic' + link_static_flag='-dn' + special_shlib_compile_flags='-belf' + ;; + + solaris*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + sunos4*) + pic_flag='-PIC' + link_static_flag='-Bstatic' + wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + uts4*) + pic_flag='-pic' + link_static_flag='-Bstatic' + ;; + sysv4*MP*) + if test -d /usr/nec ;then + pic_flag='-Kconform_pic' + link_static_flag='-Bstatic' + fi + ;; + *) + can_build_shared=no + ;; + esac +fi + +if test -n "$pic_flag"; then + echo "$ac_t$pic_flag" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $pic_flag -DPIC" + echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5 + if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + case "$host_os" in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then they + # create non-PIC objects. So, if there were any warnings, we assume that + # PIC is not supported. + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + can_build_shared=no + pic_flag= + else + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + fi + ;; + *) + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + ;; + esac + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + can_build_shared=no + pic_flag= + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + echo "$ac_t"none 1>&6 +fi + +# Check to see if options -o and -c are simultaneously supported by compiler +echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6 +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +$rm conftest* +echo "int some_variable = 0;" > conftest.c +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.o" +echo "$progname:829: checking if $compiler supports -c -o file.o" >&5 +if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + echo "$ac_t"no 1>&6 + compiler_c_o=no + else + echo "$ac_t"yes 1>&6 + compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&5 + compiler_c_o=no + echo "$ac_t"no 1>&6 +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5 +if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_o_lo=no + else + echo "$ac_t"yes 1>&6 + compiler_o_lo=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_o_lo=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + compiler_o_lo=no +fi + +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$ac_t$hard_links" 1>&6 + $rm conftest* + if test "$hard_links" = no; then + echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2 + need_locks=warn + fi +else + need_locks=no +fi + +if test "$with_gcc" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c" + echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_rtti_exceptions=no + else + echo "$ac_t"yes 1>&6 + compiler_rtti_exceptions=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_rtti_exceptions=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi + +fi + +# Check for any special shared library compilation flags. +if test -n "$special_shlib_compile_flags"; then + echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : + else + echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 + can_build_shared=no + fi +fi + +echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 +$rm conftest* +echo 'main(){return(0);}' > conftest.c +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS $link_static_flag" +echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5 +if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + echo "$ac_t$link_static_flag" 1>&6 +else + echo "$ac_t"none 1>&6 + link_static_flag= +fi +LDFLAGS="$save_LDFLAGS" +$rm conftest* + +if test -z "$LN_S"; then + # Check to see if we can use ln -s, or we need hard links. + echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 + $rm conftest.dat + if ln -s X conftest.dat 2>/dev/null; then + $rm conftest.dat + LN_S="ln -sf" + else + LN_S=ln + fi + if test "$LN_S" = "ln -sf"; then + echo "$ac_t"yes 1>&6 + else + echo "$ac_t"no 1>&6 + fi +fi + +# Make sure LD is an absolute path. +if test -z "$LD"; then + ac_prog=ld + if test "$with_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 + echo "$progname:991: checking for ld used by GCC" >&5 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we are not using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + echo "$progname:1015: checking for GNU ld" >&5 + else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 + echo "$progname:1018: checking for non-GNU ld" >&5 + fi + + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" + fi + + if test -n "$LD"; then + echo "$ac_t$LD" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi +fi + +# Check to see if it really is or is not GNU ld. +echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 +# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + with_gnu_ld=yes +else + with_gnu_ld=no +fi +echo "$ac_t$with_gnu_ld" 1>&6 + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. + +case "$host_os" in +cygwin* | mingw*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$with_gcc" != yes; then + with_gnu_ld=no + fi + ;; + +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case "$host_os" in + aix3* | aix4*) + # On AIX, the GNU linker is very broken + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ; *//" < $objdir/$soname-def > $export_symbols' + + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + _lt_hint=1; + for symbol in `cat $export_symbols`; do + echo " \$symbol @ \$_lt_hint ; " >> $objdir/$soname-def; + _lt_hint=`expr 1 + \$_lt_hint`; + done~ + test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts' + + old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib' + # can we support soname and/or expsyms with a.out? -oliva + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $compile_rpath $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $compile_rpath $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case "$host_os" in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$with_gcc" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4*) + hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib' + hardcode_libdir_separator=':' + if test "$with_gcc" = yes; then + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + shared_flag='-shared' + else + shared_flag='${wl}-bM:SRE' + hardcode_direct=yes + fi + allow_undefined_flag=' ${wl}-berok' + archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}' + archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}' + case "$host_os" in aix4.[01]|aix4.[01].*) + # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on + always_export_symbols=yes ;; + esac + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs' + fix_srcfile_path='`cygpath -w $srcfile`' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case "$host_os" in + hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + if test "$with_gcc" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts' # ELF + fi + hardcode_libdir_flag_spec='${wl}-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + openbsd*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' + ;; + + osf3*) + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # As osf3* with the addition of the -msym flag + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case "$host_os" in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + unixware7*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +echo "$ac_t$ld_shlibs" 1>&6 +test "$ld_shlibs" = no && can_build_shared=no + +if test -z "$NM"; then + echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 + case "$NM" in + [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path. + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -p" + break + else + NM=${NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$NM" && NM=nm + ;; + esac + echo "$ac_t$NM" 1>&6 +fi + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'" + ;; +irix*) + symcode='[BCDEGRST]' + ;; +solaris*) + symcode='[BDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[ABCDGISTW]' +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + $rm conftest* + cat > conftest.c <&5 + if { (eval echo $progname:1636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then + # Now try to grab the symbols. + nlist=conftest.nm + if { echo "$progname:1639: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then + + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.c +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c' + + cat <> conftest.c +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c + cat <<\EOF >> conftest.c + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$objext conftstm.$objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo $progname:1691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + global_symbol_pipe= + fi +done +if test "$pipe_works" = yes; then + echo "${ac_t}ok" 1>&6 +else + echo "${ac_t}failed" 1>&6 +fi + +if test -z "$global_symbol_pipe"; then + global_symbol_to_cdecl= +fi + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$ac_t$hardcode_action" 1>&6 + + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linkers may need a different reload flag. +reload_flag='-r' +echo "$ac_t$reload_flag" 1>&6 +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so characteristics +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib" +file_magic_cmd= +file_magic_test_file= +deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [regex]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +case "$host_os" in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4*) + version_type=linux + # AIX has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + # We preserve .a as extension for shared libraries though AIX4.2 + # and later linker supports .so + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a' + shlibpath_var=LIBPATH + deplibs_check_method=pass_all + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + deplibs_check_method=pass_all + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw*) + version_type=windows + need_version=no + need_lib_prefix=no + if test "$with_gcc" = yes; then + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a' + else + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + fi + dynamic_linker='Win32 ld.exe' + deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + file_magic_cmd='${OBJDUMP} -f' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case "$version_type" in + freebsd-elf*) + deplibs_check_method='file_magic (ELF [0-9][0-9]*-bit [LM]SB shared object|current ar archive)' + ;; + freebsd-*) + deplibs_check_method='file_magic FreeBSD.* shared library' + ;; + esac + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so.*` + if test "$release_suffix" = all; then + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}.so' + fi + need_version=no + need_lib_prefix=no + finish_cmds='/usr/bin/env OBJFORMAT="'"$objformat"'" /sbin/ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + case "$host_os" in + freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6*) + version_type=irix + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so.$major' + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so' + case "$host_os" in + irix5*) + libsuff= shlibsuff= + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case "$LD" in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib${libsuff}/libc.so*` + deplibs_check_method='pass_all' + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd*) + version_type=sunos + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + ;; + +openbsd*) + version_type=sunos + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + need_version=no + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method='file_magic COFF format alpha shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + deplibs_check_method='pass_all' + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib" + file_magic_cmd=/usr/bin/file + file_magic_test_file=/lib/libc.so + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case "$host_vendor" in + ncr) + deplibs_check_method='pass_all' + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t$dynamic_linker" 1>&6 +test "$dynamic_linker" = no && can_build_shared=no + +# Report the final consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in +# configure.in, otherwise build static only libraries. +case "$host_os" in +cygwin* | mingw* | os2*) + if test x$can_build_shared = xyes; then + test x$enable_win32_dll = xno && can_build_shared=no + echo "checking if package supports dlls... $can_build_shared" 1>&6 + fi +;; +esac + +if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then + case "$deplibs_check_method" in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac +fi + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + test "$enable_shared" = yes && enable_static=no + ;; +esac + +echo "$ac_t$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +echo $ac_n "checking for objdir... $ac_c" 1>&6 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t$objdir" 1>&6 + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else +if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then + lt_cv_dlopen=no lt_cv_dlopen_libs= +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "$progname:2212: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "$progname:2252: checking for dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_dlopen=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_dlopen=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 +echo "$progname:2299: checking for dld_link in -ldld" >&5 +ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load""... $ac_c" 1>&6 +echo "$progname:2339: checking for shl_load" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +shl_load(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shl_load=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shl_load=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 +echo "$progname:2387: checking for shl_load in -ldld" >&5 +ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +fi + + +fi + + +fi + +fi + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + fi + + case "$lt_cv_dlopen" in + dlopen) +for ac_hdr in dlfcn.h; do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "$progname:2452: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int fnord = 0; +EOF +ac_try="$ac_compile >/dev/null 2>conftest.out" +{ (eval echo $progname:2462: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +done + + if test "x$ac_cv_header_dlfcn_h" = xyes; then + CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + fi + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2490: checking whether a program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self" 1>&6 + + if test "$lt_cv_dlopen_self" = yes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2563: checking whether a statically linked program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self_static=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self_static=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self_static=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 +fi + ;; + esac + + case "$lt_cv_dlopen_self" in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case "$lt_cv_dlopen_self_static" in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + +# Copy echo and quote the copy, instead of the original, because it is +# used later. +ltecho="$echo" +if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ltecho="$CONFIG_SHELL \$0 --fallback-echo" +fi +LTSHELL="$SHELL" + +LTCONFIG_VERSION="$VERSION" + +# Only quote variables if we're using ltmain.sh. +case "$ltmain" in +*.sh) + # Now quote all the things that may contain metacharacters. + for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \ + AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \ + file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case "$var" in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case "$ltecho" in + *'\$0 --fallback-echo"') + ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + + trap "$rm \"$ofile\"; exit 1" 1 2 15 + echo "creating $ofile" + $rm "$ofile" + cat < "$ofile" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +### BEGIN LIBTOOL CONFIG +EOF + cfgfile="$ofile" + ;; + +*) + # Double-quote the variables that need it (for aesthetics). + for var in old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do + eval "$var=\\\"\$var\\\"" + done + + # Just create a config file. + cfgfile="$ofile.cfg" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + echo "creating $cfgfile" + $rm "$cfgfile" + cat < "$cfgfile" +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +EOF + ;; +esac + +cat <> "$cfgfile" +# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\ +# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\ +# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ +# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# The version of $progname that generated this script. +LTCONFIG_VERSION=$LTCONFIG_VERSION + +# Shell to use when invoking shell scripts. +SHELL=$LTSHELL + +# Whether to waste disk space. +install_ltlibs=$install_ltlibs + +# What to do with -release. +# yes - only for shared archive +# no - ingnore +# all - for all archives +release_suffix=$release_suffix + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$ltecho + +# The archiver. +AR=$AR + +# The default C compiler. +CC=$CC + +# The linker used to build libraries. +LD=$LD + +# Whether we need hard or soft links. +LN_S=$LN_S + +# A BSD-compatible nm program. +NM=$NM + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$reload_flag +reload_cmds=$reload_cmds + +# How to pass a linker flag through the compiler. +wl=$wl + +# Object file suffix (normally "o"). +objext="$objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$pic_flag + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$RANLIB +old_archive_cmds=$old_archive_cmds +old_postinstall_cmds=$old_postinstall_cmds +old_postuninstall_cmds=$old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$old_archive_from_new_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$archive_cmds +archive_expsym_cmds=$archive_expsym_cmds +postinstall_cmds=$postinstall_cmds +postuninstall_cmds=$postuninstall_cmds + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$global_symbol_to_cdecl + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$hardcode_libdir_separator + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$include_expsyms + +EOF + +case "$ltmain" in +*.sh) + echo '### END LIBTOOL CONFIG' >> "$ofile" + echo >> "$ofile" + case "$host_os" in + aix3*) + cat <<\EOF >> "$ofile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # Append the ltmain.sh script. + sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1) + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + + chmod +x "$ofile" + ;; + +*) + # Compile the libtool program. + echo "FIXME: would compile $ltmain" + ;; +esac + +test -n "$cache_file" || exit 0 + +# AC_CACHE_SAVE +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/ltmain.sh b/ltmain.sh new file mode 100644 index 00000000..ebeb20d2 --- /dev/null +++ b/ltmain.sh @@ -0,0 +1,4122 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun ltconfig. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +EXPR_COMPAT=1 +export EXPR_COMPAT + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + echo "$modename: not configured to build any kind of library" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case "$arg" in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + execute_dlfiles) + eval "$prev=\"\$$prev \$arg\"" + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case "$arg" in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + exit 0 + ;; + + --config) + sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0 + exit 0 + ;; + + --debug) + echo "$progname: enabling shell trace mode" + set -x + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --quiet | --silent) + show=: + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case "$nonopt" in + *cc | *++ | gcc* | *-gcc*) + mode=link + for arg + do + case "$arg" in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case "$mode" in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + lastarg= + srcfile="$nonopt" + suppress_output= + + user_target=no + for arg + do + # Accept any command-line options. + case "$arg" in + -o) + if test "$user_target" != "no"; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + user_target=next + ;; + + -static) + build_old_libs=yes + continue + ;; + esac + + case "$user_target" in + next) + # The next one is the -o target name + user_target=yes + continue + ;; + yes) + # We got the output file + user_target=set + libobj="$arg" + continue + ;; + esac + + # Accept the current argument as the source file. + lastarg="$srcfile" + srcfile="$arg" + + # Aesthetically quote the previous argument. + + # Backslashify any backslashes, double quotes, and dollar signs. + # These are the only characters that are still specially + # interpreted inside of double-quoted scrings. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly in scan + # sets, so we specify it separately. + case "$lastarg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + lastarg="\"$lastarg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + done + + case "$user_target" in + set) + ;; + no) + # Get the name of the library object. + libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + *) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit 1 + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSfmso]' + case "$libobj" in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case "$libobj" in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $libobj" + else + removelist="$libobj" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit 1" 1 2 15 + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit 1" 1 2 15 + else + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until ln "$0" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $srcfile $pic_flag -DPIC" + if test "$build_old_libs" = yes; then + lo_libobj="$libobj" + dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$libobj"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + + if test -d "$dir"; then + $show "$rm $libobj" + $run $rm $libobj + else + $show "$mkdir $dir" + $run $mkdir $dir + status=$? + if test $status -ne 0 && test ! -d $dir; then + exit $status + fi + fi + fi + if test "$compiler_o_lo" = yes; then + output_obj="$libobj" + command="$command -o $output_obj" + elif test "$compiler_c_o" = yes; then + output_obj="$obj" + command="$command -o $output_obj" + fi + + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed, then go on to compile the next one + if test x"$output_obj" != x"$libobj"; then + $show "$mv $output_obj $libobj" + if $run $mv $output_obj $libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # If we have no pic_flag, then copy the object into place and finish. + if test -z "$pic_flag" && test "$build_old_libs" = yes; then + # Rename the .lo from within objdir to obj + if test -f $obj; then + $show $rm $obj + $run $rm $obj + fi + + $show "$mv $libobj $obj" + if $run $mv $libobj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` + libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + # Now arrange that obj and lo_libobj become the same file + $show "(cd $xdir && $LN_S $baseobj $libobj)" + if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then + exit 0 + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Allow error messages only from the first compilation. + suppress_output=' >/dev/null 2>&1' + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + command="$base_compile $srcfile" + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + output_obj="$obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed + if test x"$output_obj" != x"$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Create an invalid libtool object if no PIC, so that we do not + # accidentally link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > \$libobj" || exit $? + else + # Move the .lo from within objdir + $show "$mv $libobj $lo_libobj" + if $run $mv $libobj $lo_libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + fi + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $rm "$lockfile" + fi + + exit 0 + ;; + + # libtool link mode + link) + modename="$modename: link" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invokation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + + # This is a source program that is used to create dlls on Windows + # Don't remove nor modify the starting and closing comments +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* for strdup() */ +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (!dll) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test $# -gt 0; do + arg="$1" + shift + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case "$prev" in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case "$arg" in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit 1 + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + release) + if test "$release_suffix" = all; then + release="$arg" + elif test "$release_suffix" = yes; then + release="-$arg" + fi + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case "$arg" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi + + prevarg="$arg" + + case "$arg" in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + build_old_libs=no + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: not more than one -exported-symbols argument allowed" + exit 1 + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + absdir="$dir" + fi + dir="$absdir" + ;; + esac + case " $deplibs " in + *" $arg "*) ;; + *) deplibs="$deplibs $arg";; + esac + case " $lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir";; + esac + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + dllsearchdir=`cd "$dir" && pwd || echo "$dir"` + case ":$dllsearchpath:" in + ::) dllsearchpath="$dllsearchdir";; + *":$dllsearchdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dllsearchdir";; + esac + ;; + esac + ;; + + -l*) + if test "$arg" = "-lc"; then + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # These systems don't actually have c library (as such) + continue + ;; + esac + elif test "$arg" = "-lm"; then + case "$host" in + *-*-cygwin* | *-*-beos*) + # These systems don't actually have math library (as such) + continue + ;; + esac + fi + deplibs="$deplibs $arg" + ;; + + -?thread) + deplibs="$deplibs $arg" + ;; + + -module) + module=yes + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -o) prev=output ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # If we have no pic_flag, then this is the same as -all-static. + if test -z "$pic_flag" && test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + + *.o | *.obj | *.a | *.lib) + # A standard object. + libobjs="$libobjs $arg" + ;; + + *.lo) + # A library object. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` + prev= + fi + libobjs="$libobjs $arg" + ;; + + *.la) + # A libtool-controlled library. + + dlname= + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + # If there is no directory component, then add one. + case "$arg" in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 + exit 1 + fi + + # Find the relevant object directory and library name. + name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` + + if test "X$installed" = Xyes; then + dir="$libdir" + else + dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$arg"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + fi + + if test -n "$dependency_libs"; then + # Extract -R and -L from dependency_libs + temp_deplibs= + for deplib in $dependency_libs; do + case "$deplib" in + -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + case " $rpath $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + -L*) case "$compile_command $temp_deplibs " in + *" $deplib "*) ;; + *) temp_deplibs="$temp_deplibs $deplib";; + esac + temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'` + case " $lib_search_path " in + *" $temp_dir "*) ;; + *) lib_search_path="$lib_search_path $temp_dir";; + esac + ;; + *) temp_deplibs="$temp_deplibs $deplib";; + esac + done + dependency_libs="$temp_deplibs" + fi + + if test -z "$libdir"; then + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$deplibs$dependency_libs" + compile_command="$compile_command $dir/$old_library$dependency_libs" + finalize_command="$finalize_command $dir/$old_library$dependency_libs" + continue + fi + + # This library was specified with -dlopen. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking statically, + # we need to preload. + prev=dlprefiles + else + # We should not create a dependency on this library, but we + # may need any libraries it requires. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + prev= + continue + fi + fi + + # The library was specified with -dlpreopen. + if test "$prev" = dlprefiles; then + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + dlprefiles="$dlprefiles $dir/$old_library" + else + dlprefiles="$dlprefiles $dir/$linklib" + fi + prev= + fi + + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + link_against_libtool_libs="$link_against_libtool_libs $arg" + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # We need an absolute path. + case "$dir" in + [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + absdir="$dir" + fi + ;; + esac + + # This is the magic to use -rpath. + # Skip directories that are in the system default run-time + # search path, unless they have been requested with -R. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + + lib_linked=yes + case "$hardcode_action" in + immediate | unsupported) + if test "$hardcode_direct" = no; then + compile_command="$compile_command $dir/$linklib" + deplibs="$deplibs $dir/$linklib" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + dllsearchdir=`cd "$dir" && pwd || echo "$dir"` + if test -n "$dllsearchpath"; then + dllsearchpath="$dllsearchpath:$dllsearchdir" + else + dllsearchpath="$dllsearchdir" + fi + ;; + esac + elif test "$hardcode_minus_L" = no; then + case "$host" in + *-*-sunos*) + compile_shlibpath="$compile_shlibpath$dir:" + ;; + esac + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = no; then + case ":$compile_shlibpath:" in + *":$dir:"*) ;; + *) compile_shlibpath="$compile_shlibpath$dir:";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -l$name" + else + lib_linked=no + fi + ;; + + relink) + if test "$hardcode_direct" = yes; then + compile_command="$compile_command $absdir/$linklib" + deplibs="$deplibs $absdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + case "$compile_command " in + *" -L$absdir "*) ;; + *) compile_command="$compile_command -L$absdir";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -L$absdir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case ":$compile_shlibpath:" in + *":$absdir:"*) ;; + *) compile_shlibpath="$compile_shlibpath$absdir:";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -l$name" + else + lib_linked=no + fi + ;; + + *) + lib_linked=no + ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + finalize_command="$finalize_command $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + case "$finalize_command " in + *" -L$libdir "*) ;; + *) finalize_command="$finalize_command -L$libdir";; + esac + finalize_command="$finalize_command -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case ":$finalize_shlibpath:" in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:";; + esac + finalize_command="$finalize_command -l$name" + else + # We cannot seem to hardcode it, guess we'll fake it. + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$libdir";; + esac + finalize_command="$finalize_command -l$name" + fi + else + # Transform directly to old archives if we don't build new libraries. + if test -n "$pic_flag" && test -z "$old_library"; then + $echo "$modename: cannot find static library for \`$arg'" 1>&2 + exit 1 + fi + + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_command="$compile_command $dir/$linklib" + finalize_command="$finalize_command $dir/$linklib" + else + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$dir";; + esac + finalize_command="$finalize_command -l$name" + fi + fi + + # Add in any libraries that this one depends upon. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + esac + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + case "$output" in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *.a | *.lib) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into archives" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + ;; + + *.la) + # Make sure we only generate libraries of the form `libNAME.la'. + case "$outputname" in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + if test -n "$objs"; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 + exit 1 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test $# -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + libext=al + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + dependency_libs="$deplibs" + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + current="$2" + revision="$3" + age="$4" + + # Check that each of the things are valid numbers. + case "$current" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$revision" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$age" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case "$version_type" in + none) ;; + + irix) + major=`expr $current - $age + 1` + versuffix="$major.$revision" + verstring="sgi$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test $loop != 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="sgi$major.$iface:$verstring" + done + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + windows) + # Like Linux, but with '-' rather than '.', since we only + # want one extension on Windows 95. + major=`expr $current - $age` + versuffix="-$major-$age-$revision" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + verstring="0.0" + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + dependency_libs="$deplibs" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-freebsd*) + # FreeBSD doesn't need this... + ;; + *) + # Add libc to deplibs on all other systems. + deplibs="$deplibs -lc" + ;; + esac + fi + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$compile_rpath " in + *" $libdir "*) ;; + *) compile_rpath="$compile_rpath $libdir" ;; + esac + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + # Create the output directory, or remove our outputs if we need to. + if test -d $output_objdir; then + $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" + $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + else + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + if test "$release_suffix" = all; then + oldlibs="$oldlibs $output_objdir/$libname$release.$libext" + else + oldlibs="$oldlibs $output_objdir/$libname.$libext" + fi + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + if test "$build_libtool_libs" = yes; then + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case "$deplibs_check_method" in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behaviour. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | sed 's/.* -> //'` + case "$potliblink" in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | sed 10q \ + | egrep "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | + grep . >/dev/null; then + echo + if test "X$deplibs_check_method" = "Xnone"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + echo "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + if test "$release_suffix" = all; then + oldlibs="$output_objdir/$libname$release.$libext" + else + oldlibs="$output_objdir/$libname.$libext" + fi + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + # Get the real and link names of the library. + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Ensure that we have .o objects for linkers which dislike .lo + # (e.g. aix) in case we are running --disable-static + for obj in $libobjs; do + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + if test ! -f $xdir/$oldobj; then + $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" + $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? + fi + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + eval cmds=\"$export_symbols_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linkopts="$linkopts $flag" + fi + + # Do each of the archive commands. + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval cmds=\"$archive_expsym_cmds\" + else + eval cmds=\"$archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + *.lo | *.o | *.obj) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into objects" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case "$output" in + *.lo) + if test -n "$objs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" + + output="$obj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show $rm $libobj + $run $rm $libobj + xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$libobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + $show "(cd $xdir && $LN_S $oldobj $baseobj)" + $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + ;; + + # Anything else should be a program. + *) + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$compile_rpath " in + *" $libdir "*) ;; + *) compile_rpath="$compile_rpath $libdir" ;; + esac + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + # Create the binary in the object directory, then wrap it. + if test ! -d $output_objdir; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case "$dlsyms" in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`echo "$arg" | sed -e 's%^.*/%%'` + $run eval 'echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{\ +" + + sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \ + -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \ + < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr_t) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case "$host" in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case "$0" in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + link_against_libtool_libs='$link_against_libtool_libs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname' + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if (cd \"\$thisdir\" && eval \$relink_command); then : + else + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + *-*-cygwin* | *-*-mingw | *-*-os2*) + # win32 systems need to use the prog path for dll + # lookup to work + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + if test "$release_suffix" = all; then + test "$build_old_libs" = yes && old_library="$libname$release.$libext" + else + test "$build_old_libs" = yes && old_library="$libname.$libext" + fi + $show "creating $output" + + if test -n "$xrpath"; then + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + fi + $rm $output + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Directory that this library needs to be installed in: +libdir='$install_libdir'\ +" + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a | *.lib) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + if test "$install_ltlibs" = yes; then + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + fi + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.o | *.obj) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + link_against_libtool_libs= + relink_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + finalize=no + fi + done + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/missing b/missing new file mode 100755 index 00000000..0a7fb5a2 --- /dev/null +++ b/missing @@ -0,0 +1,283 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing 0.3 - GNU automake" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar ${1+"$@"} && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar ${1+"$@"} && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 00000000..6b3b5fc5 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id$ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c new file mode 100644 index 00000000..19b6ff2e --- /dev/null +++ b/skeletons/BIT_STRING.c @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * BIT STRING basic type description. + */ +static ber_tlv_tag_t asn1_DEF_BIT_STRING_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING = { + "BIT STRING", + BIT_STRING_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + BIT_STRING_print, + OCTET_STRING_free, /* Implemented in terms of OCTET STRING */ + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_BIT_STRING_tags, + sizeof(asn1_DEF_BIT_STRING_tags) + / sizeof(asn1_DEF_BIT_STRING_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ + (void *)-1 /* Special indicator that this is a BIT STRING */ +}; + +/* + * BIT STRING generic constraint. + */ +int +BIT_STRING_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const BIT_STRING_t *st = sptr; + + if(st && st->buf) { + if(st->size) { + if(st->size == 1 && st->buf[0] != 0) { + _ASN_ERRLOG("%s: invalid padding byte", + td->name); + return -1; + } + } else { + _ASN_ERRLOG("%s: no padding byte", td->name); + return -1; + } + } else { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + return 0; +} + +/* + * BIT STRING specific contents printer. + */ +int +BIT_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + static char h2c[16] = "0123456789ABCDEF"; + char scratch[64]; + const BIT_STRING_t *st = sptr; + uint8_t *buf; + uint8_t *end; + char *p = scratch; + + if(!st || !st->buf) return cb("", 8, app_key); + + ilevel += 4; + buf = st->buf; + end = buf + st->size; + + /* + * Hexadecimal dump. + */ + for(buf++; buf < end; buf++) { + if(((buf - st->buf) - 1) % 16 == 0) { + int i; + /* Indentation */ + if(cb("\n", 1, app_key)) return -1; + for(i = 0; i < ilevel; i++) cb(" ", 1, app_key); + /* Dump the string */ + if(cb(scratch, p - scratch, app_key)) return -1; + p = scratch; + } + *p++ = h2c[*buf >> 4]; + *p++ = h2c[*buf & 0x0F]; + *p++ = 0x20; + } + + /* Dump the incomplete 16-bytes row */ + return cb(scratch, p - scratch, app_key); +} + diff --git a/skeletons/BIT_STRING.h b/skeletons/BIT_STRING.h new file mode 100644 index 00000000..1def8bb2 --- /dev/null +++ b/skeletons/BIT_STRING.h @@ -0,0 +1,18 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _BIT_STRING_H_ +#define _BIT_STRING_H_ + +#include +#include + +typedef OCTET_STRING_t BIT_STRING_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_BIT_STRING; + +asn_struct_print_f BIT_STRING_print; /* Human-readable output */ +asn_constr_check_f BIT_STRING_constraint; + +#endif /* _BIT_STRING_H_ */ diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c new file mode 100644 index 00000000..596974ea --- /dev/null +++ b/skeletons/BMPString.c @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * BMPString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_BMPString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (30 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_BMPString = { + "BMPString", + asn_generic_no_constraint, /* No constraint by default */ + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + BMPString_print, + OCTET_STRING_free, /* -//- */ + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_BMPString_tags, + sizeof(asn1_DEF_BMPString_tags) + / sizeof(asn1_DEF_BMPString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + +/* + * BMPString specific contents printer. + */ +int +BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const BMPString_t *st = sptr; + uint16_t *wchar; + uint16_t *wend; + char scratch[128]; /* Scratchpad buffer */ + char *p; + + if(!st || !st->buf) return cb("", 8, app_key); + + wchar = (uint16_t *)st->buf; + wend = (uint16_t *)(st->buf + st->size); + for(p = scratch; wchar < wend; wchar++) { + uint16_t wc = (((uint8_t *)wchar)[0] << 8) + | ((uint8_t *)wchar)[1]; /* 2 bytes */ + if(sizeof(scratch) - (p - scratch) < 3) { + if(cb(scratch, p - scratch, app_key)) + return -1; + p = scratch; + } + if(wc < 0x80) { + *p++ = (char)wc; + } else if(wc < 0x800) { + *p++ = 0xc0 | ((wc >> 6)); + *p++ = 0x80 | ((wc & 0x3f)); + } else { + *p++ = 0xe0 | ((wc >> 12)); + *p++ = 0x80 | ((wc >> 6) & 0x3f); + *p++ = 0x80 | ((wc & 0x3f)); + } + } + + return cb(scratch, p - scratch, app_key); +} diff --git a/skeletons/BMPString.h b/skeletons/BMPString.h new file mode 100644 index 00000000..e3957ca0 --- /dev/null +++ b/skeletons/BMPString.h @@ -0,0 +1,17 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _BMPString_H_ +#define _BMPString_H_ + +#include +#include + +typedef OCTET_STRING_t BMPString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_BMPString; + +asn_struct_print_f BMPString_print; /* Human-readable output */ + +#endif /* _BMPString_H_ */ diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c new file mode 100644 index 00000000..705d37e0 --- /dev/null +++ b/skeletons/BOOLEAN.c @@ -0,0 +1,147 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * BOOLEAN basic type description. + */ +static ber_tlv_tag_t asn1_DEF_BOOLEAN_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = { + "BOOLEAN", + asn_generic_no_constraint, + BOOLEAN_decode_ber, + BOOLEAN_encode_der, + BOOLEAN_print, + BOOLEAN_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_BOOLEAN_tags, + sizeof(asn1_DEF_BOOLEAN_tags)/sizeof(asn1_DEF_BOOLEAN_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; + +/* + * Decode BOOLEAN type. + */ +ber_dec_rval_t +BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td, + void **bool_structure, void *buf_ptr, size_t size, + int tag_mode) { + BOOLEAN_t *st = *bool_structure; + ber_dec_rval_t rval; + ber_dec_ctx_t ctx = { 0 }; + ber_tlv_len_t length; + ber_tlv_len_t lidx; + + if(st == NULL) { + st = *bool_structure = CALLOC(1, sizeof(*st)); + if(st == NULL) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + } + + ASN_DEBUG("Decoding %s as BOOLEAN (tm=%d)", + td->name, tag_mode); + + /* + * Check tags. + */ + rval = ber_check_tags(td, &ctx, + buf_ptr, size, tag_mode, &length, 0); + if(rval.code != RC_OK) + return rval; + + ASN_DEBUG("Boolean length is %d bytes", (int)length); + + buf_ptr += rval.consumed; + size -= rval.consumed; + if(length > size) { + rval.code = RC_WMORE; + rval.consumed = 0; + return rval; + } + + /* + * Compute boolean value. + */ + for(st->value = 0, lidx = 0; + (lidx < length) && st->value == 0; lidx++) { + /* + * Very simple approach: read bytes until the end or + * value is already TRUE. + * BOOLEAN is not supposed to contain meaningful data anyway. + */ + st->value |= ((uint8_t *)buf_ptr)[lidx]; + } + + rval.code = RC_OK; + rval.consumed += length; + + ASN_DEBUG("Took %ld/%ld bytes to encode %s, value=%ld", + (long)rval.consumed, (long)length, + td->name, (long)st->value); + + return rval; +} + +der_enc_rval_t +BOOLEAN_encode_der(asn1_TYPE_descriptor_t *td, void *sptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + der_enc_rval_t erval; + BOOLEAN_t *st = sptr; + + erval.encoded = der_write_tags(td, 1, tag_mode, tag, cb, app_key); + if(erval.encoded == -1) { + erval.failed_type = td; + erval.structure_ptr = sptr; + return erval; + } + + if(cb) { + uint8_t bool_value; + ssize_t ret; + + bool_value = st->value?0xff:0; /* 0xff mandated by DER */ + ret = cb(&bool_value, 1, app_key); + if(ret == -1) { + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = sptr; + return erval; + } + } + + erval.encoded += 1; + + return erval; +} + +int +BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const BOOLEAN_t *st = sptr; + + if(st) { + if(st->value) + return cb("TRUE", 4, app_key); + else + return cb("FALSE", 5, app_key); + } else { + return cb("", 8, app_key); + } +} + +void +BOOLEAN_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) { + if(td && ptr && !contents_only) { + FREEMEM(ptr); + } +} + diff --git a/skeletons/BOOLEAN.h b/skeletons/BOOLEAN.h new file mode 100644 index 00000000..234e9f8e --- /dev/null +++ b/skeletons/BOOLEAN.h @@ -0,0 +1,21 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _BOOLEAN_H_ +#define _BOOLEAN_H_ + +#include + +typedef struct BOOLEAN { + int value; +} BOOLEAN_t; + +extern asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN; + +ber_type_decoder_f BOOLEAN_decode_ber; +der_type_encoder_f BOOLEAN_encode_der; +asn_struct_print_f BOOLEAN_print; +asn_struct_free_f BOOLEAN_free; + +#endif /* _BOOLEAN_H_ */ diff --git a/skeletons/ENUMERATED.c b/skeletons/ENUMERATED.c new file mode 100644 index 00000000..1f1ae896 --- /dev/null +++ b/skeletons/ENUMERATED.c @@ -0,0 +1,26 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * ENUMERATED basic type description. + */ +static ber_tlv_tag_t asn1_DEF_ENUMERATED_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_ENUMERATED = { + "ENUMERATED", + asn_generic_no_constraint, + INTEGER_decode_ber, /* Implemented in terms of INTEGER */ + INTEGER_encode_der, /* Implemented in terms of INTEGER */ + INTEGER_print, /* Implemented in terms of INTEGER */ + INTEGER_free, /* Implemented in terms of INTEGER */ + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_ENUMERATED_tags, + sizeof(asn1_DEF_ENUMERATED_tags)/sizeof(asn1_DEF_ENUMERATED_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Primitive */ +}; + diff --git a/skeletons/ENUMERATED.h b/skeletons/ENUMERATED.h new file mode 100644 index 00000000..a0948ed0 --- /dev/null +++ b/skeletons/ENUMERATED.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _ENUMERATED_H_ +#define _ENUMERATED_H_ + +#include +#include + +typedef INTEGER_t ENUMERATED_t; /* Implemented in terms of INTEGER */ + +extern asn1_TYPE_descriptor_t asn1_DEF_ENUMERATED; + +#endif /* _ENUMERATED_H_ */ diff --git a/skeletons/GeneralString.c b/skeletons/GeneralString.c new file mode 100644 index 00000000..d69c5f16 --- /dev/null +++ b/skeletons/GeneralString.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * GeneralString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_GeneralString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (27 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_GeneralString = { + "GeneralString", + asn_generic_unknown_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print, /* non-ascii string */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_GeneralString_tags, + sizeof(asn1_DEF_GeneralString_tags) + / sizeof(asn1_DEF_GeneralString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/GeneralString.h b/skeletons/GeneralString.h new file mode 100644 index 00000000..6d5bfdf6 --- /dev/null +++ b/skeletons/GeneralString.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _GeneralString_H_ +#define _GeneralString_H_ + +#include +#include + +typedef OCTET_STRING_t GeneralString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_GeneralString; + +#endif /* _GeneralString_H_ */ diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c new file mode 100644 index 00000000..01d7a736 --- /dev/null +++ b/skeletons/GeneralizedTime.c @@ -0,0 +1,302 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include +#ifndef __NO_ASSERT_H__ +#include +#endif /* __NO_ASSERT_H__ */ + +#ifndef __NO_ASN_TABLE__ + +/* + * GeneralizedTime basic type description. + */ +static ber_tlv_tag_t asn1_DEF_GeneralizedTime_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (24 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime = { + "GeneralizedTime", + GeneralizedTime_constraint, /* Check validity of time */ + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + GeneralizedTime_print, + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_GeneralizedTime_tags, + sizeof(asn1_DEF_GeneralizedTime_tags) + / sizeof(asn1_DEF_GeneralizedTime_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + +#endif /* __NO_ASN_TABLE__ */ + +/* + * Check that the time looks like the time. + */ +int +GeneralizedTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const GeneralizedTime_t *st = sptr; + time_t tloc; + + errno = EPERM; /* Just an unlikely error code */ + tloc = asn_GT2time(st, 0); + if(tloc == -1 && errno != EPERM) { + _ASN_ERRLOG("%s: Invalid time format: %s", + td->name, strerror(errno)); + return -1; + } + + return 0; +} + +int +GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const GeneralizedTime_t *st = sptr; + + if(st && st->buf) { + char buf[32]; + struct tm tm; + int ret; + + errno = EPERM; + if(asn_GT2time(st, &tm) == -1 && errno != EPERM) + return cb("", 11, app_key); + + ret = snprintf(buf, sizeof(buf), + "%04d-%02d-%02d %02d:%02d%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); + assert(ret > 0 && ret < sizeof(buf)); + return cb(buf, ret, app_key); + } else { + return cb("", 8, app_key); + } +} + +/* + * Where to look for offset from GMT, Phase I. + * Several platforms are known. + */ +#if defined(__FreeBSD__) || (defined(__GNUC__) && defined(__APPLE_CC__)) +#undef HAVE_TM_ZONE +#define HAVE_TM_ZONE +#endif /* BSDs */ + +/* + * Where to look for offset from GMT, Phase II. + */ +#ifdef HAVE_TM_ZONE +#define GMTOFF (tm_s.tm_gmtoff) +#else /* HAVE_TM_ZONE */ +#define GMTOFF (-timezone) +#endif /* HAVE_TM_ZONE */ + +time_t +asn_GT2time(const GeneralizedTime_t *st, struct tm *_tm) { + struct tm tm_s; + uint8_t *buf; + uint8_t *end; + int tm_gmtoff_h = 0; + int tm_gmtoff_m = 0; + int tm_gmtoff = 0; /* h + m */ + int offset_specified = 0; + time_t tloc; + + if(!st || !st->buf) { + errno = EINVAL; + return -1; + } else { + buf = st->buf; + end = buf + st->size; + } + + if(st->size < 10) { + errno = EINVAL; + return -1; + } + + /* + * Decode first 10 bytes: "AAAAMMJJhh" + */ + memset(&tm_s, 0, sizeof(tm_s)); +#undef B2F +#undef B2T +#define B2F(var) do { \ + unsigned ch = *buf; \ + if(ch < 0x30 && ch > 0x39) { \ + errno = EINVAL; \ + return -1; \ + } else { \ + var = var * 10 + (ch - 0x30); \ + buf++; \ + } \ + } while(0) +#define B2T(var) B2F(tm_s.var) + + B2T(tm_year); /* 1: A */ + B2T(tm_year); /* 2: A */ + B2T(tm_year); /* 3: A */ + B2T(tm_year); /* 4: A */ + B2T(tm_mon); /* 5: M */ + B2T(tm_mon); /* 6: M */ + B2T(tm_mday); /* 7: J */ + B2T(tm_mday); /* 8: J */ + B2T(tm_hour); /* 9: h */ + B2T(tm_hour); /* 0: h */ + + if(buf == end) goto local_finish; + + /* + * Parse [mm[ss[(.|,)ffff]]] + * ^^ + */ + switch(*buf) { + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: + tm_s.tm_min = (*buf++) - 0x30; + if(buf == end) { errno = EINVAL; return -1; } + B2T(tm_min); + break; + case 0x2B: case 0x2D: /* +, - */ + goto offset; + case 0x5A: /* Z */ + goto utc_finish; + default: + errno = EINVAL; + return -1; + } + + if(buf == end) goto local_finish; + + /* + * Parse [mm[ss[(.|,)ffff]]] + * ^^ + */ + switch(*buf) { + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: + tm_s.tm_sec = (*buf++) - 0x30; + if(buf == end) { errno = EINVAL; return -1; } + B2T(tm_sec); + break; + case 0x2B: case 0x2D: /* +, - */ + goto offset; + case 0x5A: /* Z */ + goto utc_finish; + default: + errno = EINVAL; + return -1; + } + + if(buf == end) goto local_finish; + + /* + * Parse [mm[ss[(.|,)ffff]]] + * ^ ^ + */ + switch(*buf) { + case 0x2C: case 0x2E: /* (.|,) */ + /* Fractions of seconds are not supported + * by time_t or struct tm. Skip them */ + for(buf++; buf < end; buf++) { + switch(*buf) { + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: + continue; + default: + break; + } + break; + } + } + + if(buf == end) goto local_finish; + + switch(*buf) { + case 0x2B: case 0x2D: /* +, - */ + goto offset; + case 0x5A: /* Z */ + goto utc_finish; + default: + errno = EINVAL; + return -1; + } + + +offset: + + if(end - buf < 3) { + errno = EINVAL; + return -1; + } + buf++; + B2F(tm_gmtoff_h); + B2F(tm_gmtoff_h); + if(buf[-3] == 0x2D) /* Negative */ + tm_gmtoff = -1; + else + tm_gmtoff = 1; + + if((end - buf) == 2) { + B2F(tm_gmtoff_m); + B2F(tm_gmtoff_m); + } else if(end != buf) { + errno = EINVAL; + return -1; + } + + tm_gmtoff = tm_gmtoff * (3600 * tm_gmtoff_h + 60 * tm_gmtoff_m); + + /* Fall through */ +utc_finish: + + offset_specified = 1; + + /* Fall through */ +local_finish: + + /* + * Validation. + */ + if((tm_s.tm_mon > 12 || tm_s.tm_mon < 1) + || (tm_s.tm_mday > 31 || tm_s.tm_mday < 1) + || (tm_s.tm_hour > 23) + || (tm_s.tm_sec > 60) + ) { + errno = EINVAL; + return -1; + } + + /* Canonicalize */ + tm_s.tm_mon -= 1; /* 0 - 11 */ + tm_s.tm_year -= 1900; + tm_s.tm_isdst = -1; + + tloc = mktime(&tm_s); + if(tloc == -1) { + errno = EINVAL; + return -1; + } + + if(offset_specified) { + /* + * Offset from GMT is specified in the time expression. + */ + tloc += GMTOFF - tm_gmtoff; + if(_tm && (localtime_r(&tloc, &tm_s) == NULL)) { + /* Could not reconstruct the time */ + return -1; + } + } + + if(_tm) memcpy(_tm, &tm_s, sizeof(struct tm)); + + return tloc; +} + diff --git a/skeletons/GeneralizedTime.h b/skeletons/GeneralizedTime.h new file mode 100644 index 00000000..d8176be0 --- /dev/null +++ b/skeletons/GeneralizedTime.h @@ -0,0 +1,26 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _GeneralizedTime_H_ +#define _GeneralizedTime_H_ + +#include +#include + +typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented using OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime; + +asn_constr_check_f GeneralizedTime_constraint; +asn_struct_print_f GeneralizedTime_print; + +/*********************** + * Some handy helpers. * + ***********************/ + +/* On error returns -1 and errno set to EINVAL */ +struct tm; /* */ +time_t asn_GT2time(const GeneralizedTime_t *, struct tm *_optional_tm4fill); + +#endif /* _GeneralizedTime_H_ */ diff --git a/skeletons/GraphicString.c b/skeletons/GraphicString.c new file mode 100644 index 00000000..5c89685e --- /dev/null +++ b/skeletons/GraphicString.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * GraphicString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_GraphicString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (25 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_GraphicString = { + "GraphicString", + asn_generic_unknown_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print, /* non-ascii string */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_GraphicString_tags, + sizeof(asn1_DEF_GraphicString_tags) + / sizeof(asn1_DEF_GraphicString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/GraphicString.h b/skeletons/GraphicString.h new file mode 100644 index 00000000..b37b2c7e --- /dev/null +++ b/skeletons/GraphicString.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _GraphicString_H_ +#define _GraphicString_H_ + +#include +#include + +typedef OCTET_STRING_t GraphicString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_GraphicString; + +#endif /* _GraphicString_H_ */ diff --git a/skeletons/IA5String.c b/skeletons/IA5String.c new file mode 100644 index 00000000..c4afcb00 --- /dev/null +++ b/skeletons/IA5String.c @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * IA5String basic type description. + */ +static ber_tlv_tag_t asn1_DEF_IA5String_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_IA5String = { + "IA5String", + IA5String_constraint, /* Constraint on the alphabet */ + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print_ascii, /* ASCII subset */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_IA5String_tags, + sizeof(asn1_DEF_IA5String_tags) + / sizeof(asn1_DEF_IA5String_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + +int +IA5String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const IA5String_t *st = sptr; + + if(st && st->buf) { + uint8_t *buf = st->buf; + uint8_t *end = buf + st->size; + /* + * IA5String is generally equivalent to 7bit ASCII. + * ISO/ITU-T T.50, 1963. + */ + for(; buf < end; buf++) { + if(*buf > 0x7F) { + _ASN_ERRLOG("%s: value byte %d out of range: " + "%d > 127", + td->name, + (buf - st->buf) + 1, + *buf + ); + return -1; + } + } + } else { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + return 0; +} diff --git a/skeletons/IA5String.h b/skeletons/IA5String.h new file mode 100644 index 00000000..a80004e8 --- /dev/null +++ b/skeletons/IA5String.h @@ -0,0 +1,20 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _IA5String_H_ +#define _IA5String_H_ + +#include +#include + +typedef OCTET_STRING_t IA5String_t; /* Implemented in terms of OCTET STRING */ + +/* + * IA5String ASN.1 type definition. + */ +extern asn1_TYPE_descriptor_t asn1_DEF_IA5String; + +asn_constr_check_f IA5String_constraint; + +#endif /* _IA5String_H_ */ diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c new file mode 100644 index 00000000..b1a8c29b --- /dev/null +++ b/skeletons/INTEGER.c @@ -0,0 +1,305 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +/* + * INTEGER basic type description. + */ +static ber_tlv_tag_t asn1_DEF_INTEGER_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_INTEGER = { + "INTEGER", + asn_generic_no_constraint, + INTEGER_decode_ber, + INTEGER_encode_der, + INTEGER_print, + INTEGER_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_INTEGER_tags, + sizeof(asn1_DEF_INTEGER_tags)/sizeof(asn1_DEF_INTEGER_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; + +/* + * Decode INTEGER type. + */ +ber_dec_rval_t +INTEGER_decode_ber(asn1_TYPE_descriptor_t *td, + void **int_structure, void *buf_ptr, size_t size, int tag_mode) { + INTEGER_t *st = *int_structure; + ber_dec_rval_t rval; + ber_dec_ctx_t ctx = { 0 }; + ber_tlv_len_t length; + + /* + * If the structure is not there, allocate it. + */ + if(st == NULL) { + st = *int_structure = CALLOC(1, sizeof(*st)); + if(st == NULL) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + } + + ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", + td->name, tag_mode); + + /* + * Check tags. + */ + rval = ber_check_tags(td, &ctx, + buf_ptr, size, tag_mode, &length, 0); + if(rval.code != RC_OK) + return rval; + + ASN_DEBUG("%s length is %d bytes", td->name, (int)length); + + /* + * Make sure we have this length. + */ + buf_ptr += rval.consumed; + size -= rval.consumed; + if(length > size) { + rval.code = RC_WMORE; + rval.consumed = 0; + return rval; + } + + st->buf = MALLOC(length); + if(st->buf) { + st->size = length; + } else { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + + memcpy(st->buf, buf_ptr, st->size); + + rval.code = RC_OK; + rval.consumed += length; + + ASN_DEBUG("Took %ld/%ld bytes to encode %s", + (long)rval.consumed, + (long)length, td->name); + + return rval; +} + +/* + * Encode INTEGER type using DER. + */ +der_enc_rval_t +INTEGER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + der_enc_rval_t erval; + INTEGER_t *st = ptr; + + ASN_DEBUG("%s %s as INTEGER (tm=%d)", + cb?"Encoding":"Estimating", sd->name, tag_mode); + + /* + * Canonicalize integer in the buffer. + * (Remove too long sign extension, remove some first 0x00 bytes) + */ + if(st->buf) { + uint8_t *buf = st->buf; + uint8_t *end1 = buf + st->size - 1; + int shift; + + /* Compute the number of superfluous leading bytes */ + for(; buf < end1; buf++) { + /* + * If the contents octets of an integer value encoding + * consist of more than one octet, then the bits of the + * first octet and bit 8 of the second octet: + * a) shall not all be ones; and + * b) shall not all be zero. + */ + switch(*buf) { + case 0x00: if((buf[1] & 0x80) == 0) + continue; + break; + case 0xff: if((buf[1] & 0x80)) + continue; + break; + } + break; + } + + /* Remove leading superfluous bytes from the integer */ + shift = buf - st->buf; + if(shift) { + uint8_t *nb = st->buf; + uint8_t *end; + + st->size -= shift; /* New size, minus bad bytes */ + end = nb + st->size; + + for(; nb < end; nb++, buf++) + *nb = *buf; + } + + } /* if(1) */ + + erval.encoded = der_write_tags(sd, st->size, tag_mode, tag, + cb, app_key); + ASN_DEBUG("INTEGER %s wrote tags %d", sd->name, (int)erval.encoded); + if(erval.encoded == -1) { + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + + if(cb && st->buf) { + ssize_t ret; + + ret = cb(st->buf, st->size, app_key); + if(ret == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + } else { + assert(st->buf || st->size == 0); + } + + erval.encoded += st->size; + + return erval; +} + +/* + * INTEGER specific human-readable output. + */ +int +INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const INTEGER_t *st = sptr; + char scratch[32]; + uint8_t *buf = st->buf; + uint8_t *buf_end = st->buf + st->size; + signed long accum; + char *p; + int ret; + + if(!st && !st->buf) return cb("", 8, app_key); + + if(st->size == 0) + return cb("0", 1, app_key); + + /* Simple case: the integer size is small */ + if(st->size < sizeof(accum) || (st->buf[0] & 0x80)) { + accum = (st->buf[0] & 0x80) ? -1 : 0; + for(; buf < buf_end; buf++) + accum = (accum << 8) | *buf; + ret = snprintf(scratch, sizeof(scratch), "%ld", accum); + assert(ret > 0 && ret < sizeof(scratch)); + return cb(scratch, ret, app_key); + } + + /* Output in the long xx:yy:zz... format */ + for(p = scratch; buf < buf_end; buf++) { + static char h2c[16] = "0123456789ABCDEF"; + if((p - scratch) >= (sizeof(scratch) / 2)) { + /* Flush buffer */ + if(cb(scratch, p - scratch, app_key)) + return -1; + p = scratch; + } + *p++ = h2c[*buf >> 4]; + *p++ = h2c[*buf & 0x0F]; + *p++ = ':'; + } + + return cb(scratch, p - scratch, app_key); +} + +void +INTEGER_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) { + INTEGER_t *st = ptr; + + if(!td || !st) + return; + + ASN_DEBUG("Freeing %s as INTEGER (%d, %p, %p)", + td->name, contents_only, st, st->buf); + + if(st->buf) { + FREEMEM(st->buf); + } + + if(!contents_only) { + FREEMEM(st); + } +} + +int +asn1_INTEGER2long(const INTEGER_t *iptr, long *lptr) { + uint8_t *b, *end; + size_t size; + long l; + + /* Sanity checking */ + if(!iptr || !iptr->buf || !lptr) { + errno = EINVAL; + return -1; + } + + /* Cache the begin/end of the buffer */ + b = iptr->buf; /* Start of the INTEGER buffer */ + size = iptr->size; + end = b + size; /* Where to stop */ + + if(size > sizeof(long)) { + uint8_t *end1 = end - 1; + /* + * Slightly more advanced processing, + * able to >sizeof(long) bytes, + * when the actual value is small + * (0x0000000000abcdef would yield a fine 0x00abcdef) + */ + /* Skip out the insignificant leading bytes */ + for(; b < end1; b++) { + switch(*b) { + case 0x00: if((b[1] & 0x80) == 0) continue; break; + case 0xff: if((b[1] & 0x80) != 0) continue; break; + } + break; + } + + size = end - b; + if(size > sizeof(long)) { + /* Still cannot fit the long */ + errno = ERANGE; + return -1; + } + } + + /* Shortcut processing of a corner case */ + if(end == b) { + *lptr = 0; + return 0; + } + + /* Perform the sign initialization */ + /* Actually l = -(*b >> 7); gains nothing, yet unreadable! */ + if((*b >> 7)) l = -1; else l = 0; + + /* Conversion engine */ + for(; b < end; b++) + l = (l << 8) | *b; + + *lptr = l; + return 0; +} diff --git a/skeletons/INTEGER.h b/skeletons/INTEGER.h new file mode 100644 index 00000000..ef4d3f25 --- /dev/null +++ b/skeletons/INTEGER.h @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _INTEGER_H_ +#define _INTEGER_H_ + +#include + +typedef struct INTEGER { + uint8_t *buf; /* Buffer with consecutive INTEGER bits (big-endian) */ + int size; /* Size of the buffer */ +} INTEGER_t; + +extern asn1_TYPE_descriptor_t asn1_DEF_INTEGER; + +ber_type_decoder_f INTEGER_decode_ber; +der_type_encoder_f INTEGER_encode_der; +asn_struct_print_f INTEGER_print; +asn_struct_free_f INTEGER_free; + +/*********************************** + * Some handy conversion routines. * + ***********************************/ + +/* + * Returns 0 if it was possible to convert, -1 otherwise. + * -1/EINVAL: Mandatory argument missing + * -1/ERANGE: Value encoded is out of range for long representation + */ +int asn1_INTEGER2long(const INTEGER_t *i, long *l); + +#endif /* _INTEGER_H_ */ diff --git a/skeletons/ISO646String.c b/skeletons/ISO646String.c new file mode 100644 index 00000000..08b31698 --- /dev/null +++ b/skeletons/ISO646String.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * ISO646String basic type description. + */ +static ber_tlv_tag_t asn1_DEF_ISO646String_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_ISO646String = { + "ISO646String", + VisibleString_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print_ascii, /* ASCII subset */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_ISO646String_tags, + sizeof(asn1_DEF_ISO646String_tags) + / sizeof(asn1_DEF_ISO646String_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/ISO646String.h b/skeletons/ISO646String.h new file mode 100644 index 00000000..566ce3be --- /dev/null +++ b/skeletons/ISO646String.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _ISO646String_H_ +#define _ISO646String_H_ + +#include +#include + +typedef VisibleString_t ISO646String_t; /* Implemented using VisibleString */ + +extern asn1_TYPE_descriptor_t asn1_DEF_ISO646String; + +#endif /* _ISO646String_H_ */ diff --git a/skeletons/Makefile.am b/skeletons/Makefile.am new file mode 100644 index 00000000..4a01bf3d --- /dev/null +++ b/skeletons/Makefile.am @@ -0,0 +1,7 @@ + +SUBDIRS = tests + +dist_pkgdata_DATA = *.[ch] +uninstall-local: + -@echo -n " " + -rm -f -r $(DESTDIR)$(pkgdatadir) diff --git a/skeletons/Makefile.in b/skeletons/Makefile.in new file mode 100644 index 00000000..e8f42241 --- /dev/null +++ b/skeletons/Makefile.in @@ -0,0 +1,364 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +SUBDIRS = tests + +dist_pkgdata_DATA = *.[ch] +subdir = skeletons +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DATA = $(dist_pkgdata_DATA) + + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README $(dist_pkgdata_DATA) Makefile.am Makefile.in +DIST_SUBDIRS = $(SUBDIRS) +all: all-recursive + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu skeletons/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: +install-dist_pkgdataDATA: $(dist_pkgdata_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \ + done + +uninstall-dist_pkgdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \ + rm -f $(DESTDIR)$(pkgdatadir)/$$f; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + +distclean-am: clean-am distclean-generic distclean-libtool \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: install-dist_pkgdataDATA + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-dist_pkgdataDATA uninstall-info-am \ + uninstall-local + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ + clean-generic clean-libtool clean-recursive distclean \ + distclean-generic distclean-libtool distclean-recursive \ + distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-data install-data-am \ + install-data-recursive install-dist_pkgdataDATA install-exec \ + install-exec-am install-exec-recursive install-info \ + install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-libtool mostlyclean-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-dist_pkgdataDATA \ + uninstall-info-am uninstall-info-recursive uninstall-local \ + uninstall-recursive + +uninstall-local: + -@echo -n " " + -rm -f -r $(DESTDIR)$(pkgdatadir) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/skeletons/NULL.c b/skeletons/NULL.c new file mode 100644 index 00000000..9027e2c1 --- /dev/null +++ b/skeletons/NULL.c @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include /* Implemented in terms of BOOLEAN type */ + +/* + * NULL basic type description. + */ +static ber_tlv_tag_t asn1_DEF_NULL_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (5 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_NULL = { + "NULL", + asn_generic_no_constraint, + BOOLEAN_decode_ber, /* Implemented in terms of BOOLEAN */ + NULL_encode_der, /* Special handling of DER encoding */ + NULL_print, + BOOLEAN_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_NULL_tags, + sizeof(asn1_DEF_NULL_tags)/sizeof(asn1_DEF_NULL_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; + +der_enc_rval_t +NULL_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + der_enc_rval_t erval; + + erval.encoded = der_write_tags(sd, 0, tag_mode, tag, cb, app_key); + if(erval.encoded == -1) { + erval.failed_type = sd; + erval.structure_ptr = ptr; + } + + return erval; +} + +int +NULL_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + if(sptr) { + return cb("", 9, app_key); + } else { + return cb("", 8, app_key); + } +} diff --git a/skeletons/NULL.h b/skeletons/NULL.h new file mode 100644 index 00000000..14f5ffab --- /dev/null +++ b/skeletons/NULL.h @@ -0,0 +1,19 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _NULL_H_ +#define _NULL_H_ + +#include + +typedef struct NULL_s { + int value; +} NULL_t; + +extern asn1_TYPE_descriptor_t asn1_DEF_NULL; + +der_type_encoder_f NULL_encode_der; +asn_struct_print_f NULL_print; + +#endif /* _NULL_H_ */ diff --git a/skeletons/NativeEnumerated.c b/skeletons/NativeEnumerated.c new file mode 100644 index 00000000..b6d21ed2 --- /dev/null +++ b/skeletons/NativeEnumerated.c @@ -0,0 +1,32 @@ +/*- + * Copyright (c) 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * Please read the NativeInteger.h for the explanation wrt. differences between + * INTEGER and NativeInteger. + * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this + * implementation deals with the standard (machine-specific) representation + * of them instead of using the platform-independent buffer. + */ +#include + +/* + * NativeEnumerated basic type description. + */ +static ber_tlv_tag_t asn1_DEF_NativeEnumerated_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_NativeEnumerated = { + "ENUMERATED", /* The ASN.1 type is still ENUMERATED */ + asn_generic_no_constraint, + NativeInteger_decode_ber, + NativeInteger_encode_der, + NativeInteger_print, + NativeInteger_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_NativeEnumerated_tags, + sizeof(asn1_DEF_NativeEnumerated_tags)/sizeof(asn1_DEF_NativeEnumerated_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; diff --git a/skeletons/NativeEnumerated.h b/skeletons/NativeEnumerated.h new file mode 100644 index 00000000..681147c1 --- /dev/null +++ b/skeletons/NativeEnumerated.h @@ -0,0 +1,19 @@ +/*- + * Copyright (c) 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * This type differs from the standard ENUMERATED in that it is modelled using + * the fixed machine type (long, int, short), so it can hold only values of + * limited length. There is no type (i.e., NativeEnumerated_t, any integer type + * will do). + * This type may be used when integer range is limited by subtype constraints. + */ +#ifndef _NativeEnumerated_H_ +#define _NativeEnumerated_H_ + +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_NativeEnumerated; + +#endif /* _NativeEnumerated_H_ */ diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c new file mode 100644 index 00000000..d42540ef --- /dev/null +++ b/skeletons/NativeInteger.c @@ -0,0 +1,193 @@ +/*- + * Copyright (c) 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * Please read the NativeInteger.h for the explanation wrt. differences between + * INTEGER and NativeInteger. + * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this + * implementation deals with the standard (machine-specific) representation + * of them instead of using the platform-independent buffer. + */ +#include +#include +#include + +/* + * NativeInteger basic type description. + */ +static ber_tlv_tag_t asn1_DEF_NativeInteger_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_NativeInteger = { + "INTEGER", /* The ASN.1 type is still INTEGER */ + asn_generic_no_constraint, + NativeInteger_decode_ber, + NativeInteger_encode_der, + NativeInteger_print, + NativeInteger_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_NativeInteger_tags, + sizeof(asn1_DEF_NativeInteger_tags)/sizeof(asn1_DEF_NativeInteger_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; + +/* + * Decode INTEGER type. + */ +ber_dec_rval_t +NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td, + void **int_ptr, void *buf_ptr, size_t size, int tag_mode) { + int *Int = *int_ptr; + ber_dec_rval_t rval; + ber_dec_ctx_t ctx = { 0 }; + ber_tlv_len_t length; + + /* + * If the structure is not there, allocate it. + */ + if(Int == NULL) { + Int = *int_ptr = CALLOC(1, sizeof(*Int)); + if(Int == NULL) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + } + + ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", + td->name, tag_mode); + + /* + * Check tags. + */ + rval = ber_check_tags(td, &ctx, + buf_ptr, size, tag_mode, &length, 0); + if(rval.code != RC_OK) + return rval; + + ASN_DEBUG("%s length is %d bytes", td->name, (int)length); + + /* + * Make sure we have this length. + */ + buf_ptr += rval.consumed; + size -= rval.consumed; + if(length > size) { + rval.code = RC_WMORE; + rval.consumed = 0; + return rval; + } + + /* + * ASN.1 encoded INTEGER: buf_ptr, length + * Fill the Int, at the same time checking for overflow. + * If overflow occured, return with RC_FAIL. + */ + { + INTEGER_t tmp; + long l; + tmp.buf = buf_ptr; + tmp.size = length; + + if(asn1_INTEGER2long(&tmp, &l)) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + + *Int = l; + + /* + * Note that int might be shorter than long. + * This expression hopefully will be optimized away + * by compiler. + */ + if(sizeof(int) != sizeof(long) && (*Int != l)) { + *Int = 0; /* Safe value */ + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + } + + rval.code = RC_OK; + rval.consumed += length; + + ASN_DEBUG("Took %ld/%ld bytes to encode %s (%d)", + (long)rval.consumed, (long)length, td->name, *Int); + + return rval; +} + +/* + * Encode the NativeInteger using the standard INTEGER type DER encoder. + */ +der_enc_rval_t +NativeInteger_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + unsigned int Int = *(unsigned int *)ptr; /* Disable sign ext. */ + der_enc_rval_t erval; + INTEGER_t tmp; + +#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */ + + tmp.buf = ∬ + tmp.size = sizeof(Int); + +#else /* Works even if WORDS_BIGENDIAN is not set where should've been */ + uint8_t buf[sizeof(int)]; + uint8_t *p; + + /* Prepare fake INTEGER */ + for(p = buf + sizeof(buf) - 1; p >= buf; p--, Int >>= 8) + *p = Int & 0xff; + + tmp.buf = buf; + tmp.size = sizeof(buf); +#endif /* WORDS_BIGENDIAN */ + + /* Encode fake INTEGER */ + erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key); + if(erval.encoded == -1) { + assert(erval.structure_ptr == &tmp); + erval.structure_ptr = ptr; + } + return erval; +} + +/* + * INTEGER specific human-readable output. + */ +int +NativeInteger_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const int *Int = sptr; + char scratch[32]; + int ret; + + if(Int) { + ret = snprintf(scratch, sizeof(scratch), "%d", *Int); + assert(ret > 0 && ret < sizeof(scratch)); + return cb(scratch, ret, app_key); + } else { + return cb("", 8, app_key); + } +} + +void +NativeInteger_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) { + + if(!td || !ptr) + return; + + ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", + td->name, contents_only, ptr); + + if(!contents_only) { + FREEMEM(ptr); + } +} + diff --git a/skeletons/NativeInteger.h b/skeletons/NativeInteger.h new file mode 100644 index 00000000..e0f26c78 --- /dev/null +++ b/skeletons/NativeInteger.h @@ -0,0 +1,24 @@ +/*- + * Copyright (c) 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * This type differs from the standard INTEGER in that it is modelled using + * the fixed machine type (long, int, short), so it can hold only values of + * limited length. There is no type (i.e., NativeInteger_t, any integer type + * will do). + * This type may be used when integer range is limited by subtype constraints. + */ +#ifndef _NativeInteger_H_ +#define _NativeInteger_H_ + +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_NativeInteger; + +ber_type_decoder_f NativeInteger_decode_ber; +der_type_encoder_f NativeInteger_encode_der; +asn_struct_print_f NativeInteger_print; +asn_struct_free_f NativeInteger_free; + +#endif /* _NativeInteger_H_ */ diff --git a/skeletons/NumericString.c b/skeletons/NumericString.c new file mode 100644 index 00000000..a007496c --- /dev/null +++ b/skeletons/NumericString.c @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * NumericString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_NumericString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (18 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_NumericString = { + "NumericString", + NumericString_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print_ascii, /* ASCII subset */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_NumericString_tags, + sizeof(asn1_DEF_NumericString_tags) + / sizeof(asn1_DEF_NumericString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + +int +NumericString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const NumericString_t *st = sptr; + + if(st && st->buf) { + uint8_t *buf = st->buf; + uint8_t *end = buf + st->size; + + /* + * Check the alphabet of the NumericString. + * ASN.1:1984 (X.409) + */ + for(; buf < end; buf++) { + switch(*buf) { + case 0x20: + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: + continue; + } + _ASN_ERRLOG("%s: value byte %d " + "not in NumericString alphabet (%d)", + td->name, + (buf - st->buf) + 1, + *buf + ); + return -1; + } + } else { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + return 0; +} diff --git a/skeletons/NumericString.h b/skeletons/NumericString.h new file mode 100644 index 00000000..71f72c76 --- /dev/null +++ b/skeletons/NumericString.h @@ -0,0 +1,17 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _NumericString_H_ +#define _NumericString_H_ + +#include +#include + +typedef OCTET_STRING_t NumericString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_NumericString; + +asn_constr_check_f NumericString_constraint; + +#endif /* _NumericString_H_ */ diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c new file mode 100644 index 00000000..bcbcdcaf --- /dev/null +++ b/skeletons/OBJECT_IDENTIFIER.c @@ -0,0 +1,356 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +/* + * OBJECT IDENTIFIER basic type description. + */ +static ber_tlv_tag_t asn1_DEF_OBJECT_IDENTIFIER_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER = { + "OBJECT IDENTIFIER", + OBJECT_IDENTIFIER_constraint, + INTEGER_decode_ber, /* Implemented in terms of INTEGER type */ + OBJECT_IDENTIFIER_encode_der, + OBJECT_IDENTIFIER_print, + INTEGER_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_OBJECT_IDENTIFIER_tags, + sizeof(asn1_DEF_OBJECT_IDENTIFIER_tags) + / sizeof(asn1_DEF_OBJECT_IDENTIFIER_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; + + +/* + * Encode OBJECT IDENTIFIER type using DER. + */ +der_enc_rval_t +OBJECT_IDENTIFIER_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + der_enc_rval_t erval; + OBJECT_IDENTIFIER_t *st = ptr; + + ASN_DEBUG("%s %s as OBJECT IDENTIFIER (tm=%d)", + cb?"Encoding":"Estimating", sd->name, tag_mode); + + erval.encoded = der_write_tags(sd, st->size, tag_mode, tag, + cb, app_key); + ASN_DEBUG("OBJECT IDENTIFIER %s wrote tags %d", + sd->name, (int)erval.encoded); + if(erval.encoded == -1) { + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + + if(cb && st->buf) { + ssize_t ret; + + ret = cb(st->buf, st->size, app_key); + if(ret == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + } else { + assert(st->buf || st->size == 0); + } + + erval.encoded += st->size; + + return erval; +} + +int +OBJECT_IDENTIFIER_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const OBJECT_IDENTIFIER_t *st = sptr; + + if(st && st->buf) { + if(st->size < 1) { + _ASN_ERRLOG("%s: at least one numerical value expected", + td->name); + return -1; + } + } else { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + return 0; +} + +int +OBJECT_IDENTIFIER_get_arc_l(uint8_t *arcbuf, int arclen, int add, unsigned long *rvalue) { + unsigned long accum; + uint8_t *arcend = arcbuf + arclen; + + if(arclen * 7 > 8 * sizeof(accum)) { + if(arclen * 7 <= 8 * (sizeof(accum) + 1)) { + if((*arcbuf & ~0x8f)) { + errno = ERANGE; /* Overflow */ + return -1; + } + } else { + errno = ERANGE; /* Overflow */ + return -1; + } + } + + /* Gather all bits into the accumulator */ + for(accum = 0; arcbuf < arcend; arcbuf++) + accum = (accum << 7) | (*arcbuf & ~0x80); + + accum += add; /* Actually, a negative value */ + assert(accum >= 0); + + *rvalue = accum; + + return 0; +} + +int +OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add, + asn_app_consume_bytes_f *cb, void *app_key) { + char scratch[64]; /* Conservative estimate */ + unsigned long accum; /* Bits accumulator */ + char *p; /* Position in the scratch buffer */ + + if(OBJECT_IDENTIFIER_get_arc_l(arcbuf, arclen, add, &accum)) + return -1; + + /* Fill the scratch buffer in reverse. */ + p = scratch + sizeof(scratch); + for(; accum; accum /= 10) + *(--p) = (accum % 10) + 0x30; + + return cb(p, sizeof(scratch) - (p - scratch), app_key); +} + +int +OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + const OBJECT_IDENTIFIER_t *st = sptr; + int startn; + int add = 0; + int i; + + if(!st || !st->buf) + return cb("", 8, app_key); + + /* Dump preamble */ + if(cb("{ ", 2, app_key)) + return -1; + + for(i = 0, startn = 0; i < st->size; i++) { + uint8_t b = st->buf[i]; + if((b & 0x80)) /* Continuation expected */ + continue; + + if(startn == 0) { + /* + * First two arcs are encoded through the backdoor. + */ + if(i) { + add = -80; + if(cb("2", 1, app_key)) return -1; + } else if(b <= 39) { + add = 0; + if(cb("0", 1, app_key)) return -1; + } else if(b < 79) { + add = -40; + if(cb("1", 1, app_key)) return -1; + } else { + add = -80; + if(cb("2", 1, app_key)) return -1; + } + } + + if(cb(" ", 1, app_key)) /* Separate arcs */ + return -1; + + if(OBJECT_IDENTIFIER_print_arc(&st->buf[startn], + i - startn + 1, add, + cb, app_key)) + return -1; + startn = i + 1; + add = 0; + } + + return cb(" }", 2, app_key); +} + +int +OBJECT_IDENTIFIER_get_arcs_l(OBJECT_IDENTIFIER_t *oid, + unsigned long *arcs, int arcs_slots) { + unsigned long arc_value; + int cur_arc = 0; + int startn = 0; + int add = 0; + int i; + + if(!oid || !oid->buf) { + errno = EINVAL; + return -1; + } + + for(i = 0; i < oid->size; i++) { + uint8_t b = oid->buf[i]; + if((b & 0x80)) /* Continuation expected */ + continue; + + if(startn == 0) { + /* + * First two arcs are encoded through the backdoor. + */ + if(i) { + add = -80; + if(cur_arc < arcs_slots) arcs[cur_arc] = 2; + cur_arc++; + } else if(b <= 39) { + add = 0; + if(cur_arc < arcs_slots) arcs[cur_arc] = 0; + cur_arc++; + } else if(b < 79) { + add = -40; + if(cur_arc < arcs_slots) arcs[cur_arc] = 1; + cur_arc++; + } else { + add = -80; + if(cur_arc < arcs_slots) arcs[cur_arc] = 2; + cur_arc++; + } + } + + /* Do not fill */ + if(cur_arc >= arcs_slots) { + startn = i + 1; + continue; + } + + if(OBJECT_IDENTIFIER_get_arc_l(&oid->buf[startn], + i - startn + 1, + add, &arc_value)) + return -1; + arcs[cur_arc++] = arc_value; + startn = i + 1; + add = 0; + } + + return cur_arc; +} + +int +OBJECT_IDENTIFIER_set_arcs_l(OBJECT_IDENTIFIER_t *oid, unsigned long *arcs, int arcs_slots) { + uint8_t *buf; + uint8_t *bp; + unsigned long long first_value; + int size; + int i; + + if(oid == NULL || arcs == NULL || arcs_slots < 2) { + errno = EINVAL; + return -1; + } + + if(arcs[0] <= 1) { + if(arcs[1] >= 39) { + /* 8.19.4: At most 39 subsequent values (including 0) */ + errno = ERANGE; + return -1; + } + } else if(arcs[0] > 2) { + /* 8.19.4: Only three values are allocated from the root node */ + errno = ERANGE; + return -1; + } + + first_value = arcs[0] * 40 + arcs[1]; + + /* + * Roughly estimate the maximum size necessary to encode these arcs. + */ + size = ((sizeof(arcs[0]) + 1) * 8 / 7) * arcs_slots; + bp = buf = MALLOC(size + 1); + if(!buf) { + /* ENOMEM */ + return -1; + } + + /* + * Encode the arcs and refine the encoding size. + */ + size = 0; + + { + uint8_t tbuf[sizeof(first_value) * 2]; + uint8_t *tp = tbuf; + int arc_len = 0; + int add = 0; + + for(; first_value; first_value >>= 7) { + unsigned int b7 = first_value & 0x7f; + *tp++ = 0x80 | b7; + add++; + if(b7) { arc_len += add; add = 0; } + } + + if(arc_len) { + tp = &tbuf[arc_len - 1]; + /* The last octet does not have bit 8 set. */ + *tbuf &= 0x7f; + for(; tp >= tbuf; tp--) + *bp++ = *tp; + size += arc_len; + } else { + *bp++ = 0; + size++; + } + } + + for(i = 2; i < arcs_slots; i++) { + unsigned long value = arcs[i]; + uint8_t tbuf[sizeof(value) * 2]; /* Conservatively sized */ + uint8_t *tp = tbuf; + int arc_len = 0; + int add = 0; + + for(; value; value >>= 7) { + unsigned int b7 = value & 0x7F; + *tp++ = 0x80 | b7; + add++; + if(b7) { arc_len += add; add = 0; } + } + + if(arc_len) { + tp = &tbuf[arc_len - 1]; + /* The last octet does not have bit 8 set. */ + *tbuf &= 0x7f; + for(; tp >= tbuf; tp--) + *bp++ = *tp; + size += arc_len; + } else { + *bp++ = 0; + size++; + } + } + + /* + * Replace buffer. + */ + oid->size = size; + bp = oid->buf; + oid->buf = buf; + if(bp) FREEMEM(bp); + + return 0; +} diff --git a/skeletons/OBJECT_IDENTIFIER.h b/skeletons/OBJECT_IDENTIFIER.h new file mode 100644 index 00000000..3e71f316 --- /dev/null +++ b/skeletons/OBJECT_IDENTIFIER.h @@ -0,0 +1,95 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _OBJECT_IDENTIFIER_H_ +#define _OBJECT_IDENTIFIER_H_ + +#include +#include + +typedef INTEGER_t OBJECT_IDENTIFIER_t; /* Implemented in terms of INTEGER */ + +extern asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER; + +der_type_encoder_f OBJECT_IDENTIFIER_encode_der; +asn_constr_check_f OBJECT_IDENTIFIER_constraint; +asn_struct_print_f OBJECT_IDENTIFIER_print; + +/********************************** + * Some handy conversion routines * + **********************************/ + +/* + * Print the specified OBJECT IDENTIFIER arc. + */ +int OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, + int add, /* Arbitrary offset, required to process the first two arcs */ + asn_app_consume_bytes_f *cb, void *app_key); + +/* + * This function fills an (_arcs) array with OBJECT IDENTIFIER arcs + * up to specified (_arcs_slots) elements. + * The function always returns the real number of arcs, even if there is no + * sufficient (_arcs_slots) provided. + * + * EXAMPLE: + * void print_arcs(OBJECT_IDENTIFIER_t *oid) { + * unsigned long fixed_arcs[10]; // Try with fixed space first + * unsigned long *arcs = fixed_arcs; + * int arcs_slots = sizeof(fixed_arcs)/sizeof(fixed_arcs[0]); // 10 + * int count; // Real number of arcs. + * int i; + * + * count = OBJECT_IDENTIFIER_get_arcs_l(oid, arcs, arcs_slots); + * // If necessary, reallocate arcs array and try again. + * if(count > arcs_slots) { + * arcs_slots = count; + * arcs = malloc(arcs_slots * sizeof(arcs[0])); + * if(!arcs) return; + * count = OBJECT_IDENTIFIER_get_arcs_l(oid, + * arcs, arcs_slots); + * assert(count == arcs_slots); + * } + * + * // Print the contents of the arcs array. + * for(i = 0; i < count; i++) + * printf("%d\n", arcs[i]); + * + * // Avoid memory leak. + * if(arcs != fixed_arcs) free(arcs); + * } + * + * RETURN VALUES: + * -1/EINVAL: Invalid arguments (oid is missing) + * -1/ERANGE: One or more arcs have value out of array cell type range. + * >=0: Number of arcs contained in the OBJECT IDENTIFIER + */ +int OBJECT_IDENTIFIER_get_arcs_l(OBJECT_IDENTIFIER_t *_oid, + unsigned long *_arcs, int _arcs_slots); +/* +int OBJECT_IDENTIFIER_get_arcs_im(OBJECT_IDENTIFIER_t *_oid, + uintmax_t *_arcs, int _arcs_slots); + */ + + +/* + * This functions initializes the OBJECT IDENTIFIER object with + * the given set of arcs. + * The minimum of two arcs must be present; some restrictions apply. + * RETURN VALUES: + * -1/EINVAL: Invalid arguments + * -1/ERANGE: The first two arcs do not conform to ASN.1 restrictions. + * -1/ENOMEM: Memory allocation failed + * 0: The object was initialized with new arcs. + */ +int OBJECT_IDENTIFIER_set_arcs_l(OBJECT_IDENTIFIER_t *_oid, + unsigned long *arcs, int arcs_slots); + +/* + * Internal functions. + */ +int OBJECT_IDENTIFIER_get_arc_l(uint8_t *arcbuf, int arclen, + int add, unsigned long *value); + +#endif /* _OBJECT_IDENTIFIER_H_ */ diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c new file mode 100644 index 00000000..fc5c532c --- /dev/null +++ b/skeletons/OCTET_STRING.c @@ -0,0 +1,588 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +/* + * OCTET STRING basic type description. + */ +static ber_tlv_tag_t asn1_DEF_OCTET_STRING_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = { + "OCTET STRING", + asn_generic_no_constraint, + OCTET_STRING_decode_ber, + OCTET_STRING_encode_der, + OCTET_STRING_print, /* non-ascii stuff, generally */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_OCTET_STRING_tags, + sizeof(asn1_DEF_OCTET_STRING_tags) + / sizeof(asn1_DEF_OCTET_STRING_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine (primitive and constructed) */ +}; + +#define _CH_PHASE(ctx, inc) do { \ + if(ctx->phase == 0) \ + ctx->step = 0; \ + ctx->phase += inc; \ + } while(0) +#define NEXT_PHASE(ctx) _CH_PHASE(ctx, +1) +#define PREV_PHASE(ctx) _CH_PHASE(ctx, -1) + +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + buf_ptr += num; \ + size -= num; \ + consumed_myself += num; \ + } while(0) + +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +#define APPEND(bufptr, bufsize) do { \ + int _ns = ctx->step; /* Allocated */ \ + if(_ns <= (st->size + bufsize)) { \ + void *ptr; \ + do { _ns = _ns ? _ns<<2 : 16; } \ + while(_ns <= (st->size + bufsize)); \ + ptr = REALLOC(st->buf, _ns); \ + if(ptr) { \ + st->buf = ptr; \ + ctx->step = _ns; \ + } else { \ + RETURN(RC_FAIL); \ + } \ + } \ + memcpy(st->buf + st->size, bufptr, bufsize); \ + st->size += bufsize; \ + if(st->size < 0) \ + /* Why even care?.. JIC */ \ + RETURN(RC_FAIL); \ + /* Convenient nul-termination */ \ + st->buf[st->size] = '\0'; \ + } while(0) + +/* + * The main reason why ASN.1 is still alive is that too much time and effort + * is necessary for learning it more or less adequately, thus creating a gut + * necessity to demonstrate that aquired skill everywhere afterwards. + * No, I am not going to explain what the following stuff is. + */ +struct _stack_el { + ber_tlv_len_t left; /* What's left to read */ + int want_nulls; /* Want null "end of content" octets? */ + int bits_chopped; /* Flag in BIT STRING mode */ + struct _stack_el *prev; + struct _stack_el *next; +}; +struct _stack { + struct _stack_el *tail; + struct _stack_el *cur_ptr; +}; + +static struct _stack_el * +_add_stack_el(struct _stack *st) { + struct _stack_el *nel; + + if(st->cur_ptr && st->cur_ptr->next) { + nel = st->cur_ptr->next; + nel->left = 0; + nel->want_nulls = 0; + nel->bits_chopped = 0; + } else { + nel = CALLOC(1, sizeof(struct _stack_el)); + if(nel == NULL) + return NULL; + + if(st->tail) { + st->tail->next = nel; + } + nel->prev = st->tail; + st->tail = nel; + } + + st->cur_ptr = nel; + + return nel; +} + +static struct _stack * +_new_stack() { + struct _stack *st; + st = CALLOC(1, sizeof(struct _stack)); + if(st == NULL) + return NULL; + + st->cur_ptr = _add_stack_el(st); + if(st->cur_ptr == NULL) { + FREEMEM(st); + return NULL; + } + + return st; +} + +/* + * Decode OCTET STRING type. + */ +ber_dec_rval_t +OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td, + void **os_structure, void *buf_ptr, size_t size, int tag_mode) { + OCTET_STRING_t *st = *os_structure; + ber_dec_rval_t rval; + ber_dec_ctx_t *ctx; + ssize_t consumed_myself = 0; + struct _stack *stck; /* A stack structure */ + struct _stack_el *sel; /* Stack element */ + int tlv_constr; + /* + * This is a some sort of a hack. + * The OCTET STRING decoder is being used in BIT STRING mode. + */ + int is_bit_str = td->specifics?1:0; + + ASN_DEBUG("Decoding %s as %s (%ld)", + td->name, + is_bit_str ? "BIT STRING" : "OCTET STRING", + (long)size); + + /* + * Create the string if does not exist. + */ + if(st == NULL) { + st = *os_structure = CALLOC(1, sizeof(*st)); + if(st == NULL) + RETURN(RC_FAIL); + } + + /* Restore parsing context */ + ctx = &st->_ber_dec_ctx; + + switch(ctx->phase) { + case 0: + /* + * Check tags. + */ + rval = ber_check_tags(td, ctx, + buf_ptr, size, tag_mode, + &ctx->left, &tlv_constr); + if(rval.code != RC_OK) { + RETURN(rval.code); + } + + ASN_DEBUG("OS length is %d bytes, form %d", + (int)ctx->left, tlv_constr); + + if(tlv_constr) { + /* + * Complex operation, requires stack of expectations. + */ + ctx->ptr = _new_stack(); + if(ctx->ptr) { + stck = ctx->ptr; + if(ctx->left < 0) { + stck->cur_ptr->want_nulls = -ctx->left; + stck->cur_ptr->left = -1; + } else { + stck->cur_ptr->want_nulls = 0; + stck->cur_ptr->left = ctx->left; + } + ASN_DEBUG("Expectation left=%d wn=%d added", + stck->cur_ptr->left, + stck->cur_ptr->want_nulls); + if(is_bit_str) { + APPEND("\0", 1); + } + } else { + RETURN(RC_FAIL); + } + } else { + /* + * Jump into stackless primitive decoding. + */ + _CH_PHASE(ctx, 3); + ADVANCE(rval.consumed); + goto phase3; + } + + ADVANCE(rval.consumed); + NEXT_PHASE(ctx); + /* Fall through */ + case 1: + phase1: + /* + * Fill the stack with expectations. + */ + stck = ctx->ptr; + sel = stck->cur_ptr; + do { + ber_tlv_tag_t tlv_tag; + ber_tlv_len_t tlv_len; + ssize_t tl, ll; + + tl = ber_fetch_tag(buf_ptr, size, &tlv_tag); + switch(tl) { + case -1: RETURN(RC_FAIL); + case 0: RETURN(RC_WMORE); + } + + tlv_constr = BER_TLV_CONSTRUCTED(buf_ptr); + + ll = ber_fetch_length(tlv_constr, + buf_ptr + tl, size - tl, &tlv_len); + ASN_DEBUG("Got tag=%s, tl=%d, len=%d, ll=%d, {%d, %d}", + ber_tlv_tag_string(tlv_tag), tl, tlv_len, ll, + ((uint8_t *)buf_ptr)[0], + ((uint8_t *)buf_ptr)[1]); + switch(ll) { + case -1: RETURN(RC_FAIL); + case 0: RETURN(RC_WMORE); + } + + if(sel->want_nulls + && ((uint8_t *)buf_ptr)[0] == 0 + && ((uint8_t *)buf_ptr)[1] == 0) + { + sel->want_nulls--; + if(sel->want_nulls == 0) { + /* Move to the next expectation */ + sel = stck->cur_ptr = sel->prev; + if(sel == NULL) { + ADVANCE(2); + break; + } + } + if(sel->want_nulls) { + /* + * Simulate while(TRUE) for this loop. + * This is necessary to fetch the next + * "end of content" expectation. + */ + ADVANCE(2); + tlv_constr = 1; + continue; + } + } else if(tlv_tag != td->tags[td->tags_count-1]) { + char buf[2][32]; + ber_tlv_tag_snprint(tlv_tag, + buf[0], sizeof(buf[0])); + ber_tlv_tag_snprint(td->tags[td->tags_count-1], + buf[1], sizeof(buf[1])); + ASN_DEBUG("Tag does not match expectation: %s != %s", + buf[0], buf[1]); + RETURN(RC_FAIL); + } + + /* + * Append a new expectation. + */ + sel = _add_stack_el(stck); + if(sel) { + sel->want_nulls = (tlv_len==-1); + sel->left = tlv_len; + ASN_DEBUG("Expectation %d %d added", + sel->left, sel->want_nulls); + } else { + RETURN(RC_FAIL); + } + + ADVANCE(tl+ll); + } while(tlv_constr); + if(sel == NULL) { + /* Finished operation, "phase out" */ + _CH_PHASE(ctx, +3); + break; + } + + NEXT_PHASE(ctx); + /* Fall through */ + case 2: + stck = ctx->ptr; + sel = stck->cur_ptr; + ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld", + (long)sel->left, (long)size); + { + ber_tlv_len_t len; + + assert(sel->left >= 0); + + len = (size < sel->left) ? size : sel->left; + if(len > 0) { + if(is_bit_str && sel->bits_chopped == 0) { + /* + * Finalize the previous chunk: + * strip down unused bits. + */ + st->buf[st->size-1] &= 0xff << st->buf[0]; + + APPEND((buf_ptr+1), (len - 1)); + st->buf[0] = *(uint8_t *)buf_ptr; + sel->bits_chopped = 1; + } else { + APPEND(buf_ptr, len); + } + ADVANCE(len); + sel->left -= len; + } + + if(sel->left) { + RETURN(RC_WMORE); + } else { + sel->left = 0; + if(sel->prev) + sel = stck->cur_ptr = sel->prev; + PREV_PHASE(ctx); + goto phase1; + } + } + break; + case 3: + phase3: + /* + * Primitive form, no stack required. + */ + if(size < ctx->left) { + APPEND(buf_ptr, size); + ctx->left -= size; + ADVANCE(size); + RETURN(RC_WMORE); + } else { + APPEND(buf_ptr, ctx->left); + ADVANCE(ctx->left); + ctx->left = 0; + + NEXT_PHASE(ctx); + } + break; + } + + /* + * BIT STRING-specific processing. + */ + if(is_bit_str && st->size >= 2) { + /* Finalize BIT STRING: zero out unused bits. */ + st->buf[st->size-1] &= 0xff << st->buf[0]; + } + + ASN_DEBUG("Took %d bytes to encode %s: [%s]:%d", + consumed_myself, td->name, st->buf, st->size); + + rval.code = RC_OK; + rval.consumed = consumed_myself; + + return rval; +} + +/* + * Encode OCTET STRING type using DER. + */ +der_enc_rval_t +OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + der_enc_rval_t erval; + OCTET_STRING_t *st = ptr; + int add_byte = 0; + + ASN_DEBUG("%s %s as OCTET STRING", + cb?"Estimating":"Encoding", sd->name); + + /* + * Canonicalize BIT STRING. + */ + if(sd->specifics && st->buf) { + switch(st->size) { + case 0: add_byte = 1; break; + case 1: st->buf[0] = 0; break; + default: + /* Finalize BIT STRING: zero out unused bits. */ + st->buf[st->size-1] &= 0xff << st->buf[0]; + } + } + + erval.encoded = der_write_tags(sd, st->size + add_byte, tag_mode, tag, + cb, app_key); + if(erval.encoded == -1) { + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + + if(cb) { + uint8_t zero; + uint8_t *buf; + int size; + ssize_t ret; + + /* BIT STRING-aware handling */ + if(add_byte) { + zero = 0; + buf = &zero; + size = 1; + } else if(st->buf) { + buf = st->buf; + size = st->size; + } else { + assert(st->size == 0); + buf = 0; /* Not used */ + size = 0; + } + + if(size) { + ret = cb(buf, size, app_key); + if(ret == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + } + } + + erval.encoded += st->size + add_byte; + + return erval; +} + +int +OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + static char h2c[16] = "0123456789ABCDEF"; + const OCTET_STRING_t *st = sptr; + char scratch[16 * 3 + 4]; + char *p = scratch; + uint8_t *buf; + uint8_t *end; + size_t i; + int ret; + + if(!st || !st->buf) return cb("", 8, app_key); + + /* + * Dump the contents of the buffer in hexadecimal. + */ + buf = st->buf; + end = buf + st->size; + for(i = 0; buf < end; buf++, i++) { + if(!(i % 16) && (i || st->size > 16)) { + if(cb(scratch, p - scratch, app_key) + || cb("\n", 1, app_key)) + return -1; + for(ret = 0; ret < ilevel; ret++) + cb(" ", 1, app_key); + p = scratch; + } + *p++ = h2c[(*buf >> 4) & 0x0F]; + *p++ = h2c[*buf & 0x0F]; + *p++ = ' '; + } + + return cb(scratch, p - scratch, app_key); +} + +int +OCTET_STRING_print_ascii(asn1_TYPE_descriptor_t *td, const void *sptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + const OCTET_STRING_t *st = sptr; + + if(st && st->buf) { + return cb(st->buf, st->size, app_key); + } else { + return cb("", 8, app_key); + } +} + +void +OCTET_STRING_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) { + OCTET_STRING_t *st = sptr; + struct _stack *stck = st->_ber_dec_ctx.ptr; + + if(!td || !st) + return; + + ASN_DEBUG("Freeing %s as OCTET STRING", td->name); + + if(st->buf) { + FREEMEM(st->buf); + } + + /* + * Remove decode-time stack. + */ + if(stck) { + while(stck->tail) { + struct _stack_el *sel = stck->tail; + stck->tail = sel->prev; + FREEMEM(sel); + } + FREEMEM(stck); + } + + if(!contents_only) { + FREEMEM(st); + } +} + +/* + * Conversion routines. + */ +int +OCTET_STRING_fromBuf(OCTET_STRING_t *st, const char *str, int len) { + void *buf; + + if(st == 0 || (str == 0 && len)) { + errno = EINVAL; + return -1; + } + + /* + * Clear the OCTET STRING. + */ + if(str == NULL) { + if(st->buf) + FREEMEM(st->buf); + st->size = 0; + return 0; + } + + /* Determine the original string size, if not explicitly given */ + if(len < 0) + len = strlen(str); + + /* Allocate and fill the memory */ + buf = MALLOC(len + 1); + if(buf == NULL) { + return -1; + } else { + st->buf = buf; + st->size = len; + } + + memcpy(buf, str, len); + st->buf[st->size] = '\0'; /* Couldn't use memcpy(len+1)! */ + + return 0; +} + +OCTET_STRING_t * +OCTET_STRING_new_fromBuf(const char *str, int len) { + OCTET_STRING_t *st; + + st = CALLOC(1, sizeof(*st)); + if(st && str && OCTET_STRING_fromBuf(st, str, len)) { + free(st); + st = NULL; + } + + return st; +} + diff --git a/skeletons/OCTET_STRING.h b/skeletons/OCTET_STRING.h new file mode 100644 index 00000000..1aed9a35 --- /dev/null +++ b/skeletons/OCTET_STRING.h @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _OCTET_STRING_H_ +#define _OCTET_STRING_H_ + +#include + +typedef struct OCTET_STRING { + uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */ + int size; /* Size of the buffer */ + + ber_dec_ctx_t _ber_dec_ctx; /* Parsing across buffer boundaries */ +} OCTET_STRING_t; + +extern asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING; + +ber_type_decoder_f OCTET_STRING_decode_ber; +der_type_encoder_f OCTET_STRING_encode_der; +asn_struct_print_f OCTET_STRING_print; +asn_struct_print_f OCTET_STRING_print_ascii; +asn_struct_free_f OCTET_STRING_free; + +/*********************************** + * Some handy conversion routines. * + ***********************************/ + +/* + * This function clears the previous value of the OCTET STRING (if any) + * and then allocates a new memory and makes s point to the newly allocated + * memory. If size = -1, the size of the original string will be determined + * using strlen(str). + * If str equals to NULL, the function will silently clear the + * current contents of the OCTET STRING. + * Returns 0 if it was possible to perform operation, -1 otherwise. + */ +int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size); + +/* + * Allocate and fill the new OCTET STRING and return a pointer to the newly + * allocated object. NULL is permitted in str: the function will just allocate + * empty OCTET STRING. + */ +OCTET_STRING_t *OCTET_STRING_new_fromBuf(const char *str, int size); + +/* Handy conversion from the C string into the OCTET STRING. */ +#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1); +#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1); + +#endif /* _OCTET_STRING_H_ */ diff --git a/skeletons/ObjectDescriptor.c b/skeletons/ObjectDescriptor.c new file mode 100644 index 00000000..5a39380c --- /dev/null +++ b/skeletons/ObjectDescriptor.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * ObjectDescriptor basic type description. + */ +static ber_tlv_tag_t asn1_DEF_ObjectDescriptor_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_ObjectDescriptor = { + "ObjectDescriptor", + asn_generic_unknown_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print_ascii, /* Treat as ASCII subset (it's not) */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_ObjectDescriptor_tags, + sizeof(asn1_DEF_ObjectDescriptor_tags) + / sizeof(asn1_DEF_ObjectDescriptor_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/ObjectDescriptor.h b/skeletons/ObjectDescriptor.h new file mode 100644 index 00000000..67addf24 --- /dev/null +++ b/skeletons/ObjectDescriptor.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _ObjectDescriptor_H_ +#define _ObjectDescriptor_H_ + +#include +#include + +typedef GraphicString_t ObjectDescriptor_t; /* Implemented in terms of. */ + +extern asn1_TYPE_descriptor_t asn1_DEF_ObjectDescriptor; + +#endif /* _ObjectDescriptor_H_ */ diff --git a/skeletons/PrintableString.c b/skeletons/PrintableString.c new file mode 100644 index 00000000..32ee7da5 --- /dev/null +++ b/skeletons/PrintableString.c @@ -0,0 +1,81 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * PrintableString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_PrintableString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (19 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_PrintableString = { + "PrintableString", + PrintableString_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print_ascii, /* ASCII subset */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_PrintableString_tags, + sizeof(asn1_DEF_PrintableString_tags) + / sizeof(asn1_DEF_PrintableString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + + +/* + * ASN.1:1984 (X.409) + */ +static int _PrintableString_alphabet[256] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, /* ' */ +0x41, 0x42, 0x00, 0x43, 0x44, 0x45, 0x46, 0x47, /* ( ) + , - . / */ +0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, /* 0 1 2 3 4 5 6 7 */ +0x3d, 0x3e, 0x48, 0x00, 0x00, 0x49, 0x00, 0x4a, /* 8 9 : = ? */ +0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* A B C D E F G */ +0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* H I J K L M N O */ +0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* P Q R S T U V W */ +0x18, 0x19, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, /* X Y Z */ +0x00, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, /* a b c d e f g */ +0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, /* h i j k l m n o */ +0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, /* p q r s t u v w */ +0x32, 0x33, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, /* x y z */ +}; + +int +PrintableString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const PrintableString_t *st = sptr; + + if(st && st->buf) { + uint8_t *buf = st->buf; + uint8_t *end = buf + st->size; + + /* + * Check the alphabet of the PrintableString. + * ASN.1:1984 (X.409) + */ + for(; buf < end; buf++) { + if(!_PrintableString_alphabet[*buf]) { + _ASN_ERRLOG("%s: value byte %d " + "not in PrintableString alphabet (%d)", + td->name, + (buf - st->buf) + 1, + *buf + ); + return -1; + } + } + } else { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + return 0; +} diff --git a/skeletons/PrintableString.h b/skeletons/PrintableString.h new file mode 100644 index 00000000..b44a61ec --- /dev/null +++ b/skeletons/PrintableString.h @@ -0,0 +1,17 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _PrintableString_H_ +#define _PrintableString_H_ + +#include +#include + +typedef OCTET_STRING_t PrintableString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_PrintableString; + +asn_constr_check_f PrintableString_constraint; + +#endif /* _PrintableString_H_ */ diff --git a/skeletons/README b/skeletons/README new file mode 100644 index 00000000..29dbae63 --- /dev/null +++ b/skeletons/README @@ -0,0 +1,6 @@ + +Here are the canonical encoder/decoder algorithms that work with the tables +constructed by the compiler. The compiler itself does not generate code, +it just creates those tables and then copies (links) over these files +which contain generic algorithms. + diff --git a/skeletons/RELATIVE-OID.c b/skeletons/RELATIVE-OID.c new file mode 100644 index 00000000..f6572105 --- /dev/null +++ b/skeletons/RELATIVE-OID.c @@ -0,0 +1,155 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +/* + * RELATIVE-OID basic type description. + */ +static ber_tlv_tag_t asn1_DEF_RELATIVE_OID_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (13 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = { + "RELATIVE-OID", + asn_generic_no_constraint, + INTEGER_decode_ber, /* Implemented in terms of INTEGER type */ + OBJECT_IDENTIFIER_encode_der, + RELATIVE_OID_print, + INTEGER_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_RELATIVE_OID_tags, + sizeof(asn1_DEF_RELATIVE_OID_tags) + / sizeof(asn1_DEF_RELATIVE_OID_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + 0 /* Always in primitive form */ +}; + +int +RELATIVE_OID_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const RELATIVE_OID_t *st = sptr; + int startn; + int i; + + if(!st || !st->buf) + return cb("", 8, app_key); + + /* Dump preamble */ + if(cb("{ ", 2, app_key)) + return -1; + + for(i = 0, startn = 0; i < st->size; i++) { + uint8_t b = st->buf[i]; + if((b & 0x80)) /* Continuation expected */ + continue; + if(startn && cb(" ", 1, app_key)) /* Separate arcs */ + return -1; + if(OBJECT_IDENTIFIER_print_arc(&st->buf[startn], + i - startn + 1, 0, cb, app_key)) + return -1; + startn = i + 1; + } + + return cb(" }", 2, app_key); +} + + +int +RELATIVE_OID_get_arcs_l(RELATIVE_OID_t *roid, + unsigned long *arcs, int arcs_slots) { + unsigned long arc_value; + int cur_arc = 0; + int startn = 0; + int i; + + if(!roid || !roid->buf) { + errno = EINVAL; + return -1; + } + + for(i = 0; i < roid->size; i++) { + uint8_t b = roid->buf[i]; + if((b & 0x80)) /* Continuation expected */ + continue; + + if(cur_arc < arcs_slots) { + if(OBJECT_IDENTIFIER_get_arc_l(&roid->buf[startn], + i - startn + 1, 0, &arc_value)) + return -1; + arcs[cur_arc++] = arc_value; + } + + startn = i + 1; + } + + return cur_arc; +} + +int +RELATIVE_OID_set_arcs_l(RELATIVE_OID_t *roid, unsigned long *arcs, int arcs_slots) { + uint8_t *buf; + uint8_t *bp; + int size; + int i; + + if(roid == NULL || arcs == NULL || arcs_slots < 0) { + errno = EINVAL; + return -1; + } + + /* + * Roughly estimate the maximum size necessary to encode these arcs. + */ + size = ((sizeof(arcs[0]) + 1) * 8 / 7) * arcs_slots; + bp = buf = MALLOC(size + 1); + if(!buf) { + /* ENOMEM */ + return -1; + } + + /* + * Encode the arcs and refine the encoding size. + */ + size = 0; + for(i = 0; i < arcs_slots; i++) { + unsigned long value = arcs[i]; + uint8_t tbuf[sizeof(value) * 2]; /* Conservatively sized */ + uint8_t *tp = tbuf; + int arc_len = 0; + int add; + + for(add = 1; value; value >>= 7, add++) { + unsigned int b7 = value & 0x7F; + *tp++ = 0x80 | b7; + if(b7) { + arc_len += add; + add = 0; + } + } + + if(arc_len) { + tp = &tbuf[arc_len - 1]; + /* The last octet does not have bit 8 set. */ + *tbuf &= 0x7f; + for(; tp >= tbuf; tp--) + *bp++ = *tp; + size += arc_len; + } else { + *bp++ = 0; + size++; + } + } + + /* + * Replace buffer. + */ + roid->size = size; + bp = roid->buf; + roid->buf = buf; + if(bp) FREEMEM(bp); + + return 0; +} diff --git a/skeletons/RELATIVE-OID.h b/skeletons/RELATIVE-OID.h new file mode 100644 index 00000000..c0bc680e --- /dev/null +++ b/skeletons/RELATIVE-OID.h @@ -0,0 +1,30 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _RELATIVE_OID_H_ +#define _RELATIVE_OID_H_ + +#include +#include + +/* Implemented in terms of OBJECT IDENTIFIER */ +typedef OBJECT_IDENTIFIER_t RELATIVE_OID_t; + +extern asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID; + +asn_struct_print_f RELATIVE_OID_print; + +/********************************** + * Some handy conversion routines * + **********************************/ + +/* See OBJECT_IDENTIFIER_set_arcs_l() function in OBJECT_IDENTIFIER.h */ +int RELATIVE_OID_set_arcs_l(RELATIVE_OID_t *_roid, + unsigned long *arcs, int arcs_slots); + +/* See OBJECT_IDENTIFIER_get_arcs_l() function in OBJECT_IDENTIFIER.h */ +int RELATIVE_OID_get_arcs_l(RELATIVE_OID_t *_roid, + unsigned long *arcs, int arcs_slots); + +#endif /* _RELATIVE_OID_H_ */ diff --git a/skeletons/T61String.c b/skeletons/T61String.c new file mode 100644 index 00000000..e6dceb78 --- /dev/null +++ b/skeletons/T61String.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * T61String basic type description. + */ +static ber_tlv_tag_t asn1_DEF_T61String_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (20 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_T61String = { + "T61String", + asn_generic_unknown_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print, /* non-ascii string */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_T61String_tags, + sizeof(asn1_DEF_T61String_tags) + / sizeof(asn1_DEF_T61String_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/T61String.h b/skeletons/T61String.h new file mode 100644 index 00000000..1485577e --- /dev/null +++ b/skeletons/T61String.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _T61String_H_ +#define _T61String_H_ + +#include +#include + +typedef OCTET_STRING_t T61String_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_T61String; + +#endif /* _T61String_H_ */ diff --git a/skeletons/TeletexString.c b/skeletons/TeletexString.c new file mode 100644 index 00000000..1076c8af --- /dev/null +++ b/skeletons/TeletexString.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * TeletexString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_TeletexString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (20 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_TeletexString = { + "TeletexString", + asn_generic_unknown_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print, /* non-ascii string */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_TeletexString_tags, + sizeof(asn1_DEF_TeletexString_tags) + / sizeof(asn1_DEF_TeletexString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/TeletexString.h b/skeletons/TeletexString.h new file mode 100644 index 00000000..6f513581 --- /dev/null +++ b/skeletons/TeletexString.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _TeletexString_H_ +#define _TeletexString_H_ + +#include +#include + +typedef OCTET_STRING_t TeletexString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_TeletexString; + +#endif /* _TeletexString_H_ */ diff --git a/skeletons/UTCTime.c b/skeletons/UTCTime.c new file mode 100644 index 00000000..e2f758ec --- /dev/null +++ b/skeletons/UTCTime.c @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include +#include +#include + +#ifndef __NO_ASN_TABLE__ + +/* + * UTCTime basic type description. + */ +static ber_tlv_tag_t asn1_DEF_UTCTime_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (23 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_UTCTime = { + "UTCTime", + UTCTime_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + UTCTime_print, + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_UTCTime_tags, + sizeof(asn1_DEF_UTCTime_tags) + / sizeof(asn1_DEF_UTCTime_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + +#endif /* __NO_ASN_TABLE__ */ + +/* + * Check that the time looks like the time. + */ +int +UTCTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const UTCTime_t *st = sptr; + time_t tloc; + + errno = EPERM; /* Just an unlikely error code */ + tloc = asn_UT2time(st, 0); + if(tloc == -1 && errno != EPERM) { + _ASN_ERRLOG("%s: Invalid time format: %s", + td->name, strerror(errno)); + return -1; + } + + return 0; +} + +int +UTCTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const UTCTime_t *st = sptr; + + if(st && st->buf) { + char buf[32]; + struct tm tm; + int ret; + + errno = EPERM; + if(asn_UT2time(st, &tm) == -1 && errno != EPERM) + return cb("", 11, app_key); + + ret = snprintf(buf, sizeof(buf), + "%04d-%02d-%02d %02d:%02d%02d", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); + assert(ret > 0 && ret < sizeof(buf)); + return cb(buf, ret, app_key); + } else { + return cb("", 8, app_key); + } +} + +time_t +asn_UT2time(const UTCTime_t *st, struct tm *_tm) { + char buf[17+2]; /* "AAMMJJhhmmss+hhmm" = 17, + 2 = 19 */ + GeneralizedTime_t gt; + + if(!st || !st->buf || st->size < 11 || st->size > (sizeof(buf) - 2)) { + errno = EINVAL; + return -1; + } + + gt.buf = buf; + gt.size = st->size + 2; + memcpy(gt.buf + 2, st->buf, st->size); + if(st->buf[0] > 0x35) { + /* 19xx */ + gt.buf[0] = 0x31; + gt.buf[1] = 0x39; + } else { + /* 20xx */ + gt.buf[0] = 0x32; + gt.buf[1] = 0x30; + } + + return asn_GT2time(>, _tm); +} diff --git a/skeletons/UTCTime.h b/skeletons/UTCTime.h new file mode 100644 index 00000000..1e52388e --- /dev/null +++ b/skeletons/UTCTime.h @@ -0,0 +1,26 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _UTCTime_H_ +#define _UTCTime_H_ + +#include +#include + +typedef OCTET_STRING_t UTCTime_t; /* Implemented using OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_UTCTime; + +asn_constr_check_f UTCTime_constraint; +asn_struct_print_f UTCTime_print; + +/*********************** + * Some handy helpers. * + ***********************/ + +/* On error returns -1 and errno set to EINVAL */ +struct tm; /* */ +time_t asn_UT2time(const UTCTime_t *, struct tm *_optional_tm4fill); + +#endif /* _UTCTime_H_ */ diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c new file mode 100644 index 00000000..fdd13d87 --- /dev/null +++ b/skeletons/UTF8String.c @@ -0,0 +1,112 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * UTF8String basic type description. + */ +static ber_tlv_tag_t asn1_DEF_UTF8String_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_UTF8String = { + "UTF8String", + UTF8String_constraint, /* Check for invalid codes, etc. */ + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + UTF8String_print, + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_UTF8String_tags, + sizeof(asn1_DEF_UTF8String_tags) + / sizeof(asn1_DEF_UTF8String_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + +static int _UTF8String_h1[16] = { + 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0 ... 0x7 */ + 0, 0, 0, 0, 2, 2, 3, -1 +}; +static int _UTF8String_h2[16] = { + 4, 4, 4, 4, 4, 4, 4, 4, /* 0xF0 .. 0xF7 */ + 5, 5, 5, 5, 6, 6, -1, -1 +}; + +int +UTF8String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + ssize_t len; + len = UTF8String_length(sptr, td->name, app_errlog, app_key); + if(len > 0) len = 0; + return len; +} + +ssize_t +UTF8String_length(const UTF8String_t *st, const char *opt_type_name, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + + if(st && st->buf) { + size_t length = 0; + uint8_t *buf = st->buf; + uint8_t *end = buf + st->size; + int want; /* Number of bytes wanted */ + + for(want = 0; buf < end; buf++) { + uint8_t ch = *buf; + int w = _UTF8String_h1[ch >> 4]; + if(want) { /* Continuation expected */ + if(w) { + _ASN_ERRLOG("%s: UTF-8 expectation " + "failed at byte %d", + opt_type_name, + (buf - st->buf) + 1); + return -1; + } + want--; + } else { + switch(w) { + case -1: /* Long UTF-8 */ + w = _UTF8String_h2[ch & 0xF0]; + if(w != -1) + break; + /* Fall through */ + case 0: + _ASN_ERRLOG( + "%s: UTF-8 expectation" + "failed at byte %d", + opt_type_name, + (buf - st->buf) + 1); + return -1; + } + want = w - 1; /* Expect this much */ + } + if(!want) length++; + } + + /* If still want something, then something is wrong */ + if(want) { + _ASN_ERRLOG("%s: truncated UTF-8 sequence", + opt_type_name); + return -1; + } + + return length; + } else { + _ASN_ERRLOG("%s: value not given", opt_type_name); + return -1; + } +} + +int +UTF8String_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const UTF8String_t *st = sptr; + + if(st && st->buf) { + return cb(st->buf, st->size, app_key); + } else { + return cb("", 8, app_key); + } +} diff --git a/skeletons/UTF8String.h b/skeletons/UTF8String.h new file mode 100644 index 00000000..f18bf703 --- /dev/null +++ b/skeletons/UTF8String.h @@ -0,0 +1,22 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _UTF8String_H_ +#define _UTF8String_H_ + +#include +#include + +typedef OCTET_STRING_t UTF8String_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_UTF8String; + +asn_constr_check_f UTF8String_constraint; +asn_struct_print_f UTF8String_print; + +/* Returns length of UTF-8 string in characters or -1 if error. */ +ssize_t UTF8String_length(const UTF8String_t *st, const char *opt_type_name, + asn_app_consume_bytes_f *app_errlog, void *app_key); + +#endif /* _UTF8String_H_ */ diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c new file mode 100644 index 00000000..7d75e079 --- /dev/null +++ b/skeletons/UniversalString.c @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * UniversalString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_UniversalString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_UniversalString = { + "UniversalString", + asn_generic_no_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + UniversalString_print, /* Convert into UTF8 and print */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_UniversalString_tags, + sizeof(asn1_DEF_UniversalString_tags) + / sizeof(asn1_DEF_UniversalString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + + +int +UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + const UniversalString_t *st = sptr; + uint32_t *wchar; + uint32_t *wend; + char scratch[128]; /* Scratchpad buffer */ + char *p; + + if(!st || !st->buf) return cb("", 8, app_key); + + wchar = (uint32_t *)st->buf; + wend = (uint32_t *)(st->buf + st->size); + for(p = scratch; wchar < wend; wchar++) { + uint32_t wc = (((uint8_t *)wchar)[0] << 24) + | (((uint8_t *)wchar)[1] << 16) + | (((uint8_t *)wchar)[2] << 8) + | ((uint8_t *)wchar)[3]; /* 4 bytes */ + if(sizeof(scratch) - (p - scratch) < 6) { + if(cb(scratch, p - scratch, app_key)) + return -1; + p = scratch; + } + if(wc < 0x80) { + *p++ = (char)wc; + } else if(wc < 0x800) { + *p++ = 0xc0 | ((wc >> 6)); + *p++ = 0x80 | ((wc & 0x3f)); + } else if(wc < 0x10000) { + *p++ = 0xe0 | ((wc >> 12)); + *p++ = 0x80 | ((wc >> 6) & 0x3f); + *p++ = 0x80 | ((wc & 0x3f)); + } else if(wc < 0x200000) { + *p++ = 0xf0 | ((wc >> 18)); + *p++ = 0x80 | ((wc >> 12) & 0x3f); + *p++ = 0x80 | ((wc >> 6) & 0x3f); + *p++ = 0x80 | ((wc & 0x3f)); + } else if(wc < 0x4000000) { + *p++ = 0xf8 | ((wc >> 24)); + *p++ = 0x80 | ((wc >> 18) & 0x3f); + *p++ = 0x80 | ((wc >> 12) & 0x3f); + *p++ = 0x80 | ((wc >> 6) & 0x3f); + *p++ = 0x80 | ((wc & 0x3f)); + } else { + *p++ = 0xfc | ((wc >> 30) & 0x1); + *p++ = 0x80 | ((wc >> 24) & 0x3f); + *p++ = 0x80 | ((wc >> 18) & 0x3f); + *p++ = 0x80 | ((wc >> 12) & 0x3f); + *p++ = 0x80 | ((wc >> 6) & 0x3f); + *p++ = 0x80 | ((wc & 0x3f)); + } + } + + return cb(scratch, p - scratch, app_key); +} diff --git a/skeletons/UniversalString.h b/skeletons/UniversalString.h new file mode 100644 index 00000000..cafbc80c --- /dev/null +++ b/skeletons/UniversalString.h @@ -0,0 +1,17 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _UniversalString_H_ +#define _UniversalString_H_ + +#include +#include + +typedef OCTET_STRING_t UniversalString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_UniversalString; + +asn_struct_print_f UniversalString_print; /* Human-readable output */ + +#endif /* _UniversalString_H_ */ diff --git a/skeletons/VideotexString.c b/skeletons/VideotexString.c new file mode 100644 index 00000000..ab92ebd9 --- /dev/null +++ b/skeletons/VideotexString.c @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * VideotexString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_VideotexString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (21 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_VideotexString = { + "VideotexString", + asn_generic_unknown_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print, /* non-ascii string */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_VideotexString_tags, + sizeof(asn1_DEF_VideotexString_tags) + / sizeof(asn1_DEF_VideotexString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + diff --git a/skeletons/VideotexString.h b/skeletons/VideotexString.h new file mode 100644 index 00000000..4dd7c8e7 --- /dev/null +++ b/skeletons/VideotexString.h @@ -0,0 +1,15 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _VideotexString_H_ +#define _VideotexString_H_ + +#include +#include + +typedef OCTET_STRING_t VideotexString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_VideotexString; + +#endif /* _VideotexString_H_ */ diff --git a/skeletons/VisibleString.c b/skeletons/VisibleString.c new file mode 100644 index 00000000..af9525f8 --- /dev/null +++ b/skeletons/VisibleString.c @@ -0,0 +1,81 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * VisibleString basic type description. + */ +static ber_tlv_tag_t asn1_DEF_VisibleString_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_VisibleString = { + "VisibleString", + VisibleString_constraint, + OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ + OCTET_STRING_print_ascii, /* ASCII subset */ + OCTET_STRING_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_VisibleString_tags, + sizeof(asn1_DEF_VisibleString_tags) + / sizeof(asn1_DEF_VisibleString_tags[0]), + 1, /* Single UNIVERSAL tag may be implicitly overriden */ + -1, /* Both ways are fine */ +}; + + +/* + * ISO646, ISOReg#6 + */ +static int _VisibleString_alphabet[256] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* ! " # $ % & ' */ +0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, /* ( ) * + , - . / */ +0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, /* 0 1 2 3 4 5 6 7 */ +0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, /* 8 9 : ; < = > ? */ +0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, /* @ A B C D E F G */ +0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, /* H I J K L M N O */ +0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, /* P Q R S T U V W */ +0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, /* X Y Z [ \ ] ^ _ */ +0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ` a b c d e f g */ +0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* h i j k l m n o */ +0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* p q r s t u v w */ +0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x00, /* x y z { | } ~ */ +}; + +int +VisibleString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + const VisibleString_t *st = sptr; + + if(st && st->buf) { + uint8_t *buf = st->buf; + uint8_t *end = buf + st->size; + + /* + * Check the alphabet of the VisibleString. + * ISO646, ISOReg#6 + */ + for(; buf < end; buf++) { + if(!_VisibleString_alphabet[*buf]) { + _ASN_ERRLOG("%s: value byte %d " + "not in VisibleString alphabet (%d)", + td->name, + (buf - st->buf) + 1, + *buf + ); + return -1; + } + } + } else { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + return 0; +} diff --git a/skeletons/VisibleString.h b/skeletons/VisibleString.h new file mode 100644 index 00000000..3c1df420 --- /dev/null +++ b/skeletons/VisibleString.h @@ -0,0 +1,17 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _VisibleString_H_ +#define _VisibleString_H_ + +#include +#include + +typedef OCTET_STRING_t VisibleString_t; /* Implemented in terms of OCTET STRING */ + +extern asn1_TYPE_descriptor_t asn1_DEF_VisibleString; + +asn_constr_check_f VisibleString_constraint; + +#endif /* _VisibleString_H_ */ diff --git a/skeletons/asn_SEQUENCE_OF.c b/skeletons/asn_SEQUENCE_OF.c new file mode 100644 index 00000000..71f6f0cd --- /dev/null +++ b/skeletons/asn_SEQUENCE_OF.c @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include /* for MALLOC/REALLOC/FREEMEM */ +#include + +typedef A_SEQUENCE_OF(void) asn_sequence; + +void +asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) { + asn_sequence *as = asn_sequence_of_x; + + if(as) { + void *ptr; + int n; + + if(number < 0 || number >= as->count) + return; /* Nothing to delete */ + + if(_do_free && as->free) { + ptr = as->array[number]; + } else { + ptr = 0; + } + + /* + * Shift all elements to the left to hide the gap. + */ + --as->count; + for(n = number; n < as->count; n++) + as->array[n] = as->array[n+1]; + + /* + * Invoke the third-party function only when the state + * of the parent structure is consistent. + */ + if(ptr) as->free(ptr); + } +} + diff --git a/skeletons/asn_SEQUENCE_OF.h b/skeletons/asn_SEQUENCE_OF.h new file mode 100644 index 00000000..e9967340 --- /dev/null +++ b/skeletons/asn_SEQUENCE_OF.h @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef ASN_SEQUENCE_OF_H +#define ASN_SEQUENCE_OF_H + +#include + +/* + * SEQUENCE OF is the same as SET OF with a tiny difference: + * the delete operation preserves the initial order of elements + * and thus MAY operate in non-constant time. + */ +#define A_SEQUENCE_OF(type) A_SET_OF(type) + +#define ASN_SEQUENCE_ADD(headptr, ptr) \ + asn_sequence_add((headptr), (ptr)) + +/*********************************************** + * Implementation of the SEQUENCE OF structure. + */ + +#define asn_sequence_add asn_set_add +#define asn_sequence_empty asn_set_empty + +/* + * Delete the element from the set by its number (base 0). + * This is NOT a constant-time operation. + * The order of elements is preserved. + * If _do_free is given AND the (*free) is initialized, the element + * will be freed using the custom (*free) function as well. + */ +void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free); + +#endif /* ASN_SEQUENCE_OF_H */ diff --git a/skeletons/asn_SET_OF.c b/skeletons/asn_SET_OF.c new file mode 100644 index 00000000..dfa99067 --- /dev/null +++ b/skeletons/asn_SET_OF.c @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include /* for MALLOC/REALLOC/FREEMEM */ +#include +#include + +typedef A_SET_OF(void) asn_set; + +/* + * Add another element into the set. + */ +int +asn_set_add(void *asn_set_of_x, void *ptr) { + asn_set *as = asn_set_of_x; + + if(as == 0 || ptr == 0) { + errno = EINVAL; /* Invalid arguments */ + return -1; + } + + /* + * Make sure there's enough space to insert an element. + */ + if(as->count == as->size) { + int _newsize = as->size ? (as->size << 1) : 4; + void *_new_arr; + _new_arr = REALLOC(as->array, _newsize * sizeof(as->array[0])); + if(_new_arr) { + as->array = _new_arr; + as->size = _newsize; + } else { + /* ENOMEM */ + return -1; + } + } + + as->array[as->count++] = ptr; + + return 0; +} + +void +asn_set_del(void *asn_set_of_x, int number, int _do_free) { + asn_set *as = asn_set_of_x; + + if(as) { + void *ptr; + if(number < 0 || number >= as->count) + return; + + if(_do_free && as->free) { + ptr = as->array[number]; + } else { + ptr = 0; + } + + as->array[number] = as->array[--as->count]; + + /* + * Invoke the third-party function only when the state + * of the parent structure is consistent. + */ + if(ptr) as->free(ptr); + } +} + +/* + * Free the contents of the set, do not free the set itself. + */ +void +asn_set_empty(void *asn_set_of_x) { + asn_set *as = asn_set_of_x; + + if(as) { + if(as->array) { + if(as->free) { + while(as->count--) + as->free(as->array[as->count]); + } + free(as->array); + } + as->count = 0; + as->size = 0; + } + +} + diff --git a/skeletons/asn_SET_OF.h b/skeletons/asn_SET_OF.h new file mode 100644 index 00000000..1443a7b8 --- /dev/null +++ b/skeletons/asn_SET_OF.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef ASN_SET_OF_H +#define ASN_SET_OF_H + +#define A_SET_OF(type) \ + struct { \ + type **array; \ + int count; /* Meaningful size */ \ + int size; /* Allocated size */ \ + void (*free)(type *); \ + } + +#define ASN_SET_ADD(headptr, ptr) \ + asn_set_add((headptr), (ptr)) + +/******************************************* + * Implementation of the SET OF structure. + */ + +/* + * Add another structure into the set by its pointer. + * RETURN VALUES: + * 0 for success and -1/errno for failure. + */ +int asn_set_add(void *asn_set_of_x, void *ptr); + +/* + * Delete the element from the set by its number (base 0). + * This is a constant-time operation. The order of elements before the + * deleted ones is guaranteed, the order of elements after the deleted + * one is NOT guaranteed. + * If _do_free is given AND the (*free) is initialized, the element + * will be freed using the custom (*free) function as well. + */ +void asn_set_del(void *asn_set_of_x, int number, int _do_free); + +/* + * Empty the contents of the set. Will free the elements, if (*free) is given. + * Will NOT free the set itself. + */ +void asn_set_empty(void *asn_set_of_x); + +#endif /* ASN_SET_OF_H */ diff --git a/skeletons/asn_types.h b/skeletons/asn_types.h new file mode 100644 index 00000000..6d426673 --- /dev/null +++ b/skeletons/asn_types.h @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * Miscellaneous system-dependent types. + */ +#ifndef _ASN_TYPES_H_ +#define _ASN_TYPES_H_ + +#include /* For fprintf() */ +#include /* For *alloc(3) */ +#include /* For memcpy(3) */ +#include /* For size_t */ +#include /* For va_start */ +#include /* C99 Standard specifies this file, for uintXX_t */ +#include /* for offsetof and ptrdiff_t */ + +#ifndef offsetof +#define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) +#endif /* offsetof */ + +#define CALLOC(nmemb, size) calloc(nmemb, size) +#define MALLOC(size) malloc(size) +#define REALLOC(oldptr, size) realloc(oldptr, size) +#define FREEMEM(ptr) free(ptr) + +#ifndef MIN /* Suitable for comparing primitive types (integers) */ +#if defined(__GNUC__) +#define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \ + ((_a)<(_b)?(_a):(_b)); }) +#else /* !__GNUC__ */ +#define MIN(a,b) ((a)<(b)?(a):(b)) /* Unsafe variant */ +#endif /* __GNUC__ */ +#endif /* MIN */ + +/* + * A macro for debugging the ASN.1 internals. + * You may enable or override it. + */ +#ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */ +#if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */ +#define ASN_DEBUG(fmt, args...) do { \ + fprintf(stderr, fmt, ##args); \ + fprintf(stderr, "\n"); \ + } while(0) +#else /* EMIT_ASN_DEBUG */ +#define ASN_DEBUG(fmt, args...) ((void)0) /* Emit a no-op operator */ +#endif /* EMIT_ASN_DEBUG */ +#endif /* ASN_DEBUG */ + + +/* + * Generic type of an application-defined callback to return various + * types of data to the application. + * EXPECTED RETURN VALUES: + * -1: Failed to consume bytes. Abort the mission. + * Other return values indicate success, and ignored. + */ +typedef int (asn_app_consume_bytes_f)(const void *buffer, size_t size, + void *application_specific_key); + +#endif /* _ASN_TYPES_H_ */ diff --git a/skeletons/ber_decoder.c b/skeletons/ber_decoder.c new file mode 100644 index 00000000..135e7910 --- /dev/null +++ b/skeletons/ber_decoder.c @@ -0,0 +1,230 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include + +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr += num; \ + size -= num; \ + consumed_myself += num; \ + } while(0) +#define RETURN(_code) do { \ + ber_dec_rval_t rval; \ + rval.code = _code; \ + rval.consumed = consumed_myself; \ + return rval; \ + } while(0) + +/* + * The BER decoder of any type. + */ +ber_dec_rval_t +ber_decode(asn1_TYPE_descriptor_t *type_descriptor, + void **struct_ptr, void *ptr, size_t size) { + + /* + * Invoke type-specific decoder. + */ + return type_descriptor->ber_decoder(type_descriptor, + struct_ptr, /* Pointer to the destination structure */ + ptr, size, /* Buffer and its size */ + 0 /* Default tag mode is 0 */ + ); +} + +/* + * Check the set of >> tags matches the definition. + */ +ber_dec_rval_t +ber_check_tags(asn1_TYPE_descriptor_t *head, ber_dec_ctx_t *ctx, + void *ptr, size_t size, int tag_mode, + ber_tlv_len_t *last_length, int *opt_tlv_form) { + ssize_t consumed_myself = 0; + ssize_t tag_len; + ssize_t len_len; + ber_tlv_tag_t tlv_tag; + ber_tlv_len_t tlv_len; + ber_tlv_len_t limit_len = -1; + int expect_00_terminators = 0; + int tlv_constr = -1; /* If CHOICE, opt_tlv_form is not given */ + int tagno; + + /* + * So what does all this tags_impl_skip stuff mean? + * Imagine two types, + * A ::= [5] IMPLICIT T + * B ::= [2] EXPLICIT T + * Where T is defined as + * T ::= [4] IMPLICIT SEQUENCE { ... } + * + * Let's say, we are starting to decode type A, given the + * following TLV stream: <5> <0>. What does this mean? + * It means that the type A contains type T which is, + * in turn, empty. + * Remember though, that we are still in A. We cannot + * just pass control to the type T decoder. Why? Because + * the type T decoder expects <4> <0>, not <5> <0>. + * So, we must make sure we are going to receive <5> while + * still in A, then pass control to the T decoder, indicating + * that the tag <4> was implicitly skipped. The decoder of T + * hence will be prepared to treat <4> as valid tag, and decode + * it appropriately. + */ + + /* + * We have a list of tags that must occur in the stream: + * {A,B,C} + * However, it may be indicated that the type is + * implicitly tagged in the caller, so it really boils down to the + * {I,B,C} or even {I,C} + * This is because the implicit tag at above structure may replace + * zero or more (or every) tags which follow it. We don't care + * about the precise number, as it is already computed for us + * by the ASN.1 compiler and placed into head->tags_impl_skip. + * So let's suppose the only tag left after implicit tagging is {I}. + * Yet, the table we have is {A,B,C} and head->tags_impl_skip=3. + * We need to check at least one tag in the loop, so the loop range + * is modified so it will be invoked at least one time. + */ + tagno = ctx->step /* Continuing where left previously */ + + (tag_mode==-1?(head->tags_impl_skip-1):0) + + (tag_mode==1?-1:0) + ; + //assert(head->tags_count >= 1); ?May not be the case for CHOICE! + assert(tagno < head->tags_count); /* At least one loop */ + for((void)tagno; tagno < head->tags_count; tagno++, ctx->step++) { + + /* + * Fetch and process T from TLV. + */ + tag_len = ber_fetch_tag(ptr, size, &tlv_tag); + ASN_DEBUG("Fetching tag from {%p,%ld} %02X: " + "len %ld, tag %s", + ptr, (long)size, + *(uint8_t *)ptr, (long)tag_len, + ber_tlv_tag_string(tlv_tag)); + switch(tag_len) { + case -1: RETURN(RC_FAIL); + case 0: RETURN(RC_WMORE); + } + + tlv_constr = BER_TLV_CONSTRUCTED(ptr); + + /* + * If {I}, don't check anything. + * If {I,B,C}, check B and C unless we're at I. + */ + if(tag_mode != 0 && ctx->step == 0) { + /* + * We don't expect tag to match here. + * It's just because we don't know how the tag + * is supposed to look like. + */ + } else { + assert(tagno >= 0); /* Guaranteed by the code above */ + if(tlv_tag != head->tags[tagno]) { + /* + * Unexpected tag. Too bad. + */ + ASN_DEBUG("Expected: %s, expectation failed", + ber_tlv_tag_string(head->tags[tagno])); + RETURN(RC_FAIL); + } + } + + /* + * Attention: if there are more tags expected, + * ensure that the current tag is presented + * in constructed form (it contains other tags!). + * If this one is the last one, check that the tag form + * matches the one given in descriptor. + */ + if(tagno < (head->tags_count - 1)) { + if(tlv_constr == 0) { + RETURN(RC_FAIL); + } + } else { + if(head->last_tag_form != tlv_constr + && head->last_tag_form != -1) { + RETURN(RC_FAIL); + } + } + + /* + * Fetch and process L from TLV. + */ + len_len = ber_fetch_length(tlv_constr, + ptr + tag_len, size - tag_len, &tlv_len); + switch(len_len) { + case -1: RETURN(RC_FAIL); + case 0: RETURN(RC_WMORE); + } + + /* + * FIXME + * As of today, the chain of tags + * must either contain several indefinite length TLVs, + * or several definite length ones. + * No mixing is allowed. + */ + if(tlv_len == -1) { + /* + * Indefinite length. + */ + if(limit_len == -1) { + expect_00_terminators++; + } else { + ASN_DEBUG("Unexpected indefinite length " + "in a chain of definite lengths"); + RETURN(RC_FAIL); + } + ADVANCE(tag_len + len_len); + continue; + } else { + if(expect_00_terminators) { + ASN_DEBUG("Unexpected definite length " + "in a chain of indefinite lengths"); + RETURN(RC_FAIL); + } + } + + /* + * Check that multiple TLVs specify ever decreasing length, + * which is consistent. + */ + if(limit_len == -1) { + limit_len = tlv_len + tag_len + len_len; + } else if(limit_len != tlv_len + tag_len + len_len) { + /* + * Inner TLV specifies length which is inconsistent + * with the outer TLV's length value. + */ + ASN_DEBUG("Outer TLV is %d and inner is %d", + limit_len, tlv_len); + RETURN(RC_FAIL); + } + + ADVANCE(tag_len + len_len); + + limit_len -= (tag_len + len_len); + if(size > limit_len) { + /* + * Make sure that we won't consume more bytes + * from the large buffer than the inferred limit. + */ + size = limit_len; + } + } + + if(opt_tlv_form) + *opt_tlv_form = tlv_constr; + if(expect_00_terminators) + *last_length = -expect_00_terminators; + else + *last_length = tlv_len; + + RETURN(RC_OK); +} diff --git a/skeletons/ber_decoder.h b/skeletons/ber_decoder.h new file mode 100644 index 00000000..8240270a --- /dev/null +++ b/skeletons/ber_decoder.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _BER_DECODER_H_ +#define _BER_DECODER_H_ + +#include + +struct asn1_TYPE_descriptor_s; /* Forward declaration */ + +/* + * This structure describes the return value common across the + * various BER decoders. + * + * Please note that the number of consumed bytes is ALWAYS meaningful, + * even if code!=RC_OK. This is so to indicate the number of successfully + * decoded bytes, hence provide a possibility, to fail with more diagnostics + * (i.e., print the offending remainder of the buffer). + */ +typedef struct ber_dec_rval_s { + enum { + RC_OK, /* Decoded successfully */ + RC_WMORE, /* More data expected, call again */ + RC_FAIL, /* Failure to decode data */ + } code; + + size_t consumed; /* Number of bytes consumed */ +} ber_dec_rval_t; + +/* + * A context for decoding BER across buffer boundaries. + */ +typedef struct ber_dec_ctx_s { + int phase; /* Decoding phase */ + int step; /* Elementary step of a phase */ + ber_tlv_len_t left; /* Number of bytes left, -1 for indefinite */ + void *ptr; /* Decoder-specific stuff */ +} ber_dec_ctx_t; + +/* + * The BER decoder of any type. + * This function may be invoked directly from the application. + */ +ber_dec_rval_t ber_decode(struct asn1_TYPE_descriptor_s *type_descriptor, + void **struct_ptr, /* Pointer to a target structure's pointer */ + void *buffer, /* Data to be decoded */ + size_t size /* Size of that buffer */ + ); + +/* + * Type of generic function which decodes the byte stream into the structure. + */ +typedef ber_dec_rval_t (ber_type_decoder_f)( + struct asn1_TYPE_descriptor_s *type_descriptor, + void **type_structure, void *buf_ptr, size_t size, + int tag_mode); + +/******************************* + * INTERNALLY USEFUL FUNCTIONS * + *******************************/ + +/* + * Check that all tags correspond to the type definition (as given in head). + * On return, last_length would contain either a non-negative length of the + * value part of the last TLV, or the negative number of expected + * "end of content" sequences. The number may only be negative if the + * head->last_tag_form is non-zero. + */ +ber_dec_rval_t ber_check_tags(struct asn1_TYPE_descriptor_s *type_dsc, + ber_dec_ctx_t *ctx, /* saved context */ + void *ptr, size_t size, + int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ + ber_tlv_len_t *last_length, + int *opt_tlv_form); + +#endif /* _BER_DECODER_H_ */ diff --git a/skeletons/ber_tlv_length.c b/skeletons/ber_tlv_length.c new file mode 100644 index 00000000..cd08f6ab --- /dev/null +++ b/skeletons/ber_tlv_length.c @@ -0,0 +1,159 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +ssize_t +ber_fetch_length(int _is_constructed, void *bufptr, size_t size, + ber_tlv_len_t *len_r) { + uint8_t *buf = bufptr; + unsigned oct; + + if(size == 0) + return 0; /* Want more */ + + oct = *(uint8_t *)buf; + if((oct & 0x80) == 0) { + /* + * Short definite length. + */ + *len_r = (oct & 0x7F); + return 1; + } else { + ber_tlv_len_t len; + ssize_t skipped; + + if(_is_constructed && oct == 0x80) { + *len_r = -1; /* Indefinite length */ + return 1; + } + + if(oct == 0xff) { + /* Reserved in standard for future use. */ + return -1; + } + + oct &= 0x7F; /* Leave only the 7 LS bits */ + for(len = 0, buf++, skipped = 1; + oct && (++skipped < size); buf++, oct--) { + + len = (len << 8) | *buf; + if(len < 0 + || (len >> ((8 * sizeof(len)) - 8) && oct > 1)) { + /* + * Too large length value. + */ + return -1; + } + } + + if(oct == 0) { + *len_r = len; + return skipped; + } + + return 0; /* Want more */ + } + +} + +ssize_t +ber_skip_length(int _is_constructed, void *ptr, size_t size) { + ber_tlv_len_t vlen; /* Length of V in TLV */ + ssize_t tl; /* Length of L in TLV */ + ssize_t ll; /* Length of L in TLV */ + ssize_t skip; + + /* + * Determine the size of L in TLV. + */ + ll = ber_fetch_length(_is_constructed, ptr, size, &vlen); + if(ll <= 0) return ll; + + /* + * Definite length. + */ + if(vlen >= 0) { + skip = ll + vlen; + if(skip > size) + return 0; /* Want more */ + return skip; + } + + /* + * Indefinite length! + */ + ASN_DEBUG("Skipping indefinite length"); + for(skip = ll, ptr += ll, size -= ll;;) { + ber_tlv_tag_t tag; + + /* Fetch the tag */ + tl = ber_fetch_tag(ptr, size, &tag); + if(tl <= 0) return tl; + + ll = ber_skip_length(BER_TLV_CONSTRUCTED(ptr), + ptr + tl, size - tl); + if(ll <= 0) return ll; + + skip += tl + ll; + + /* + * This may be the end of the indefinite length structure, + * two consecutive 0 octets. + * Check if it is true. + */ + if(((uint8_t *)ptr)[0] == 0 + && ((uint8_t *)ptr)[1] == 0) + return skip; + + ptr += tl + ll; + size -= tl + ll; + } + + /* UNREACHABLE */ +} + +ssize_t +der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) { + ssize_t computed_size; /* Size of len encoding */ + uint8_t *buf = bufp; + uint8_t *end; + int i; + + if(len <= 127) { + /* Encoded in 1 octet */ + if(size) *buf = len; + return 1; + } + + /* + * Compute the size of the subsequent bytes. + */ + computed_size = sizeof(len); /* assert(sizeof(len)<128), n.p. */ + for(i = (8*(sizeof(len)-1)); i > 0; i -= 8) { + if((len >> i) & 0xFF) break; + computed_size--; + } + + if(size) { + *buf++ = 0x80 | computed_size; /* Length of the encoding */ + size--; + } + + /* + * Produce the len encoding, space permitting. + */ + if(size > computed_size) + end = buf + computed_size; + else + end = buf + size; + for((void)i /* Reuse bits count */; buf < end; i -= 8, buf++) { + *buf = (len >> i) & 0xFF; + } + + return computed_size + 1; +} + diff --git a/skeletons/ber_tlv_length.h b/skeletons/ber_tlv_length.h new file mode 100644 index 00000000..7e5d5f8a --- /dev/null +++ b/skeletons/ber_tlv_length.h @@ -0,0 +1,40 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _BER_TLV_LENGTH_H_ +#define _BER_TLV_LENGTH_H_ + +typedef ssize_t ber_tlv_len_t; + +/* + * This function tries to fetch the length of the BER TLV value and place it + * in *len_r. + * RETURN VALUES: + * 0: More data expected than bufptr contains. + * -1: Fatal error deciphering length. + * >0: Number of bytes used from bufptr. + * On return with >0, len_r is constrained as -1..MAX, where -1 mean + * that the value is of indefinite length. + */ +ssize_t ber_fetch_length(int _is_constructed, void *bufptr, size_t size, + ber_tlv_len_t *len_r); + +/* + * This function expects bufptr to be positioned over L in TLV. + * It returns number of bytes occupied by L and V together, suitable + * for skipping. The function properly handles indefinite length. + * RETURN VALUES: + * Standard {-1,0,>0} convention. + */ +ssize_t ber_skip_length(int _is_constructed, void *bufptr, size_t size); + +/* + * This function serializes the length (L from TLV) in DER format. + * It always return number of bytes necessary to represent the length, + * it is a caller's responsibility to check the return value + * against the supplied buffer's size. + */ +ssize_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size); + +#endif /* _BER_TLV_LENGTH_H_ */ diff --git a/skeletons/ber_tlv_tag.c b/skeletons/ber_tlv_tag.c new file mode 100644 index 00000000..50c9e69b --- /dev/null +++ b/skeletons/ber_tlv_tag.c @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +ssize_t +ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) { + ber_tlv_tag_t val; + ber_tlv_tag_t tclass; + ssize_t skipped; + + if(size == 0) + return 0; + + val = *(uint8_t *)ptr; + tclass = (val >> 6); + if((val &= 31) != 31) { + /* + * Simple form: everything encoded in a single octet. + * Tag Class is encoded using two least significant bits. + */ + *tag_r = (val << 2) | tclass; + return 1; + } + + /* + * Each octet contains 7 bits of useful information. + * The MSB is 0 if it is the last octet of the tag. + */ + for(val = 0, ptr++, skipped = 2; skipped < size; ptr++, skipped++) { + unsigned oct = *(uint8_t *)ptr; + if(oct & 0x80) { + val = (val << 7) | (oct & 0x7F); + /* + * Make sure there are at least 9 bits spare + * at the MS side of a value. + */ + if(val >> ((8 * sizeof(val)) - 9)) { + /* + * We would not be able to accomodate + * any more tag bits. + */ + return -1; + } + } else { + *tag_r = (val << 9) | (oct << 2) | tclass; + return skipped; + } + } + + return 0; /* Want more */ +} + + +ssize_t +ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *f) { + char buf[sizeof("[APPLICATION ]") + 32]; + ssize_t ret; + + ret = ber_tlv_tag_snprint(tag, buf, sizeof(buf)); + if(ret >= sizeof(buf) || ret < 2) { + errno = EPERM; + return -1; + } + + return fwrite(buf, 1, ret, f); +} + +ssize_t +ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size) { + char *type = 0; + int ret; + + switch(tag & 0x3) { + case ASN_TAG_CLASS_UNIVERSAL: type = "UNIVERSAL "; break; + case ASN_TAG_CLASS_APPLICATION: type = "APPLICATION "; break; + case ASN_TAG_CLASS_CONTEXT: type = ""; break; + case ASN_TAG_CLASS_PRIVATE: type = "PRIVATE "; break; + } + + ret = snprintf(buf, size, "[%s%u]", type, ((unsigned)tag) >> 2); + if(ret <= 0 && size) buf[0] = '\0'; /* against broken libc's */ + + return ret; +} + +char * +ber_tlv_tag_string(ber_tlv_tag_t tag) { + static char buf[sizeof("[APPLICATION ]") + 32]; + + (void)ber_tlv_tag_snprint(tag, buf, sizeof(buf)); + + return buf; +} + + +ssize_t +der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) { + int tclass = BER_TAG_CLASS(tag); + ber_tlv_tag_t tval = BER_TAG_VALUE(tag); + uint8_t *buf = bufp; + uint8_t *end; + ssize_t computed_size; + int i; + + if(tval <= 30) { + /* Encoded in 1 octet */ + if(size) buf[0] = (tclass << 6) | tval; + return 1; + } else if(size) { + *buf++ = (tclass << 6) | 0x1F; + size--; + } + + /* + * Compute the size of the subsequent bytes. + * The routine is written so every floating-point + * operation is done at compile time. + * Note, there is a subtle problem lurking here, + * could you guess where it is? :) + * Hint: what happens when ((8*sizeof(tag))%7) == 0? + */ + computed_size = 1 + 8 * sizeof(tag) / 7; + for(i = (8*sizeof(tag)) - ((8*sizeof(tag))%7); i >= 7; i -= 7) { + if((tval >> i) & 0x7F) break; + computed_size--; + } + + /* + * Fill in the buffer, space permitting. + */ + if(size > computed_size) + end = buf + computed_size; + else + end = buf + size; + for((void)i; buf < end; i -= 7, buf++) { + *buf = 0x80 | ((tval>>i) & 0x7F); + } + + return computed_size + 1; +} + diff --git a/skeletons/ber_tlv_tag.h b/skeletons/ber_tlv_tag.h new file mode 100644 index 00000000..50419702 --- /dev/null +++ b/skeletons/ber_tlv_tag.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _BER_TLV_TAG_H_ +#define _BER_TLV_TAG_H_ + +enum asn_tag_class { + ASN_TAG_CLASS_UNIVERSAL = 0, /* 0b00 */ + ASN_TAG_CLASS_APPLICATION = 1, /* 0b01 */ + ASN_TAG_CLASS_CONTEXT = 2, /* 0b10 */ + ASN_TAG_CLASS_PRIVATE = 3, /* 0b11 */ +}; +typedef unsigned ber_tlv_tag_t; /* BER TAG from Tag-Length-Value */ + +/* + * Tag class is encoded together with tag value for optimization purposes. + */ +#define BER_TAG_CLASS(tag) ((tag) & 0x3) +#define BER_TAG_VALUE(tag) ((tag) >> 2) +#define BER_TLV_CONSTRUCTED(tagptr) (((*(uint8_t *)tagptr) & 0x20)?1:0) + +#define BER_TAGS_EQUAL(tag1, tag2) ((tag1) == (tag2)) + +/* + * Several functions for printing the TAG in the canonical form + * (i.e. "[PRIVATE 0]"). + * Return values correspond to their libc counterparts (if any). + */ +ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t buflen); +ssize_t ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *); +char *ber_tlv_tag_string(ber_tlv_tag_t tag); + + +/* + * This function tries to fetch the tag from the input stream. + * RETURN VALUES: + * 0: More data expected than bufptr contains. + * -1: Fatal error deciphering tag. + * >0: Number of bytes used from bufptr. tag_r will contain the tag. + */ +ssize_t ber_fetch_tag(void *bufptr, size_t size, ber_tlv_tag_t *tag_r); + +/* + * This function serializes the tag (T from TLV) in DER format. + * It always return number of bytes necessary to represent the tag, + * it is a caller's responsibility to check the return value + * against the supplied buffer's size. + */ +ssize_t der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufptr, size_t size); + +#endif /* _BER_TLV_TAG_H_ */ diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c new file mode 100644 index 00000000..2cfac3b6 --- /dev/null +++ b/skeletons/constr_CHOICE.c @@ -0,0 +1,627 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include /* for ntohl */ +#include + +/* + * Number of bytes left for this structure. + * (ctx->left) indicates the number of bytes _transferred_ for the structure. + * (size) contains the number of bytes in the buffer passed. + */ +#define LEFT ((sizeleft)?size:ctx->left) + +/* + * If the subprocessor function returns with an indication that it wants + * more data, it may well be a fatal decoding problem, because the + * size is constrained by the 's L, even if the buffer size allows + * reading more data. + * For example, consider the buffer containing the following TLVs: + * ... + * The TLV length clearly indicates that one byte is expected in V, but + * if the V processor returns with "want more data" even if the buffer + * contains way more data than the V processor have seen. + */ +#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size) + +/* + * This macro "eats" the part of the buffer which is definitely "consumed", + * i.e. was correctly converted into local representation or rightfully skipped. + */ +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr += num; \ + size -= num; \ + if(ctx->left >= 0) \ + ctx->left -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Switch to the next phase of parsing. + */ +#define NEXT_PHASE(ctx) do { \ + ctx->phase++; \ + ctx->step = 0; \ + } while(0) + +/* + * Return a standardized complex structure. + */ +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +/* + * See the definitions. + */ +static inline int _fetch_present_idx(const void *struct_ptr, int off, int size); +static inline void _set_present_idx(void *sptr, int offset, int size, int pres); + +/* + * Tags are canonically sorted in the tag to member table. + */ +static int +_search4tag(const void *ap, const void *bp) { + const asn1_CHOICE_tag2member_t *a = ap; + const asn1_CHOICE_tag2member_t *b = bp; + int a_class = BER_TAG_CLASS(a->el_tag); + int b_class = BER_TAG_CLASS(b->el_tag); + + if(a_class == b_class) { + ber_tlv_tag_t a_value = BER_TAG_VALUE(a->el_tag); + ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); + + if(a_value == b_value) + return 0; + else if(a_value < b_value) + return -1; + else + return 1; + } else if(a_class < b_class) { + return -1; + } else { + return 1; + } +} + +/* + * The decoder of the CHOICE type. + */ +ber_dec_rval_t +CHOICE_decode_ber(asn1_TYPE_descriptor_t *sd, + void **struct_ptr, void *ptr, size_t size, int tag_mode) { + /* + * Bring closer parts of structure description. + */ + asn1_CHOICE_specifics_t *specs = sd->specifics; + asn1_CHOICE_element_t *elements = specs->elements; + + /* + * Parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + ber_dec_ctx_t *ctx; /* Decoder context */ + + ber_tlv_tag_t tlv_tag; /* T from TLV */ + ssize_t tag_len; /* Length of TLV's T */ + //ber_tlv_len_t tlv_len; /* L from TLV */ + ber_dec_rval_t rval; /* Return code from subparsers */ + + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + + ASN_DEBUG("Decoding %s as CHOICE", sd->name); + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) { + RETURN(RC_FAIL); + } + } + + /* + * Restore parsing context. + */ + ctx = (st + specs->ctx_offset); + + /* + * Start to parse where left previously + */ + switch(ctx->phase) { + case 0: + /* + * PHASE 0. + * Check that the set of tags associated with given structure + * perfectly fits our expectations. + */ + + if(tag_mode || sd->tags_count) { + rval = ber_check_tags(sd, ctx, ptr, size, + tag_mode, &ctx->left, 0); + if(rval.code != RC_OK) { + ASN_DEBUG("%s tagging check failed: %d", + sd->name, rval.code); + consumed_myself += rval.consumed; + RETURN(rval.code); + } + + if(ctx->left >= 0) { + /* ?Substracted below! */ + ctx->left += rval.consumed; + } + ADVANCE(rval.consumed); + } else { + ctx->left = -1; + } + + NEXT_PHASE(ctx); + + ASN_DEBUG("Structure consumes %ld bytes, buffer %ld", + (long)ctx->left, (long)size); + + /* Fall through */ + case 1: + /* + * Fetch the T from TLV. + */ + tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); + ASN_DEBUG("In %s CHOICE tag length %d", sd->name, (int)tag_len); + switch(tag_len) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + do { + asn1_CHOICE_tag2member_t *t2m; + asn1_CHOICE_tag2member_t key; + + key.el_tag = tlv_tag; + t2m = bsearch(&key, specs->tag2el, specs->tag2el_count, + sizeof(specs->tag2el[0]), _search4tag); + if(t2m) { + /* + * Found the element corresponding to the tag. + */ + NEXT_PHASE(ctx); + ctx->step = t2m->el_no; + break; + } else if(specs->extensible == 0) { + ASN_DEBUG("Unexpected tag %s " + "in non-extensible CHOICE %s", + ber_tlv_tag_string(tlv_tag), sd->name); + RETURN(RC_FAIL); + } else { + /* Skip this tag */ + ssize_t skip; + + ASN_DEBUG("Skipping unknown tag %s", + ber_tlv_tag_string(tlv_tag)); + + skip = ber_skip_length( + BER_TLV_CONSTRUCTED(ptr), + ptr + tag_len, LEFT - tag_len); + + switch(skip) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + ADVANCE(skip + tag_len); + RETURN(RC_OK); + } + } while(0); + + case 2: + /* + * PHASE 2. + * Read in the element. + */ + do { + asn1_CHOICE_element_t *elm; /* CHOICE's element */ + void *memb_ptr; /* Pointer to the member */ + void *memb_ptr2; /* Pointer to that pointer */ + + elm = &elements[ctx->step]; + + /* + * Compute the position of the member inside a structure, + * and also a type of containment (it may be contained + * as pointer or using inline inclusion). + */ + if(elm->optional) { + /* Optional member, hereby, a simple pointer */ + memb_ptr2 = (char *)st + elm->memb_offset; + } else { + /* + * A pointer to a pointer + * holding the start of the structure + */ + memb_ptr = (char *)st + elm->memb_offset; + memb_ptr2 = &memb_ptr; + } + /* + * Invoke the member fetch routine according to member's type + */ + rval = elm->type->ber_decoder( + (void *)elm->type, + memb_ptr2, ptr, LEFT, + elm->tag_mode); + switch(rval.code) { + case RC_OK: + _set_present_idx(st, specs->pres_offset, + specs->pres_size, ctx->step + 1); + break; + case RC_WMORE: /* More data expected */ + if(!SIZE_VIOLATION) { + ADVANCE(rval.consumed); + RETURN(RC_WMORE); + } + RETURN(RC_FAIL); + case RC_FAIL: /* Fatal error */ + RETURN(rval.code); + } /* switch(rval) */ + + ADVANCE(rval.consumed); + } while(0); + + NEXT_PHASE(ctx); + + /* Fall through */ + case 3: + ASN_DEBUG("CHOICE %s Leftover: %ld, size = %ld, tm=%d, tc=%d", + sd->name, (long)ctx->left, (long)size, + tag_mode, sd->tags_count); + + if(ctx->left > 0) { + /* + * The type must be fully decoded + * by the CHOICE member-specific decoder. + */ + RETURN(RC_FAIL); + } + + if(ctx->left == -1 + && !(tag_mode || sd->tags_count)) { + /* + * This is an untagged CHOICE. + * It doesn't contain nothing + * except for the member itself, including all its tags. + * The decoding is completed. + */ + NEXT_PHASE(ctx); + break; + } + + /* + * Read in the "end of data chunks"'s. + */ + while(ctx->left < 0) { + ssize_t tl; + + tl = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tl) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + /* + * Expected <0><0>... + */ + if(((uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((uint8_t *)ptr)[1] == 0) { + /* + * Correctly finished with <0><0>. + */ + continue; + } + } else { + ASN_DEBUG("Unexpected continuation in %s", + sd->name); + RETURN(RC_FAIL); + } + + ADVANCE(2); + ctx->left++; + } + + NEXT_PHASE(ctx); + case 4: + /* No meaningful work here */ + break; + } + + RETURN(RC_OK); +} + +der_enc_rval_t +CHOICE_encode_der(asn1_TYPE_descriptor_t *sd, + void *struct_ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_CHOICE_specifics_t *specs = sd->specifics; + asn1_CHOICE_element_t *elm; /* CHOICE element */ + der_enc_rval_t erval; + void *memb_ptr; + size_t computed_size = 0; + int present; + + ASN_DEBUG("%s %s as CHOICE", + cb?"Encoding":"Estimating", sd->name); + + present = _fetch_present_idx(struct_ptr, + specs->pres_offset, specs->pres_size); + + /* + * If the structure was not initialized, it cannot be encoded: + * can't deduce what to encode in the choice type. + */ + if(present <= 0 || present > specs->elements_count) { + if(present == 0 && specs->elements_count == 0) { + /* The CHOICE is empty?! */ + erval.encoded = 0; + return erval; + } + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = struct_ptr; + return erval; + } + + /* + * Seek over the present member of the structure. + */ + elm = &specs->elements[present-1]; + if(elm->optional) { + memb_ptr = *(void **)((char *)struct_ptr + elm->memb_offset); + if(memb_ptr == 0) { + erval.encoded = 0; + return erval; + } + } else { + memb_ptr = (void *)((char *)struct_ptr + elm->memb_offset); + } + + /* + * If the CHOICE itself is tagged EXPLICIT: + * T ::= [2] EXPLICIT CHOICE { ... } + * Then emit the appropriate tags. + */ + if(tag_mode == 1 || sd->tags_count) { + /* + * For this, we need to pre-compute the member. + */ + ssize_t ret; + + /* Encode member with its tag */ + erval = elm->type->der_encoder(elm->type, memb_ptr, + elm->tag_mode, elm->tag, 0, 0); + if(erval.encoded == -1) + return erval; + + /* Encode CHOICE with parent or my own tag */ + ret = der_write_tags(sd, erval.encoded, tag_mode, tag, + cb, app_key); + if(ret == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = struct_ptr; + return erval; + } + computed_size += ret; + } + + /* + * Encode the single underlying member. + */ + erval = elm->type->der_encoder(elm->type, memb_ptr, + elm->tag_mode, elm->tag, cb, app_key); + if(erval.encoded == -1) + return erval; + + ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", + (long)erval.encoded, (long)computed_size); + + erval.encoded += computed_size; + + return erval; +} + +ber_tlv_tag_t +CHOICE_outmost_tag(asn1_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) { + asn1_CHOICE_specifics_t *specs = td->specifics; + int present; + + assert(tag_mode == 0); + assert(tag == 0); + + /* + * Figure out which CHOICE element is encoded. + */ + present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); + + if(present > 0 || present <= specs->elements_count) { + asn1_CHOICE_element_t *elm = &specs->elements[present-1]; + void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + } + + return asn1_TYPE_outmost_tag(elm->type, memb_ptr, + elm->tag_mode, elm->tag); + } else { + return -1; + } +} + +int +CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + asn1_CHOICE_specifics_t *specs = td->specifics; + int present; + + if(!sptr) { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + /* + * Figure out which CHOICE element is encoded. + */ + present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size); + if(present > 0 && present <= specs->elements_count) { + asn1_CHOICE_element_t *elm = &specs->elements[present-1]; + const void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); + if(!memb_ptr) return 0; + } else { + memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); + } + + return elm->type->check_constraints(elm->type, memb_ptr, + app_errlog, app_key); + } else { + _ASN_ERRLOG("%s: no CHOICE element given", td->name); + return -1; + } +} + +int +CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_CHOICE_specifics_t *specs = td->specifics; + int present; + + if(!sptr) return cb("", 8, app_key); + + /* + * Figure out which CHOICE element is encoded. + */ + present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size); + + /* + * Free that element. + */ + if(present > 0 && present <= specs->elements_count) { + asn1_CHOICE_element_t *elm = &specs->elements[present-1]; + const void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); + if(!memb_ptr) return cb("", 8, app_key); + } else { + memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); + } + + /* Print member's name and stuff */ + if(cb(elm->name, strlen(elm->name), app_key) + || cb(": ", 2, app_key)) + return -1; + + return elm->type->print_struct(elm->type, memb_ptr, ilevel, + cb, app_key); + } else { + return cb("", 8, app_key); + } +} + +void +CHOICE_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) { + asn1_CHOICE_specifics_t *specs = td->specifics; + int present; + + if(!td || !ptr) + return; + + ASN_DEBUG("Freeing %s as CHOICE", td->name); + + /* + * Figure out which CHOICE element is encoded. + */ + present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size); + + /* + * Free that element. + */ + if(present > 0 && present <= specs->elements_count) { + asn1_CHOICE_element_t *elm = &specs->elements[present-1]; + void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + if(memb_ptr) + elm->type->free_struct(elm->type, memb_ptr, 0); + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + elm->type->free_struct(elm->type, memb_ptr, 1); + } + } + + if(!contents_only) { + FREEMEM(ptr); + } +} + + +/* + * The following functions functions offer protection against -fshort-enums, + * compatible with little- and big-endian machines. + * If assertion is triggered, either disable -fshort-enums, or add an entry + * here with the ->pres_size of your target stracture. + * Unless the target structure is packed, the ".present" member + * is guaranteed to be aligned properly. ASN.1 compiler itself does not + * produce packed code. + */ +static inline int +_fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) { + const void *present_ptr; + int present; + + present_ptr = ((const char *)struct_ptr) + pres_offset; + + switch(pres_size) { + case sizeof(int): present = *(const int *)present_ptr; break; + case sizeof(short): present = *(const short *)present_ptr; break; + case sizeof(char): present = *(const char *)present_ptr; break; + default: + /* ANSI C mandates enum to be equivalent to integer */ + assert(pres_size != sizeof(int)); + return 0; /* If not aborted, pass back safe value */ + } + + return present; +} + +static inline void +_set_present_idx(void *struct_ptr, int pres_offset, int pres_size, int present) { + void *present_ptr; + present_ptr = ((char *)struct_ptr) + pres_offset; + + switch(pres_size) { + case sizeof(int): *(int *)present_ptr = present; break; + case sizeof(short): *(short *)present_ptr = present; break; + case sizeof(char): *(char *)present_ptr = present; break; + default: + /* ANSI C mandates enum to be equivalent to integer */ + assert(pres_size != sizeof(int)); + } +} diff --git a/skeletons/constr_CHOICE.h b/skeletons/constr_CHOICE.h new file mode 100644 index 00000000..70766e9d --- /dev/null +++ b/skeletons/constr_CHOICE.h @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _CONSTR_CHOICE_H_ +#define _CONSTR_CHOICE_H_ + +#include + +/* + * A single element of the CHOICE type. + */ +typedef struct asn1_CHOICE_element_s { + int memb_offset; /* Offset of the element */ + int optional; /* Whether the element is optional */ + ber_tlv_tag_t tag; /* Outmost (most immediate) tag */ + int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */ + asn1_TYPE_descriptor_t + *type; /* Member type descriptor */ + char *name; /* ASN.1 identifier of the element */ +} asn1_CHOICE_element_t; + +typedef struct asn1_CHOICE_tag2member_s { + ber_tlv_tag_t el_tag; /* Outmost tag of the member */ + int el_no; /* Index of the associated member, base 0 */ +} asn1_CHOICE_tag2member_t; + +typedef struct asn1_CHOICE_specifics_s { + /* + * Target structure description. + */ + int struct_size; /* Size of the target structure. */ + int ctx_offset; /* Offset of the ber_dec_ctx_t member */ + int pres_offset; /* Identifier of the present member */ + int pres_size; /* Size of the identifier (enum) */ + + /* + * Members of the CHOICE structure. + */ + asn1_CHOICE_element_t *elements; + int elements_count; + + /* + * Tags to members mapping table. + */ + asn1_CHOICE_tag2member_t *tag2el; + int tag2el_count; + + /* + * Extensions-related stuff. + */ + int extensible; /* Whether CHOICE is extensible */ +} asn1_CHOICE_specifics_t; + +/* + * A set specialized functions dealing with the CHOICE type. + */ +asn_constr_check_f CHOICE_constraint; +ber_type_decoder_f CHOICE_decode_ber; +der_type_encoder_f CHOICE_encode_der; +asn_outmost_tag_f CHOICE_outmost_tag; +asn_struct_print_f CHOICE_print; +asn_struct_free_f CHOICE_free; + +#endif /* _CONSTR_CHOICE_H_ */ diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c new file mode 100644 index 00000000..6704dd84 --- /dev/null +++ b/skeletons/constr_SEQUENCE.c @@ -0,0 +1,588 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include + +/* + * Number of bytes left for this structure. + * (ctx->left) indicates the number of bytes _transferred_ for the structure. + * (size) contains the number of bytes in the buffer passed. + */ +#define LEFT ((sizeleft)?size:ctx->left) + +/* + * If the subprocessor function returns with an indication that it wants + * more data, it may well be a fatal decoding problem, because the + * size is constrained by the 's L, even if the buffer size allows + * reading more data. + * For example, consider the buffer containing the following TLVs: + * ... + * The TLV length clearly indicates that one byte is expected in V, but + * if the V processor returns with "want more data" even if the buffer + * contains way more data than the V processor have seen. + */ +#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size) + +/* + * This macro "eats" the part of the buffer which is definitely "consumed", + * i.e. was correctly converted into local representation or rightfully skipped. + */ +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr += num; \ + size -= num; \ + if(ctx->left >= 0) \ + ctx->left -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Switch to the next phase of parsing. + */ +#define NEXT_PHASE(ctx) do { \ + ctx->phase++; \ + ctx->step = 0; \ + } while(0) +#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) + +/* + * Return a standardized complex structure. + */ +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +/* + * Check whether we are inside the extensions group. + */ +#define IN_EXTENSION_GROUP(specs, memb_idx) \ + ( ((memb_idx) > (specs)->ext_after) \ + &&((memb_idx) < (specs)->ext_before)) + +/* + * The decoder of the SEQUENCE type. + */ +ber_dec_rval_t +SEQUENCE_decode_ber(asn1_TYPE_descriptor_t *sd, + void **struct_ptr, void *ptr, size_t size, int tag_mode) { + /* + * Bring closer parts of structure description. + */ + asn1_SEQUENCE_specifics_t *specs = sd->specifics; + asn1_SEQUENCE_element_t *elements = specs->elements; + + /* + * Parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + ber_dec_ctx_t *ctx; /* Decoder context */ + + ber_tlv_tag_t tlv_tag; /* T from TLV */ + //ber_tlv_len_t tlv_len; /* L from TLV */ + ber_dec_rval_t rval; /* Return code from subparsers */ + + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + int edx; /* SEQUENCE element's index */ + + ASN_DEBUG("Decoding %s as SEQUENCE", sd->name); + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) { + RETURN(RC_FAIL); + } + } + + /* + * Restore parsing context. + */ + ctx = (st + specs->ctx_offset); + + /* + * Start to parse where left previously + */ + switch(ctx->phase) { + case 0: + /* + * PHASE 0. + * Check that the set of tags associated with given structure + * perfectly fits our expectations. + */ + + rval = ber_check_tags(sd, ctx, ptr, size, + tag_mode, &ctx->left, 0); + if(rval.code != RC_OK) { + ASN_DEBUG("%s tagging check failed: %d", + sd->name, rval.code); + consumed_myself += rval.consumed; + RETURN(rval.code); + } + + if(ctx->left >= 0) + ctx->left += rval.consumed; /* ?Substracted below! */ + ADVANCE(rval.consumed); + + NEXT_PHASE(ctx); + + ASN_DEBUG("Structure consumes %ld bytes, buffer %ld", + (long)ctx->left, (long)size); + + /* Fall through */ + case 1: + /* + * PHASE 1. + * From the place where we've left it previously, + * try to decode the next member from the list of + * this structure's elements. + * (ctx->step) stores the member being processed + * between invocations and the microphase {0,1} of parsing + * that member: + * step = ( * 2 + ). + */ + for(edx = (ctx->step >> 1); edx < specs->elements_count; + edx++, ctx->step = (ctx->step & ~1) + 2) { + void *memb_ptr; /* Pointer to the member */ + void *memb_ptr2; /* Pointer to that pointer */ + ssize_t tag_len; /* Length of TLV's T */ + int opt_edx_end; /* Next non-optional element */ + int n; + + if(ctx->step & 1) + goto microphase2; + + /* + * MICROPHASE 1: Synchronize decoding. + */ + ASN_DEBUG("In %s SEQUENCE left %d, edx=%d opt=%d ec=%d", + sd->name, (int)ctx->left, + edx, elements[edx].optional, specs->elements_count); + + if(ctx->left == 0 /* No more stuff is expected */ + && ( + /* Explicit OPTIONAL specification reaches the end */ + (edx + elements[edx].optional == specs->elements_count) + || + /* All extensions are optional */ + (IN_EXTENSION_GROUP(specs, edx) + && specs->ext_before > specs->elements_count) + ) + ) { + ASN_DEBUG("End of SEQUENCE %s", sd->name); + /* + * Found the legitimate end of the structure. + */ + PHASE_OUT(ctx); + RETURN(RC_OK); + } + + /* + * Fetch the T from TLV. + */ + tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); + ASN_DEBUG("In %s SEQUENCE for %d %s next tag length %d", + sd->name, edx, elements[edx].name, (int)tag_len); + switch(tag_len) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + /* + * Find the next available type with this tag. + */ + opt_edx_end = edx + elements[edx].optional + 1; + if(opt_edx_end > specs->elements_count) + opt_edx_end = specs->elements_count; /* Cap */ + for(n = edx; n < opt_edx_end; n++) { + if(BER_TAGS_EQUAL(tlv_tag, elements[n].tag)) { + /* + * Found element corresponding to the tag + * being looked at. + * Reposition over the right element. + */ + edx = n; + ctx->step = 2 * edx; /* Remember! */ + break; + } + } + if(n == opt_edx_end) { + /* + * If tag is unknown, it may be either + * an unknown (thus, incorrect) tag, + * or an extension (...), + * or an end of the indefinite-length structure. + */ + + if(!IN_EXTENSION_GROUP(specs, edx)) { + ASN_DEBUG("Unexpected tag %s", + ber_tlv_tag_string(tlv_tag)); + ASN_DEBUG("Expected tag %s%s", + ber_tlv_tag_string(elements[edx].tag), + elements[edx].optional + ?" or alternatives":""); + RETURN(RC_FAIL); + } + + if(ctx->left < 0 + && ((uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((uint8_t *)ptr)[1] == 0) { + /* + * Yeah, baby! Found the terminator + * of the indefinite length structure. + */ + /* + * Proceed to the canonical + * finalization function. + * No advancing is necessary. + */ + goto phase3; + } + } else { + /* Skip this tag */ + ssize_t skip; + + skip = ber_skip_length( + BER_TLV_CONSTRUCTED(ptr), + ptr + tag_len, LEFT - tag_len); + ASN_DEBUG("Skip length %d in %s", + (int)skip, sd->name); + switch(skip) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + ADVANCE(skip + tag_len); + ctx->step -= 2; + edx--; + continue; /* Try again with the next tag */ + } + } + + /* + * MICROPHASE 2: Invoke the member-specific decoder. + */ + ctx->step |= 1; /* Confirm entering next microphase */ + microphase2: + ASN_DEBUG("Inside SEQUENCE %s MF2", sd->name); + + /* + * Compute the position of the member inside a structure, + * and also a type of containment (it may be contained + * as pointer or using inline inclusion). + */ + if(elements[edx].optional) { + /* Optional member, hereby, a simple pointer */ + memb_ptr2 = (char *)st + elements[edx].memb_offset; + } else { + /* + * A pointer to a pointer + * holding the start of the structure + */ + memb_ptr = (char *)st + elements[edx].memb_offset; + memb_ptr2 = &memb_ptr; + } + /* + * Invoke the member fetch routine according to member's type + */ + rval = elements[edx].type->ber_decoder( + (void *)elements[edx].type, + memb_ptr2, ptr, LEFT, + elements[edx].tag_mode); + ASN_DEBUG("In %s SEQUENCE decoded %d %s in %d bytes code %d", + sd->name, edx, elements[edx].type->name, + (int)rval.consumed, rval.code); + switch(rval.code) { + case RC_OK: + break; + case RC_WMORE: /* More data expected */ + if(!SIZE_VIOLATION) { + ADVANCE(rval.consumed); + RETURN(RC_WMORE); + } + /* Fall through */ + case RC_FAIL: /* Fatal error */ + RETURN(RC_FAIL); + } /* switch(rval) */ + + ADVANCE(rval.consumed); + } /* for(all structure members) */ + + phase3: + ctx->phase = 3; + case 3: /* 00 and other tags expected */ + case 4: /* only 00's expected */ + + ASN_DEBUG("SEQUENCE %s Leftover: %ld, size = %ld", + sd->name, (long)ctx->left, (long)size); + + /* + * Skip everything until the end of the SEQUENCE. + */ + while(ctx->left) { + ssize_t tl, ll; + + tl = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tl) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + /* + * If expected <0><0>... + */ + if(ctx->left < 0 + && ((uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((uint8_t *)ptr)[1] == 0) { + /* + * Correctly finished with <0><0>. + */ + ADVANCE(2); + ctx->left++; + ctx->phase = 4; + continue; + } + } + + if(!IN_EXTENSION_GROUP(specs, specs->elements_count) + || ctx->phase == 4) { + ASN_DEBUG("Unexpected continuation " + "of a non-extensible type " + "%s (SEQUENCE): %s", + sd->name, + ber_tlv_tag_string(tlv_tag)); + RETURN(RC_FAIL); + } + + ll = ber_skip_length( + BER_TLV_CONSTRUCTED(ptr), + ptr + tl, LEFT - tl); + switch(ll) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + ADVANCE(tl + ll); + } + + PHASE_OUT(ctx); + } + + RETURN(RC_OK); +} + +/* + * The DER encoder of the SEQUENCE type. + */ +der_enc_rval_t +SEQUENCE_encode_der(asn1_TYPE_descriptor_t *sd, + void *ptr, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SEQUENCE_specifics_t *specs = sd->specifics; + size_t computed_size = 0; + der_enc_rval_t erval; + ssize_t ret; + int edx; + + ASN_DEBUG("%s %s as SEQUENCE", + cb?"Encoding":"Estimating", sd->name); + + /* + * Gather the length of the underlying members sequence. + */ + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SEQUENCE_element_t *elm = &specs->elements[edx]; + void *memb_ptr; + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + if(!memb_ptr) continue; + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + } + erval = elm->type->der_encoder(elm->type, memb_ptr, + elm->tag_mode, elm->tag, + 0, 0); + if(erval.encoded == -1) + return erval; + computed_size += erval.encoded; + ASN_DEBUG("Member %d %s estimated %ld bytes", + edx, elm->name, (long)erval.encoded); + } + + /* + * Encode the TLV for the sequence itself. + */ + ret = der_write_tags(sd, computed_size, tag_mode, tag, cb, app_key); + ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size); + if(ret == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + erval.encoded = computed_size + ret; + + if(!cb) return erval; + + /* + * Encode all members. + */ + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SEQUENCE_element_t *elm = &specs->elements[edx]; + der_enc_rval_t tmperval; + void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + if(!memb_ptr) continue; + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + } + tmperval = elm->type->der_encoder(elm->type, memb_ptr, + elm->tag_mode, elm->tag, + cb, app_key); + if(tmperval.encoded == -1) + return tmperval; + computed_size -= tmperval.encoded; + ASN_DEBUG("Member %d %s of SEQUENCE %s encoded in %d bytes", + edx, elm->name, sd->name, tmperval.encoded); + } + + if(computed_size != 0) { + /* + * Encoded size is not equal to the computed size. + */ + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + } + + return erval; +} + +int +SEQUENCE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SEQUENCE_specifics_t *specs = td->specifics; + int edx; + int ret; + + if(!sptr) return cb("", 8, app_key); + + /* Dump preamble */ + if(cb(td->name, strlen(td->name), app_key) + || cb(" ::= {\n", 7, app_key)) + return -1; + + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SEQUENCE_element_t *elm = &specs->elements[edx]; + const void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); + if(!memb_ptr) continue; + } else { + memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); + } + + /* Indentation */ + for(ret = 0; ret < ilevel; ret++) cb(" ", 1, app_key); + + /* Print the member's name and stuff */ + if(cb(elm->name, strlen(elm->name), app_key) + || cb(": ", 2, app_key)) + return -1; + + /* Print the member itself */ + ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 4, + cb, app_key); + if(ret) return ret; + + /* Print out the terminator */ + ret = cb("\n", 1, app_key); + if(ret) return ret; + } + + /* Indentation */ + for(ret = 0; ret < ilevel - 4; ret++) cb(" ", 1, app_key); + + return cb("}", 1, app_key); +} + +void +SEQUENCE_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) { + asn1_SEQUENCE_specifics_t *specs = td->specifics; + int edx; + + if(!td || !sptr) + return; + + ASN_DEBUG("Freeing %s as SEQUENCE", td->name); + + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SEQUENCE_element_t *elm = &specs->elements[edx]; + void *memb_ptr; + if(elm->optional) { + memb_ptr = *(void **)((char *)sptr + elm->memb_offset); + if(memb_ptr) + elm->type->free_struct(elm->type, memb_ptr, 0); + } else { + memb_ptr = (void *)((char *)sptr + elm->memb_offset); + elm->type->free_struct(elm->type, memb_ptr, 1); + } + } + + if(!contents_only) { + FREEMEM(sptr); + } +} + +int +SEQUENCE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + asn1_SEQUENCE_specifics_t *specs = td->specifics; + int edx; + + if(!sptr) { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + /* + * Iterate over structure members and check their validity. + */ + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SEQUENCE_element_t *elm = &specs->elements[edx]; + const void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(const void **)((const char *)sptr + elm->memb_offset); + if(!memb_ptr) continue; + } else { + memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); + } + + return elm->type->check_constraints(elm->type, memb_ptr, + app_errlog, app_key); + } + + return 0; +} diff --git a/skeletons/constr_SEQUENCE.h b/skeletons/constr_SEQUENCE.h new file mode 100644 index 00000000..c15729ca --- /dev/null +++ b/skeletons/constr_SEQUENCE.h @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _CONSTR_SEQUENCE_H_ +#define _CONSTR_SEQUENCE_H_ + +#include + +/* + * A single element of the SEQUENCE type. + */ +typedef struct asn1_SEQUENCE_element_s { + int memb_offset; /* Offset of the element */ + int optional; /* Whether the element is optional */ + ber_tlv_tag_t tag; /* Outmost (most immediate) tag */ + int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */ + asn1_TYPE_descriptor_t + *type; /* Member type descriptor */ + char *name; /* ASN.1 identifier of the element */ +} asn1_SEQUENCE_element_t; + +typedef struct asn1_SEQUENCE_specifics_s { + /* + * Target structure description. + */ + int struct_size; /* Size of the target structure. */ + int ctx_offset; /* Offset of the ber_dec_ctx_t member */ + + /* + * Members of the SEQUENCE structure. + */ + asn1_SEQUENCE_element_t *elements; + int elements_count; + + /* + * Description of an extensions group. + */ + int ext_after; /* Extensions start after this member */ + int ext_before; /* Extensions stop before this member */ +} asn1_SEQUENCE_specifics_t; + + +/* + * A set specialized functions dealing with the SEQUENCE type. + */ +asn_constr_check_f SEQUENCE_constraint; +ber_type_decoder_f SEQUENCE_decode_ber; +der_type_encoder_f SEQUENCE_encode_der; +asn_struct_print_f SEQUENCE_print; +asn_struct_free_f SEQUENCE_free; + +#endif /* _CONSTR_SEQUENCE_H_ */ diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c new file mode 100644 index 00000000..cdddf607 --- /dev/null +++ b/skeletons/constr_SEQUENCE_OF.c @@ -0,0 +1,84 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include + +/* + * The DER encoder of the SEQUENCE OF type. + */ +der_enc_rval_t +SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SET_OF_specifics_t *specs = sd->specifics; + asn1_SET_OF_element_t *elm = specs->element; + A_SEQUENCE_OF(void) *list = ptr; + size_t computed_size = 0; + ssize_t encoding_size = 0; + der_enc_rval_t erval; + int edx; + + ASN_DEBUG("Estimating size of SEQUENCE OF %s", sd->name); + + /* + * Gather the length of the underlying members sequence. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + erval = elm->type->der_encoder(elm->type, memb_ptr, + 0, elm->tag, + 0, 0); + if(erval.encoded == -1) + return erval; + computed_size += erval.encoded; + } + + /* + * Encode the TLV for the sequence itself. + */ + encoding_size = der_write_tags(sd, computed_size, tag_mode, tag, + cb, app_key); + if(encoding_size == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + + computed_size += encoding_size; + if(!cb) { + erval.encoded = computed_size; + return erval; + } + + ASN_DEBUG("Encoding members of SEQUENCE OF %s", sd->name); + + /* + * Encode all members. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + erval = elm->type->der_encoder(elm->type, memb_ptr, + 0, elm->tag, + cb, app_key); + if(erval.encoded == -1) + return erval; + encoding_size += erval.encoded; + } + + if(computed_size != encoding_size) { + /* + * Encoded size is not equal to the computed size. + */ + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + } else { + erval.encoded = computed_size; + } + + return erval; +} + diff --git a/skeletons/constr_SEQUENCE_OF.h b/skeletons/constr_SEQUENCE_OF.h new file mode 100644 index 00000000..d2560c6a --- /dev/null +++ b/skeletons/constr_SEQUENCE_OF.h @@ -0,0 +1,21 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _CONSTR_SEQUENCE_OF_H_ +#define _CONSTR_SEQUENCE_OF_H_ + +#include +#include /* Implemented using SET OF */ + +/* + * A set specialized functions dealing with the SEQUENCE OF type. + * Implemented using SET OF. + */ +#define SEQUENCE_OF_constraint SET_OF_constraint +#define SEQUENCE_OF_decode_ber SET_OF_decode_ber +der_type_encoder_f SEQUENCE_OF_encode_der; +#define SEQUENCE_OF_print SET_OF_print +#define SEQUENCE_OF_free SET_OF_free + +#endif /* _CONSTR_SET_OF_H_ */ diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c new file mode 100644 index 00000000..f1df9c1b --- /dev/null +++ b/skeletons/constr_SET.c @@ -0,0 +1,682 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include /* for ntohl() */ +#include /* for assert() */ + +/* + * Number of bytes left for this structure. + * (ctx->left) indicates the number of bytes _transferred_ for the structure. + * (size) contains the number of bytes in the buffer passed. + */ +#define LEFT ((sizeleft)?size:ctx->left) + +/* + * If the subprocessor function returns with an indication that it wants + * more data, it may well be a fatal decoding problem, because the + * size is constrained by the 's L, even if the buffer size allows + * reading more data. + * For example, consider the buffer containing the following TLVs: + * ... + * The TLV length clearly indicates that one byte is expected in V, but + * if the V processor returns with "want more data" even if the buffer + * contains way more data than the V processor have seen. + */ +#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size) + +/* + * This macro "eats" the part of the buffer which is definitely "consumed", + * i.e. was correctly converted into local representation or rightfully skipped. + */ +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr += num; \ + size -= num; \ + if(ctx->left >= 0) \ + ctx->left -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Switch to the next phase of parsing. + */ +#define NEXT_PHASE(ctx) do { \ + ctx->phase++; \ + ctx->step = 0; \ + } while(0) + +/* + * Return a standardized complex structure. + */ +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +/* + * Tags are canonically sorted in the tag2element map. + */ +static int +_t2e_cmp(const void *ap, const void *bp) { + const asn1_SET_tag2member_t *a = ap; + const asn1_SET_tag2member_t *b = bp; + int a_class = BER_TAG_CLASS(a->el_tag); + int b_class = BER_TAG_CLASS(b->el_tag); + + if(a_class == b_class) { + ber_tlv_tag_t a_value = BER_TAG_VALUE(a->el_tag); + ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag); + + if(a_value == b_value) + return 0; + else if(a_value < b_value) + return -1; + else + return 1; + } else if(a_class < b_class) { + return -1; + } else { + return 1; + } +} + +/* + * The decoder of the SET type. + */ +ber_dec_rval_t +SET_decode_ber(asn1_TYPE_descriptor_t *sd, + void **struct_ptr, void *ptr, size_t size, int tag_mode) { + /* + * Bring closer parts of structure description. + */ + asn1_SET_specifics_t *specs = sd->specifics; + asn1_SET_element_t *elements = specs->elements; + + /* + * Parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + ber_dec_ctx_t *ctx; /* Decoder context */ + + ber_tlv_tag_t tlv_tag; /* T from TLV */ + //ber_tlv_len_t tlv_len; /* L from TLV */ + ber_dec_rval_t rval; /* Return code from subparsers */ + + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + int edx; /* SET element's index */ + + ASN_DEBUG("Decoding %s as SET", sd->name); + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) { + RETURN(RC_FAIL); + } + } + + /* + * Restore parsing context. + */ + ctx = (st + specs->ctx_offset); + + /* + * Start to parse where left previously + */ + switch(ctx->phase) { + case 0: + /* + * PHASE 0. + * Check that the set of tags associated with given structure + * perfectly fits our expectations. + */ + + rval = ber_check_tags(sd, ctx, ptr, size, + tag_mode, &ctx->left, 0); + if(rval.code != RC_OK) { + ASN_DEBUG("%s tagging check failed: %d", + sd->name, rval.code); + consumed_myself += rval.consumed; + RETURN(rval.code); + } + + if(ctx->left >= 0) + ctx->left += rval.consumed; /* ?Substracted below! */ + ADVANCE(rval.consumed); + + NEXT_PHASE(ctx); + + ASN_DEBUG("Structure advertised %ld bytes, " + "buffer contains %ld", (long)ctx->left, (long)size); + + /* Fall through */ + case 1: + /* + * PHASE 1. + * From the place where we've left it previously, + * try to decode the next member from the list of + * this structure's elements. + * (ctx->step) stores the member being processed + * between invocations and the microphase {0,1} of parsing + * that member: + * step = (2 * + ). + * Note, however, that the elements in BER may arrive out of + * order, yet DER mandates that they shall arive in the + * canonical order of their tags. So, there is a room + * for optimization. + */ + for(edx = (ctx->step >> 1); edx < specs->elements_count; + ctx->step = (ctx->step & ~1) + 2, + edx = (ctx->step >> 1)) { + void *memb_ptr; /* Pointer to the member */ + void *memb_ptr2; /* Pointer to that pointer */ + ssize_t tag_len; /* Length of TLV's T */ + + if(ctx->step & 1) + goto microphase2; + + /* + * MICROPHASE 1: Synchronize decoding. + */ + + if(ctx->left == 0) + /* + * No more things to decode. + * Exit out of here and check whether all mandatory + * elements have been received (in the next phase). + */ + break; + + /* + * Fetch the T from TLV. + */ + tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tag_len) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + if(ctx->left < 0 && ((uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((uint8_t *)ptr)[1] == 0) { + /* + * Found the terminator of the + * indefinite length structure. + * Invoke the generic finalization function. + */ + goto phase3; + } + } + + if(BER_TAGS_EQUAL(tlv_tag, elements[edx].tag)) { + /* + * The elements seem to go in order. + * This is not particularly strange, + * but is not strongly anticipated either. + */ + } else { + asn1_SET_tag2member_t *t2m; + asn1_SET_tag2member_t key; + + key.el_tag = tlv_tag; + t2m = bsearch(&key, specs->tag2el, specs->tag2el_count, + sizeof(specs->tag2el[0]), _t2e_cmp); + if(t2m) { + /* + * Found the element corresponding to the tag. + */ + edx = t2m->el_no; + ctx->step = 2 * edx; + } else if(specs->extensible == 0) { + ASN_DEBUG("Unexpected tag %s " + "in non-extensible SET %s", + ber_tlv_tag_string(tlv_tag), sd->name); + RETURN(RC_FAIL); + } else { + /* Skip this tag */ + ssize_t skip; + + ASN_DEBUG("Skipping unknown tag %s", + ber_tlv_tag_string(tlv_tag)); + + skip = ber_skip_length( + BER_TLV_CONSTRUCTED(ptr), + ptr + tag_len, LEFT - tag_len); + + switch(skip) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + ADVANCE(skip + tag_len); + ctx->step -= 2; + edx--; + continue; /* Try again with the next tag */ + } + } + + /* + * MICROPHASE 2: Invoke the member-specific decoder. + */ + ctx->step |= 1; /* Confirm entering next microphase */ + microphase2: + + /* + * Check for duplications: must not overwrite + * already decoded elements. + */ + if(ASN_SET_ISPRESENT2(st + specs->pres_offset, edx)) { + ASN_DEBUG("Duplicate element %d", edx); + RETURN(RC_FAIL); + } + + /* + * Compute the position of the member inside a structure, + * and also a type of containment (it may be contained + * as pointer or using inline inclusion). + */ + if(elements[edx].optional) { + /* Optional member, hereby, a simple pointer */ + memb_ptr2 = (char *)st + elements[edx].memb_offset; + } else { + /* + * A pointer to a pointer + * holding the start of the structure + */ + memb_ptr = (char *)st + elements[edx].memb_offset; + memb_ptr2 = &memb_ptr; + } + /* + * Invoke the member fetch routine according to member's type + */ + rval = elements[edx].type->ber_decoder( + (void *)elements[edx].type, + memb_ptr2, ptr, LEFT, + elements[edx].tag_mode); + switch(rval.code) { + case RC_OK: + ASN_SET_MKPRESENT(st + specs->pres_offset, edx); + break; + case RC_WMORE: /* More data expected */ + if(!SIZE_VIOLATION) { + ADVANCE(rval.consumed); + RETURN(RC_WMORE); + } + /* Fail through */ + case RC_FAIL: /* Fatal error */ + RETURN(RC_FAIL); + } /* switch(rval) */ + + ADVANCE(rval.consumed); + } /* for(all structure members) */ + + phase3: + ctx->phase = 3; + /* Fall through */ + case 3: + case 4: /* Only 00 is expected */ + ASN_DEBUG("SET %s Leftover: %ld, size = %ld", + sd->name, (long)ctx->left, (long)size); + + /* + * Skip everything until the end of the SET. + */ + while(ctx->left) { + ssize_t tl, ll; + + tl = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tl) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + /* + * If expected <0><0>... + */ + if(ctx->left < 0 + && ((uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((uint8_t *)ptr)[1] == 0) { + /* + * Correctly finished with <0><0>. + */ + ADVANCE(2); + ctx->left++; + ctx->phase = 4; + continue; + } + } + + if(specs->extensible == 0 || ctx->phase == 4) { + ASN_DEBUG("Unexpected continuation " + "of a non-extensible type %s", + sd->name); + RETURN(RC_FAIL); + } + + ll = ber_skip_length( + BER_TLV_CONSTRUCTED(ptr), + ptr + tl, LEFT - tl); + switch(ll) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + ADVANCE(tl + ll); + } + + ctx->phase = 5; + case 5: + /* + * Check that all mandatory elements are present. + */ + for(edx = 0; edx < specs->elements_count; + edx += (8 * sizeof(specs->_mandatory_elements[0]))) { + unsigned int midx, pres, must; + + midx = edx/(8 * sizeof(specs->_mandatory_elements[0])); + pres = ((unsigned int *)(st+specs->pres_offset))[midx]; + must = ntohl(specs->_mandatory_elements[midx]); + + if((pres & must) == must) { + /* + * Yes, everything seems to be in place. + */ + } else { + ASN_DEBUG("One or more mandatory elements " + "of a SET %s %d (%08x.%08x)=%08x " + "are not present", + sd->name, + midx, + pres, + must, + (~(pres & must) & must) + ); + RETURN(RC_FAIL); + } + } + + NEXT_PHASE(ctx); + } + + RETURN(RC_OK); +} + +/* + * The DER encoder of the SET type. + */ +der_enc_rval_t +SET_encode_der(asn1_TYPE_descriptor_t *sd, + void *ptr, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SET_specifics_t *specs = sd->specifics; + size_t computed_size = 0; + der_enc_rval_t my_erval; + int t2m_build_own = (specs->tag2el_count != specs->elements_count); + asn1_SET_tag2member_t *t2m; + int t2m_count; + ssize_t ret; + int edx; + + /* + * Use existing, or build our own tags map. + */ + if(t2m_build_own) { + t2m = alloca(specs->elements_count * sizeof(t2m[0])); + t2m_count = 0; + } else { + /* + * There is no untagged CHOICE in this SET. + * Employ existing table. + */ + t2m = specs->tag2el; + t2m_count = specs->tag2el_count; + } + + /* + * Gather the length of the underlying members sequence. + */ + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SET_element_t *elm = &specs->elements[edx]; + der_enc_rval_t erval; + void *memb_ptr; + + /* + * Compute the length of the encoding of this member. + */ + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + if(!memb_ptr) { + if(t2m_build_own) { + t2m[t2m_count].el_no = edx; + t2m[t2m_count].el_tag = 0; + t2m_count++; + } + continue; + } + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + } + erval = elm->type->der_encoder(elm->type, memb_ptr, + elm->tag_mode, elm->tag, + 0, 0); + if(erval.encoded == -1) + return erval; + computed_size += erval.encoded; + + /* + * Remember the outmost tag of this member. + */ + if(t2m_build_own) { + t2m[t2m_count].el_no = edx; + t2m[t2m_count].el_tag = asn1_TYPE_outmost_tag( + elm->type, memb_ptr, elm->tag_mode, elm->tag); + t2m_count++; + } else { + /* + * No dynamic sorting is necessary. + */ + } + } + + /* + * Finalize order of the components. + */ + assert(t2m_count == specs->elements_count); + if(t2m_build_own) { + /* + * Sort the underlying members according to their + * canonical tags order. DER encoding mandates it. + */ + qsort(t2m, t2m_count, sizeof(specs->tag2el[0]), _t2e_cmp); + } else { + /* + * Tags are already sorted by the compiler. + */ + } + + /* + * Encode the TLV for the sequence itself. + */ + ret = der_write_tags(sd, computed_size, tag_mode, tag, cb, app_key); + if(ret == -1) { + my_erval.encoded = -1; + my_erval.failed_type = sd; + my_erval.structure_ptr = ptr; + return my_erval; + } + my_erval.encoded = computed_size + ret; + + if(!cb) return my_erval; + + /* + * Encode all members. + */ + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SET_element_t *elm; + der_enc_rval_t erval; + void *memb_ptr; + + /* Encode according to the tag order */ + elm = &specs->elements[t2m[edx].el_no]; + + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + if(!memb_ptr) continue; + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + } + erval = elm->type->der_encoder(elm->type, memb_ptr, + elm->tag_mode, elm->tag, + cb, app_key); + if(erval.encoded == -1) + return erval; + computed_size -= erval.encoded; + } + + if(computed_size != 0) { + /* + * Encoded size is not equal to the computed size. + */ + my_erval.encoded = -1; + my_erval.failed_type = sd; + my_erval.structure_ptr = ptr; + } + + return my_erval; +} + +int +SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SET_specifics_t *specs = td->specifics; + int edx; + int ret; + + if(!sptr) return cb("", 8, app_key); + + /* Dump preamble */ + if(cb(td->name, strlen(td->name), app_key) + || cb(" ::= {\n", 7, app_key)) + return -1; + + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SET_element_t *elm = &specs->elements[edx]; + const void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); + if(!memb_ptr) continue; + } else { + memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); + } + + /* Indentation */ + for(ret = 0; ret < ilevel; ret++) cb(" ", 1, app_key); + + /* Print the member's name and stuff */ + if(cb(elm->name, strlen(elm->name), app_key) + || cb(": ", 2, app_key)) + return -1; + + /* Print the member itself */ + ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 4, + cb, app_key); + if(ret) return ret; + + ret = cb("\n", 1, app_key); + if(ret) return ret; + } + + /* Indentation */ + for(ret = 0; ret < ilevel - 4; ret++) cb(" ", 1, app_key); + + return cb("}", 1, app_key); +} + +void +SET_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) { + asn1_SET_specifics_t *specs = td->specifics; + int edx; + + if(!td || !ptr) + return; + + ASN_DEBUG("Freeing %s as SET", td->name); + + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SET_element_t *elm = &specs->elements[edx]; + void *memb_ptr; + if(elm->optional) { + memb_ptr = *(void **)((char *)ptr + elm->memb_offset); + if(memb_ptr) + elm->type->free_struct(elm->type, memb_ptr, 0); + } else { + memb_ptr = (void *)((char *)ptr + elm->memb_offset); + elm->type->free_struct(elm->type, memb_ptr, 1); + } + } + + if(!contents_only) { + FREEMEM(ptr); + } +} + +int +SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + asn1_SET_specifics_t *specs = td->specifics; + int edx; + + if(!sptr) { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + /* + * Iterate over structure members and check their validity. + */ + for(edx = 0; edx < specs->elements_count; edx++) { + asn1_SET_element_t *elm = &specs->elements[edx]; + const void *memb_ptr; + + if(elm->optional) { + memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset); + if(!memb_ptr) { + if(ASN_SET_ISPRESENT2( + &(specs->_mandatory_elements), edx)) { + _ASN_ERRLOG( + "%s: mandatory element " + "%s absent", + td->name, elm->name); + return -1; + } + continue; + } + } else { + memb_ptr = (const void *)((const char *)sptr + elm->memb_offset); + } + + return elm->type->check_constraints(elm->type, memb_ptr, + app_errlog, app_key); + } + + return 0; +} diff --git a/skeletons/constr_SET.h b/skeletons/constr_SET.h new file mode 100644 index 00000000..c0ac07f5 --- /dev/null +++ b/skeletons/constr_SET.h @@ -0,0 +1,90 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _CONSTR_SET_H_ +#define _CONSTR_SET_H_ + +#include + +/* + * Description of a single element of the SET type. + */ +typedef struct asn1_SET_element_s { + int memb_offset; /* Offset of the element */ + int optional; /* Whether the element is optional */ + ber_tlv_tag_t tag; /* Outmost (most immediate) tag */ + int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */ + asn1_TYPE_descriptor_t + *type; /* Member type descriptor */ + char *name; /* ASN.1 identifier of the element */ +} asn1_SET_element_t; + +/* + * Map between the outmost tag of the element and the corresponding + * element's index. + */ +typedef struct asn1_SET_tag2member_s { + ber_tlv_tag_t el_tag; /* Outmost tag of the member */ + int el_no; /* Index of the associated member, base 0 */ +} asn1_SET_tag2member_t; + +typedef struct asn1_SET_specifics_s { + /* + * Target structure description. + */ + int struct_size; /* Size of the target structure. */ + int ctx_offset; /* Offset of the ber_dec_ctx_t member */ + int pres_offset; /* Offset of _presence_map member */ + + /* + * Members of the SET structure. + */ + asn1_SET_element_t *elements; + int elements_count; + + /* + * Tags to members mapping table (sorted). + */ + asn1_SET_tag2member_t *tag2el; + int tag2el_count; + + /* + * Extensions-related stuff. + */ + int extensible; /* Whether SET is extensible */ + unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ +} asn1_SET_specifics_t; + +/* + * A set specialized functions dealing with the SET type. + */ +asn_constr_check_f SET_constraint; +ber_type_decoder_f SET_decode_ber; +der_type_encoder_f SET_encode_der; +asn_struct_print_f SET_print; +asn_struct_free_f SET_free; + +/*********************** + * Some handy helpers. * + ***********************/ + +/* + * Figure out whether the SET member indicated by PR_x has already been decoded. + * It is very simple bitfield test, despite its visual complexity. + */ +#define ASN_SET_ISPRESENT(set_ptr, PR_x) \ + ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map)) +#define ASN_SET_ISPRESENT2(map_ptr, PR_x) \ + (((unsigned int *)(map_ptr)) \ + [(PR_x) / (8 * sizeof(unsigned int))] \ + & (1 << ((8 * sizeof(unsigned int)) - 1 \ + - ((PR_x) % (8 * sizeof(unsigned int)))))) + +#define ASN_SET_MKPRESENT(map_ptr, PR_x) \ + (((unsigned int *)(map_ptr)) \ + [(PR_x) / (8 * sizeof(unsigned int))] \ + |= (1 << ((8 * sizeof(unsigned int)) - 1 \ + - ((PR_x) % (8 * sizeof(unsigned int)))))) + +#endif /* _CONSTR_SET_H_ */ diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c new file mode 100644 index 00000000..9dcf638f --- /dev/null +++ b/skeletons/constr_SET_OF.c @@ -0,0 +1,530 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include + +/* + * Number of bytes left for this structure. + * (ctx->left) indicates the number of bytes _transferred_ for the structure. + * (size) contains the number of bytes in the buffer passed. + */ +#define LEFT ((sizeleft)?size:ctx->left) + +/* + * If the subprocessor function returns with an indication that it wants + * more data, it may well be a fatal decoding problem, because the + * size is constrained by the 's L, even if the buffer size allows + * reading more data. + * For example, consider the buffer containing the following TLVs: + * ... + * The TLV length clearly indicates that one byte is expected in V, but + * if the V processor returns with "want more data" even if the buffer + * contains way more data than the V processor have seen. + */ +#define SIZE_VIOLATION (ctx->left != -1 && ctx->left <= size) + +/* + * This macro "eats" the part of the buffer which is definitely "consumed", + * i.e. was correctly converted into local representation or rightfully skipped. + */ +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr += num; \ + size -= num; \ + if(ctx->left >= 0) \ + ctx->left -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Switch to the next phase of parsing. + */ +#define NEXT_PHASE(ctx) do { \ + ctx->phase++; \ + ctx->step = 0; \ + } while(0) +#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) + +/* + * Return a standardized complex structure. + */ +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +/* + * The decoder of the SET OF type. + */ +ber_dec_rval_t +SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd, + void **struct_ptr, void *ptr, size_t size, int tag_mode) { + /* + * Bring closer parts of structure description. + */ + asn1_SET_OF_specifics_t *specs = sd->specifics; + asn1_SET_OF_element_t *element = specs->element; + + /* + * Parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + ber_dec_ctx_t *ctx; /* Decoder context */ + + ber_tlv_tag_t tlv_tag; /* T from TLV */ + //ber_tlv_len_t tlv_len; /* L from TLV */ + ber_dec_rval_t rval; /* Return code from subparsers */ + + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + + ASN_DEBUG("Decoding %s as SET OF", sd->name); + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) { + RETURN(RC_FAIL); + } + } + + /* + * Restore parsing context. + */ + ctx = (st + specs->ctx_offset); + + /* + * Start to parse where left previously + */ + switch(ctx->phase) { + case 0: + /* + * PHASE 0. + * Check that the set of tags associated with given structure + * perfectly fits our expectations. + */ + + rval = ber_check_tags(sd, ctx, ptr, size, + tag_mode, &ctx->left, 0); + if(rval.code != RC_OK) { + ASN_DEBUG("%s tagging check failed: %d", + sd->name, rval.code); + consumed_myself += rval.consumed; + RETURN(rval.code); + } + + if(ctx->left >= 0) + ctx->left += rval.consumed; /* ?Substracted below! */ + ADVANCE(rval.consumed); + + ASN_DEBUG("Structure consumes %ld bytes, " + "buffer %ld", (long)ctx->left, (long)size); + + NEXT_PHASE(ctx); + /* Fall through */ + case 1: + /* + * PHASE 1. + * From the place where we've left it previously, + * try to decode the next item. + */ + for(;; ctx->step = 0) { + ssize_t tag_len; /* Length of TLV's T */ + + if(ctx->step & 1) + goto microphase2; + + /* + * MICROPHASE 1: Synchronize decoding. + */ + + if(ctx->left == 0) { + ASN_DEBUG("End of SET OF %s", sd->name); + /* + * No more things to decode. + * Exit out of here. + */ + PHASE_OUT(ctx); + RETURN(RC_OK); + } + + /* + * Fetch the T from TLV. + */ + tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tag_len) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + if(ctx->left < 0 && ((uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((uint8_t *)ptr)[1] == 0) { + /* + * Found the terminator of the + * indefinite length structure. + */ + break; + } + } + + /* Outmost tag may be unknown and cannot be fetched/compared */ + if(element->tag != -1) { + if(BER_TAGS_EQUAL(tlv_tag, element->tag)) { + /* + * The new list member of expected type has arrived. + */ + } else { + ASN_DEBUG("Unexpected tag %s fixed SET OF %s", + ber_tlv_tag_string(tlv_tag), sd->name); + ASN_DEBUG("%s SET OF has tag %s", + sd->name, ber_tlv_tag_string(element->tag)); + RETURN(RC_FAIL); + } + } + + /* + * MICROPHASE 2: Invoke the member-specific decoder. + */ + ctx->step |= 1; /* Confirm entering next microphase */ + microphase2: + + /* + * Invoke the member fetch routine according to member's type + */ + rval = element->type->ber_decoder( + (void *)element->type, + &ctx->ptr, ptr, LEFT, 0); + ASN_DEBUG("In %s SET OF %s code %d consumed %d", + sd->name, element->type->name, + rval.code, (int)rval.consumed); + switch(rval.code) { + case RC_OK: + { + A_SET_OF(void) *list = st; + if(ASN_SET_ADD(list, ctx->ptr) != 0) + RETURN(RC_FAIL); + else + ctx->ptr = 0; + } + break; + case RC_WMORE: /* More data expected */ + if(!SIZE_VIOLATION) { + ADVANCE(rval.consumed); + RETURN(RC_WMORE); + } + /* Fall through */ + case RC_FAIL: /* Fatal error */ + RETURN(RC_FAIL); + } /* switch(rval) */ + + ADVANCE(rval.consumed); + } /* for(all list members) */ + + NEXT_PHASE(ctx); + case 2: + /* + * Read in all "end of content" TLVs. + */ + while(ctx->left < 0) { + if(LEFT < 2) { + if(LEFT > 0 && ((char *)ptr)[0] != 0) { + /* Unexpected tag */ + RETURN(RC_FAIL); + } else { + RETURN(RC_WMORE); + } + } + if(((char *)ptr)[0] == 0 + && ((char *)ptr)[1] == 0) { + ADVANCE(2); + ctx->left++; + } else { + RETURN(RC_FAIL); + } + } + + PHASE_OUT(ctx); + } + + RETURN(RC_OK); +} + +/* + * Internally visible buffer holding a single encoded element. + */ +struct _el_buffer { + uint8_t *buf; + size_t length; + size_t size; +}; +/* Append bytes to the above structure */ +static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { + struct _el_buffer *el_buf = el_buf_ptr; + + if(el_buf->length + size > el_buf->size) + return -1; + + memcpy(el_buf->buf + el_buf->length, buffer, size); + + el_buf->length += size; + return 0; +} +static int _el_buf_cmp(const void *ap, const void *bp) { + const struct _el_buffer *a = ap; + const struct _el_buffer *b = bp; + int ret; + size_t common_len; + + if(a->length < b->length) + common_len = a->length; + else + common_len = b->length; + + ret = memcmp(a->buf, b->buf, common_len); + if(ret == 0) { + if(a->length < b->length) + ret = -1; + else if(a->length > b->length) + ret = 1; + } + + return ret; +} + +/* + * The DER encoder of the SET OF type. + */ +der_enc_rval_t +SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SET_OF_specifics_t *specs = sd->specifics; + asn1_SET_OF_element_t *elm = specs->element; + asn1_TYPE_descriptor_t *elm_type = elm->type; + der_type_encoder_f *der_encoder = elm_type->der_encoder; + A_SET_OF(void) *list = ptr; + size_t computed_size = 0; + ssize_t encoding_size = 0; + struct _el_buffer *encoded_els; + size_t max_encoded_len = 1; + der_enc_rval_t erval; + int ret; + int edx; + + ASN_DEBUG("Estimating size for SET OF %s", sd->name); + + /* + * Gather the length of the underlying members sequence. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); + if(erval.encoded == -1) + return erval; + computed_size += erval.encoded; + + /* Compute maximum encoding's size */ + if(max_encoded_len < erval.encoded) + max_encoded_len = erval.encoded; + } + + /* + * Encode the TLV for the sequence itself. + */ + encoding_size = der_write_tags(sd, computed_size, tag_mode, tag, + cb, app_key); + if(encoding_size == -1) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + computed_size += encoding_size; + + if(!cb) { + erval.encoded = computed_size; + return erval; + } + + /* + * DER mandates dynamic sorting of the SET OF elements + * according to their encodings. Build an array of the + * encoded elements. + */ + encoded_els = MALLOC(list->count * sizeof(encoded_els[0])); + if(encoded_els == NULL) { + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + + ASN_DEBUG("Encoding members of %s SET OF", sd->name); + + /* + * Encode all members. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + struct _el_buffer *encoded_el = &encoded_els[edx]; + + /* + * Prepare space for encoding. + */ + encoded_el->buf = MALLOC(max_encoded_len); + if(encoded_el->buf) { + encoded_el->length = 0; + encoded_el->size = max_encoded_len; + } else { + for(edx--; edx >= 0; edx--) + FREEMEM(encoded_els[edx].buf); + FREEMEM(encoded_els); + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + return erval; + } + + /* + * Encode the member into the prepared space. + */ + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, + _el_addbytes, encoded_el); + if(erval.encoded == -1) { + for(; edx >= 0; edx--) + FREEMEM(encoded_els[edx].buf); + FREEMEM(encoded_els); + return erval; + } + encoding_size += erval.encoded; + } + + /* + * Sort the encoded elements according to their encoding. + */ + qsort(encoded_els, list->count, sizeof(encoded_els[0]), _el_buf_cmp); + + /* + * Report encoded elements to the application. + * Dispose of temporary sorted members table. + */ + ret = 0; + for(edx = 0; edx < list->count; edx++) { + struct _el_buffer *encoded_el = &encoded_els[edx]; + /* Report encoded chunks to the application */ + if(ret == 0 + && cb(encoded_el->buf, encoded_el->length, app_key) == -1) + ret = -1; + FREEMEM(encoded_el->buf); + } + FREEMEM(encoded_els); + + if(ret || computed_size != encoding_size) { + /* + * Standard callback failed, or + * encoded size is not equal to the computed size. + */ + erval.encoded = -1; + erval.failed_type = sd; + erval.structure_ptr = ptr; + } else { + erval.encoded = computed_size; + } + + return erval; +} + +int +SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn1_SET_OF_specifics_t *specs = td->specifics; + asn1_SET_OF_element_t *element = specs->element; + const A_SET_OF(void) *list = sptr; + int ret; + int i; + + if(!sptr) return cb("", 8, app_key); + + /* Dump preamble */ + if(cb(td->name, strlen(td->name), app_key) + || cb(" ::= {\n", 7, app_key)) + return -1; + + for(i = 0; i < list->count; i++) { + const void *memb_ptr = list->array[i]; + if(!memb_ptr) continue; + + /* Indentation */ + for(ret = 0; ret < ilevel; ret++) cb(" ", 1, app_key); + + ret = element->type->print_struct(element->type, memb_ptr, + ilevel + 4, cb, app_key); + if(ret) return ret; + + ret = cb("\n", 1, app_key); + if(ret) return ret; + } + + /* Indentation */ + for(ret = 0; ret < ilevel - 4; ret++) cb(" ", 1, app_key); + + return cb("}", 1, app_key); +} + +void +SET_OF_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) { + if(td && ptr) { + asn1_SET_OF_specifics_t *specs = td->specifics; + asn1_SET_OF_element_t *element = specs->element; + A_SET_OF(void) *list = ptr; + int i; + + /* + * Could not use set_of_empty() because of (*free) + * incompatibility. + */ + for(i = 0; i < list->count; i++) { + void *memb_ptr = list->array[i]; + if(memb_ptr) + element->type->free_struct(element->type, memb_ptr, 0); + } + list->count = 0; /* Just in case */ + + if(!contents_only) { + FREEMEM(ptr); + } + } +} + +int +SET_OF_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + asn1_SET_OF_specifics_t *specs = td->specifics; + asn1_SET_OF_element_t *element = specs->element; + const A_SET_OF(void) *list = sptr; + int i; + + if(!sptr) { + _ASN_ERRLOG("%s: value not given", td->name); + return -1; + } + + for(i = 0; i < list->count; i++) { + const void *memb_ptr = list->array[i]; + if(!memb_ptr) continue; + return element->type->check_constraints(element->type, memb_ptr, + app_errlog, app_key); + } + + return 0; +} diff --git a/skeletons/constr_SET_OF.h b/skeletons/constr_SET_OF.h new file mode 100644 index 00000000..814774dc --- /dev/null +++ b/skeletons/constr_SET_OF.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2003 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _CONSTR_SET_OF_H_ +#define _CONSTR_SET_OF_H_ + +#include + +typedef struct asn1_SET_OF_element_s { + ber_tlv_tag_t tag; /* Outmost (most immediate) tag */ + asn1_TYPE_descriptor_t + *type; /* Member type descriptor */ +} asn1_SET_OF_element_t; + +typedef struct asn1_SET_OF_specifics_s { + /* + * Target structure description. + */ + int struct_size; /* Size of the target structure. */ + int ctx_offset; /* Offset of the ber_dec_ctx_t member */ + + /* + * Members of the SET OF list. + */ + asn1_SET_OF_element_t *element; +} asn1_SET_OF_specifics_t; + +/* + * A set specialized functions dealing with the SET OF type. + */ +asn_constr_check_f SET_OF_constraint; +ber_type_decoder_f SET_OF_decode_ber; +der_type_encoder_f SET_OF_encode_der; +asn_struct_print_f SET_OF_print; +asn_struct_free_f SET_OF_free; + +#endif /* _CONSTR_SET_OF_H_ */ diff --git a/skeletons/constr_TYPE.c b/skeletons/constr_TYPE.c new file mode 100644 index 00000000..9ab1bdc5 --- /dev/null +++ b/skeletons/constr_TYPE.c @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include + +static asn_app_consume_bytes_f _print2fp; + +/* + * Return the outmost tag of the type. + */ +ber_tlv_tag_t +asn1_TYPE_outmost_tag(asn1_TYPE_descriptor_t *type_descriptor, + const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) { + + if(tag_mode) + return tag; + + if(type_descriptor->tags_count) + return type_descriptor->tags[0]; + + return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0); +} + +/* + * Print the target language's structure in human readable form. + */ +int +asn_fprint(FILE *stream, asn1_TYPE_descriptor_t *td, const void *struct_ptr) { + if(!stream) stream = stdout; + if(!td || !struct_ptr) { + errno = EINVAL; + return -1; + } + + /* Invoke type-specific printer */ + if(td->print_struct(td, struct_ptr, 4, _print2fp, stream)) + return -1; + + /* Terminate the output */ + if(_print2fp("\n", 1, stream)) + return -1; + + return fflush(stream); +} + +/* Dump the data into the specified stdio stream */ +static int +_print2fp(const void *buffer, size_t size, void *app_key) { + FILE *stream = app_key; + + if(fwrite(buffer, 1, size, stream) != size) + return -1; + + return 0; +} + diff --git a/skeletons/constr_TYPE.h b/skeletons/constr_TYPE.h new file mode 100644 index 00000000..c7cfb22b --- /dev/null +++ b/skeletons/constr_TYPE.h @@ -0,0 +1,98 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _CONSTR_TYPE_H_ +#define _CONSTR_TYPE_H_ + +#include /* System-dependent types */ +#include +#include +#include +#include +#include + +struct asn1_TYPE_descriptor_s; /* Forward declaration */ + +/* + * Free the structure according to its specification. + * If (free_contents_only) is set, the wrapper structure itself (struct_ptr) + * will not be freed. (It may be useful in case the structure is allocated + * statically or arranged on the stack, yet its elements are allocated + * dynamically.) + */ +typedef void (asn_struct_free_f)( + struct asn1_TYPE_descriptor_s *type_descriptor, + void *struct_ptr, int free_contents_only); + +/* + * Print the structure according to its specification. + */ +typedef int (asn_struct_print_f)( + struct asn1_TYPE_descriptor_s *type_descriptor, + const void *struct_ptr, + int level, /* Indentation level */ + asn_app_consume_bytes_f *callback, void *app_key); + +/* + * Return the outmost tag of the type. + * If the type is untagged CHOICE, the dynamic operation is performed. + * NOTE: This function pointer type is only useful internally. + * Do not use it in your application. + */ +typedef ber_tlv_tag_t (asn_outmost_tag_f)( + struct asn1_TYPE_descriptor_s *type_descriptor, + const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag); +/* The instance of the above function type */ +asn_outmost_tag_f asn1_TYPE_outmost_tag; + + +/* + * The definitive description of the destination language's structure. + */ +typedef struct asn1_TYPE_descriptor_s { + char *name; /* A name of the ASN.1 type */ + + /* + * Generalized functions for dealing with the specific type. + * May be directly invoked by applications. + */ + asn_constr_check_f *check_constraints; /* Constraints validator */ + ber_type_decoder_f *ber_decoder; /* Free-form BER decoder */ + der_type_encoder_f *der_encoder; /* Canonical DER encoder */ + asn_struct_print_f *print_struct; /* Human readable output */ + asn_struct_free_f *free_struct; /* Free the structure */ + + /* + * Functions used internally. Should not be used by applications. + */ + asn_outmost_tag_f *outmost_tag; /* */ + + /* + * Tags that are expected, with some of their vital properties. + */ + ber_tlv_tag_t *tags; /* At least one tag must be specified */ + int tags_count; /* Number of tags which are expected */ + int tags_impl_skip; /* Tags to skip in implicit mode */ + int last_tag_form; /* Acceptable form of the tag (prim, constr) */ + + /* + * Additional information describing the type, used by appropriate + * functions above. + */ + void *specifics; +} asn1_TYPE_descriptor_t; + +/* + * This function is a wrapper around (td)->print_struct, which prints out + * the contents of the target language's structure (struct_ptr) into the + * file pointer (stream) in human readable form. + * RETURN VALUES: + * 0: The structure is printed. + * -1: Problem dumping the structure. + */ +int asn_fprint(FILE *stream, /* Destination stream descriptor */ + asn1_TYPE_descriptor_t *td, /* ASN.1 type descriptor */ + const void *struct_ptr); /* Structure to be printed */ + +#endif /* _CONSTR_TYPE_H_ */ diff --git a/skeletons/constraints.c b/skeletons/constraints.c new file mode 100644 index 00000000..13a1b402 --- /dev/null +++ b/skeletons/constraints.c @@ -0,0 +1,111 @@ +#include +#include + +int +asn_generic_no_constraint(asn1_TYPE_descriptor_t *type_descriptor, + const void *struct_ptr, asn_app_consume_bytes_f *cb, void *key) { + /* Nothing to check */ + return 0; +} + +int +asn_generic_unknown_constraint(asn1_TYPE_descriptor_t *type_descriptor, + const void *struct_ptr, asn_app_consume_bytes_f *cb, void *key) { + /* Unknown how to check */ + return 0; +} + +struct __fill_errbuf_arg { + char *errbuf; + size_t errlen; + size_t erroff; +}; + +static int +__fill_errbuf(const void *buffer, size_t size, void *app_key) { + struct __fill_errbuf_arg *arg = app_key; + size_t avail = arg->errlen - arg->erroff; + + if(avail > size) + avail = size + 1; + + switch(avail) { + default: + memcpy(arg->errbuf + arg->erroff, buffer, avail - 1); + arg->erroff += avail - 1; + case 1: + arg->errbuf[arg->erroff] = '\0'; + case 0: + return 0; + } + +} + +int +asn_check_constraints(asn1_TYPE_descriptor_t *type_descriptor, + const void *struct_ptr, char *errbuf, size_t *errlen) { + + if(errlen) { + struct __fill_errbuf_arg arg; + int ret; + + arg.errbuf = errbuf; + arg.errlen = *errlen; + arg.erroff = 0; + + ret = type_descriptor->check_constraints(type_descriptor, + struct_ptr, __fill_errbuf, &arg); + + if(ret == -1) + *errlen = arg.erroff; + + return ret; + } else { + return type_descriptor->check_constraints(type_descriptor, + struct_ptr, 0, 0); + } +} + +void +_asn_i_log_error(asn_app_consume_bytes_f *cb, void *key, const char *fmt, ...) { + char buf[64]; + char *p; + va_list ap; + ssize_t ret; + size_t len; + + va_start(ap, fmt); + ret = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + if(ret < 0) { + /* + * The libc on this system is broken. + */ + ret = sizeof("") - 1; + memcpy(buf, "", ret + 1); + /* Fall through */ + } + + if(ret < sizeof(buf)) { + cb(buf, ret, key); + return; + } + + /* + * More space required to hold the message. + */ + len = ret + 1; + p = alloca(len); + if(!p) return; /* Can't be though. */ + + + va_start(ap, fmt); + ret = vsnprintf(buf, len, fmt, ap); + va_end(ap); + if(ret < 0 || ret >= len) { + ret = sizeof("") - 1; + memcpy(buf, "", ret + 1); + } + + cb(buf, ret, key); +} diff --git a/skeletons/constraints.h b/skeletons/constraints.h new file mode 100644 index 00000000..255b6ae2 --- /dev/null +++ b/skeletons/constraints.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _ASN1_CONSTRAINTS_VALIDATOR_H_ +#define _ASN1_CONSTRAINTS_VALIDATOR_H_ + +#include /* System-dependent types */ + +struct asn1_TYPE_descriptor_s; /* Forward declaration */ + +/* + * Validate the structure according to the ASN.1 constraints. + * If errbuf and errlen are given, they shall be pointing to the appropriate + * buffer space and its length before calling this function. Alternatively, + * they could be passed as NULL's. If constraints validation fails, + * errlen will contain the actual number of bytes taken from the errbuf + * to encode an error message (properly 0-terminated). + */ +int +asn_check_constraints(struct asn1_TYPE_descriptor_s *type_descriptor, + const void *struct_ptr, /* Target language's structure */ + char *errbuf, /* Returned error description */ + size_t *errlen /* Length of the error description */ + ); + +/* + * Generic type for constraint checking callback, + * associated with every type descriptor. + */ +typedef int (asn_constr_check_f)( + struct asn1_TYPE_descriptor_s *type_descriptor, + const void *struct_ptr, + asn_app_consume_bytes_f *optional_app_errlog, /* Log the error */ + void *optional_app_key /* Opaque key passed to app_errlog */ + ); + +/******************************* + * INTERNALLY USEFUL FUNCTIONS * + *******************************/ + +asn_constr_check_f asn_generic_no_constraint; /* No constraint whatsoever */ +asn_constr_check_f asn_generic_unknown_constraint; /* Not fully supported */ + +/* + * Invoke the callback with a complete error message. + */ +#define _ASN_ERRLOG(fmt, args...) do { \ + if(app_errlog) \ + _asn_i_log_error(app_errlog, \ + app_key, fmt, ##args); \ + break; \ + } while(0); +void _asn_i_log_error(asn_app_consume_bytes_f *, void *key, + const char *fmt, ...) __attribute__ ((format(printf, 3, 4))); + +#endif /* _ASN1_CONSTRAINTS_VALIDATOR_H_ */ diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c new file mode 100644 index 00000000..f275f9c1 --- /dev/null +++ b/skeletons/der_encoder.c @@ -0,0 +1,143 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include + +static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len, + asn_app_consume_bytes_f *cb, void *app_key, int constructed); + +/* + * The DER encoder of any type. + */ +der_enc_rval_t +der_encode(asn1_TYPE_descriptor_t *type_descriptor, void *struct_ptr, + asn_app_consume_bytes_f *consume_bytes, void *app_key) { + + ASN_DEBUG("DER encoder invoked for %s", + type_descriptor->name); + + /* + * Invoke type-specific encoder. + */ + return type_descriptor->der_encoder(type_descriptor, + struct_ptr, /* Pointer to the destination structure */ + 0, 0, + consume_bytes, app_key); +} + +/* + * Write out leading TL[v] sequence according to the type definition. + */ +ssize_t +der_write_tags(asn1_TYPE_descriptor_t *sd, + size_t struct_length, + int tag_mode, + ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */ + asn_app_consume_bytes_f *cb, + void *app_key) { + ber_tlv_tag_t *tags; /* Copy of tags stream */ + int tags_count; /* Number of tags */ + size_t overall_length; + ssize_t *lens; + int i; + + if(tag_mode) { + /* + * Instead of doing shaman dance like we do in ber_check_tags(), + * allocate a small array on the stack + * and initialize it appropriately. + */ + tags = alloca((sd->tags_count + (tag_mode?1:0)) + * sizeof(ber_tlv_tag_t)); + if(tags == NULL) return -1; /* Impossible on i386 */ + tags_count = sd->tags_count + + 1 /* EXPLICIT or IMPLICIT tag is given */ + - ((tag_mode==-1)?sd->tags_impl_skip:0); + /* Copy tags over */ + tags[0] = tag; + for(i = 1; i < tags_count; i++) + tags[i] = sd->tags[i - 1 + sd->tags_impl_skip]; + } else { + tags = sd->tags; + tags_count = sd->tags_count; + } + + /* No tags to write */ + if(tags_count == 0) + return 0; + + lens = alloca(tags_count * sizeof(lens[0])); + if(lens == NULL) return -1; + + /* + * Array of tags is initialized. + * Now, compute the size of the TLV pairs, from right to left. + */ + overall_length = struct_length; + for(i = tags_count - 1; i >= 0; --i) { + lens[i] = der_write_TL(tags[i], overall_length, 0, 0, 0); + if(lens[i] == -1) return -1; + overall_length += lens[i]; + lens[i] = overall_length - lens[i]; + } + + if(!cb) return overall_length - struct_length; + + ASN_DEBUG("%s %s TL sequence (%d elements)", + cb?"Encoding":"Estimating", sd->name, tags_count); + + /* + * Encode the TL sequence for real. + */ + for(i = 0; i < tags_count; i++) { + ssize_t len; + int _constr; + + /* If this one happens to be constructed, do it. */ + if(i < (tags_count - 1) || sd->last_tag_form == 1) + _constr = 1; + else _constr = 0; + + len = der_write_TL(tags[i], lens[i], cb, app_key, _constr); + if(len == -1) return -1; + } + + return overall_length - struct_length; +} + +static ssize_t +der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len, + asn_app_consume_bytes_f *cb, void *app_key, + int constructed) { + uint8_t buf[32]; + size_t size = 0; + int buf_size = cb?sizeof(buf):0; + ssize_t tmp; + + /* Serialize tag (T from TLV) into possibly zero-length buffer */ + tmp = der_tlv_tag_serialize(tag, buf, buf_size); + if(tmp == -1 || tmp > sizeof(buf)) return -1; + size += tmp; + + /* Serialize length (L from TLV) into possibly zero-length buffer */ + tmp = der_tlv_length_serialize(len, buf+size, buf_size?buf_size-size:0); + if(tmp == -1) return -1; + size += tmp; + + if(size > sizeof(buf)) + return -1; + + /* + * If callback is specified, invoke it, and check its return value. + */ + if(cb) { + if(constructed) *buf |= 0x20; + if(cb(buf, size, app_key) == -1) { + return -1; + } + } + + return size; +} diff --git a/skeletons/der_encoder.h b/skeletons/der_encoder.h new file mode 100644 index 00000000..052d9f4c --- /dev/null +++ b/skeletons/der_encoder.h @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef _DER_ENCODER_H_ +#define _DER_ENCODER_H_ + +#include + +struct asn1_TYPE_descriptor_s; /* Forward declaration */ + +/* + * Type of the return value of the der_encode function. + */ +typedef struct der_enc_rval_s { + /* + * Number of bytes encoded. + * -1 indicates failure to encode the structure. + * In this case, the members below this one are meaningful. + */ + ssize_t encoded; + + /* + * Members meaningful when (encoded == -1), for post-mortem analysis. + */ + + /* Type which cannot be encoded */ + struct asn1_TYPE_descriptor_s *failed_type; + + /* Pointer to the structure of that type */ + void *structure_ptr; +} der_enc_rval_t; + + +/* + * The DER encoder of any type. May be invoked by the application. + */ +der_enc_rval_t der_encode(struct asn1_TYPE_descriptor_s *type_descriptor, + void *struct_ptr, /* Structure to be encoded */ + asn_app_consume_bytes_f *consume_bytes_cb, + void *app_key /* Arbitrary callback argument */ + ); + +/* + * Type of the generic DER encoder. + */ +typedef der_enc_rval_t (der_type_encoder_f)( + struct asn1_TYPE_descriptor_s *type_descriptor, + void *struct_ptr, /* Structure to be encoded */ + int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ + ber_tlv_tag_t tag, + asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */ + void *app_key /* Arbitrary callback argument */ + ); + + +/******************************* + * INTERNALLY USEFUL FUNCTIONS * + *******************************/ + +/* + * Write out leading TL[v] sequence according to the type definition. + */ +ssize_t der_write_tags( + struct asn1_TYPE_descriptor_s *type_descriptor, + size_t struct_length, + int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */ + ber_tlv_tag_t tag, + asn_app_consume_bytes_f *consume_bytes_cb, + void *app_key + ); + +#endif /* _DER_ENCODER_H_ */ diff --git a/skeletons/tests/Makefile.am b/skeletons/tests/Makefile.am new file mode 100644 index 00000000..e620ade6 --- /dev/null +++ b/skeletons/tests/Makefile.am @@ -0,0 +1,9 @@ +AM_CPPFLAGS = -I${top_srcdir}/skeletons + +check_PROGRAMS = \ + check-GeneralizedTime \ + check-UTCTime \ + check-INTEGER \ + check-OIDs + +TESTS = ${check_PROGRAMS} diff --git a/skeletons/tests/Makefile.in b/skeletons/tests/Makefile.in new file mode 100644 index 00000000..779f93a5 --- /dev/null +++ b/skeletons/tests/Makefile.in @@ -0,0 +1,411 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CPPFLAGS = -I${top_srcdir}/skeletons + +check_PROGRAMS = \ + check-GeneralizedTime \ + check-UTCTime \ + check-INTEGER \ + check-OIDs + + +TESTS = ${check_PROGRAMS} +subdir = skeletons/tests +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +check_PROGRAMS = check-GeneralizedTime$(EXEEXT) check-UTCTime$(EXEEXT) \ + check-INTEGER$(EXEEXT) check-OIDs$(EXEEXT) +check_GeneralizedTime_SOURCES = check-GeneralizedTime.c +check_GeneralizedTime_OBJECTS = check-GeneralizedTime.$(OBJEXT) +check_GeneralizedTime_LDADD = $(LDADD) +check_GeneralizedTime_DEPENDENCIES = +check_GeneralizedTime_LDFLAGS = +check_INTEGER_SOURCES = check-INTEGER.c +check_INTEGER_OBJECTS = check-INTEGER.$(OBJEXT) +check_INTEGER_LDADD = $(LDADD) +check_INTEGER_DEPENDENCIES = +check_INTEGER_LDFLAGS = +check_OIDs_SOURCES = check-OIDs.c +check_OIDs_OBJECTS = check-OIDs.$(OBJEXT) +check_OIDs_LDADD = $(LDADD) +check_OIDs_DEPENDENCIES = +check_OIDs_LDFLAGS = +check_UTCTime_SOURCES = check-UTCTime.c +check_UTCTime_OBJECTS = check-UTCTime.$(OBJEXT) +check_UTCTime_LDADD = $(LDADD) +check_UTCTime_DEPENDENCIES = +check_UTCTime_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/check-GeneralizedTime.Po \ +@AMDEP_TRUE@ $(DEPDIR)/check-INTEGER.Po $(DEPDIR)/check-OIDs.Po \ +@AMDEP_TRUE@ $(DEPDIR)/check-UTCTime.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = check-GeneralizedTime.c check-INTEGER.c check-OIDs.c \ + check-UTCTime.c +DIST_COMMON = Makefile.am Makefile.in +SOURCES = check-GeneralizedTime.c check-INTEGER.c check-OIDs.c check-UTCTime.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu skeletons/tests/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check-GeneralizedTime$(EXEEXT): $(check_GeneralizedTime_OBJECTS) $(check_GeneralizedTime_DEPENDENCIES) + @rm -f check-GeneralizedTime$(EXEEXT) + $(LINK) $(check_GeneralizedTime_LDFLAGS) $(check_GeneralizedTime_OBJECTS) $(check_GeneralizedTime_LDADD) $(LIBS) +check-INTEGER$(EXEEXT): $(check_INTEGER_OBJECTS) $(check_INTEGER_DEPENDENCIES) + @rm -f check-INTEGER$(EXEEXT) + $(LINK) $(check_INTEGER_LDFLAGS) $(check_INTEGER_OBJECTS) $(check_INTEGER_LDADD) $(LIBS) +check-OIDs$(EXEEXT): $(check_OIDs_OBJECTS) $(check_OIDs_DEPENDENCIES) + @rm -f check-OIDs$(EXEEXT) + $(LINK) $(check_OIDs_LDFLAGS) $(check_OIDs_OBJECTS) $(check_OIDs_LDADD) $(LIBS) +check-UTCTime$(EXEEXT): $(check_UTCTime_OBJECTS) $(check_UTCTime_DEPENDENCIES) + @rm -f check-UTCTime$(EXEEXT) + $(LINK) $(check_UTCTime_LDFLAGS) $(check_UTCTime_OBJECTS) $(check_UTCTime_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check-GeneralizedTime.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check-INTEGER.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check-OIDs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check-UTCTime.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool distclean \ + distclean-compile distclean-depend distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/skeletons/tests/check-GeneralizedTime.c b/skeletons/tests/check-GeneralizedTime.c new file mode 100644 index 00000000..3451cffe --- /dev/null +++ b/skeletons/tests/check-GeneralizedTime.c @@ -0,0 +1,54 @@ +#define __NO_ASN_TABLE__ +#include "../GeneralizedTime.c" +#include "../constraints.c" + +static void +check(char *time_str, time_t sample) { + GeneralizedTime_t gt; + struct tm tm; + time_t tloc; + + gt.buf = time_str; + gt.size = strlen(time_str); + + tloc = asn_GT2time(>, &tm); + printf("[%s] -> %ld == %ld\n", time_str, (long)tloc, (long)sample); + if(tloc != -1) + printf("\t%d-%d-%dT%02d:%02d:%02d %ld\n", + tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday, + tm.tm_hour, + tm.tm_min, + tm.tm_sec, + tm.tm_gmtoff + ); + assert(tloc == sample); +} + +int +main(int ac, char **av) { + + check("200401250", -1); + check("2004012509300", -1); + check("20040125093000-", -1); + check("20040125093007-0", -1); + check("20040125093007-080", -1); + check("200401250930.01Z", -1); + + check("20040125093007Z", 1075023007); + check("20040125093007+00", 1075023007); + check("20040125093007.01+0000", 1075023007); + check("20040125093007,1+0000", 1075023007); + check("20040125093007-0800", 1075051807); + + if(ac > 1) { + /* These will be valid only inside PST time zone */ + check("20040125093007", 1075051807); + check("200401250930", 1075051800); + check("20040125093000,01", 1075051800); + check("20040125093000,1234", 1075051800); + } + + return 0; +} diff --git a/skeletons/tests/check-INTEGER.c b/skeletons/tests/check-INTEGER.c new file mode 100644 index 00000000..4053075e --- /dev/null +++ b/skeletons/tests/check-INTEGER.c @@ -0,0 +1,56 @@ +#include "../INTEGER.c" +#include "../ber_decoder.c" +#include "../ber_tlv_length.c" +#include "../ber_tlv_tag.c" +#include "../der_encoder.c" +#include "../constraints.c" + +static void +check(uint8_t *buf, int size, long check_long, int check_ret) { + INTEGER_t val; + int ret; + long rlong = 123; + + assert(buf); + assert(size >= 0); + + val.buf = buf; + val.size = size; + + + ret = asn1_INTEGER2long(&val, &rlong); + printf("Testing (%ld, %d) vs (%ld, %d)\n", + rlong, ret, check_long, check_ret); + assert(ret == check_ret); + if(ret == -1) return; + assert(rlong == check_long); +} + +int +main(int ac, char **av) { + uint8_t buf1[] = { 1 }; + uint8_t buf2[] = { 0xff }; + uint8_t buf3[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + uint8_t buf4[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0 }; + uint8_t buf5[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; + uint8_t buf6[] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + uint8_t buf7[] = { 0xff, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + uint8_t buf8[] = { 0x7f, 0x7e, 0x7d, 0x7c }; + uint8_t buf9[] = { 0, 0x7f, 0x7e, 0x7d, 0x7c }; + uint8_t buf10[] = { 0, 0, 0, 0, 0, 0, 0x7f, 0x7e, 0x7d, 0x7c }; + +#define CHECK(buf, val, ret) check(buf, sizeof(buf), val, ret) + + CHECK(buf1, 1, 0); + CHECK(buf2, -1, 0); + CHECK(buf3, -1, 0); + CHECK(buf4, -16, 0); + CHECK(buf5, 257, 0); + CHECK(buf6, 123, -1); + CHECK(buf7, 123, -1); + CHECK(buf8, 0x7F7E7D7C, 0); + CHECK(buf9, 0x7F7E7D7C, 0); + CHECK(buf10, 0x7F7E7D7C, 0); + + return 0; +} diff --git a/skeletons/tests/check-OIDs.c b/skeletons/tests/check-OIDs.c new file mode 100644 index 00000000..a97a910a --- /dev/null +++ b/skeletons/tests/check-OIDs.c @@ -0,0 +1,228 @@ +#include "../RELATIVE-OID.c" +#include "../OBJECT_IDENTIFIER.c" +#include "../INTEGER.c" +#include "../ber_decoder.c" +#include "../ber_tlv_length.c" +#include "../ber_tlv_tag.c" +#include "../der_encoder.c" +#include "../constraints.c" + +static int +_print(const void *buffer, size_t size, void *app_key) { + fwrite(buffer, size, 1, stdout); + return 0; +} + +static void +check_OID(uint8_t *buf, size_t len, int *ck_buf, int ck_len) { + OBJECT_IDENTIFIER_t *oid; + ber_dec_rval_t rval; + unsigned long arcs[10]; + int alen; + int i; + + printf("Checking {"); + for(i = 0; i < len; i++) { printf("%s%02x", i?" ":"", buf[i]); } + printf("} against {"); + for(i = 0; i < ck_len; i++) { printf("%s%d", i?" ":"", ck_buf[i]); } + printf("}\n"); + + oid = NULL; + rval = ber_decode(&asn1_DEF_OBJECT_IDENTIFIER, (void *)&oid, buf, len); + assert(rval.code == RC_OK); + + assert(oid->size == len - 2); + + /* + * Print the contents for visual debugging. + */ + printf("OBJECT_IDENTIFIER_print() => "); + OBJECT_IDENTIFIER_print(&asn1_DEF_OBJECT_IDENTIFIER, oid, 0, _print, 0); + printf("\n"); + + alen = OBJECT_IDENTIFIER_get_arcs_l(oid, + arcs, sizeof(arcs)/sizeof(arcs[0])); + assert(alen > 0); + assert(alen == ck_len); + + /* + * Make sure they are equivalent. + */ + printf("OBJECT_IDENTIFIER_get_arcs() => {"); + for(i = 0; i < alen; i++) { + printf(" %lu", arcs[i]); + assert(arcs[i] == ck_buf[i]); + } + printf(" }\n"); +} + +static void +check_ROID(uint8_t *buf, size_t len, int *ck_buf, int ck_len) { + RELATIVE_OID_t *oid; + ber_dec_rval_t rval; + unsigned long arcs[10]; + int alen; + int i; + + printf("Checking {"); + for(i = 0; i < len; i++) { printf("%s%02x", i?" ":"", buf[i]); } + printf("} against {"); + for(i = 0; i < ck_len; i++) { printf("%s%d", i?" ":"", ck_buf[i]); } + printf("}\n"); + + oid = NULL; + rval = ber_decode(&asn1_DEF_RELATIVE_OID, (void *)&oid, buf, len); + assert(rval.code == RC_OK); + + assert(oid->size == len - 2); + + /* + * Print the contents for visual debugging. + */ + printf("RELATIVE_OID_print() => "); + RELATIVE_OID_print(&asn1_DEF_RELATIVE_OID, oid, 0, _print, 0); + printf("\n"); + + alen = RELATIVE_OID_get_arcs_l(oid, + arcs, sizeof(arcs)/sizeof(arcs[0])); + assert(alen > 0); + assert(alen == ck_len); + + /* + * Make sure they are equivalent. + */ + printf("RELATIVE_OID_get_arcs() => {"); + for(i = 0; i < alen; i++) { + printf(" %lu", (unsigned long)arcs[i]); + assert(arcs[i] == ck_buf[i]); + } + printf(" }\n"); +} + +/* + * Encode the specified array of arcs as RELATIVE-OID, decode it and compare. + */ +static void +check_REGEN(int *arcs, int acount) { + static RELATIVE_OID_t oid; + unsigned long tmp_arcs[10]; + int tmp_alen = 10; + int alen; + int ret; + int i; + + printf("Encoding {"); + for(i = 0; i < acount; i++) { + printf(" %u", arcs[i]); + } + printf(" }\n"); + + ret = RELATIVE_OID_set_arcs_l(&oid, (unsigned long *)arcs, acount); + assert(ret == 0); + + alen = RELATIVE_OID_get_arcs_l(&oid, tmp_arcs, tmp_alen); + assert(alen >= 0); + assert(alen < tmp_alen); + + printf("Encoded {"); + for(i = 0; i < alen; i++) { + printf(" %lu", tmp_arcs[i]); + assert(arcs[i] == tmp_arcs[i]); + } + printf(" }\n"); +} + +/* + * Encode the specified array of arcs as OBJECT IDENTIFIER, + * decode it and compare. + */ +static void +check_REGEN_OID(int *arcs, int acount) { + static OBJECT_IDENTIFIER_t oid; + unsigned long tmp_arcs[10]; + int tmp_alen = 10; + int alen; + int ret; + int i; + + printf("Encoding {"); + for(i = 0; i < acount; i++) { + printf(" %u", arcs[i]); + } + printf(" }\n"); + + ret = OBJECT_IDENTIFIER_set_arcs_l(&oid, (unsigned long *)arcs, acount); + assert(ret == 0); + + alen = OBJECT_IDENTIFIER_get_arcs_l(&oid, tmp_arcs, tmp_alen); + assert(alen >= 0); + assert(alen < tmp_alen); + + printf("Encoded {"); + for(i = 0; i < alen; i++) { + printf(" %lu", tmp_arcs[i]); + assert(arcs[i] == tmp_arcs[i]); + } + printf(" }\n"); +} + +#define CHECK_OID(n) check_OID(buf ## n, sizeof(buf ## n), \ + buf ## n ## _check, \ + sizeof(buf ## n ## _check)/sizeof(buf ## n ## _check[0])) +#define CHECK_ROID(n) check_ROID(buf ## n, sizeof(buf ## n), \ + buf ## n ## _check, \ + sizeof(buf ## n ## _check)/sizeof(buf ## n ## _check[0])) +#define CHECK_REGEN(n) check_REGEN(buf ## n ## _check, \ + sizeof(buf ## n ## _check)/sizeof(buf ## n ## _check[0])) +#define CHECK_REGEN_OID(n) check_REGEN_OID(buf ## n ## _check, \ + sizeof(buf ## n ## _check)/sizeof(buf ## n ## _check[0])) + +int +main(int ac, char **av) { + /* {joint-iso-itu-t 100 3} */ + uint8_t buf1[] = { + 0x06, /* OBJECT IDENTIFIER */ + 0x03, /* Length */ + 0x81, 0x34, 0x03 + }; + int buf1_check[] = { 2, 100, 3 }; + + /* {8571 3 2} */ + uint8_t buf2[] = { + 0x0D, /* RELATIVE-OID */ + 0x04, /* Length */ + 0xC2, 0x7B, 0x03, 0x02 + }; + int buf2_check[] = { 8571, 3, 2 }; + + int buf3_check[] = { 0 }; + int buf4_check[] = { 1 }; + int buf5_check[] = { 80, 40 }; + int buf6_check[] = { 127 }; + int buf7_check[] = { 128 }; + int buf8_check[] = { 65535, 65536 }; + int buf9_check[] = { 100000, 0x20000, 1234, 256, 127, 128 }; + int buf10_check[] = { 0, 0xffffffff, 0xff00ff00, 0 }; + int buf11_check[] = { 0, 1, 2 }; + int buf12_check[] = { 1, 38, 3 }; + int buf13_check[] = { 0, 0, 0xf000 }; + + + CHECK_OID(1); /* buf1, buf1_check */ + CHECK_ROID(2); /* buf2, buf2_check */ + + CHECK_REGEN(3); /* Regenerate RELATIVE-OID */ + CHECK_REGEN(4); + CHECK_REGEN(5); + CHECK_REGEN(6); + CHECK_REGEN(7); + CHECK_REGEN(8); + CHECK_REGEN(9); + CHECK_REGEN(10); + CHECK_REGEN_OID(1); /* Regenerate OBJECT IDENTIFIER */ + CHECK_REGEN_OID(11); + CHECK_REGEN_OID(12); + CHECK_REGEN_OID(13); + + return 0; +} diff --git a/skeletons/tests/check-UTCTime.c b/skeletons/tests/check-UTCTime.c new file mode 100644 index 00000000..7522140e --- /dev/null +++ b/skeletons/tests/check-UTCTime.c @@ -0,0 +1,54 @@ +#define __NO_ASN_TABLE__ +#include "../UTCTime.c" +#define __NO_ASSERT_H__ +#include "../GeneralizedTime.c" +#include "../constraints.c" + +static void +check(char *time_str, time_t sample) { + UTCTime_t gt; + struct tm tm; + time_t tloc; + + gt.buf = time_str; + gt.size = strlen(time_str); + + tloc = asn_UT2time(>, &tm); + printf("[%s] -> %ld == %ld\n", time_str, (long)tloc, (long)sample); + if(tloc != -1) + printf("\t%d-%d-%dT%02d:%02d:%02d %ld\n", + tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday, + tm.tm_hour, + tm.tm_min, + tm.tm_sec, + tm.tm_gmtoff + ); + assert(tloc == sample); +} + +int +main(int ac, char **av) { + + check("0401250", -1); + check("0401250930", -1); /* "Z" or "(+|-)hhmm" required */ + check("04012509300", -1); + check("040125093000-", -1); + check("040125093007-0", -1); + check("040125093007-080", -1); + check("0401250930.01Z", -1); + + check("040125093007Z", 1075023007); + check("040125093007+00", 1075023007); + check("040125093007-0800", 1075051807); + + if(ac > 1) { + /* These will be valid only inside PST time zone */ + check("040125093007", 1075051807); + check("040125093000,01", 1075051800); + check("040125093000,1234", 1075051800); + } + + return 0; +} diff --git a/stamp-h.in b/stamp-h.in new file mode 100644 index 00000000..9788f702 --- /dev/null +++ b/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/tests/00-empty-OK.asn1 b/tests/00-empty-OK.asn1 new file mode 100644 index 00000000..532d4fb0 --- /dev/null +++ b/tests/00-empty-OK.asn1 @@ -0,0 +1 @@ +ModuleTestEmpty DEFINITIONS ::= BEGIN END diff --git a/tests/01-empty-OK.asn1 b/tests/01-empty-OK.asn1 new file mode 100644 index 00000000..04d9ba77 --- /dev/null +++ b/tests/01-empty-OK.asn1 @@ -0,0 +1,14 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .1 + +ModuleTestEmpty + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 1 } + DEFINITIONS ::= +BEGIN + +END diff --git a/tests/02-garbage-NP.asn1 b/tests/02-garbage-NP.asn1 new file mode 100644 index 00000000..410c7bc0 --- /dev/null +++ b/tests/02-garbage-NP.asn1 @@ -0,0 +1,17 @@ + +-- NP: Non-parseable. + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .2 + +ModuleTestGarbage + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 2 } + DEFINITIONS ::= +BEGIN + + -- must fail on the next line -- + some garbage + +END diff --git a/tests/03-enum-OK.asn1 b/tests/03-enum-OK.asn1 new file mode 100644 index 00000000..567df26a --- /dev/null +++ b/tests/03-enum-OK.asn1 @@ -0,0 +1,22 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .3 + +ModuleTestEnum1 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 3 } + DEFINITIONS ::= +BEGIN + + Enum1 ::= ENUMERATED + { red, -- will be 0 -- + green, -- will be 1 -- + blue(4), + alpha, + ... -- extensible -- + } + +END diff --git a/tests/04-enum-SE.asn1 b/tests/04-enum-SE.asn1 new file mode 100644 index 00000000..e9a37c4b --- /dev/null +++ b/tests/04-enum-SE.asn1 @@ -0,0 +1,19 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .4 + +ModuleTestEnum2 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 4 } + DEFINITIONS ::= +BEGIN + + enum1 Enum1 ::= blue + + Enum1 ::= ENUMERATED { red, green, ..., + blue(1) -- collides with green -- } + +END diff --git a/tests/05-enum-SE.asn1 b/tests/05-enum-SE.asn1 new file mode 100644 index 00000000..083724d2 --- /dev/null +++ b/tests/05-enum-SE.asn1 @@ -0,0 +1,21 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .5 + +ModuleTestEnum3 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 5 } + DEFINITIONS ::= +BEGIN + + enum1 Enum1 ::= red + + Enum1 ::= ENUMERATED { red(5), green(4), ..., blue(6), + -- second extension marker is not allowed -- + ..., + white(7) } + +END diff --git a/tests/06-enum-SE.asn1 b/tests/06-enum-SE.asn1 new file mode 100644 index 00000000..ad304af1 --- /dev/null +++ b/tests/06-enum-SE.asn1 @@ -0,0 +1,20 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .6 + +ModuleTestEnum4 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 6 } + DEFINITIONS ::= +BEGIN + + enum1 Enum1 ::= red + + Enum1 ::= ENUMERATED { red(5), ..., + green(7), blue(6) -- order is not maintained after ... + } + +END diff --git a/tests/07-int-OK.asn1 b/tests/07-int-OK.asn1 new file mode 100644 index 00000000..bf596273 --- /dev/null +++ b/tests/07-int-OK.asn1 @@ -0,0 +1,26 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .7 + +ModuleTestInt1 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 7 } + DEFINITIONS ::= +BEGIN + + int123456 INTEGER ::= 123456 + + Interval ::= INTEGER (1..int123456) + + SameInterval INTEGER ::= { 1 | 2 | 3 | 4 | 5 | 6 } + + Reason ::= INTEGER { + no-reason(0), + negative-reason(-10), + some-large-value(1324324) + } + +END diff --git a/tests/08-int-SE.asn1 b/tests/08-int-SE.asn1 new file mode 100644 index 00000000..8ff97fdf --- /dev/null +++ b/tests/08-int-SE.asn1 @@ -0,0 +1,19 @@ + +-- OK: Semantic Error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .8 + +ModuleTestInt2 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 8 } + DEFINITIONS ::= +BEGIN + + Reason ::= INTEGER { + value1(0), + value1(2) -- identifiers must be distinct -- + } + +END diff --git a/tests/09-int-SE.asn1 b/tests/09-int-SE.asn1 new file mode 100644 index 00000000..c696e19e --- /dev/null +++ b/tests/09-int-SE.asn1 @@ -0,0 +1,20 @@ + +-- OK: Semantic Error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .9 + +ModuleTestInt3 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 9 } + DEFINITIONS ::= +BEGIN + + Reason ::= INTEGER { + value1(1), + value5(5), + value2-1(1) -- integers must be distinct -- + } + +END diff --git a/tests/10-int-OK.asn1 b/tests/10-int-OK.asn1 new file mode 100644 index 00000000..c17265fc --- /dev/null +++ b/tests/10-int-OK.asn1 @@ -0,0 +1,29 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .10 + +ModuleTestInt4 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 10 } + DEFINITIONS ::= +BEGIN + + alpha INTEGER ::= 1 + Type1 ::= INTEGER { alpha(2) } + Type2 ::= INTEGER { alpha(3), beta(alpha) } + gamma Type2 ::= beta -- equals 1 -- + delta Type2 ::= alpha -- equals 3 -- + + /* + * The following are for post-fix checking by the check_fixer. + * It will be able to pick-up these values if the file is parseable, + * even if it contains some semantic errors. + */ + + check-gamma INTEGER ::= 1 -- check "gamma"'s value + check-delta INTEGER ::= 3 -- check "delta"'s value + +END diff --git a/tests/11-int-SE.asn1 b/tests/11-int-SE.asn1 new file mode 100644 index 00000000..57978d7d --- /dev/null +++ b/tests/11-int-SE.asn1 @@ -0,0 +1,18 @@ + +-- OK: Semantic Error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .11 + +ModuleTestInt5 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 11 } + DEFINITIONS ::= +BEGIN + + -- recursive definition loop + alpha INTEGER ::= beta + beta INTEGER ::= alpha + +END diff --git a/tests/12-int-SE.asn1 b/tests/12-int-SE.asn1 new file mode 100644 index 00000000..90939b62 --- /dev/null +++ b/tests/12-int-SE.asn1 @@ -0,0 +1,17 @@ + +-- OK: Semantic Error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .12 + +ModuleTestInt6 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 12 } + DEFINITIONS ::= +BEGIN + + -- unresolved reference + alpha INTEGER ::= beta + +END diff --git a/tests/13-resolver-OK.asn1 b/tests/13-resolver-OK.asn1 new file mode 100644 index 00000000..5237b011 --- /dev/null +++ b/tests/13-resolver-OK.asn1 @@ -0,0 +1,47 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .13 1 +-- .13 2 + +ModuleTestResolver1 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 13 1 } + DEFINITIONS ::= +BEGIN + IMPORTS IntegerType, beta FROM + Renamed + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 13 2 }; + + -- external reference + alpha IntegerType ::= beta + alpha2 Renamed.IntegerType ::= beta + + -- + -- The following are for post-fix checking by the check_fixer. + -- It will be able to pick-up these values if the file is parseable, + -- even if it contains some semantic errors. + -- + + check-alpha INTEGER ::= 123 + check-alpha2 INTEGER ::= 123 + +END + +ModuleTestResolver2 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 13 2 } + DEFINITIONS ::= +BEGIN + EXPORTS beta, IntegerType ; + + beta HiddenType ::= 123 + + HiddenType ::= INTEGER + + IntegerType ::= INTEGER + +END diff --git a/tests/14-resolver-OK.asn1 b/tests/14-resolver-OK.asn1 new file mode 100644 index 00000000..48fb0cc3 --- /dev/null +++ b/tests/14-resolver-OK.asn1 @@ -0,0 +1,45 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .14 1 +-- .14 2 + +ModuleTestResolver2 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 14 1 } + DEFINITIONS ::= +BEGIN + IMPORTS Enumeration, beta FROM + OtherModuleRenamed + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 14 2 }; + + -- external reference + alpha Enumeration ::= beta + + -- + -- The following are for post-fix checking by the check_fixer. + -- It will be able to pick-up these values if the file is parseable, + -- even if it contains some semantic errors. + -- + + check-alpha INTEGER ::= 2 + +END + +ModuleTestResolver3 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 14 2 } + DEFINITIONS ::= +BEGIN + EXPORTS Enumeration, beta ; + + beta HiddenEnum ::= b + + HiddenEnum ::= ENUMERATED { a(1), b(2) } + + Enumeration ::= ENUMERATED { a(1), b(2) } -- the same type -- + +END diff --git a/tests/15-resolver-SE.asn1 b/tests/15-resolver-SE.asn1 new file mode 100644 index 00000000..f4255c89 --- /dev/null +++ b/tests/15-resolver-SE.asn1 @@ -0,0 +1,35 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .15 1 +-- .15 2 + +ModuleTestResolver4 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 15 1 } + DEFINITIONS ::= +BEGIN + IMPORTS Enumeration, beta FROM + OtherModuleRenamed + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 15 2 }; + + -- external reference + alpha Enumeration ::= beta + +END + +ModuleTestResolver5 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 15 2 } + DEFINITIONS ::= +BEGIN + EXPORTS; -- Does not export anything! + + beta Enumeration ::= b + + Enumeration ::= ENUMERATED { a(1), b(2) } + +END diff --git a/tests/16-constraint-OK.asn1 b/tests/16-constraint-OK.asn1 new file mode 100644 index 00000000..5625d7fd --- /dev/null +++ b/tests/16-constraint-OK.asn1 @@ -0,0 +1,23 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .16 + +ModuleTestConstraint + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 16 } + DEFINITIONS ::= +BEGIN + + -- external reference + Type1 ::= IA5String (SIZE(1..10,...))(FROM("a".."z"|"#")) + Type2 ::= IA5String (SIZE (MIN..4)|FROM ("abc")) + Type3 ::= BMPString (SIZE(1)) + Type4 ::= INTEGER (1..MAX) + Type5 ::= BOOLEAN (TRUE|FALSE) + + v1 Type1 ::= "#value wi + th ""double quotes""" +END diff --git a/tests/17-tags-OK.asn1 b/tests/17-tags-OK.asn1 new file mode 100644 index 00000000..40f9c07e --- /dev/null +++ b/tests/17-tags-OK.asn1 @@ -0,0 +1,24 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .17 + +ModuleTestTags + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 17 } + DEFINITIONS ::= +BEGIN + + T3 ::= [3] IMPLICIT T2 + T1 ::= [1] INTEGER + T2 ::= [2] EXPLICIT T1 + + T4 ::= [APPLICATION 1] SET { + t1 [4] IMPLICIT T1, + t2 [5] T2, + t3 [6] T3 + } + +END diff --git a/tests/18-class-OK.asn1 b/tests/18-class-OK.asn1 new file mode 100644 index 00000000..edae8566 --- /dev/null +++ b/tests/18-class-OK.asn1 @@ -0,0 +1,36 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .18 + +ModuleTestClass + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 18 } + DEFINITIONS ::= +BEGIN + + AlphaNumeric ::= IA5String (FROM ("A".."Z"|"a".."z"|"0".."9")) + + FUNCTION ::= CLASS { + &code INTEGER (0..MAX) UNIQUE, + &Alphabet IA5String DEFAULT {AlphaNumeric}, + &ArgType , + &SupportedArguments &ArgType OPTIONAL, + &ResultType DEFAULT NULL, + &result-if-error &ResultType DEFAULT NULL, + &associated-function FUNCTION OPTIONAL + } + + operator-plus FUNCTION ::= { + &ArgType Pair, + &SupportedArguments { PosPair | NegPair } + &ResultType INTEGER, + &result-if-error 0, + &code 1 + } + + FunctionCodeType ::= FUNCTION.&code + +END diff --git a/tests/19-param-OK.asn1 b/tests/19-param-OK.asn1 new file mode 100644 index 00000000..37d7c448 --- /dev/null +++ b/tests/19-param-OK.asn1 @@ -0,0 +1,30 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .19 + +ModuleTestParam + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 19 } + DEFINITIONS ::= +BEGIN + + SIGNED { ToBeSigned } ::= SEQUENCE { + toBeSigned ToBeSigned, + algorithm OBJECT IDENTIFIER, + signature BIT STRING + } + + Certificate ::= SIGNED { SEQUENCE { + version INTEGER, + signature OBJECT IDENTIFIER, + issuer Name + } } + + Name ::= SEQUENCE OF RelativeDistinguishedName + + RelativeDistinguishedName ::= SET SIZE (1..MAX) OF IA5String + +END diff --git a/tests/20-constr-OK.asn1 b/tests/20-constr-OK.asn1 new file mode 100644 index 00000000..f2a97f06 --- /dev/null +++ b/tests/20-constr-OK.asn1 @@ -0,0 +1,30 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .20 + +ModuleTestConstr + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 20 } + DEFINITIONS IMPLICIT TAGS EXTENSIBILITY IMPLIED ::= +BEGIN + + ConstructedType1 ::= SEQUENCE { + a [1] INTEGER, + b [2] INTEGER, + ...!ex1, + c IA5String, + ..., + d UTF8String + } + + ConstructedType2 ::= SET { + a [1] INTEGER, + b [2] INTEGER + } + + ex1 INTEGER ::= 1 + +END diff --git a/tests/21-tags-OK.asn1 b/tests/21-tags-OK.asn1 new file mode 100644 index 00000000..3a46c325 --- /dev/null +++ b/tests/21-tags-OK.asn1 @@ -0,0 +1,34 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .21 1 +-- .21 2 + +ModuleTestTags1 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 21 1 } + DEFINITIONS EXPLICIT TAGS ::= +BEGIN + + T1 ::= CHOICE { + first [0] INTEGER, + second [1] INTEGER + } + +END + +ModuleTestTags2 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 21 2 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + IMPORTS T1 FROM ModuleTestTags1; + + T2 ::= SEQUENCE { + one [0] T1, + two [1] IA5String + } + +END diff --git a/tests/22-tags-OK.asn1 b/tests/22-tags-OK.asn1 new file mode 100644 index 00000000..562e14b4 --- /dev/null +++ b/tests/22-tags-OK.asn1 @@ -0,0 +1,23 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .22 + +ModuleTestTags3 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 22 } + DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + + T1 ::= SEQUENCE { + a INTEGER, + b CHOICE { + i INTEGER, + n IA5String + }, + c UTF8String + } + +END diff --git a/tests/23-bits-OK.asn1 b/tests/23-bits-OK.asn1 new file mode 100644 index 00000000..f41b923d --- /dev/null +++ b/tests/23-bits-OK.asn1 @@ -0,0 +1,22 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .23 + +ModuleTestBitString + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 23 } + DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + + v28 INTEGER ::= 28 + + BS1 ::= BIT STRING { first(0), third(2), twenty-eight(v28) } + + one-zero-one BS1 ::= { first, third } -- Equivalent to '101'B + + one0one BS1 ::= '1010000'B -- Equivalent to '101'B + +END diff --git a/tests/24-sequence-OK.asn1 b/tests/24-sequence-OK.asn1 new file mode 100644 index 00000000..851ebf0d --- /dev/null +++ b/tests/24-sequence-OK.asn1 @@ -0,0 +1,21 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .24 + +ModuleTestSequence + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 24 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + T ::= [5] EXPLICIT SEQUENCE { + a INTEGER, + b [0] INTEGER OPTIONAL, + c [1] INTEGER DEFAULT 10, + d [5] EXPLICIT INTEGER + } + +END diff --git a/tests/25-misc-OK.asn1 b/tests/25-misc-OK.asn1 new file mode 100644 index 00000000..3a7eb917 --- /dev/null +++ b/tests/25-misc-OK.asn1 @@ -0,0 +1,29 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .25 + +ModuleTestMisc + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 25 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + T ::= SEQUENCE { + a INTEGER, + b [2] BOOLEAN, + c NULL, + ..., + d ENUMERATED { + a(1), b(2) + }, + e OCTET STRING, + f OCTET STRING, + g BIT STRING, + h BIT STRING, + ... + } + +END diff --git a/tests/26-sequence-SE.asn1 b/tests/26-sequence-SE.asn1 new file mode 100644 index 00000000..8c5866ae --- /dev/null +++ b/tests/26-sequence-SE.asn1 @@ -0,0 +1,20 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .26 + +ModuleTestSequenceTagsDistinct + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 26 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + T ::= SEQUENCE { + a INTEGER, + b INTEGER OPTIONAL, + c INTEGER + } + +END diff --git a/tests/27-set-SE.asn1 b/tests/27-set-SE.asn1 new file mode 100644 index 00000000..91e56973 --- /dev/null +++ b/tests/27-set-SE.asn1 @@ -0,0 +1,21 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .27 + +ModuleTestSetTagsDistinct + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 27 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + T ::= SET { + a INTEGER, + b CHOICE { -- Could we lookup tag past CHOICE?.. + c INTEGER -- Tags must be distinct here. + } + } + +END diff --git a/tests/28-tags-SE.asn1 b/tests/28-tags-SE.asn1 new file mode 100644 index 00000000..b3af0e3e --- /dev/null +++ b/tests/28-tags-SE.asn1 @@ -0,0 +1,26 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .28 + +ModuleTestTagsDistinct + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 28 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + S ::= SET { + a INTEGER, + b CHOICE { + c IA5String, + ... + }, + d CHOICE { + e BOOLEAN, + ... + } + } + +END diff --git a/tests/29-tags-OK.asn1 b/tests/29-tags-OK.asn1 new file mode 100644 index 00000000..440f16c9 --- /dev/null +++ b/tests/29-tags-OK.asn1 @@ -0,0 +1,26 @@ + +-- OK: Everything is fin + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .29 + +ModuleTestTagsDistinct2 + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 29 } + DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + + S ::= SET { + a INTEGER, + b CHOICE { + c IA5String, + ... + }, + d CHOICE { + e BOOLEAN, + ... + } + } + +END diff --git a/tests/30-set-OK.asn1 b/tests/30-set-OK.asn1 new file mode 100644 index 00000000..2cd6a5a4 --- /dev/null +++ b/tests/30-set-OK.asn1 @@ -0,0 +1,21 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .30 + +ModuleTestSetSimple + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 30 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + T ::= SET { + a [APPLICATION 3] INTEGER, + b IA5String, + ..., + c [2] BOOLEAN + } + +END diff --git a/tests/31-set-of-OK.asn1 b/tests/31-set-of-OK.asn1 new file mode 100644 index 00000000..cd108ba0 --- /dev/null +++ b/tests/31-set-of-OK.asn1 @@ -0,0 +1,21 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .31 + +ModuleTestSetOfSimple + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 31 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + Forest ::= SET OF Tree + + Tree ::= SEQUENCE { + height INTEGER, + width INTEGER + } + +END diff --git a/tests/32-sequence-of-OK.asn1 b/tests/32-sequence-of-OK.asn1 new file mode 100644 index 00000000..ced163af --- /dev/null +++ b/tests/32-sequence-of-OK.asn1 @@ -0,0 +1,22 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .32 + +ModuleTestSequenceSimple + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 32 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + Programming ::= SEQUENCE OF Fault + + Fault ::= SET OF Error + + Error ::= SEQUENCE { + ... + } + +END diff --git a/tests/33-misc-OK.asn1 b/tests/33-misc-OK.asn1 new file mode 100644 index 00000000..1018a40c --- /dev/null +++ b/tests/33-misc-OK.asn1 @@ -0,0 +1,33 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .33 + +ModuleTestMiscComplex + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 33 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + T ::= SEQUENCE { + a [1] INTEGER, + ..., + b [2] EXPLICIT BitString, + c [8] IMPLICIT Label, + d [10] IMPLICIT Int, + e [12] T2 + } + + BitString ::= [8] BIT STRING + + Label ::= [9] EXPLICIT UTF8String + + Label2 ::= [1] Label + + Int ::= [3] IMPLICIT INTEGER { a(1), b(2) } + + T2 ::= SEQUENCE { l Label2 } + +END diff --git a/tests/34-class-OK.asn1 b/tests/34-class-OK.asn1 new file mode 100644 index 00000000..b2d4dffd --- /dev/null +++ b/tests/34-class-OK.asn1 @@ -0,0 +1,51 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .34 + +ModuleTestClassSimple + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 34 } + DEFINITIONS IMPLICIT TAGS ::= +BEGIN + + -- First CLASS + + EXTENSION ::= CLASS { + &id OBJECT IDENTIFIER UNIQUE, + &ExtnType + } WITH SYNTAX { + SYNTAX &ExtnType + IDENTIFIED BY &id + } + + -- Basic CLASS extraction + Ext1 ::= SEQUENCE { + extnId EXTENSION.&id + } + + -- Second CLASS + + EXTENSION-ATTRIBUTE ::= CLASS { + &id INTEGER (0..ub-extension-attributes) UNIQUE, + &Type + } WITH SYNTAX {&Type IDENTIFIED BY &id} + + terminal-type EXTENSION-ATTRIBUTE ::= {TerminalType IDENTIFIED BY 23} + + -- Advanced CLASS extraction + + ExtensionAttribute ::= SEQUENCE { + extension-attribute-type [0] EXTENSION-ATTRIBUTE.&id + ({ExtensionAttributeTable}), + extension-attribute-value [1] EXTENSION-ATTRIBUTE.&Type + ({ExtensionAttributeTable} {@extension-attribute-type}) + } + + -- Variables referenced by subtype constraints + + ub-extension-attributes INTEGER ::= 256 + +END diff --git a/tests/35-set-choice-OK.asn1 b/tests/35-set-choice-OK.asn1 new file mode 100644 index 00000000..36780213 --- /dev/null +++ b/tests/35-set-choice-OK.asn1 @@ -0,0 +1,36 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .35 + +ModuleTestSetAndUntaggedChoice + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 35 } + DEFINITIONS ::= +BEGIN + + T ::= SET { + a NumericString, + b CHOICE { -- Untagged choice + b1 IA5String, + b2 ObjectDescriptor, + b3 Choice + }, + c BOOLEAN, + ..., + d OID + } + + Choice ::= CHOICE { -- One more level + ch-a OCTET STRING, + ch-b BIT STRING + } + + OID ::= CHOICE { + oid OBJECT IDENTIFIER, + r-oid RELATIVE-OID + } + +END diff --git a/tests/36-indirect-choice-SE.asn1 b/tests/36-indirect-choice-SE.asn1 new file mode 100644 index 00000000..8fcb07b6 --- /dev/null +++ b/tests/36-indirect-choice-SE.asn1 @@ -0,0 +1,25 @@ + +-- SE: Semantic Error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .36 + +ModuleTestIndirectChoiceError + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 36 } + DEFINITIONS ::= +BEGIN + + T ::= CHOICE { + t-a INTEGER, + t-b OCTET STRING, + t-c Choice + } + + Choice ::= CHOICE { -- One more level + c-a OCTET STRING, + c-b INTEGER + } + +END diff --git a/tests/37-indirect-choice-OK.asn1 b/tests/37-indirect-choice-OK.asn1 new file mode 100644 index 00000000..b0361c46 --- /dev/null +++ b/tests/37-indirect-choice-OK.asn1 @@ -0,0 +1,32 @@ + +-- OK: Everything is Fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .37 + +ModuleTestIndirectChoiceFine + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 37 } + DEFINITIONS ::= +BEGIN + + T ::= CHOICE { + t-a INTEGER, + t-b OCTET STRING, + t-c [1] Choice1, + t-d Choice2 + } + + Choice1 ::= CHOICE { + c-a OCTET STRING, + c-b INTEGER + } + + Choice2 ::= [2] CHOICE { + c-a OCTET STRING, + c-b INTEGER, + c-d [3] Choice1 + } + +END diff --git a/tests/38-comments-OK.asn1 b/tests/38-comments-OK.asn1 new file mode 100644 index 00000000..f2f9aab5 --- /dev/null +++ b/tests/38-comments-OK.asn1 @@ -0,0 +1,33 @@ + +-- OK: Everything is Fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .38 + +ModuleNestedCTypeComments + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 38 } + DEFINITIONS ::= +BEGIN + + T ::= CHOICE { + t-a INTEGER, + t-b OCTET STRING +/* t-c [1] Choice1, t-d Choice2 */ + } + + -- this is a comment too -- This-Is-Not-A-Comment + ::= INTEGER + +/* + ISO/IEC 8824-1 #11.6.4 + + blah blah blah + /* nested comment */ + -- this is an insignificant coment + -- this is a comment too -- and this is a comment + + */ + +END diff --git a/tests/39-sequence-of-OK.asn1 b/tests/39-sequence-of-OK.asn1 new file mode 100644 index 00000000..b8ac3f4a --- /dev/null +++ b/tests/39-sequence-of-OK.asn1 @@ -0,0 +1,24 @@ + +-- OK: Everything is Fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .39 + +ModuleNestedSequenceOf + { iso org(3) dod(6) internet(1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 39 } + DEFINITIONS ::= +BEGIN + + T ::= SEQUENCE { + int INTEGER, + collection SEQUENCE OF T2 + } + + T2 ::= SEQUENCE { + flag BOOLEAN, + str UTF8String + } + +END diff --git a/tests/39-sequence-of-OK.asn1.-P b/tests/39-sequence-of-OK.asn1.-P new file mode 100644 index 00000000..afadff7b --- /dev/null +++ b/tests/39-sequence-of-OK.asn1.-P @@ -0,0 +1,171 @@ + +/*** <<< DEPS [T] >>> ***/ + +/* Dependencies for T */ +#include + +/* Dependencies for collection */ +#include +#include + + #include +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_T; + +/*** <<< TYPE-DECLS [T] >>> ***/ + + +typedef struct T { + INTEGER_t int; + struct collection { + A_SEQUENCE_OF(struct T2) list; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } collection; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; +} T_t; + +/*** <<< STAT-DEFS [T] >>> ***/ + + static asn1_SET_OF_element_t asn1_DEF_collection_elements[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + (void *)&asn1_DEF_T2 }, + }; + static ber_tlv_tag_t asn1_DEF_collection_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) + }; + static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = { + sizeof(struct collection), + offsetof(struct collection, _ber_dec_ctx), + asn1_DEF_collection_elements + }; + asn1_TYPE_descriptor_t asn1_DEF_collection = { + "collection", + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_print, + SEQUENCE_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_collection_tags, + sizeof(asn1_DEF_collection_tags) + /sizeof(asn1_DEF_collection_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_collection_specs /* Additional specs */ + }; + +#include + +static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = { + { offsetof(struct T, int), 0, + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + 0, + (void *)&asn1_DEF_INTEGER, + "int" + }, + { offsetof(struct T, collection), 0, + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + 0, + (void *)&asn1_DEF_collection, + "collection" + }, +}; +static ber_tlv_tag_t asn1_DEF_T_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = { + sizeof(struct T), + offsetof(struct T, _ber_dec_ctx), + asn1_DEF_T_elements, + 2, /* Elements count */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_T = { + "T", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_T_tags, + sizeof(asn1_DEF_T_tags) + /sizeof(asn1_DEF_T_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_T_specs /* Additional specs */ +}; + + +/*** <<< DEPS [T2] >>> ***/ + +/* Dependencies for T2 */ +#include +#include + +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_T2; + +/*** <<< TYPE-DECLS [T2] >>> ***/ + + +typedef struct T2 { + BOOLEAN_t flag; + UTF8String_t str; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; +} T2_t; + +/*** <<< STAT-DEFS [T2] >>> ***/ + +#include + +static asn1_SEQUENCE_element_t asn1_DEF_T2_elements[] = { + { offsetof(struct T2, flag), 0, + (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), + 0, + (void *)&asn1_DEF_BOOLEAN, + "flag" + }, + { offsetof(struct T2, str), 0, + (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), + 0, + (void *)&asn1_DEF_UTF8String, + "str" + }, +}; +static ber_tlv_tag_t asn1_DEF_T2_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = { + sizeof(struct T2), + offsetof(struct T2, _ber_dec_ctx), + asn1_DEF_T2_elements, + 2, /* Elements count */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_T2 = { + "T2", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_T2_tags, + sizeof(asn1_DEF_T2_tags) + /sizeof(asn1_DEF_T2_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_T2_specs /* Additional specs */ +}; + diff --git a/tests/40-int-optional-SE.asn1 b/tests/40-int-optional-SE.asn1 new file mode 100644 index 00000000..abe10659 --- /dev/null +++ b/tests/40-int-optional-SE.asn1 @@ -0,0 +1,27 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .40 + +ModuleTestIntOptional + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 40 } + DEFINITIONS ::= +BEGIN + + T ::= CHOICE { + seq SEQUENCE { + string UTF8String, + alpha INTEGER OPTIONAL, + beta INTEGER OPTIONAL + }, + set SET { + string UTF8String, + alpha INTEGER OPTIONAL, + beta INTEGER OPTIONAL + } + } + +END diff --git a/tests/41-int-optional-OK.asn1 b/tests/41-int-optional-OK.asn1 new file mode 100644 index 00000000..3e091d78 --- /dev/null +++ b/tests/41-int-optional-OK.asn1 @@ -0,0 +1,27 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .41 + +ModuleTestIntOptional + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 41 } + DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + + T ::= CHOICE { + seq SEQUENCE { + string UTF8String, + alpha INTEGER OPTIONAL, + beta INTEGER OPTIONAL + }, + set SET { + string UTF8String, + alpha INTEGER OPTIONAL, + beta INTEGER OPTIONAL + } + } + +END diff --git a/tests/42-real-life-OK.asn1 b/tests/42-real-life-OK.asn1 new file mode 100644 index 00000000..33802c21 --- /dev/null +++ b/tests/42-real-life-OK.asn1 @@ -0,0 +1,67 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .42 + +ModuleLAPStorage + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 42 } + DEFINITIONS EXTENSIBILITY IMPLIED ::= +BEGIN + + /* + * A package representing a distinguished log line. + * It contains + * - a digest of that line (actually, a normalized + * form with bells (\007) in place of variable components), + * - one or more sets of variable parts (presumably with different + * acceptability rules). + */ + LogLine ::= SEQUENCE { + line-digest IA5String, -- Log line normal form + varsets SEQUENCE (1..MAX) OF VariablePartSet + } + + /* + * This package contains a set of variable components of a log line. + * Each variable component may contain one or more "value samples", + * or a range between two samples. + */ + VariablePartSet ::= SEQUENCE { + vparts SEQUENCE (0..MAX) OF VariablePart, -- {123,321} + resolution ActionItem + } + + /* + * A description of a single variable part. + */ + VariablePart ::= CHOICE { + -- A set of acceptable values + vset SET (1..MAX) OF VisibleString, + -- A range of acceptable values + vrange SEQUENCE { + from VisibleString, + to VisibleString + } + } + + /* + * What to do with the log line. + */ + ActionItem ::= SEQUENCE { + accept-as ENUMERATED { + unknown, -- Action yet unknown. + safe, -- No action, just move on. + unsafe, -- Unsafe message. Inform NOC. + ... + }, + notify SEQUENCE { -- How to notify NOC. + critical BOOLEAN, -- Emit critical message + email SET OF VisibleString, -- Send emails + ... + } OPTIONAL + } + +END diff --git a/tests/42-real-life-OK.asn1.-PR b/tests/42-real-life-OK.asn1.-PR new file mode 100644 index 00000000..bcac56cb --- /dev/null +++ b/tests/42-real-life-OK.asn1.-PR @@ -0,0 +1,569 @@ + +/*** <<< DEPS [LogLine] >>> ***/ + +/* Dependencies for LogLine */ +#include + +/* Dependencies for varsets */ +#include +#include + + #include +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_LogLine; + +/*** <<< TYPE-DECLS [LogLine] >>> ***/ + + +typedef struct LogLine { + IA5String_t line_digest; + struct varsets { + A_SEQUENCE_OF(struct VariablePartSet) list; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } varsets; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; +} LogLine_t; + +/*** <<< STAT-DEFS [LogLine] >>> ***/ + + static asn1_SET_OF_element_t asn1_DEF_varsets_elements[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + (void *)&asn1_DEF_VariablePartSet }, + }; + static ber_tlv_tag_t asn1_DEF_varsets_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) + }; + static asn1_SET_OF_specifics_t asn1_DEF_varsets_specs = { + sizeof(struct varsets), + offsetof(struct varsets, _ber_dec_ctx), + asn1_DEF_varsets_elements + }; + asn1_TYPE_descriptor_t asn1_DEF_varsets = { + "varsets", + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_print, + SEQUENCE_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_varsets_tags, + sizeof(asn1_DEF_varsets_tags) + /sizeof(asn1_DEF_varsets_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_varsets_specs /* Additional specs */ + }; + +#include + +static asn1_SEQUENCE_element_t asn1_DEF_LogLine_elements[] = { + { offsetof(struct LogLine, line_digest), 0, + (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), + 0, + (void *)&asn1_DEF_IA5String, + "line-digest" + }, + { offsetof(struct LogLine, varsets), 0, + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + 0, + (void *)&asn1_DEF_varsets, + "varsets" + }, +}; +static ber_tlv_tag_t asn1_DEF_LogLine_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_LogLine_specs = { + sizeof(struct LogLine), + offsetof(struct LogLine, _ber_dec_ctx), + asn1_DEF_LogLine_elements, + 2, /* Elements count */ + 1, /* Start extensions */ + 3 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_LogLine = { + "LogLine", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_LogLine_tags, + sizeof(asn1_DEF_LogLine_tags) + /sizeof(asn1_DEF_LogLine_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_LogLine_specs /* Additional specs */ +}; + + +/*** <<< DEPS [VariablePartSet] >>> ***/ + +/* Dependencies for VariablePartSet */ +#include + +/* Dependencies for vparts */ +#include +#include + + #include +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_VariablePartSet; + +/*** <<< TYPE-DECLS [VariablePartSet] >>> ***/ + + +typedef struct VariablePartSet { + struct vparts { + A_SEQUENCE_OF(struct VariablePart) list; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } vparts; + ActionItem_t resolution; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; +} VariablePartSet_t; + +/*** <<< STAT-DEFS [VariablePartSet] >>> ***/ + + static asn1_SET_OF_element_t asn1_DEF_vparts_elements[] = { + { -1 /* Ambiguous tag (CHOICE?) */, + (void *)&asn1_DEF_VariablePart }, + }; + static ber_tlv_tag_t asn1_DEF_vparts_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) + }; + static asn1_SET_OF_specifics_t asn1_DEF_vparts_specs = { + sizeof(struct vparts), + offsetof(struct vparts, _ber_dec_ctx), + asn1_DEF_vparts_elements + }; + asn1_TYPE_descriptor_t asn1_DEF_vparts = { + "vparts", + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_print, + SEQUENCE_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_vparts_tags, + sizeof(asn1_DEF_vparts_tags) + /sizeof(asn1_DEF_vparts_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_vparts_specs /* Additional specs */ + }; + +#include + +static asn1_SEQUENCE_element_t asn1_DEF_VariablePartSet_elements[] = { + { offsetof(struct VariablePartSet, vparts), 0, + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + 0, + (void *)&asn1_DEF_vparts, + "vparts" + }, + { offsetof(struct VariablePartSet, resolution), 0, + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + 0, + (void *)&asn1_DEF_ActionItem, + "resolution" + }, +}; +static ber_tlv_tag_t asn1_DEF_VariablePartSet_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_VariablePartSet_specs = { + sizeof(struct VariablePartSet), + offsetof(struct VariablePartSet, _ber_dec_ctx), + asn1_DEF_VariablePartSet_elements, + 2, /* Elements count */ + 1, /* Start extensions */ + 3 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_VariablePartSet = { + "VariablePartSet", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_VariablePartSet_tags, + sizeof(asn1_DEF_VariablePartSet_tags) + /sizeof(asn1_DEF_VariablePartSet_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_VariablePartSet_specs /* Additional specs */ +}; + + +/*** <<< DEPS [VariablePart] >>> ***/ + + +/* Dependencies for vset */ +#include +#include + + #include + +/* Dependencies for vrange */ +#include +#include + + #include + +extern asn1_TYPE_descriptor_t asn1_DEF_VariablePart; + +/*** <<< TYPE-DECLS [VariablePart] >>> ***/ + + +typedef struct VariablePart { + enum { + VariablePart_PR_NOTHING, /* No components present */ + VariablePart_PR_vset, + VariablePart_PR_vrange, + } present; + union { + struct vset { + A_SET_OF(VisibleString_t) list; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } vset; + struct vrange { + VisibleString_t from; + VisibleString_t to; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } vrange; + /* + * This type is extensible, + * possible extensions are below. + */ + } choice; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; +} VariablePart_t; + +/*** <<< STAT-DEFS [VariablePart] >>> ***/ + + static asn1_SET_OF_element_t asn1_DEF_vset_elements[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + (void *)&asn1_DEF_VisibleString }, + }; + static ber_tlv_tag_t asn1_DEF_vset_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) + }; + static asn1_SET_OF_specifics_t asn1_DEF_vset_specs = { + sizeof(struct vset), + offsetof(struct vset, _ber_dec_ctx), + asn1_DEF_vset_elements + }; + asn1_TYPE_descriptor_t asn1_DEF_vset = { + "vset", + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_print, + SET_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_vset_tags, + sizeof(asn1_DEF_vset_tags) + /sizeof(asn1_DEF_vset_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_vset_specs /* Additional specs */ + }; + + #include + + static asn1_SEQUENCE_element_t asn1_DEF_vrange_elements[] = { + { offsetof(struct vrange, from), 0, + (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + 0, + (void *)&asn1_DEF_VisibleString, + "from" + }, + { offsetof(struct vrange, to), 0, + (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + 0, + (void *)&asn1_DEF_VisibleString, + "to" + }, + }; + static ber_tlv_tag_t asn1_DEF_vrange_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) + }; + static asn1_SEQUENCE_specifics_t asn1_DEF_vrange_specs = { + sizeof(struct vrange), + offsetof(struct vrange, _ber_dec_ctx), + asn1_DEF_vrange_elements, + 2, /* Elements count */ + 1, /* Start extensions */ + 3 /* Stop extensions */ + }; + asn1_TYPE_descriptor_t asn1_DEF_vrange = { + "vrange", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_vrange_tags, + sizeof(asn1_DEF_vrange_tags) + /sizeof(asn1_DEF_vrange_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_vrange_specs /* Additional specs */ + }; + +#include + +static asn1_CHOICE_element_t asn1_DEF_VariablePart_elements[] = { + { offsetof(struct VariablePart, choice.vset), 0, + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + 0, + (void *)&asn1_DEF_vset, + "vset" + }, + { offsetof(struct VariablePart, choice.vrange), 0, + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + 0, + (void *)&asn1_DEF_vrange, + "vrange" + }, +}; +static ber_tlv_tag_t asn1_DEF_VariablePart_tags[] = { + +}; +static asn1_CHOICE_tag2member_t asn1_DEF_VariablePart_tag2el[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1 }, /* vrange at 45 */ + { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 0 }, /* vset at 42 */ +}; +static asn1_CHOICE_specifics_t asn1_DEF_VariablePart_specs = { + sizeof(struct VariablePart), + offsetof(struct VariablePart, _ber_dec_ctx), + offsetof(struct VariablePart, present), + sizeof(((struct VariablePart *)0)->present), + asn1_DEF_VariablePart_elements, + 2, /* Elements count */ + asn1_DEF_VariablePart_tag2el, + 2, /* Count of tags in the map */ + 0 /* Whether extensible */ +}; +asn1_TYPE_descriptor_t asn1_DEF_VariablePart = { + "VariablePart", + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_print, + CHOICE_free, + CHOICE_outmost_tag, + asn1_DEF_VariablePart_tags, + sizeof(asn1_DEF_VariablePart_tags) + /sizeof(asn1_DEF_VariablePart_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_VariablePart_specs /* Additional specs */ +}; + + +/*** <<< DEPS [ActionItem] >>> ***/ + +/* Dependencies for ActionItem */ +#include + + typedef enum accept_as { + accept_as_unknown = 0, + accept_as_safe = 1, + accept_as_unsafe = 2, + /* + * Enumeration is extensible + */ + } accept_as_e; +/* Dependencies for notify */ +#include + +/* Dependencies for email */ +#include +#include + + #include + + #include + +#include + +extern asn1_TYPE_descriptor_t asn1_DEF_ActionItem; + +/*** <<< TYPE-DECLS [ActionItem] >>> ***/ + + +typedef struct ActionItem { + ENUMERATED_t accept_as; + struct notify { + BOOLEAN_t critical; + struct email { + A_SET_OF(VisibleString_t) list; + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } email; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; + } *notify; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + ber_dec_ctx_t _ber_dec_ctx; +} ActionItem_t; + +/*** <<< STAT-DEFS [ActionItem] >>> ***/ + + static asn1_SET_OF_element_t asn1_DEF_email_elements[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + (void *)&asn1_DEF_VisibleString }, + }; + static ber_tlv_tag_t asn1_DEF_email_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) + }; + static asn1_SET_OF_specifics_t asn1_DEF_email_specs = { + sizeof(struct email), + offsetof(struct email, _ber_dec_ctx), + asn1_DEF_email_elements + }; + asn1_TYPE_descriptor_t asn1_DEF_email = { + "email", + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_print, + SET_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_email_tags, + sizeof(asn1_DEF_email_tags) + /sizeof(asn1_DEF_email_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_email_specs /* Additional specs */ + }; + + #include + + static asn1_SEQUENCE_element_t asn1_DEF_notify_elements[] = { + { offsetof(struct notify, critical), 0, + (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), + 0, + (void *)&asn1_DEF_BOOLEAN, + "critical" + }, + { offsetof(struct notify, email), 0, + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + 0, + (void *)&asn1_DEF_email, + "email" + }, + }; + static ber_tlv_tag_t asn1_DEF_notify_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) + }; + static asn1_SEQUENCE_specifics_t asn1_DEF_notify_specs = { + sizeof(struct notify), + offsetof(struct notify, _ber_dec_ctx), + asn1_DEF_notify_elements, + 2, /* Elements count */ + 1, /* Start extensions */ + 3 /* Stop extensions */ + }; + asn1_TYPE_descriptor_t asn1_DEF_notify = { + "notify", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_notify_tags, + sizeof(asn1_DEF_notify_tags) + /sizeof(asn1_DEF_notify_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_notify_specs /* Additional specs */ + }; + +#include + +static asn1_SEQUENCE_element_t asn1_DEF_ActionItem_elements[] = { + { offsetof(struct ActionItem, accept_as), 0, + (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)), + 0, + (void *)&asn1_DEF_ENUMERATED, + "accept-as" + }, + { offsetof(struct ActionItem, notify), 1, + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + 0, + (void *)&asn1_DEF_notify, + "notify" + }, +}; +static ber_tlv_tag_t asn1_DEF_ActionItem_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_ActionItem_specs = { + sizeof(struct ActionItem), + offsetof(struct ActionItem, _ber_dec_ctx), + asn1_DEF_ActionItem_elements, + 2, /* Elements count */ + 1, /* Start extensions */ + 3 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_ActionItem = { + "ActionItem", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_ActionItem_tags, + sizeof(asn1_DEF_ActionItem_tags) + /sizeof(asn1_DEF_ActionItem_tags[0]), + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + &asn1_DEF_ActionItem_specs /* Additional specs */ +}; + diff --git a/tests/43-recursion-OK.asn1 b/tests/43-recursion-OK.asn1 new file mode 100644 index 00000000..185b8ccb --- /dev/null +++ b/tests/43-recursion-OK.asn1 @@ -0,0 +1,26 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .43 + +ModuleRecursion + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 43 } + DEFINITIONS ::= +BEGIN + + Test-structure-1 ::= SEQUENCE { + t-member1 SET OF Test-structure-1, + t-member2 SEQUENCE OF Test-structure-1, + t-member3 Test-structure-1 OPTIONAL + } + + Sets ::= SEQUENCE { + s-member1 SET OF INTEGER, + s-member2 SET OF ENUMERATED { a, b }, + s-member3 SET OF IA5String + } + +END diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 00000000..03dda3b3 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,2 @@ + +EXTRA_DIST = *.asn1* diff --git a/tests/Makefile.in b/tests/Makefile.in new file mode 100644 index 00000000..a391a53a --- /dev/null +++ b/tests/Makefile.in @@ -0,0 +1,219 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +EXTRA_DIST = *.asn1* +subdir = tests +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = README Makefile.am Makefile.in +all: all-am + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: +tags: TAGS +TAGS: + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tests/README b/tests/README new file mode 100644 index 00000000..abba3502 --- /dev/null +++ b/tests/README @@ -0,0 +1,24 @@ + +This is a collection of various little ASN.1 modules, used independently +by several different testing engines below the main tree (i.e. libasn1fix) +for stressing various aspects of compiler operation. + +The files follow certain naming conventions: + +Source file: + --{OK|SE|NP}.asn1 + +Regenerator test file: + --{OK|SE|NP}.asn1.[] + +Where + is arbitrary number (digits) + is arbitrary string, without dots + OK file syntax and semantics are absolutely correct + SE file semantics is wrong + NP file syntax is incorrect, file not parseable + command-line flags for compiler + +Example: + 07-int-OK.asn1 # Correct ASN.1 file + 07-int-OK.asn1.-EFN # Test of file regeneration with -EFN flags.