MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / tr_eval_string

Function tr_eval_string

transformations.c:259–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
260 pv_value_t *val)
261{
262 int i, j;
263 char *p, *s, *_tr_buffer = get_tr_buffer();
264 str st;
265 pv_value_t v;
266 pv_elem_p el=NULL;
267
268 if (!val)
269 return -1;
270
271 if (val->flags & PV_VAL_NULL)
272 return 0;
273
274 switch(subtype)
275 {
276 case TR_S_LEN:
277 if(!(val->flags&PV_VAL_STR))
278 val->rs.s = int2str(val->ri, &val->rs.len);
279
280 val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
281 val->ri = val->rs.len;
282 val->rs.s = int2str(val->ri, &val->rs.len);
283 break;
284 case TR_S_INT:
285 if(!(val->flags&PV_VAL_INT))
286 {
287 //Default conversion to 0
288 val->ri = 0;
289 /*Ignore the return value of str2sint.
290 str2sint will convert the string up until it finds a non-number char
291 which is the desired behavior for the script level transformation*/
292 str2sint(&val->rs, &val->ri);
293 } else {
294 if(!(val->flags&PV_VAL_STR))
295 val->rs.s = int2str(val->ri, &val->rs.len);
296 }
297
298 val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
299 break;
300 case TR_S_MD5:
301 if(!(val->flags&PV_VAL_STR))
302 val->rs.s = int2str(val->ri, &val->rs.len);
303
304 compute_md5(_tr_buffer, val->rs.s, val->rs.len);
305 _tr_buffer[MD5_LEN] = '\0';
306 val->flags = PV_VAL_STR;
307 val->ri = 0;
308 val->rs.s = _tr_buffer;
309 val->rs.len = MD5_LEN;
310 break;
311 case TR_S_SHA1:
312 case TR_S_SHA1_HMAC:
313 case TR_S_SHA224:
314 case TR_S_SHA224_HMAC:
315 case TR_S_SHA256:
316 case TR_S_SHA256_HMAC:

Callers

nothing calls this directly

Calls 15

int2strFunction · 0.85
str2sintFunction · 0.85
compute_md5Function · 0.85
pv_get_spec_valueFunction · 0.85
sha1Function · 0.85
sha256Function · 0.85
sha512Function · 0.85
sha1_hmacFunction · 0.85
sha256_hmacFunction · 0.85
sha512_hmacFunction · 0.85
string2hexFunction · 0.85
crc32_uintFunction · 0.85

Tested by

no test coverage detected