diff options
Diffstat (limited to 'source4/heimdal')
-rw-r--r-- | source4/heimdal/lib/asn1/asn1parse.c (renamed from source4/heimdal/lib/asn1/parse.c) | 190 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/asn1parse.h (renamed from source4/heimdal/lib/asn1/parse.h) | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/asn1parse.y | 1015 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/lex.c | 6 | ||||
-rw-r--r-- | source4/heimdal/lib/com_err/lex.c | 44 | ||||
-rw-r--r-- | source4/heimdal/lib/com_err/parse.c | 32 | ||||
-rw-r--r-- | source4/heimdal/lib/com_err/parse.h | 2 | ||||
-rw-r--r-- | source4/heimdal/lib/hx509/sel-gram.c | 65 | ||||
-rw-r--r-- | source4/heimdal/lib/hx509/sel-gram.h | 2 |
9 files changed, 1185 insertions, 175 deletions
diff --git a/source4/heimdal/lib/asn1/parse.c b/source4/heimdal/lib/asn1/asn1parse.c index 5e73953b24..5dbb63b392 100644 --- a/source4/heimdal/lib/asn1/parse.c +++ b/source4/heimdal/lib/asn1/asn1parse.c @@ -248,11 +248,11 @@ /* Copy the first part of user declarations. */ -#line 36 "heimdal/lib/asn1/parse.y" +#line 36 "heimdal/lib/asn1/asn1parse.y" + -#ifdef HAVE_CONFIG_H #include <config.h> -#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -298,7 +298,7 @@ struct string_list { #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 65 "heimdal/lib/asn1/parse.y" +#line 65 "heimdal/lib/asn1/asn1parse.y" { int constant; struct value *value; @@ -314,7 +314,7 @@ typedef union YYSTYPE struct constraint_spec *constraint_spec; } /* Line 187 of yacc.c. */ -#line 318 "heimdal/lib/asn1/parse.y" +#line 318 "heimdal/lib/asn1/asn1parse.y" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -327,7 +327,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 331 "heimdal/lib/asn1/parse.y" +#line 331 "heimdal/lib/asn1/asn1parse.y" #ifdef short # undef short @@ -1762,29 +1762,29 @@ yyreduce: switch (yyn) { case 2: -#line 235 "heimdal/lib/asn1/parse.y" +#line 235 "heimdal/lib/asn1/asn1parse.y" { checkundefined(); } break; case 4: -#line 242 "heimdal/lib/asn1/parse.y" +#line 242 "heimdal/lib/asn1/asn1parse.y" { error_message("implicit tagging is not supported"); } break; case 5: -#line 244 "heimdal/lib/asn1/parse.y" +#line 244 "heimdal/lib/asn1/asn1parse.y" { error_message("automatic tagging is not supported"); } break; case 7: -#line 249 "heimdal/lib/asn1/parse.y" +#line 249 "heimdal/lib/asn1/asn1parse.y" { error_message("no extensibility options supported"); } break; case 17: -#line 270 "heimdal/lib/asn1/parse.y" +#line 270 "heimdal/lib/asn1/asn1parse.y" { struct string_list *sl; for(sl = (yyvsp[(1) - (4)].sl); sl != NULL; sl = sl->next) { @@ -1796,7 +1796,7 @@ yyreduce: break; case 22: -#line 289 "heimdal/lib/asn1/parse.y" +#line 289 "heimdal/lib/asn1/asn1parse.y" { (yyval.sl) = emalloc(sizeof(*(yyval.sl))); (yyval.sl)->string = (yyvsp[(1) - (3)].name); @@ -1805,7 +1805,7 @@ yyreduce: break; case 23: -#line 295 "heimdal/lib/asn1/parse.y" +#line 295 "heimdal/lib/asn1/asn1parse.y" { (yyval.sl) = emalloc(sizeof(*(yyval.sl))); (yyval.sl)->string = (yyvsp[(1) - (1)].name); @@ -1814,7 +1814,7 @@ yyreduce: break; case 24: -#line 303 "heimdal/lib/asn1/parse.y" +#line 303 "heimdal/lib/asn1/asn1parse.y" { Symbol *s = addsym ((yyvsp[(1) - (3)].name)); s->stype = Stype; @@ -1825,7 +1825,7 @@ yyreduce: break; case 42: -#line 334 "heimdal/lib/asn1/parse.y" +#line 334 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_Boolean, TE_EXPLICIT, new_type(TBoolean)); @@ -1833,7 +1833,7 @@ yyreduce: break; case 43: -#line 341 "heimdal/lib/asn1/parse.y" +#line 341 "heimdal/lib/asn1/asn1parse.y" { if((yyvsp[(2) - (5)].value)->type != integervalue) error_message("Non-integer used in first part of range"); @@ -1846,8 +1846,8 @@ yyreduce: break; case 44: -#line 351 "heimdal/lib/asn1/parse.y" - { +#line 351 "heimdal/lib/asn1/asn1parse.y" + { if((yyvsp[(2) - (5)].value)->type != integervalue) error_message("Non-integer in first part of range"); (yyval.range) = ecalloc(1, sizeof(*(yyval.range))); @@ -1857,8 +1857,8 @@ yyreduce: break; case 45: -#line 359 "heimdal/lib/asn1/parse.y" - { +#line 359 "heimdal/lib/asn1/asn1parse.y" + { if((yyvsp[(4) - (5)].value)->type != integervalue) error_message("Non-integer in second part of range"); (yyval.range) = ecalloc(1, sizeof(*(yyval.range))); @@ -1868,7 +1868,7 @@ yyreduce: break; case 46: -#line 367 "heimdal/lib/asn1/parse.y" +#line 367 "heimdal/lib/asn1/asn1parse.y" { if((yyvsp[(2) - (3)].value)->type != integervalue) error_message("Non-integer used in limit"); @@ -1879,7 +1879,7 @@ yyreduce: break; case 47: -#line 378 "heimdal/lib/asn1/parse.y" +#line 378 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, new_type(TInteger)); @@ -1887,7 +1887,7 @@ yyreduce: break; case 48: -#line 383 "heimdal/lib/asn1/parse.y" +#line 383 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TInteger); (yyval.type)->range = (yyvsp[(2) - (2)].range); @@ -1896,7 +1896,7 @@ yyreduce: break; case 49: -#line 389 "heimdal/lib/asn1/parse.y" +#line 389 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TInteger); (yyval.type)->members = (yyvsp[(3) - (4)].members); @@ -1905,7 +1905,7 @@ yyreduce: break; case 50: -#line 397 "heimdal/lib/asn1/parse.y" +#line 397 "heimdal/lib/asn1/asn1parse.y" { (yyval.members) = emalloc(sizeof(*(yyval.members))); ASN1_TAILQ_INIT((yyval.members)); @@ -1914,7 +1914,7 @@ yyreduce: break; case 51: -#line 403 "heimdal/lib/asn1/parse.y" +#line 403 "heimdal/lib/asn1/asn1parse.y" { ASN1_TAILQ_INSERT_TAIL((yyvsp[(1) - (3)].members), (yyvsp[(3) - (3)].member), members); (yyval.members) = (yyvsp[(1) - (3)].members); @@ -1922,12 +1922,12 @@ yyreduce: break; case 52: -#line 408 "heimdal/lib/asn1/parse.y" +#line 408 "heimdal/lib/asn1/asn1parse.y" { (yyval.members) = (yyvsp[(1) - (3)].members); } break; case 53: -#line 412 "heimdal/lib/asn1/parse.y" +#line 412 "heimdal/lib/asn1/asn1parse.y" { (yyval.member) = emalloc(sizeof(*(yyval.member))); (yyval.member)->name = (yyvsp[(1) - (4)].name); @@ -1941,7 +1941,7 @@ yyreduce: break; case 54: -#line 425 "heimdal/lib/asn1/parse.y" +#line 425 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TInteger); (yyval.type)->members = (yyvsp[(3) - (4)].members); @@ -1950,7 +1950,7 @@ yyreduce: break; case 56: -#line 436 "heimdal/lib/asn1/parse.y" +#line 436 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TBitString); (yyval.type)->members = emalloc(sizeof(*(yyval.type)->members)); @@ -1960,7 +1960,7 @@ yyreduce: break; case 57: -#line 443 "heimdal/lib/asn1/parse.y" +#line 443 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TBitString); (yyval.type)->members = (yyvsp[(4) - (5)].members); @@ -1969,7 +1969,7 @@ yyreduce: break; case 58: -#line 451 "heimdal/lib/asn1/parse.y" +#line 451 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_OID, TE_EXPLICIT, new_type(TOID)); @@ -1977,7 +1977,7 @@ yyreduce: break; case 59: -#line 457 "heimdal/lib/asn1/parse.y" +#line 457 "heimdal/lib/asn1/asn1parse.y" { Type *t = new_type(TOctetString); t->range = (yyvsp[(3) - (3)].range); @@ -1987,7 +1987,7 @@ yyreduce: break; case 60: -#line 466 "heimdal/lib/asn1/parse.y" +#line 466 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_Null, TE_EXPLICIT, new_type(TNull)); @@ -1995,17 +1995,17 @@ yyreduce: break; case 61: -#line 473 "heimdal/lib/asn1/parse.y" +#line 473 "heimdal/lib/asn1/asn1parse.y" { (yyval.range) = NULL; } break; case 62: -#line 475 "heimdal/lib/asn1/parse.y" +#line 475 "heimdal/lib/asn1/asn1parse.y" { (yyval.range) = (yyvsp[(2) - (2)].range); } break; case 63: -#line 480 "heimdal/lib/asn1/parse.y" +#line 480 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TSequence); (yyval.type)->members = (yyvsp[(3) - (4)].members); @@ -2014,7 +2014,7 @@ yyreduce: break; case 64: -#line 486 "heimdal/lib/asn1/parse.y" +#line 486 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TSequence); (yyval.type)->members = NULL; @@ -2023,7 +2023,7 @@ yyreduce: break; case 65: -#line 494 "heimdal/lib/asn1/parse.y" +#line 494 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TSequenceOf); (yyval.type)->range = (yyvsp[(2) - (4)].range); @@ -2033,7 +2033,7 @@ yyreduce: break; case 66: -#line 503 "heimdal/lib/asn1/parse.y" +#line 503 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TSet); (yyval.type)->members = (yyvsp[(3) - (4)].members); @@ -2042,7 +2042,7 @@ yyreduce: break; case 67: -#line 509 "heimdal/lib/asn1/parse.y" +#line 509 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TSet); (yyval.type)->members = NULL; @@ -2051,7 +2051,7 @@ yyreduce: break; case 68: -#line 517 "heimdal/lib/asn1/parse.y" +#line 517 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TSetOf); (yyval.type)->subtype = (yyvsp[(3) - (3)].type); @@ -2060,7 +2060,7 @@ yyreduce: break; case 69: -#line 525 "heimdal/lib/asn1/parse.y" +#line 525 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TChoice); (yyval.type)->members = (yyvsp[(3) - (4)].members); @@ -2068,7 +2068,7 @@ yyreduce: break; case 72: -#line 536 "heimdal/lib/asn1/parse.y" +#line 536 "heimdal/lib/asn1/asn1parse.y" { Symbol *s = addsym((yyvsp[(1) - (1)].name)); (yyval.type) = new_type(TType); @@ -2080,7 +2080,7 @@ yyreduce: break; case 73: -#line 547 "heimdal/lib/asn1/parse.y" +#line 547 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_GeneralizedTime, TE_EXPLICIT, new_type(TGeneralizedTime)); @@ -2088,7 +2088,7 @@ yyreduce: break; case 74: -#line 552 "heimdal/lib/asn1/parse.y" +#line 552 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_UTCTime, TE_EXPLICIT, new_type(TUTCTime)); @@ -2096,7 +2096,7 @@ yyreduce: break; case 75: -#line 559 "heimdal/lib/asn1/parse.y" +#line 559 "heimdal/lib/asn1/asn1parse.y" { /* if (Constraint.type == contentConstrant) { assert(Constraint.u.constraint.type == octetstring|bitstring-w/o-NamedBitList); // remember to check type reference too @@ -2112,14 +2112,14 @@ yyreduce: break; case 76: -#line 575 "heimdal/lib/asn1/parse.y" +#line 575 "heimdal/lib/asn1/asn1parse.y" { (yyval.constraint_spec) = (yyvsp[(2) - (3)].constraint_spec); } break; case 80: -#line 588 "heimdal/lib/asn1/parse.y" +#line 588 "heimdal/lib/asn1/asn1parse.y" { (yyval.constraint_spec) = new_constraint_spec(CT_CONTENTS); (yyval.constraint_spec)->u.content.type = (yyvsp[(2) - (2)].type); @@ -2128,7 +2128,7 @@ yyreduce: break; case 81: -#line 594 "heimdal/lib/asn1/parse.y" +#line 594 "heimdal/lib/asn1/asn1parse.y" { if ((yyvsp[(3) - (3)].value)->type != objectidentifiervalue) error_message("Non-OID used in ENCODED BY constraint"); @@ -2139,7 +2139,7 @@ yyreduce: break; case 82: -#line 602 "heimdal/lib/asn1/parse.y" +#line 602 "heimdal/lib/asn1/asn1parse.y" { if ((yyvsp[(5) - (5)].value)->type != objectidentifiervalue) error_message("Non-OID used in ENCODED BY constraint"); @@ -2150,14 +2150,14 @@ yyreduce: break; case 83: -#line 612 "heimdal/lib/asn1/parse.y" +#line 612 "heimdal/lib/asn1/asn1parse.y" { (yyval.constraint_spec) = new_constraint_spec(CT_USER); } break; case 84: -#line 618 "heimdal/lib/asn1/parse.y" +#line 618 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_type(TTag); (yyval.type)->tag = (yyvsp[(1) - (3)].tag); @@ -2171,7 +2171,7 @@ yyreduce: break; case 85: -#line 631 "heimdal/lib/asn1/parse.y" +#line 631 "heimdal/lib/asn1/asn1parse.y" { (yyval.tag).tagclass = (yyvsp[(2) - (4)].constant); (yyval.tag).tagvalue = (yyvsp[(3) - (4)].constant); @@ -2180,56 +2180,56 @@ yyreduce: break; case 86: -#line 639 "heimdal/lib/asn1/parse.y" +#line 639 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = ASN1_C_CONTEXT; } break; case 87: -#line 643 "heimdal/lib/asn1/parse.y" +#line 643 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = ASN1_C_UNIV; } break; case 88: -#line 647 "heimdal/lib/asn1/parse.y" +#line 647 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = ASN1_C_APPL; } break; case 89: -#line 651 "heimdal/lib/asn1/parse.y" +#line 651 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = ASN1_C_PRIVATE; } break; case 90: -#line 657 "heimdal/lib/asn1/parse.y" +#line 657 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = TE_EXPLICIT; } break; case 91: -#line 661 "heimdal/lib/asn1/parse.y" +#line 661 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = TE_EXPLICIT; } break; case 92: -#line 665 "heimdal/lib/asn1/parse.y" +#line 665 "heimdal/lib/asn1/asn1parse.y" { (yyval.constant) = TE_IMPLICIT; } break; case 93: -#line 672 "heimdal/lib/asn1/parse.y" +#line 672 "heimdal/lib/asn1/asn1parse.y" { Symbol *s; s = addsym ((yyvsp[(1) - (4)].name)); @@ -2241,7 +2241,7 @@ yyreduce: break; case 95: -#line 686 "heimdal/lib/asn1/parse.y" +#line 686 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_GeneralString, TE_EXPLICIT, new_type(TGeneralString)); @@ -2249,7 +2249,7 @@ yyreduce: break; case 96: -#line 691 "heimdal/lib/asn1/parse.y" +#line 691 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_UTF8String, TE_EXPLICIT, new_type(TUTF8String)); @@ -2257,7 +2257,7 @@ yyreduce: break; case 97: -#line 696 "heimdal/lib/asn1/parse.y" +#line 696 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_PrintableString, TE_EXPLICIT, new_type(TPrintableString)); @@ -2265,7 +2265,7 @@ yyreduce: break; case 98: -#line 701 "heimdal/lib/asn1/parse.y" +#line 701 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_VisibleString, TE_EXPLICIT, new_type(TVisibleString)); @@ -2273,7 +2273,7 @@ yyreduce: break; case 99: -#line 706 "heimdal/lib/asn1/parse.y" +#line 706 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_IA5String, TE_EXPLICIT, new_type(TIA5String)); @@ -2281,7 +2281,7 @@ yyreduce: break; case 100: -#line 711 "heimdal/lib/asn1/parse.y" +#line 711 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_BMPString, TE_EXPLICIT, new_type(TBMPString)); @@ -2289,7 +2289,7 @@ yyreduce: break; case 101: -#line 716 "heimdal/lib/asn1/parse.y" +#line 716 "heimdal/lib/asn1/asn1parse.y" { (yyval.type) = new_tag(ASN1_C_UNIV, UT_UniversalString, TE_EXPLICIT, new_type(TUniversalString)); @@ -2297,7 +2297,7 @@ yyreduce: break; case 102: -#line 724 "heimdal/lib/asn1/parse.y" +#line 724 "heimdal/lib/asn1/asn1parse.y" { (yyval.members) = emalloc(sizeof(*(yyval.members))); ASN1_TAILQ_INIT((yyval.members)); @@ -2306,7 +2306,7 @@ yyreduce: break; case 103: -#line 730 "heimdal/lib/asn1/parse.y" +#line 730 "heimdal/lib/asn1/asn1parse.y" { ASN1_TAILQ_INSERT_TAIL((yyvsp[(1) - (3)].members), (yyvsp[(3) - (3)].member), members); (yyval.members) = (yyvsp[(1) - (3)].members); @@ -2314,7 +2314,7 @@ yyreduce: break; case 104: -#line 735 "heimdal/lib/asn1/parse.y" +#line 735 "heimdal/lib/asn1/asn1parse.y" { struct member *m = ecalloc(1, sizeof(*m)); m->name = estrdup("..."); @@ -2326,7 +2326,7 @@ yyreduce: break; case 105: -#line 746 "heimdal/lib/asn1/parse.y" +#line 746 "heimdal/lib/asn1/asn1parse.y" { (yyval.member) = emalloc(sizeof(*(yyval.member))); (yyval.member)->name = (yyvsp[(1) - (2)].name); @@ -2338,7 +2338,7 @@ yyreduce: break; case 106: -#line 757 "heimdal/lib/asn1/parse.y" +#line 757 "heimdal/lib/asn1/asn1parse.y" { (yyval.member) = (yyvsp[(1) - (1)].member); (yyval.member)->optional = 0; @@ -2347,7 +2347,7 @@ yyreduce: break; case 107: -#line 763 "heimdal/lib/asn1/parse.y" +#line 763 "heimdal/lib/asn1/asn1parse.y" { (yyval.member) = (yyvsp[(1) - (2)].member); (yyval.member)->optional = 1; @@ -2356,7 +2356,7 @@ yyreduce: break; case 108: -#line 769 "heimdal/lib/asn1/parse.y" +#line 769 "heimdal/lib/asn1/asn1parse.y" { (yyval.member) = (yyvsp[(1) - (3)].member); (yyval.member)->optional = 0; @@ -2365,7 +2365,7 @@ yyreduce: break; case 109: -#line 777 "heimdal/lib/asn1/parse.y" +#line 777 "heimdal/lib/asn1/asn1parse.y" { (yyval.members) = emalloc(sizeof(*(yyval.members))); ASN1_TAILQ_INIT((yyval.members)); @@ -2374,7 +2374,7 @@ yyreduce: break; case 110: -#line 783 "heimdal/lib/asn1/parse.y" +#line 783 "heimdal/lib/asn1/asn1parse.y" { ASN1_TAILQ_INSERT_TAIL((yyvsp[(1) - (3)].members), (yyvsp[(3) - (3)].member), members); (yyval.members) = (yyvsp[(1) - (3)].members); @@ -2382,7 +2382,7 @@ yyreduce: break; case 111: -#line 790 "heimdal/lib/asn1/parse.y" +#line 790 "heimdal/lib/asn1/asn1parse.y" { (yyval.member) = emalloc(sizeof(*(yyval.member))); (yyval.member)->name = (yyvsp[(1) - (4)].name); @@ -2396,26 +2396,26 @@ yyreduce: break; case 113: -#line 803 "heimdal/lib/asn1/parse.y" +#line 803 "heimdal/lib/asn1/asn1parse.y" { (yyval.objid) = NULL; } break; case 114: -#line 807 "heimdal/lib/asn1/parse.y" +#line 807 "heimdal/lib/asn1/asn1parse.y" { (yyval.objid) = (yyvsp[(2) - (3)].objid); } break; case 115: -#line 813 "heimdal/lib/asn1/parse.y" +#line 813 "heimdal/lib/asn1/asn1parse.y" { (yyval.objid) = NULL; } break; case 116: -#line 817 "heimdal/lib/asn1/parse.y" +#line 817 "heimdal/lib/asn1/asn1parse.y" { if ((yyvsp[(2) - (2)].objid)) { (yyval.objid) = (yyvsp[(2) - (2)].objid); @@ -2427,14 +2427,14 @@ yyreduce: break; case 117: -#line 828 "heimdal/lib/asn1/parse.y" +#line 828 "heimdal/lib/asn1/asn1parse.y" { (yyval.objid) = new_objid((yyvsp[(1) - (4)].name), (yyvsp[(3) - (4)].constant)); } break; case 118: -#line 832 "heimdal/lib/asn1/parse.y" +#line 832 "heimdal/lib/asn1/asn1parse.y" { Symbol *s = addsym((yyvsp[(1) - (1)].name)); if(s->stype != SValue || @@ -2448,14 +2448,14 @@ yyreduce: break; case 119: -#line 843 "heimdal/lib/asn1/parse.y" +#line 843 "heimdal/lib/asn1/asn1parse.y" { (yyval.objid) = new_objid(NULL, (yyvsp[(1) - (1)].constant)); } break; case 129: -#line 866 "heimdal/lib/asn1/parse.y" +#line 866 "heimdal/lib/asn1/asn1parse.y" { Symbol *s = addsym((yyvsp[(1) - (1)].name)); if(s->stype != SValue) @@ -2467,7 +2467,7 @@ yyreduce: break; case 130: -#line 877 "heimdal/lib/asn1/parse.y" +#line 877 "heimdal/lib/asn1/asn1parse.y" { (yyval.value) = emalloc(sizeof(*(yyval.value))); (yyval.value)->type = stringvalue; @@ -2476,7 +2476,7 @@ yyreduce: break; case 131: -#line 885 "heimdal/lib/asn1/parse.y" +#line 885 "heimdal/lib/asn1/asn1parse.y" { (yyval.value) = emalloc(sizeof(*(yyval.value))); (yyval.value)->type = booleanvalue; @@ -2485,7 +2485,7 @@ yyreduce: break; case 132: -#line 891 "heimdal/lib/asn1/parse.y" +#line 891 "heimdal/lib/asn1/asn1parse.y" { (yyval.value) = emalloc(sizeof(*(yyval.value))); (yyval.value)->type = booleanvalue; @@ -2494,7 +2494,7 @@ yyreduce: break; case 133: -#line 899 "heimdal/lib/asn1/parse.y" +#line 899 "heimdal/lib/asn1/asn1parse.y" { (yyval.value) = emalloc(sizeof(*(yyval.value))); (yyval.value)->type = integervalue; @@ -2503,13 +2503,13 @@ yyreduce: break; case 135: -#line 910 "heimdal/lib/asn1/parse.y" +#line 910 "heimdal/lib/asn1/asn1parse.y" { } break; case 136: -#line 915 "heimdal/lib/asn1/parse.y" +#line 915 "heimdal/lib/asn1/asn1parse.y" { (yyval.value) = emalloc(sizeof(*(yyval.value))); (yyval.value)->type = objectidentifiervalue; @@ -2519,7 +2519,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 2523 "heimdal/lib/asn1/parse.y" +#line 2523 "heimdal/lib/asn1/asn1parse.y" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2733,7 +2733,7 @@ yyreturn: } -#line 922 "heimdal/lib/asn1/parse.y" +#line 922 "heimdal/lib/asn1/asn1parse.y" void diff --git a/source4/heimdal/lib/asn1/parse.h b/source4/heimdal/lib/asn1/asn1parse.h index bea506ca7b..67b9aacc0a 100644 --- a/source4/heimdal/lib/asn1/parse.h +++ b/source4/heimdal/lib/asn1/asn1parse.h @@ -222,7 +222,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 65 "heimdal/lib/asn1/parse.y" +#line 65 "heimdal/lib/asn1/asn1parse.y" { int constant; struct value *value; @@ -238,7 +238,7 @@ typedef union YYSTYPE struct constraint_spec *constraint_spec; } /* Line 1489 of yacc.c. */ -#line 242 "heimdal/lib/asn1/parse.y" +#line 242 "heimdal/lib/asn1/asn1parse.y" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 diff --git a/source4/heimdal/lib/asn1/asn1parse.y b/source4/heimdal/lib/asn1/asn1parse.y new file mode 100644 index 0000000000..7975fe4f6b --- /dev/null +++ b/source4/heimdal/lib/asn1/asn1parse.y @@ -0,0 +1,1015 @@ +/* + * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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$ */ + +%{ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "symbol.h" +#include "lex.h" +#include "gen_locl.h" +#include "der.h" + +RCSID("$Id$"); + +static Type *new_type (Typetype t); +static struct constraint_spec *new_constraint_spec(enum ctype); +static Type *new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype); +void yyerror (const char *); +static struct objid *new_objid(const char *label, int value); +static void add_oid_to_tail(struct objid *, struct objid *); +static void fix_labels(Symbol *s); + +struct string_list { + char *string; + struct string_list *next; +}; + +%} + +%union { + int constant; + struct value *value; + struct range *range; + char *name; + Type *type; + Member *member; + struct objid *objid; + char *defval; + struct string_list *sl; + struct tagtype tag; + struct memhead *members; + struct constraint_spec *constraint_spec; +} + +%token kw_ABSENT +%token kw_ABSTRACT_SYNTAX +%token kw_ALL +%token kw_APPLICATION +%token kw_AUTOMATIC +%token kw_BEGIN +%token kw_BIT +%token kw_BMPString +%token kw_BOOLEAN +%token kw_BY +%token kw_CHARACTER +%token kw_CHOICE +%token kw_CLASS +%token kw_COMPONENT +%token kw_COMPONENTS +%token kw_CONSTRAINED +%token kw_CONTAINING +%token kw_DEFAULT +%token kw_DEFINITIONS +%token kw_EMBEDDED +%token kw_ENCODED +%token kw_END +%token kw_ENUMERATED +%token kw_EXCEPT +%token kw_EXPLICIT +%token kw_EXPORTS +%token kw_EXTENSIBILITY +%token kw_EXTERNAL +%token kw_FALSE +%token kw_FROM +%token kw_GeneralString +%token kw_GeneralizedTime +%token kw_GraphicString +%token kw_IA5String +%token kw_IDENTIFIER +%token kw_IMPLICIT +%token kw_IMPLIED +%token kw_IMPORTS +%token kw_INCLUDES +%token kw_INSTANCE +%token kw_INTEGER +%token kw_INTERSECTION +%token kw_ISO646String +%token kw_MAX +%token kw_MIN +%token kw_MINUS_INFINITY +%token kw_NULL +%token kw_NumericString +%token kw_OBJECT +%token kw_OCTET +%token kw_OF +%token kw_OPTIONAL +%token kw_ObjectDescriptor +%token kw_PATTERN +%token kw_PDV +%token kw_PLUS_INFINITY +%token kw_PRESENT +%token kw_PRIVATE +%token kw_PrintableString +%token kw_REAL +%token kw_RELATIVE_OID +%token kw_SEQUENCE +%token kw_SET +%token kw_SIZE +%token kw_STRING +%token kw_SYNTAX +%token kw_T61String +%token kw_TAGS +%token kw_TRUE +%token kw_TYPE_IDENTIFIER +%token kw_TeletexString +%token kw_UNION +%token kw_UNIQUE +%token kw_UNIVERSAL +%token kw_UTCTime +%token kw_UTF8String +%token kw_UniversalString +%token kw_VideotexString +%token kw_VisibleString +%token kw_WITH + +%token RANGE +%token EEQUAL +%token ELLIPSIS + +%token <name> IDENTIFIER referencename +%token <name> STRING + +%token <constant> NUMBER +%type <constant> SignedNumber +%type <constant> Class tagenv + +%type <value> Value +%type <value> BuiltinValue +%type <value> IntegerValue +%type <value> BooleanValue +%type <value> ObjectIdentifierValue +%type <value> CharacterStringValue +%type <value> NullValue +%type <value> DefinedValue +%type <value> ReferencedValue +%type <value> Valuereference + +%type <type> Type +%type <type> BuiltinType +%type <type> BitStringType +%type <type> BooleanType +%type <type> ChoiceType +%type <type> ConstrainedType +%type <type> EnumeratedType +%type <type> IntegerType +%type <type> NullType +%type <type> OctetStringType +%type <type> SequenceType +%type <type> SequenceOfType +%type <type> SetType +%type <type> SetOfType +%type <type> TaggedType +%type <type> ReferencedType +%type <type> DefinedType +%type <type> UsefulType +%type <type> ObjectIdentifierType +%type <type> CharacterStringType +%type <type> RestrictedCharactedStringType + +%type <tag> Tag + +%type <member> ComponentType +%type <member> NamedBit +%type <member> NamedNumber +%type <member> NamedType +%type <members> ComponentTypeList +%type <members> Enumerations +%type <members> NamedBitList +%type <members> NamedNumberList + +%type <objid> objid objid_list objid_element objid_opt +%type <range> range size + +%type <sl> referencenames + +%type <constraint_spec> Constraint +%type <constraint_spec> ConstraintSpec +%type <constraint_spec> GeneralConstraint +%type <constraint_spec> ContentsConstraint +%type <constraint_spec> UserDefinedConstraint + + + +%start ModuleDefinition + +%% + +ModuleDefinition: IDENTIFIER objid_opt kw_DEFINITIONS TagDefault ExtensionDefault + EEQUAL kw_BEGIN ModuleBody kw_END + { + checkundefined(); + } + ; + +TagDefault : kw_EXPLICIT kw_TAGS + | kw_IMPLICIT kw_TAGS + { error_message("implicit tagging is not supported"); } + | kw_AUTOMATIC kw_TAGS + { error_message("automatic tagging is not supported"); } + | /* empty */ + ; + +ExtensionDefault: kw_EXTENSIBILITY kw_IMPLIED + { error_message("no extensibility options supported"); } + | /* empty */ + ; + +ModuleBody : /* Exports */ Imports AssignmentList + | /* empty */ + ; + +Imports : kw_IMPORTS SymbolsImported ';' + | /* empty */ + ; + +SymbolsImported : SymbolsFromModuleList + | /* empty */ + ; + +SymbolsFromModuleList: SymbolsFromModule + | SymbolsFromModuleList SymbolsFromModule + ; + +SymbolsFromModule: referencenames kw_FROM IDENTIFIER objid_opt + { + struct string_list *sl; + for(sl = $1; sl != NULL; sl = sl->next) { + Symbol *s = addsym(sl->string); + s->stype = Stype; + } + add_import($3); + } + ; + +AssignmentList : Assignment + | Assignment AssignmentList + ; + +Assignment : TypeAssignment + | ValueAssignment + ; + +referencenames : IDENTIFIER ',' referencenames + { + $$ = emalloc(sizeof(*$$)); + $$->string = $1; + $$->next = $3; + } + | IDENTIFIER + { + $$ = emalloc(sizeof(*$$)); + $$->string = $1; + $$->next = NULL; + } + ; + +TypeAssignment : IDENTIFIER EEQUAL Type + { + Symbol *s = addsym ($1); + s->stype = Stype; + s->type = $3; + fix_labels(s); + generate_type (s); + } + ; + +Type : BuiltinType + | ReferencedType + | ConstrainedType + ; + +BuiltinType : BitStringType + | BooleanType + | CharacterStringType + | ChoiceType + | EnumeratedType + | IntegerType + | NullType + | ObjectIdentifierType + | OctetStringType + | SequenceType + | SequenceOfType + | SetType + | SetOfType + | TaggedType + ; + +BooleanType : kw_BOOLEAN + { + $$ = new_tag(ASN1_C_UNIV, UT_Boolean, + TE_EXPLICIT, new_type(TBoolean)); + } + ; + +range : '(' Value RANGE Value ')' + { + if($2->type != integervalue) + error_message("Non-integer used in first part of range"); + if($2->type != integervalue) + error_message("Non-integer in second part of range"); + $$ = ecalloc(1, sizeof(*$$)); + $$->min = $2->u.integervalue; + $$->max = $4->u.integervalue; + } + | '(' Value RANGE kw_MAX ')' + { + if($2->type != integervalue) + error_message("Non-integer in first part of range"); + $$ = ecalloc(1, sizeof(*$$)); + $$->min = $2->u.integervalue; + $$->max = $2->u.integervalue - 1; + } + | '(' kw_MIN RANGE Value ')' + { + if($4->type != integervalue) + error_message("Non-integer in second part of range"); + $$ = ecalloc(1, sizeof(*$$)); + $$->min = $4->u.integervalue + 2; + $$->max = $4->u.integervalue; + } + | '(' Value ')' + { + if($2->type != integervalue) + error_message("Non-integer used in limit"); + $$ = ecalloc(1, sizeof(*$$)); + $$->min = $2->u.integervalue; + $$->max = $2->u.integervalue; + } + ; + + +IntegerType : kw_INTEGER + { + $$ = new_tag(ASN1_C_UNIV, UT_Integer, + TE_EXPLICIT, new_type(TInteger)); + } + | kw_INTEGER range + { + $$ = new_type(TInteger); + $$->range = $2; + $$ = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, $$); + } + | kw_INTEGER '{' NamedNumberList '}' + { + $$ = new_type(TInteger); + $$->members = $3; + $$ = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, $$); + } + ; + +NamedNumberList : NamedNumber + { + $$ = emalloc(sizeof(*$$)); + ASN1_TAILQ_INIT($$); + ASN1_TAILQ_INSERT_HEAD($$, $1, members); + } + | NamedNumberList ',' NamedNumber + { + ASN1_TAILQ_INSERT_TAIL($1, $3, members); + $$ = $1; + } + | NamedNumberList ',' ELLIPSIS + { $$ = $1; } /* XXX used for Enumerations */ + ; + +NamedNumber : IDENTIFIER '(' SignedNumber ')' + { + $$ = emalloc(sizeof(*$$)); + $$->name = $1; + $$->gen_name = estrdup($1); + output_name ($$->gen_name); + $$->val = $3; + $$->optional = 0; + $$->ellipsis = 0; + $$->type = NULL; + } + ; + +EnumeratedType : kw_ENUMERATED '{' Enumerations '}' + { + $$ = new_type(TInteger); + $$->members = $3; + $$ = new_tag(ASN1_C_UNIV, UT_Enumerated, TE_EXPLICIT, $$); + } + ; + +Enumerations : NamedNumberList /* XXX */ + ; + +BitStringType : kw_BIT kw_STRING + { + $$ = new_type(TBitString); + $$->members = emalloc(sizeof(*$$->members)); + ASN1_TAILQ_INIT($$->members); + $$ = new_tag(ASN1_C_UNIV, UT_BitString, TE_EXPLICIT, $$); + } + | kw_BIT kw_STRING '{' NamedBitList '}' + { + $$ = new_type(TBitString); + $$->members = $4; + $$ = new_tag(ASN1_C_UNIV, UT_BitString, TE_EXPLICIT, $$); + } + ; + +ObjectIdentifierType: kw_OBJECT kw_IDENTIFIER + { + $$ = new_tag(ASN1_C_UNIV, UT_OID, + TE_EXPLICIT, new_type(TOID)); + } + ; +OctetStringType : kw_OCTET kw_STRING size + { + Type *t = new_type(TOctetString); + t->range = $3; + $$ = new_tag(ASN1_C_UNIV, UT_OctetString, + TE_EXPLICIT, t); + } + ; + +NullType : kw_NULL + { + $$ = new_tag(ASN1_C_UNIV, UT_Null, + TE_EXPLICIT, new_type(TNull)); + } + ; + +size : + { $$ = NULL; } + | kw_SIZE range + { $$ = $2; } + ; + + +SequenceType : kw_SEQUENCE '{' /* ComponentTypeLists */ ComponentTypeList '}' + { + $$ = new_type(TSequence); + $$->members = $3; + $$ = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, $$); + } + | kw_SEQUENCE '{' '}' + { + $$ = new_type(TSequence); + $$->members = NULL; + $$ = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, $$); + } + ; + +SequenceOfType : kw_SEQUENCE size kw_OF Type + { + $$ = new_type(TSequenceOf); + $$->range = $2; + $$->subtype = $4; + $$ = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, $$); + } + ; + +SetType : kw_SET '{' /* ComponentTypeLists */ ComponentTypeList '}' + { + $$ = new_type(TSet); + $$->members = $3; + $$ = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, $$); + } + | kw_SET '{' '}' + { + $$ = new_type(TSet); + $$->members = NULL; + $$ = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, $$); + } + ; + +SetOfType : kw_SET kw_OF Type + { + $$ = new_type(TSetOf); + $$->subtype = $3; + $$ = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, $$); + } + ; + +ChoiceType : kw_CHOICE '{' /* AlternativeTypeLists */ ComponentTypeList '}' + { + $$ = new_type(TChoice); + $$->members = $3; + } + ; + +ReferencedType : DefinedType + | UsefulType + ; + +DefinedType : IDENTIFIER + { + Symbol *s = addsym($1); + $$ = new_type(TType); + if(s->stype != Stype && s->stype != SUndefined) + error_message ("%s is not a type\n", $1); + else + $$->symbol = s; + } + ; + +UsefulType : kw_GeneralizedTime + { + $$ = new_tag(ASN1_C_UNIV, UT_GeneralizedTime, + TE_EXPLICIT, new_type(TGeneralizedTime)); + } + | kw_UTCTime + { + $$ = new_tag(ASN1_C_UNIV, UT_UTCTime, + TE_EXPLICIT, new_type(TUTCTime)); + } + ; + +ConstrainedType : Type Constraint + { + /* if (Constraint.type == contentConstrant) { + assert(Constraint.u.constraint.type == octetstring|bitstring-w/o-NamedBitList); // remember to check type reference too + if (Constraint.u.constraint.type) { + assert((Constraint.u.constraint.type.length % 8) == 0); + } + } + if (Constraint.u.constraint.encoding) { + type == der-oid|ber-oid + } + */ + } + ; + + +Constraint : '(' ConstraintSpec ')' + { + $$ = $2; + } + ; + +ConstraintSpec : GeneralConstraint + ; + +GeneralConstraint: ContentsConstraint + | UserDefinedConstraint + ; + +ContentsConstraint: kw_CONTAINING Type + { + $$ = new_constraint_spec(CT_CONTENTS); + $$->u.content.type = $2; + $$->u.content.encoding = NULL; + } + | kw_ENCODED kw_BY Value + { + if ($3->type != objectidentifiervalue) + error_message("Non-OID used in ENCODED BY constraint"); + $$ = new_constraint_spec(CT_CONTENTS); + $$->u.content.type = NULL; + $$->u.content.encoding = $3; + } + | kw_CONTAINING Type kw_ENCODED kw_BY Value + { + if ($5->type != objectidentifiervalue) + error_message("Non-OID used in ENCODED BY constraint"); + $$ = new_constraint_spec(CT_CONTENTS); + $$->u.content.type = $2; + $$->u.content.encoding = $5; + } + ; + +UserDefinedConstraint: kw_CONSTRAINED kw_BY '{' '}' + { + $$ = new_constraint_spec(CT_USER); + } + ; + +TaggedType : Tag tagenv Type + { + $$ = new_type(TTag); + $$->tag = $1; + $$->tag.tagenv = $2; + if($3->type == TTag && $2 == TE_IMPLICIT) { + $$->subtype = $3->subtype; + free($3); + } else + $$->subtype = $3; + } + ; + +Tag : '[' Class NUMBER ']' + { + $$.tagclass = $2; + $$.tagvalue = $3; + $$.tagenv = TE_EXPLICIT; + } + ; + +Class : /* */ + { + $$ = ASN1_C_CONTEXT; + } + | kw_UNIVERSAL + { + $$ = ASN1_C_UNIV; + } + | kw_APPLICATION + { + $$ = ASN1_C_APPL; + } + | kw_PRIVATE + { + $$ = ASN1_C_PRIVATE; + } + ; + +tagenv : /* */ + { + $$ = TE_EXPLICIT; + } + | kw_EXPLICIT + { + $$ = TE_EXPLICIT; + } + | kw_IMPLICIT + { + $$ = TE_IMPLICIT; + } + ; + + +ValueAssignment : IDENTIFIER Type EEQUAL Value + { + Symbol *s; + s = addsym ($1); + + s->stype = SValue; + s->value = $4; + generate_constant (s); + } + ; + +CharacterStringType: RestrictedCharactedStringType + ; + +RestrictedCharactedStringType: kw_GeneralString + { + $$ = new_tag(ASN1_C_UNIV, UT_GeneralString, + TE_EXPLICIT, new_type(TGeneralString)); + } + | kw_UTF8String + { + $$ = new_tag(ASN1_C_UNIV, UT_UTF8String, + TE_EXPLICIT, new_type(TUTF8String)); + } + | kw_PrintableString + { + $$ = new_tag(ASN1_C_UNIV, UT_PrintableString, + TE_EXPLICIT, new_type(TPrintableString)); + } + | kw_VisibleString + { + $$ = new_tag(ASN1_C_UNIV, UT_VisibleString, + TE_EXPLICIT, new_type(TVisibleString)); + } + | kw_IA5String + { + $$ = new_tag(ASN1_C_UNIV, UT_IA5String, + TE_EXPLICIT, new_type(TIA5String)); + } + | kw_BMPString + { + $$ = new_tag(ASN1_C_UNIV, UT_BMPString, + TE_EXPLICIT, new_type(TBMPString)); + } + | kw_UniversalString + { + $$ = new_tag(ASN1_C_UNIV, UT_UniversalString, + TE_EXPLICIT, new_type(TUniversalString)); + } + + ; + +ComponentTypeList: ComponentType + { + $$ = emalloc(sizeof(*$$)); + ASN1_TAILQ_INIT($$); + ASN1_TAILQ_INSERT_HEAD($$, $1, members); + } + | ComponentTypeList ',' ComponentType + { + ASN1_TAILQ_INSERT_TAIL($1, $3, members); + $$ = $1; + } + | ComponentTypeList ',' ELLIPSIS + { + struct member *m = ecalloc(1, sizeof(*m)); + m->name = estrdup("..."); + m->gen_name = estrdup("asn1_ellipsis"); + m->ellipsis = 1; + ASN1_TAILQ_INSERT_TAIL($1, m, members); + $$ = $1; + } + ; + +NamedType : IDENTIFIER Type + { + $$ = emalloc(sizeof(*$$)); + $$->name = $1; + $$->gen_name = estrdup($1); + output_name ($$->gen_name); + $$->type = $2; + $$->ellipsis = 0; + } + ; + +ComponentType : NamedType + { + $$ = $1; + $$->optional = 0; + $$->defval = NULL; + } + | NamedType kw_OPTIONAL + { + $$ = $1; + $$->optional = 1; + $$->defval = NULL; + } + | NamedType kw_DEFAULT Value + { + $$ = $1; + $$->optional = 0; + $$->defval = $3; + } + ; + +NamedBitList : NamedBit + { + $$ = emalloc(sizeof(*$$)); + ASN1_TAILQ_INIT($$); + ASN1_TAILQ_INSERT_HEAD($$, $1, members); + } + | NamedBitList ',' NamedBit + { + ASN1_TAILQ_INSERT_TAIL($1, $3, members); + $$ = $1; + } + ; + +NamedBit : IDENTIFIER '(' NUMBER ')' + { + $$ = emalloc(sizeof(*$$)); + $$->name = $1; + $$->gen_name = estrdup($1); + output_name ($$->gen_name); + $$->val = $3; + $$->optional = 0; + $$->ellipsis = 0; + $$->type = NULL; + } + ; + +objid_opt : objid + | /* empty */ { $$ = NULL; } + ; + +objid : '{' objid_list '}' + { + $$ = $2; + } + ; + +objid_list : /* empty */ + { + $$ = NULL; + } + | objid_element objid_list + { + if ($2) { + $$ = $2; + add_oid_to_tail($2, $1); + } else { + $$ = $1; + } + } + ; + +objid_element : IDENTIFIER '(' NUMBER ')' + { + $$ = new_objid($1, $3); + } + | IDENTIFIER + { + Symbol *s = addsym($1); + if(s->stype != SValue || + s->value->type != objectidentifiervalue) { + error_message("%s is not an object identifier\n", + s->name); + exit(1); + } + $$ = s->value->u.objectidentifiervalue; + } + | NUMBER + { + $$ = new_objid(NULL, $1); + } + ; + +Value : BuiltinValue + | ReferencedValue + ; + +BuiltinValue : BooleanValue + | CharacterStringValue + | IntegerValue + | ObjectIdentifierValue + | NullValue + ; + +ReferencedValue : DefinedValue + ; + +DefinedValue : Valuereference + ; + +Valuereference : IDENTIFIER + { + Symbol *s = addsym($1); + if(s->stype != SValue) + error_message ("%s is not a value\n", + s->name); + else + $$ = s->value; + } + ; + +CharacterStringValue: STRING + { + $$ = emalloc(sizeof(*$$)); + $$->type = stringvalue; + $$->u.stringvalue = $1; + } + ; + +BooleanValue : kw_TRUE + { + $$ = emalloc(sizeof(*$$)); + $$->type = booleanvalue; + $$->u.booleanvalue = 0; + } + | kw_FALSE + { + $$ = emalloc(sizeof(*$$)); + $$->type = booleanvalue; + $$->u.booleanvalue = 0; + } + ; + +IntegerValue : SignedNumber + { + $$ = emalloc(sizeof(*$$)); + $$->type = integervalue; + $$->u.integervalue = $1; + } + ; + +SignedNumber : NUMBER + ; + +NullValue : kw_NULL + { + } + ; + +ObjectIdentifierValue: objid + { + $$ = emalloc(sizeof(*$$)); + $$->type = objectidentifiervalue; + $$->u.objectidentifiervalue = $1; + } + ; + +%% + +void +yyerror (const char *s) +{ + error_message ("%s\n", s); +} + +static Type * +new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype) +{ + Type *t; + if(oldtype->type == TTag && oldtype->tag.tagenv == TE_IMPLICIT) { + t = oldtype; + oldtype = oldtype->subtype; /* XXX */ + } else + t = new_type (TTag); + + t->tag.tagclass = tagclass; + t->tag.tagvalue = tagvalue; + t->tag.tagenv = tagenv; + t->subtype = oldtype; + return t; +} + +static struct objid * +new_objid(const char *label, int value) +{ + struct objid *s; + s = emalloc(sizeof(*s)); + s->label = label; + s->value = value; + s->next = NULL; + return s; +} + +static void +add_oid_to_tail(struct objid *head, struct objid *tail) +{ + struct objid *o; + o = head; + while (o->next) + o = o->next; + o->next = tail; +} + +static Type * +new_type (Typetype tt) +{ + Type *t = ecalloc(1, sizeof(*t)); + t->type = tt; + return t; +} + +static struct constraint_spec * +new_constraint_spec(enum ctype ct) +{ + struct constraint_spec *c = ecalloc(1, sizeof(*c)); + c->ctype = ct; + return c; +} + +static void fix_labels2(Type *t, const char *prefix); +static void fix_labels1(struct memhead *members, const char *prefix) +{ + Member *m; + + if(members == NULL) + return; + ASN1_TAILQ_FOREACH(m, members, members) { + asprintf(&m->label, "%s_%s", prefix, m->gen_name); + if (m->label == NULL) + errx(1, "malloc"); + if(m->type != NULL) + fix_labels2(m->type, m->label); + } +} + +static void fix_labels2(Type *t, const char *prefix) +{ + for(; t; t = t->subtype) + fix_labels1(t->members, prefix); +} + +static void +fix_labels(Symbol *s) +{ + char *p; + asprintf(&p, "choice_%s", s->gen_name); + if (p == NULL) + errx(1, "malloc"); + fix_labels2(s->type, p); + free(p); +} diff --git a/source4/heimdal/lib/asn1/lex.c b/source4/heimdal/lib/asn1/lex.c index 5eaa156f7b..9fe039240d 100644 --- a/source4/heimdal/lib/asn1/lex.c +++ b/source4/heimdal/lib/asn1/lex.c @@ -844,7 +844,7 @@ char *yytext; #endif #undef ECHO #include "symbol.h" -#include "parse.h" +#include "asn1parse.h" #include "lex.h" #include "gen_locl.h" @@ -1590,7 +1590,7 @@ YY_RULE_SETUP char *p = buf; int f = 0; int skip_ws = 0; - + while((c = input()) != EOF) { if(isspace(c) && skip_ws) { if(c == '\n') @@ -1598,7 +1598,7 @@ YY_RULE_SETUP continue; } skip_ws = 0; - + if(c == '"') { if(f) { *p++ = '"'; diff --git a/source4/heimdal/lib/com_err/lex.c b/source4/heimdal/lib/com_err/lex.c index fbc14c9984..a7ff6766fb 100644 --- a/source4/heimdal/lib/com_err/lex.c +++ b/source4/heimdal/lib/com_err/lex.c @@ -527,8 +527,6 @@ char *yytext; #include "parse.h" #include "lex.h" -RCSID("$Id$"); - static unsigned lineno = 1; static int getstring(void); @@ -536,7 +534,7 @@ static int getstring(void); #undef ECHO -#line 539 "heimdal/lib/com_err/lex.c" +#line 537 "heimdal/lib/com_err/lex.c" #define INITIAL 0 @@ -689,9 +687,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 59 "lex.l" +#line 57 "lex.l" -#line 694 "heimdal/lib/com_err/lex.c" +#line 692 "heimdal/lib/com_err/lex.c" if ( !(yy_init) ) { @@ -776,86 +774,86 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 60 "lex.l" +#line 58 "lex.l" { return ET; } YY_BREAK case 2: YY_RULE_SETUP -#line 61 "lex.l" +#line 59 "lex.l" { return ET; } YY_BREAK case 3: YY_RULE_SETUP -#line 62 "lex.l" +#line 60 "lex.l" { return EC; } YY_BREAK case 4: YY_RULE_SETUP -#line 63 "lex.l" +#line 61 "lex.l" { return EC; } YY_BREAK case 5: YY_RULE_SETUP -#line 64 "lex.l" +#line 62 "lex.l" { return PREFIX; } YY_BREAK case 6: YY_RULE_SETUP -#line 65 "lex.l" +#line 63 "lex.l" { return INDEX; } YY_BREAK case 7: YY_RULE_SETUP -#line 66 "lex.l" +#line 64 "lex.l" { return ID; } YY_BREAK case 8: YY_RULE_SETUP -#line 67 "lex.l" +#line 65 "lex.l" { return END; } YY_BREAK case 9: YY_RULE_SETUP -#line 68 "lex.l" +#line 66 "lex.l" { yylval.number = atoi(yytext); return NUMBER; } YY_BREAK case 10: YY_RULE_SETUP -#line 69 "lex.l" +#line 67 "lex.l" ; YY_BREAK case 11: YY_RULE_SETUP -#line 70 "lex.l" +#line 68 "lex.l" ; YY_BREAK case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 71 "lex.l" +#line 69 "lex.l" { lineno++; } YY_BREAK case 13: YY_RULE_SETUP -#line 72 "lex.l" +#line 70 "lex.l" { return getstring(); } YY_BREAK case 14: YY_RULE_SETUP -#line 73 "lex.l" +#line 71 "lex.l" { yylval.string = strdup(yytext); return STRING; } YY_BREAK case 15: YY_RULE_SETUP -#line 74 "lex.l" +#line 72 "lex.l" { return *yytext; } YY_BREAK case 16: YY_RULE_SETUP -#line 75 "lex.l" +#line 73 "lex.l" ECHO; YY_BREAK -#line 858 "heimdal/lib/com_err/lex.c" +#line 856 "heimdal/lib/com_err/lex.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1853,7 +1851,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 75 "lex.l" +#line 73 "lex.l" diff --git a/source4/heimdal/lib/com_err/parse.c b/source4/heimdal/lib/com_err/parse.c index 70b6a1528f..e089ccb314 100644 --- a/source4/heimdal/lib/com_err/parse.c +++ b/source4/heimdal/lib/com_err/parse.c @@ -128,8 +128,6 @@ #include "compile_et.h" #include "lex.h" -RCSID("$Id$"); - void yyerror (char *s); static long name2number(const char *str); @@ -163,13 +161,13 @@ extern char *yytext; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 53 "heimdal/lib/com_err/parse.y" +#line 51 "heimdal/lib/com_err/parse.y" { char *string; int number; } /* Line 187 of yacc.c. */ -#line 173 "heimdal/lib/com_err/parse.y" +#line 171 "heimdal/lib/com_err/parse.y" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -182,7 +180,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 186 "heimdal/lib/com_err/parse.y" +#line 184 "heimdal/lib/com_err/parse.y" #ifdef short # undef short @@ -469,8 +467,8 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 64, 64, 65, 68, 69, 72, 78, 84, 93, - 94, 97, 101, 109, 116, 136 + 0, 62, 62, 63, 66, 67, 70, 76, 82, 91, + 92, 95, 99, 107, 114, 134 }; #endif @@ -1381,14 +1379,14 @@ yyreduce: switch (yyn) { case 6: -#line 73 "heimdal/lib/com_err/parse.y" +#line 71 "heimdal/lib/com_err/parse.y" { id_str = (yyvsp[(2) - (2)].string); } break; case 7: -#line 79 "heimdal/lib/com_err/parse.y" +#line 77 "heimdal/lib/com_err/parse.y" { base_id = name2number((yyvsp[(2) - (2)].string)); strlcpy(name, (yyvsp[(2) - (2)].string), sizeof(name)); @@ -1397,7 +1395,7 @@ yyreduce: break; case 8: -#line 85 "heimdal/lib/com_err/parse.y" +#line 83 "heimdal/lib/com_err/parse.y" { base_id = name2number((yyvsp[(2) - (3)].string)); strlcpy(name, (yyvsp[(3) - (3)].string), sizeof(name)); @@ -1407,14 +1405,14 @@ yyreduce: break; case 11: -#line 98 "heimdal/lib/com_err/parse.y" +#line 96 "heimdal/lib/com_err/parse.y" { number = (yyvsp[(2) - (2)].number); } break; case 12: -#line 102 "heimdal/lib/com_err/parse.y" +#line 100 "heimdal/lib/com_err/parse.y" { free(prefix); asprintf (&prefix, "%s_", (yyvsp[(2) - (2)].string)); @@ -1425,7 +1423,7 @@ yyreduce: break; case 13: -#line 110 "heimdal/lib/com_err/parse.y" +#line 108 "heimdal/lib/com_err/parse.y" { prefix = realloc(prefix, 1); if (prefix == NULL) @@ -1435,7 +1433,7 @@ yyreduce: break; case 14: -#line 117 "heimdal/lib/com_err/parse.y" +#line 115 "heimdal/lib/com_err/parse.y" { struct error_code *ec = malloc(sizeof(*ec)); @@ -1458,7 +1456,7 @@ yyreduce: break; case 15: -#line 137 "heimdal/lib/com_err/parse.y" +#line 135 "heimdal/lib/com_err/parse.y" { YYACCEPT; } @@ -1466,7 +1464,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 1470 "heimdal/lib/com_err/parse.y" +#line 1468 "heimdal/lib/com_err/parse.y" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1680,7 +1678,7 @@ yyreturn: } -#line 142 "heimdal/lib/com_err/parse.y" +#line 140 "heimdal/lib/com_err/parse.y" static long diff --git a/source4/heimdal/lib/com_err/parse.h b/source4/heimdal/lib/com_err/parse.h index 9aabca9023..394d6505b3 100644 --- a/source4/heimdal/lib/com_err/parse.h +++ b/source4/heimdal/lib/com_err/parse.h @@ -64,7 +64,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 53 "heimdal/lib/com_err/parse.y" +#line 51 "heimdal/lib/com_err/parse.y" { char *string; int number; diff --git a/source4/heimdal/lib/hx509/sel-gram.c b/source4/heimdal/lib/hx509/sel-gram.c index 4d9cf78c1b..e89d6c9640 100644 --- a/source4/heimdal/lib/hx509/sel-gram.c +++ b/source4/heimdal/lib/hx509/sel-gram.c @@ -101,7 +101,6 @@ #include <stdlib.h> #include <hx_locl.h> -RCSID("$Id$"); @@ -125,13 +124,13 @@ RCSID("$Id$"); #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 46 "heimdal/lib/hx509/sel-gram.y" +#line 45 "heimdal/lib/hx509/sel-gram.y" { char *string; struct hx_expr *expr; } /* Line 187 of yacc.c. */ -#line 135 "heimdal/lib/hx509/sel-gram.y" +#line 134 "heimdal/lib/hx509/sel-gram.y" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -144,7 +143,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 148 "heimdal/lib/hx509/sel-gram.y" +#line 147 "heimdal/lib/hx509/sel-gram.y" #ifdef short # undef short @@ -436,9 +435,9 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 74, 74, 76, 77, 78, 79, 80, 81, 82, - 85, 86, 89, 90, 91, 92, 93, 96, 97, 98, - 99, 102, 103, 105, 108, 111, 113 + 0, 73, 73, 75, 76, 77, 78, 79, 80, 81, + 84, 85, 88, 89, 90, 91, 92, 95, 96, 97, + 98, 101, 102, 104, 107, 110, 112 }; #endif @@ -1368,136 +1367,136 @@ yyreduce: switch (yyn) { case 2: -#line 74 "heimdal/lib/hx509/sel-gram.y" +#line 73 "heimdal/lib/hx509/sel-gram.y" { _hx509_expr_input.expr = (yyvsp[(1) - (1)].expr); } break; case 3: -#line 76 "heimdal/lib/hx509/sel-gram.y" +#line 75 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(op_TRUE, NULL, NULL); } break; case 4: -#line 77 "heimdal/lib/hx509/sel-gram.y" +#line 76 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(op_FALSE, NULL, NULL); } break; case 5: -#line 78 "heimdal/lib/hx509/sel-gram.y" +#line 77 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(op_NOT, (yyvsp[(2) - (2)].expr), NULL); } break; case 6: -#line 79 "heimdal/lib/hx509/sel-gram.y" +#line 78 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(op_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 7: -#line 80 "heimdal/lib/hx509/sel-gram.y" +#line 79 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(op_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 8: -#line 81 "heimdal/lib/hx509/sel-gram.y" +#line 80 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); } break; case 9: -#line 82 "heimdal/lib/hx509/sel-gram.y" +#line 81 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(op_COMP, (yyvsp[(1) - (1)].expr), NULL); } break; case 10: -#line 85 "heimdal/lib/hx509/sel-gram.y" +#line 84 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_WORDS, (yyvsp[(1) - (1)].expr), NULL); } break; case 11: -#line 86 "heimdal/lib/hx509/sel-gram.y" +#line 85 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_WORDS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 12: -#line 89 "heimdal/lib/hx509/sel-gram.y" +#line 88 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(comp_EQ, (yyvsp[(1) - (4)].expr), (yyvsp[(4) - (4)].expr)); } break; case 13: -#line 90 "heimdal/lib/hx509/sel-gram.y" +#line 89 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(comp_NE, (yyvsp[(1) - (4)].expr), (yyvsp[(4) - (4)].expr)); } break; case 14: -#line 91 "heimdal/lib/hx509/sel-gram.y" +#line 90 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(comp_TAILEQ, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 15: -#line 92 "heimdal/lib/hx509/sel-gram.y" +#line 91 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(comp_IN, (yyvsp[(1) - (5)].expr), (yyvsp[(4) - (5)].expr)); } break; case 16: -#line 93 "heimdal/lib/hx509/sel-gram.y" +#line 92 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(comp_IN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 17: -#line 96 "heimdal/lib/hx509/sel-gram.y" +#line 95 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 18: -#line 97 "heimdal/lib/hx509/sel-gram.y" +#line 96 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 19: -#line 98 "heimdal/lib/hx509/sel-gram.y" +#line 97 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 20: -#line 99 "heimdal/lib/hx509/sel-gram.y" +#line 98 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 21: -#line 102 "heimdal/lib/hx509/sel-gram.y" +#line 101 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_NUMBER, (yyvsp[(1) - (1)].string), NULL); } break; case 22: -#line 103 "heimdal/lib/hx509/sel-gram.y" +#line 102 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_STRING, (yyvsp[(1) - (1)].string), NULL); } break; case 23: -#line 105 "heimdal/lib/hx509/sel-gram.y" +#line 104 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_FUNCTION, (yyvsp[(1) - (4)].string), (yyvsp[(3) - (4)].expr)); } break; case 24: -#line 108 "heimdal/lib/hx509/sel-gram.y" +#line 107 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = (yyvsp[(3) - (4)].expr); } break; case 25: -#line 111 "heimdal/lib/hx509/sel-gram.y" +#line 110 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_VAR, (yyvsp[(1) - (3)].string), (yyvsp[(3) - (3)].expr)); } break; case 26: -#line 113 "heimdal/lib/hx509/sel-gram.y" +#line 112 "heimdal/lib/hx509/sel-gram.y" { (yyval.expr) = _hx509_make_expr(expr_VAR, (yyvsp[(1) - (1)].string), NULL); } break; /* Line 1267 of yacc.c. */ -#line 1501 "heimdal/lib/hx509/sel-gram.y" +#line 1500 "heimdal/lib/hx509/sel-gram.y" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/source4/heimdal/lib/hx509/sel-gram.h b/source4/heimdal/lib/hx509/sel-gram.h index bb4a64d1c7..6e763ef1bf 100644 --- a/source4/heimdal/lib/hx509/sel-gram.h +++ b/source4/heimdal/lib/hx509/sel-gram.h @@ -66,7 +66,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 46 "heimdal/lib/hx509/sel-gram.y" +#line 45 "heimdal/lib/hx509/sel-gram.y" { char *string; struct hx_expr *expr; |