Browse code

dialplan: prefixed some global variables to avoid naming conflicts

(cherry picked from commit e43083e32df03b629f0eab9d567bd41d6cb749ff)

Daniel-Constantin Mierla authored on 15/09/2022 07:28:54
Showing 1 changed files
... ...
@@ -80,11 +80,11 @@ static int ki_dp_translate_vars(sip_msg_t* msg, int id, str *input, str *output)
80 80
 int dp_replace_fixup(void** param, int param_no);
81 81
 int dp_replace_fixup_free(void** param, int param_no);
82 82
 
83
-str attr_pvar_s = STR_NULL;
84
-pv_spec_t *attr_pvar = NULL;
83
+str dp_attr_pvar_s = STR_NULL;
84
+pv_spec_t *dp_attr_pvar = NULL;
85 85
 
86
-str default_param_s = str_init("$rU");
87
-dp_param_p default_par2 = NULL;
86
+str dp_default_param_s = str_init("$rU");
87
+dp_param_p dp_default_par2 = NULL;
88 88
 
89 89
 int dp_fetch_rows = 1000;
90 90
 int dp_match_dynamic = 0;
... ...
@@ -104,7 +104,7 @@ static param_export_t mod_params[]={
104 104
 	{ "subst_exp_col",	PARAM_STR,	&subst_exp_column },
105 105
 	{ "repl_exp_col",	PARAM_STR,	&repl_exp_column },
106 106
 	{ "attrs_col",		PARAM_STR,	&attrs_column },
107
-	{ "attrs_pvar",	    PARAM_STR,	&attr_pvar_s },
107
+	{ "attrs_pvar",	    PARAM_STR,	&dp_attr_pvar_s },
108 108
 	{ "fetch_rows",		PARAM_INT,	&dp_fetch_rows },
109 109
 	{ "match_dynamic",	PARAM_INT,	&dp_match_dynamic },
110 110
 	{ "append_branch",	PARAM_INT,	&dp_append_branch },
... ...
@@ -150,35 +150,35 @@ static int mod_init(void)
150 150
 
151 151
 	LM_DBG("db_url=%s/%d/%p\n", ZSW(dp_db_url.s), dp_db_url.len,dp_db_url.s);
152 152
 
153
-	if(attr_pvar_s.s && attr_pvar_s.len>0) {
154
-		attr_pvar = pv_cache_get(&attr_pvar_s);
155
-		if( (attr_pvar==NULL) ||
156
-				((attr_pvar->type != PVT_AVP) &&
157
-				 (attr_pvar->type != PVT_XAVP) &&
158
-				 (attr_pvar->type!=PVT_SCRIPTVAR))) {
153
+	if(dp_attr_pvar_s.s && dp_attr_pvar_s.len>0) {
154
+		dp_attr_pvar = pv_cache_get(&dp_attr_pvar_s);
155
+		if( (dp_attr_pvar==NULL) ||
156
+				((dp_attr_pvar->type != PVT_AVP) &&
157
+				 (dp_attr_pvar->type != PVT_XAVP) &&
158
+				 (dp_attr_pvar->type != PVT_SCRIPTVAR))) {
159 159
 			LM_ERR("invalid pvar name\n");
160 160
 			return -1;
161 161
 		}
162 162
 	}
163 163
 
164
-	default_par2 = (dp_param_p)shm_malloc(sizeof(dp_param_t));
165
-	if(default_par2 == NULL){
164
+	dp_default_par2 = (dp_param_p)shm_malloc(sizeof(dp_param_t));
165
+	if(dp_default_par2 == NULL){
166 166
 		LM_ERR("no shm more memory\n");
167 167
 		return -1;
168 168
 	}
169
-	memset(default_par2, 0, sizeof(dp_param_t));
169
+	memset(dp_default_par2, 0, sizeof(dp_param_t));
170 170
 
171 171
 	/* emulate "$rU/$rU" as second parameter for dp_translate() */
172
-	default_param_s.len = strlen(default_param_s.s);
173
-	default_par2->v.sp[0] = pv_cache_get(&default_param_s);
174
-	if (default_par2->v.sp[0]==NULL) {
172
+	dp_default_param_s.len = strlen(dp_default_param_s.s);
173
+	dp_default_par2->v.sp[0] = pv_cache_get(&dp_default_param_s);
174
+	if (dp_default_par2->v.sp[0]==NULL) {
175 175
 		LM_ERR("input pv is invalid\n");
176 176
 		return -1;
177 177
 	}
178 178
 
179
-	default_param_s.len = strlen(default_param_s.s);
180
-	default_par2->v.sp[1] = pv_cache_get(&default_param_s);
181
-	if (default_par2->v.sp[1]==NULL) {
179
+	dp_default_param_s.len = strlen(dp_default_param_s.s);
180
+	dp_default_par2->v.sp[1] = pv_cache_get(&dp_default_param_s);
181
+	if (dp_default_par2->v.sp[1]==NULL) {
182 182
 		LM_ERR("output pv is invalid\n");
183 183
 		return -1;
184 184
 	}
... ...
@@ -214,9 +214,9 @@ static int child_init(int rank)
214 214
 static void mod_destroy(void)
215 215
 {
216 216
 	/*destroy shared memory*/
217
-	if(default_par2){
218
-		shm_free(default_par2);
219
-		default_par2 = NULL;
217
+	if(dp_default_par2){
218
+		shm_free(dp_default_par2);
219
+		dp_default_par2 = NULL;
220 220
 	}
221 221
 	if(dp_rpc_reload_time!=NULL) {
222 222
 		shm_free(dp_rpc_reload_time);
... ...
@@ -306,11 +306,11 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * dest,
306 306
 
307 307
 set_attr_pvar:
308 308
 
309
-	if(attr_pvar==NULL || attrs==NULL)
309
+	if(dp_attr_pvar==NULL || attrs==NULL)
310 310
 		return 0;
311 311
 
312 312
 	val.rs = *attrs;
313
-	if(attr_pvar->setf(msg, &attr_pvar->pvp, (int)EQ_T, &val)<0)
313
+	if(dp_attr_pvar->setf(msg, &dp_attr_pvar->pvp, (int)EQ_T, &val)<0)
314 314
 	{
315 315
 		LM_ERR("setting attr pseudo-variable failed\n");
316 316
 		return -1;
... ...
@@ -343,7 +343,7 @@ static int dp_translate_f(struct sip_msg* msg, char* str1, char* str2)
343 343
 		return -2;
344 344
 	}
345 345
 
346
-	repl_par = (str2!=NULL)? ((dp_param_p)str2):default_par2;
346
+	repl_par = (str2!=NULL)? ((dp_param_p)str2):dp_default_par2;
347 347
 	if (dp_get_svalue(msg, repl_par->v.sp[0], &input)!=0){
348 348
 		LM_ERR("invalid param 2\n");
349 349
 		return -1;
... ...
@@ -351,7 +351,7 @@ static int dp_translate_f(struct sip_msg* msg, char* str1, char* str2)
351 351
 
352 352
 	LM_DBG("input is %.*s\n", input.len, input.s);
353 353
 
354
-	outattrs = (!attr_pvar)?NULL:&attrs;
354
+	outattrs = (!dp_attr_pvar)?NULL:&attrs;
355 355
 	if (dp_translate_helper(msg, &input, &output, idp, outattrs)!=0) {
356 356
 		LM_DBG("could not translate %.*s "
357 357
 				"with dpid %i\n", input.len, input.s, idp->dp_id);
... ...
@@ -493,7 +493,7 @@ static int dp_replace_helper(sip_msg_t *msg, int dpid, str *input,
493 493
 		return -2;
494 494
 	}
495 495
 
496
-	outattrs = (!attr_pvar)?NULL:&attrs;
496
+	outattrs = (!dp_attr_pvar)?NULL:&attrs;
497 497
 	output = (!pvd)?NULL:&tmp;
498 498
 	if (dp_translate_helper(msg, input, output, idp, outattrs)!=0) {
499 499
 		LM_DBG("could not translate %.*s "
... ...
@@ -879,8 +879,8 @@ static int ki_dp_translate(sip_msg_t* msg, int id, str *input_spv, str *output_s
879 879
 	}
880 880
 
881 881
 	if (input_spv == NULL && output_spv == NULL) {
882
-		pvs_i = pv_cache_get(&default_param_s);
883
-		pvs_o = pv_cache_get(&default_param_s);
882
+		pvs_i = pv_cache_get(&dp_default_param_s);
883
+		pvs_o = pv_cache_get(&dp_default_param_s);
884 884
 	} else {
885 885
 		pvs_i = pv_cache_get(input_spv);
886 886
 		pvs_o = pv_cache_get(output_spv);
... ...
@@ -912,7 +912,7 @@ static int ki_dp_translate(sip_msg_t* msg, int id, str *input_spv, str *output_s
912 912
 
913 913
 	LM_DBG("input is %.*s\n", input.len, input.s);
914 914
 
915
-	outattrs = (!attr_pvar)?NULL:&attrs;
915
+	outattrs = (!dp_attr_pvar)?NULL:&attrs;
916 916
 	if (dp_translate_helper(msg, &input, &output, idp, outattrs)!=0) {
917 917
 		LM_DBG("could not translate %.*s "
918 918
 				"with dpid %i\n", input.len, input.s, idp->dp_id);