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

Function l_siplua_pseudoVar

modules/lua/sipapi.c:592–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592static int l_siplua_pseudoVar(lua_State *L)
593{
594 struct sipapi_object *o;
595 const char *name;
596 str s;
597 pv_elem_t *model;
598 int buf_size = 4096;
599 char *out;
600
601 o = luaL_checkudata(L, 1, "siplua.api");
602 name = luaL_checkstring(L, 2);
603 s.s = (char *)name;
604 s.len = strlen(name);
605 if (pv_parse_format(&s, &model) < 0)
606 {
607 lua_pushnil(L);
608 return 1;
609 }
610 out = pkg_malloc(buf_size);
611 if (!out)
612 {
613 pv_elem_free_all(model);
614 return luaL_error(L, "Not enough memory");
615 }
616 if (pv_printf(o->msg, model, out, &buf_size) < 0)
617 lua_pushnil(L);
618 else
619 lua_pushstring(L, out);
620 pkg_free(out);
621 pv_elem_free_all(model);
622 return 1;
623}
624
625static int l_siplua_pseudoVarSet(lua_State *L)
626{

Callers

nothing calls this directly

Calls 3

pv_parse_formatFunction · 0.85
pv_elem_free_allFunction · 0.85
pv_printfFunction · 0.85

Tested by

no test coverage detected