summaryrefslogtreecommitdiffabout
path: root/mfd/drivers.c
Unidiff
Diffstat (limited to 'mfd/drivers.c') (more/less context) (show whitespace changes)
-rw-r--r--mfd/drivers.c113
1 files changed, 78 insertions, 35 deletions
diff --git a/mfd/drivers.c b/mfd/drivers.c
index d8dfb4b..ed8a288 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
933void 932static void
934code_type_result(NODE *node, struct locus **old_locus) 933code_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
943static NODE *
944result_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
952void
953code_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 }

Return to:

Send suggestions and report system problems to the System administrator.