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

Function script_return_set

route.c:2214–2267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2212}
2213
2214void script_return_set(struct sip_msg *msg, struct script_return_param *params)
2215{
2216 pv_value_t val;
2217 struct script_return_param *p;
2218 struct script_return_value *v, *ret = NULL;
2219 if (script_return_level <= 0) {
2220 LM_ERR("no return level initialized\n");
2221 return;
2222 }
2223 /* itertate through each parameter to store it's value */
2224 for (p = params; p; p = p->next) {
2225 memset(&val, 0, sizeof val);
2226 switch (p->type) {
2227 case SCRIPT_ROUTE_RET_INT:
2228 val.ri = p->rint;
2229 val.flags = PV_VAL_INT;
2230 break;
2231 case SCRIPT_ROUTE_RET_STR:
2232 val.rs = p->rstr;
2233 val.flags = PV_VAL_STR;
2234 break;
2235 case SCRIPT_ROUTE_RET_VAR:
2236 if (pv_get_spec_value(msg, p->rspec, &val) != 0) {
2237 LM_ERR("cannot get return value\n");
2238 pv_get_null(NULL, NULL, &val);
2239 }
2240 break;
2241 case SCRIPT_ROUTE_RET_NULL:
2242 pv_get_null(NULL, NULL, &val);
2243 break;
2244 default:
2245 LM_BUG("unhandled return type %d\n", p->type);
2246 script_return_free(&ret);
2247 return;
2248 }
2249 v = pkg_malloc(sizeof(*v) + ((val.flags & PV_VAL_STR)?val.rs.len:0));
2250 if (v) {
2251 v->val = val;
2252 if (val.flags & PV_VAL_STR) {
2253 v->val.rs.s = v->buf;
2254 memcpy(v->val.rs.s, val.rs.s, val.rs.len);
2255 }
2256 v->next = ret;
2257 ret = v;
2258 } else {
2259 LM_ERR("could not allocate return value\n");
2260 script_return_free(&ret);
2261 return;
2262 }
2263 }
2264 if (script_return_values[script_return_level - 1])
2265 script_return_free(&script_return_values[script_return_level - 1]);
2266 script_return_values[script_return_level - 1] = ret;
2267}
2268
2269int script_return_get(pv_value_t *res, int index)
2270{

Callers 1

do_actionFunction · 0.85

Calls 3

pv_get_spec_valueFunction · 0.85
pv_get_nullFunction · 0.85
script_return_freeFunction · 0.85

Tested by

no test coverage detected