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

Function pv_print_spec

pvar.c:5537–5566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5535}
5536
5537int pv_print_spec(struct sip_msg* msg, const pv_spec_p sp, char *buf, int *len)
5538{
5539 pv_value_t tok;
5540 if(msg==NULL || sp==NULL || buf==NULL || len==NULL)
5541 return -1;
5542
5543 if(*len <= 0)
5544 return -1;
5545
5546 memset(&tok, 0, sizeof(pv_value_t));
5547
5548 /* put the value of the specifier */
5549 if(pv_get_spec_value(msg, sp, &tok)==0)
5550 {
5551 if(tok.flags&PV_VAL_NULL)
5552 tok.rs = str_null;
5553 if(tok.rs.len < *len)
5554 memcpy(buf, tok.rs.s, tok.rs.len);
5555 else
5556 goto overflow;
5557 }
5558
5559 *len = tok.rs.len;
5560 buf[tok.rs.len] = '\0';
5561 return 0;
5562
5563overflow:
5564 LM_ERR("buffer overflow -- increase the buffer size...\n");
5565 return -1;
5566}
5567
5568
5569int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len)

Callers

nothing calls this directly

Calls 1

pv_get_spec_valueFunction · 0.85

Tested by

no test coverage detected