aboutsummaryrefslogtreecommitdiff
path: root/mfd/gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'mfd/gram.y')
-rw-r--r--mfd/gram.y131
1 files changed, 92 insertions, 39 deletions
diff --git a/mfd/gram.y b/mfd/gram.y
index 332a748a..15ee9602 100644
--- a/mfd/gram.y
+++ b/mfd/gram.y
@@ -301,3 +301,3 @@ _create_alias(void *item, void *data)
301%error-verbose 301%error-verbose
302%expect 29 302%expect 28
303 303
@@ -362,3 +362,3 @@ _create_alias(void *item, void *data)
362%token <locus> FOR LOOP WHILE BREAK NEXT ARGCOUNT ALIAS DOTS ARGX VAPTR 362%token <locus> FOR LOOP WHILE BREAK NEXT ARGCOUNT ALIAS DOTS ARGX VAPTR
363%token <literal> STRING CODE XCODE 363%token <literal> STRING
364%token <literal> SYMBOL IDENTIFIER 364%token <literal> SYMBOL IDENTIFIER
@@ -388,3 +388,4 @@ _create_alias(void *item, void *data)
388 if_cond else_cond on_cond atom argref paren_argref 388 if_cond else_cond on_cond atom argref paren_argref
389 funcall proccall expr common_expr simp_expr atom_expr 389 funcall proccall expr maybe_expr maybe_xcode_expr
390 common_expr simp_expr atom_expr
390 asgn catch throw return case_cond autodcl constdecl 391 asgn catch throw return case_cond autodcl constdecl
@@ -396,6 +397,5 @@ _create_alias(void *item, void *data)
396%type <loop> opt_loop_parms loop_parm_list 397%type <loop> opt_loop_parms loop_parm_list
397%type <number> number
398%type <arglist> arglist 398%type <arglist> arglist
399%type <var> variable 399%type <var> variable
400%type <literal> string opt_ident loop_ident alias 400%type <literal> string opt_ident loop_ident alias code xcode
401%type <state> state_ident 401%type <state> state_ident
@@ -894,6 +894,2 @@ sendmail_action:
894 { 894 {
895 if ($2.code && $2.code->text[0] != '5')
896 parse_error(_("Reject code should be 5xx"));
897 if ($2.xcode && $2.xcode->text[0] != '5')
898 parse_error(_("Reject extended code should be 5.x.x"));
899 $$ = alloc_node(node_type_result, &$1); 895 $$ = alloc_node(node_type_result, &$1);
@@ -902,8 +898,12 @@ sendmail_action:
902 } 898 }
899 | ACT_REJECT '(' maybe_expr ',' maybe_xcode_expr ',' maybe_expr ')'
900 {
901 $$ = alloc_node(node_type_result, &$1);
902 $$->v.ret.stat = SMFIS_REJECT;
903 $$->v.ret.code = $3 ? cast_to(dtype_string, $3) : NULL;
904 $$->v.ret.xcode = $5 ? cast_to(dtype_string, $5) : NULL;
905 $$->v.ret.message = $7 ? cast_to(dtype_string, $7) : NULL;
906 }
903 | ACT_TEMPFAIL maybe_triplet 907 | ACT_TEMPFAIL maybe_triplet
904 { 908 {
905 if ($2.code && $2.code->text[0] != '4')
906 parse_error(_("Tempfail code should be 4xx"));
907 if ($2.xcode && $2.xcode->text[0] != '4')
908 parse_error(_("Tempfail extended code should be 4.x.x"));
909 $$ = alloc_node(node_type_result, &$1); 909 $$ = alloc_node(node_type_result, &$1);
@@ -912,2 +912,10 @@ sendmail_action:
912 } 912 }
913 | ACT_TEMPFAIL '(' maybe_expr ',' maybe_xcode_expr ',' maybe_expr ')'
914 {
915 $$ = alloc_node(node_type_result, &$1);
916 $$->v.ret.stat = SMFIS_TEMPFAIL;
917 $$->v.ret.code = $3 ? cast_to(dtype_string, $3) : NULL;
918 $$->v.ret.xcode = $5 ? cast_to(dtype_string, $5) : NULL;
919 $$->v.ret.message = $7 ? cast_to(dtype_string, $7) : NULL;
920 }
913 | ACT_CONTINUE 921 | ACT_CONTINUE
@@ -926,2 +934,11 @@ sendmail_action:
926 934
935maybe_xcode_expr: maybe_expr
936 | xcode
937 {
938 $$ = alloc_node(node_type_string, get_locus());
939 $$->v.literal = $1;
940 }
941 ;
942
943
927header_action: 944header_action:
@@ -957,5 +974,6 @@ maybe_triplet: /* empty */
957 974
958triplet : CODE 975triplet : code
959 { 976 {
960 $$.code = $1; 977 $$.code = alloc_node(node_type_string, get_locus());
978 $$.code->v.literal = $1;
961 $$.xcode = NULL; 979 $$.xcode = NULL;
@@ -963,17 +981,22 @@ triplet : CODE
963 } 981 }
964 | CODE XCODE 982 | code xcode
965 { 983 {
966 $$.code = $1; 984 $$.code = alloc_node(node_type_string, get_locus());
967 $$.xcode = $2; 985 $$.code->v.literal = $1;
986 $$.xcode = alloc_node(node_type_string, get_locus());
987 $$.xcode->v.literal = $2;
968 $$.message = NULL; 988 $$.message = NULL;
969 } 989 }
970 | CODE XCODE expr 990 | code xcode expr
971 { 991 {
972 $$.code = $1; 992 $$.code = alloc_node(node_type_string, get_locus());
973 $$.xcode = $2; 993 $$.code->v.literal = $1;
994 $$.xcode = alloc_node(node_type_string, get_locus());
995 $$.xcode->v.literal = $2;
974 $$.message = cast_to(dtype_string, $3); 996 $$.message = cast_to(dtype_string, $3);
975 } 997 }
976 | CODE expr 998 | code expr
977 { 999 {
978 $$.code = $1; 1000 $$.code = alloc_node(node_type_string, get_locus());
1001 $$.code->v.literal = $1;
979 $$.xcode = NULL; 1002 $$.xcode = NULL;
@@ -983,2 +1006,38 @@ triplet : CODE
983 1006
1007code : NUMBER
1008 {
1009 char buf[4];
1010
1011 if ($1 < 200 || $1 > 599) {
1012 yyerror(_("Invalid SMTP reply code"));
1013 buf[0] = 0;
1014 } else
1015 snprintf(buf, sizeof(buf), "%lu", $1);
1016 $$ = string_alloc(buf, strlen(buf));
1017 }
1018 ;
1019
1020xcode : NUMBER '.' NUMBER '.' NUMBER
1021 {
1022 char buf[sizeof("5.999.999")];
1023
1024 /* RFC 1893:
1025 The syntax of the new status codes is defined as:
1026
1027 status-code = class "." subject "." detail
1028 class = "2"/"4"/"5"
1029 subject = 1*3digit
1030 detail = 1*3digit
1031 */
1032 if (($1 != 2 && $1 != 4 && $1 !=5)
1033 || $3 > 999 || $5 > 999) {
1034 yyerror(_("Invalid extended reply code"));
1035 buf[0] = 0;
1036 } else
1037 snprintf(buf, sizeof(buf), "%lu.%lu.%lu",
1038 $1, $3, $5);
1039 $$ = string_alloc(buf, strlen(buf));
1040 }
1041 ;
1042
984condition : if_cond 1043condition : if_cond
@@ -1123,3 +1182,3 @@ value : STRING
1123 } 1182 }
1124 | number 1183 | NUMBER
1125 { 1184 {
@@ -1166,15 +1225,2 @@ fnmatches : FNMATCHES
1166 1225
1167number : NUMBER
1168 | CODE
1169 {
1170 char *p;
1171 $$ = strtol($1->text, &p, 10);
1172 if (*p) {
1173 /* should not happen */
1174 parse_error(_("Invalid number (near `%s')"), p);
1175 YYERROR;
1176 }
1177 }
1178 ;
1179
1180 1226
@@ -1404,2 +1450,9 @@ expr : NOT expr
1404 1450
1451maybe_expr : /* empty */
1452 {
1453 $$ = NULL;
1454 }
1455 | expr
1456 ;
1457
1405common_expr: simp_expr 1458common_expr: simp_expr
@@ -1952,3 +2005,3 @@ on : ON
1952 { 2005 {
1953 onblock(1); 2006 tie_in_onblock(1);
1954 } 2007 }
@@ -1958,3 +2011,3 @@ do : DO
1958 { 2011 {
1959 onblock(0); 2012 tie_in_onblock(0);
1960 } 2013 }

Return to:

Send suggestions and report system problems to the System administrator.