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 745
 									);
746 746
 				if (ret==0) h->run_flags|=EXIT_R_F;
747 747
 				h->last_retcode=ret;
748
+				_last_returned_code = h->last_retcode;
748 749
 			} else {
749 750
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
750 751
 			}
... ...
@@ -762,6 +764,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
762 762
 									);
763 763
 				if (ret==0) h->run_flags|=EXIT_R_F;
764 764
 				h->last_retcode=ret;
765
+				_last_returned_code = h->last_retcode;
765 766
 			} else {
766 767
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
767 768
 			}
... ...
@@ -777,6 +780,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
777 777
 									);
778 778
 				if (ret==0) h->run_flags|=EXIT_R_F;
779 779
 				h->last_retcode=ret;
780
+				_last_returned_code = h->last_retcode;
780 781
 			} else {
781 782
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
782 783
 			}
... ...
@@ -793,6 +797,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
793 793
 									);
794 794
 				if (ret==0) h->run_flags|=EXIT_R_F;
795 795
 				h->last_retcode=ret;
796
+				_last_returned_code = h->last_retcode;
796 797
 			} else {
797 798
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
798 799
 			}
... ...
@@ -810,6 +815,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
810 810
 									);
811 811
 				if (ret==0) h->run_flags|=EXIT_R_F;
812 812
 				h->last_retcode=ret;
813
+				_last_returned_code = h->last_retcode;
813 814
 			} else {
814 815
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
815 816
 			}
... ...
@@ -823,6 +829,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
823 823
 										);
824 824
 				if (ret==0) h->run_flags|=EXIT_R_F;
825 825
 				h->last_retcode=ret;
826
+				_last_returned_code = h->last_retcode;
826 827
 			} else {
827 828
 				LOG(L_CRIT,"BUG: do_action: bad module call\n");
828 829
 			}
... ...
@@ -1119,6 +1126,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
1119 1119
 	if (h->rec_lev==1){
1120 1120
 		h->run_flags=0;
1121 1121
 		h->last_retcode=0;
1122
+		_last_returned_code = h->last_retcode;
1122 1123
 #ifdef USE_LONGJMP
1123 1124
 		if (setjmp(h->jmp_env)){
1124 1125
 			h->rec_lev=0;
... ...
@@ -1142,6 +1150,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
1142 1142
 			if (h->run_flags & EXIT_R_F){
1143 1143
 #ifdef USE_LONGJMP
1144 1144
 				h->last_retcode=ret;
1145
+				_last_returned_code = h->last_retcode;
1145 1146
 				longjmp(h->jmp_env, ret);
1146 1147
 #endif
1147 1148
 			}