Browse code

uac: use dlg api functions get_dlg_varval() and get_dlg_varref()

Daniel-Constantin Mierla authored on 23/09/2022 11:59:36
Showing 1 changed files
... ...
@@ -391,7 +391,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
391 391
 
392 392
 	if (dlg) {
393 393
 		dlgvar_names = (uac_flag==FL_USE_UAC_FROM)?from_dlgvar:to_dlgvar;
394
-		if(dlg_api.get_dlg_var(dlg, &dlgvar_names[0])) {
394
+		if(dlg_api.get_dlg_varref(dlg, &dlgvar_names[0])) {
395 395
 
396 396
 			LM_INFO("Already called uac_replace for this dialog\n");
397 397
 			/* delete the from_new dlg var */
... ...
@@ -873,8 +873,8 @@ static void replace_callback(struct dlg_cell *dlg, int type,
873 873
 	struct hdr_field *hdr;
874 874
 	struct to_body *body;
875 875
 	str old_uri;
876
-	str* new_uri;
877
-	str* new_display;
876
+	str new_uri = {0};
877
+	str new_display = {0};
878 878
 	str buf = STR_NULL;
879 879
 	char *p;
880 880
 	unsigned int uac_flag;
... ...
@@ -927,20 +927,22 @@ static void replace_callback(struct dlg_cell *dlg, int type,
927 927
 				" with the original uri\n");
928 928
 	}
929 929
 
930
-	if ((new_uri = dlg_api.get_dlg_var(dlg, &dlgvar_names[dlgvar_index])) == 0) {
930
+	dlg_api.get_dlg_varval(dlg, &dlgvar_names[dlgvar_index], &new_uri);
931
+	if (new_uri.s == NULL) {
931 932
 		LM_DBG("<%.*s> param not found\n", dlgvar_names[dlgvar_index].len,
932 933
 				dlgvar_names[dlgvar_index].s);
933 934
 		return;
934 935
 	}
935
-	if ((new_display = dlg_api.get_dlg_var(dlg, &dlgvar_names[dlgvar_dpindex])) == 0) {
936
+	dlg_api.get_dlg_varval(dlg, &dlgvar_names[dlgvar_dpindex], &new_display);
937
+	if (new_display.s == NULL) {
936 938
 		LM_DBG("<%.*s> param not found\n", dlgvar_names[dlgvar_dpindex].len,
937 939
 				dlgvar_names[dlgvar_dpindex].s);
938 940
 		return;
939 941
 	}
940 942
 
941 943
 	LM_DBG("Replace [%.*s %.*s] with [%.*s %.*s]\n", body->display.len, body->display.s,
942
-			old_uri.len, old_uri.s, new_display->len, new_display->s,
943
-			new_uri->len, new_uri->s);
944
+			old_uri.len, old_uri.s, new_display.len, new_display.s,
945
+			new_uri.len, new_uri.s);
944 946
 
945 947
 	/* deal with display name */
946 948
 	l = 0;
... ...
@@ -955,17 +957,17 @@ static void replace_callback(struct dlg_cell *dlg, int type,
955 957
 			return;
956 958
 		}
957 959
 	}
958
-	if (new_display->s && new_display->len > 0) {
960
+	if (new_display.s && new_display.len > 0) {
959 961
 		LM_DBG("inserting display [%.*s]\n",
960
-				new_display->len, new_display->s);
962
+				new_display.len, new_display.s);
961 963
 		/* add the new display exactly over the deleted one */
962
-		buf.s = pkg_malloc(new_display->len + 2);
964
+		buf.s = pkg_malloc(new_display.len + 2);
963 965
 		if (buf.s==0) {
964 966
 			PKG_MEM_ERROR;
965 967
 			return;
966 968
 		}
967
-		memcpy( buf.s, new_display->s, new_display->len);
968
-		buf.len = new_display->len;
969
+		memcpy(buf.s, new_display.s, new_display.len);
970
+		buf.len = new_display.len;
969 971
 		if (l==0 && (l=get_display_anchor(msg, hdr, body, &buf)) == 0) {
970 972
 			LM_ERR("failed to insert anchor\n");
971 973
 			pkg_free(buf.s);
... ...
@@ -979,12 +981,12 @@ static void replace_callback(struct dlg_cell *dlg, int type,
979 981
 	}
980 982
 
981 983
 	/* uri update - duplicate the decoded value */
982
-	p = pkg_malloc( new_uri->len);
984
+	p = pkg_malloc(new_uri.len);
983 985
 	if (!p) {
984 986
 		PKG_MEM_ERROR;
985 987
 		return;
986 988
 	}
987
-	memcpy(p, new_uri->s, new_uri->len);
989
+	memcpy(p, new_uri.s, new_uri.len);
988 990
 
989 991
 	/* build del/add lumps */
990 992
 	l = del_lump(msg, old_uri.s-msg->buf, old_uri.len, 0);
... ...
@@ -994,7 +996,7 @@ static void replace_callback(struct dlg_cell *dlg, int type,
994 996
 		return;
995 997
 	}
996 998
 
997
-	if (insert_new_lump_after( l, p, new_uri->len, 0)==0) {
999
+	if (insert_new_lump_after(l, p, new_uri.len, 0)==0) {
998 1000
 		LM_ERR("insert new lump failed\n");
999 1001
 		pkg_free(p);
1000 1002
 		return;