| 590 | } |
| 591 | |
| 592 | static 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 | |
| 625 | static int l_siplua_pseudoVarSet(lua_State *L) |
| 626 | { |
nothing calls this directly
no test coverage detected