diff options
Diffstat (limited to 'mfd')
-rw-r--r-- | mfd/drivers.c | 113 | ||||
-rw-r--r-- | mfd/gram.y | 131 | ||||
-rw-r--r-- | mfd/lex.l | 4 | ||||
-rw-r--r-- | mfd/mailfromd.h | 8 | ||||
-rw-r--r-- | mfd/opcodes | 2 | ||||
-rw-r--r-- | mfd/prog.c | 10 |
6 files changed, 181 insertions, 87 deletions
diff --git a/mfd/drivers.c b/mfd/drivers.c index d8dfb4b2..ed8a288a 100644 --- a/mfd/drivers.c +++ b/mfd/drivers.c | |||
@@ -891,25 +891,24 @@ print_type_result(NODE *node, int level) | |||
891 | { | 891 | { |
892 | if (node->v.ret.code) { | 892 | NODE *code, *xcode; |
893 | const char *s = NULL; | 893 | |
894 | int expr = 0; | 894 | code = node->v.ret.code; |
895 | xcode = node->v.ret.xcode; | ||
895 | 896 | ||
896 | print_level(level); | 897 | print_level(level); |
897 | if (node->v.ret.message) { | 898 | printf("SET REPLY "); |
898 | if (node->v.ret.message->type == node_type_string) | ||
899 | s = node->v.ret.message->v.literal->text; | ||
900 | else { | ||
901 | expr = 1; | ||
902 | s = "(expression)"; | ||
903 | } | ||
904 | } | ||
905 | dbg_setreply(NULL, | ||
906 | (char*) LITERAL_TEXT(node->v.ret.code), | ||
907 | (char*) LITERAL_TEXT(node->v.ret.xcode), | ||
908 | (char*) s); | ||
909 | if (expr) | ||
910 | print_node(node->v.ret.message, level+1); | ||
911 | } | ||
912 | print_level(level); | ||
913 | print_stat(node->v.ret.stat); | 899 | print_stat(node->v.ret.stat); |
914 | printf("\n"); | 900 | printf("\n"); |
901 | print_level(level); | ||
902 | printf("CODE:\n"); | ||
903 | if (code) | ||
904 | print_node(code, level+1); | ||
905 | print_level(level); | ||
906 | printf("XCODE:\n"); | ||
907 | if (xcode) | ||
908 | print_node(xcode, level+1); | ||
909 | print_level(level); | ||
910 | printf("MESSAGE:\n"); | ||
911 | if (node->v.ret.message) | ||
912 | print_node(node->v.ret.message, level+1); | ||
913 | printf("\n"); | ||
915 | } | 914 | } |
@@ -919,6 +918,4 @@ mark_type_result(NODE *node) | |||
919 | { | 918 | { |
920 | if (node->v.ret.code) | 919 | mark(node->v.ret.code); |
921 | node->v.ret.code->flags |= VAR_REFERENCED; | 920 | mark(node->v.ret.xcode); |
922 | if (node->v.ret.xcode) | ||
923 | node->v.ret.xcode->flags |= VAR_REFERENCED; | ||
924 | mark(node->v.ret.message); | 921 | mark(node->v.ret.message); |
@@ -929,2 +926,4 @@ optimize_type_result(NODE *node) | |||
929 | { | 926 | { |
927 | optimize(node->v.ret.code); | ||
928 | optimize(node->v.ret.xcode); | ||
930 | optimize(node->v.ret.message); | 929 | optimize(node->v.ret.message); |
@@ -932,8 +931,7 @@ optimize_type_result(NODE *node) | |||
932 | 931 | ||
933 | void | 932 | static void |
934 | code_type_result(NODE *node, struct locus **old_locus) | 933 | code_result_arg(NODE *node) |
935 | { | 934 | { |
936 | MARK_LOCUS(); | 935 | if (node) |
937 | if (node->v.ret.message) | 936 | code_node(node); |
938 | code_node(node->v.ret.message); | ||
939 | else { | 937 | else { |
@@ -942,2 +940,51 @@ code_type_result(NODE *node, struct locus **old_locus) | |||
942 | } | 940 | } |
941 | } | ||
942 | |||
943 | static NODE * | ||
944 | result_argptr(NODE *arg) | ||
945 | { | ||
946 | if (arg && arg->type == node_type_string | ||
947 | && arg->v.literal->text[0] == 0) | ||
948 | arg = NULL; | ||
949 | return arg; | ||
950 | } | ||
951 | |||
952 | void | ||
953 | code_type_result(NODE *node, struct locus **old_locus) | ||
954 | { | ||
955 | NODE *code, *xcode; | ||
956 | |||
957 | code = result_argptr(node->v.ret.code); | ||
958 | xcode = result_argptr(node->v.ret.xcode); | ||
959 | |||
960 | switch (node->v.ret.stat) { | ||
961 | case SMFIS_REJECT: | ||
962 | if (code && code->type == node_type_string | ||
963 | && code->v.literal->text[0] != '5') | ||
964 | parse_error_locus(&node->locus, | ||
965 | _("Reject code should be 5xx")); | ||
966 | if (xcode && xcode->type == node_type_string | ||
967 | && xcode->v.literal->text[0] != '5') | ||
968 | parse_error_locus(&node->locus, | ||
969 | _("Reject extended code should be 5.x.x")); | ||
970 | break; | ||
971 | |||
972 | case SMFIS_TEMPFAIL: | ||
973 | if (code && code->type == node_type_string | ||
974 | && code->v.literal->text[0] != '4') | ||
975 | parse_error_locus(&node->locus, | ||
976 | _("Tempfail code should be 4xx")); | ||
977 | if (xcode && xcode->type == node_type_string | ||
978 | && xcode->v.literal->text[0] != '4') | ||
979 | parse_error_locus(&node->locus, | ||
980 | _("Tempfail extended code should be 4.x.x")); | ||
981 | break; | ||
982 | default: | ||
983 | break; | ||
984 | } | ||
985 | |||
986 | code_result_arg(node->v.ret.message); | ||
987 | code_result_arg(xcode); | ||
988 | code_result_arg(code); | ||
989 | |||
943 | MARK_LOCUS(); | 990 | MARK_LOCUS(); |
@@ -945,4 +992,2 @@ code_type_result(NODE *node, struct locus **old_locus) | |||
945 | code_immediate((void*)node->v.ret.stat); | 992 | code_immediate((void*)node->v.ret.stat); |
946 | code_immediate((void*)LITERAL_OFF(node->v.ret.code)); | ||
947 | code_immediate((void*)LITERAL_OFF(node->v.ret.xcode)); | ||
948 | code_op(opcode_nil); | 993 | code_op(opcode_nil); |
@@ -1484,9 +1529,7 @@ code_type_catch(NODE *node, struct locus **old_locus) | |||
1484 | } else { | 1529 | } else { |
1485 | code_op(opcode_push); | 1530 | code_result_arg(NULL); |
1486 | code_immediate(NULL); | 1531 | code_result_arg(NULL); |
1532 | code_result_arg(NULL); | ||
1487 | code_op(opcode_result); | 1533 | code_op(opcode_result); |
1488 | code_immediate(SMFIS_CONTINUE); | 1534 | code_immediate(SMFIS_CONTINUE); |
1489 | code_immediate(NULL); | ||
1490 | code_immediate(NULL); | ||
1491 | code_immediate(NULL); | ||
1492 | } | 1535 | } |
@@ -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 | ||
935 | maybe_xcode_expr: maybe_expr | ||
936 | | xcode | ||
937 | { | ||
938 | $$ = alloc_node(node_type_string, get_locus()); | ||
939 | $$->v.literal = $1; | ||
940 | } | ||
941 | ; | ||
942 | |||
943 | |||
927 | header_action: | 944 | header_action: |
@@ -957,5 +974,6 @@ maybe_triplet: /* empty */ | |||
957 |