Browse code

Kamailio compatiblity: export last_retcode via a global variable

Jan Janak authored on 19/03/2009 13:44:52
Showing 1 changed files
... ...
@@ -93,7 +93,7 @@
93 93
 #include <dmalloc.h>
94 94
 #endif
95 95
 
96
-
96
+int _last_returned_code  = 0;
97 97
 struct onsend_info* p_onsend=0; /* onsend route send info */
98 98
 
99 99
 /* ret= 0! if action -> end of list(e.g DROP),
... ...
@@ -461,6 +461,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
461 461
 			/*ret=((ret=run_actions(rlist[a->val[0].u.number], msg))<0)?ret:1;*/
462 462
 			ret=run_actions(h, main_rt.rlist[a->val[0].u.number], msg);
463 463
 			h->last_retcode=ret;
464
+			_last_returned_code = h->last_retcode;
464 465
 			h->run_flags&=~(RETURN_R_F|BREAK_R_F); /* absorb return & break */
465 466
 			break;
466 467
 		case EXEC_T:
... ...
@@ -745,6 +746,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
745 746
 									);
746 747
 				if (ret==0) h->run_flags|=EXIT_R_F;
747 748
 				h->last_retcode=ret;
749
+				_last_returned_code = h->last_retcode;
748 750
 			} else {
749 751
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
750 752
 			}
... ...
@@ -762,6 +764,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
762 764
 									);
763 765
 				if (ret==0) h->run_flags|=EXIT_R_F;
764 766
 				h->last_retcode=ret;
767
+				_last_returned_code = h->last_retcode;
765 768
 			} else {
766 769
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
767 770
 			}
... ...
@@ -777,6 +780,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
777 780
 									);
778 781
 				if (ret==0) h->run_flags|=EXIT_R_F;
779 782
 				h->last_retcode=ret;
783
+				_last_returned_code = h->last_retcode;
780 784
 			} else {
781 785
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
782 786
 			}
... ...
@@ -793,6 +797,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
793 797
 									);
794 798
 				if (ret==0) h->run_flags|=EXIT_R_F;
795 799
 				h->last_retcode=ret;
800
+				_last_returned_code = h->last_retcode;
796 801
 			} else {
797 802
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
798 803
 			}
... ...
@@ -810,6 +815,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
810 815
 									);
811 816
 				if (ret==0) h->run_flags|=EXIT_R_F;
812 817
 				h->last_retcode=ret;
818
+				_last_returned_code = h->last_retcode;
813 819
 			} else {
814 820
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
815 821
 			}
... ...
@@ -823,6 +829,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
823 829
 										);
824 830
 				if (ret==0) h->run_flags|=EXIT_R_F;
825 831
 				h->last_retcode=ret;
832
+				_last_returned_code = h->last_retcode;
826 833
 			} else {
827 834
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
828 835
 			}
... ...
@@ -1119,6 +1126,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
1119 1126
 	if (h->rec_lev==1){
1120 1127
 		h->run_flags=0;
1121 1128
 		h->last_retcode=0;
1129
+		_last_returned_code = h->last_retcode;
1122 1130
 #ifdef USE_LONGJMP
1123 1131
 		if (setjmp(h->jmp_env)){
1124 1132
 			h->rec_lev=0;
... ...
@@ -1142,6 +1150,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
1142 1150
 			if (h->run_flags & EXIT_R_F){
1143 1151
 #ifdef USE_LONGJMP
1144 1152
 				h->last_retcode=ret;
1153
+				_last_returned_code = h->last_retcode;
1145 1154
 				longjmp(h->jmp_env, ret);
1146 1155
 #endif
1147 1156
 			}