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

Function l_siplua_getContact

modules/lua/sipapi.c:203–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203static int l_siplua_getContact(lua_State *L)
204{
205 struct sipapi_object *o;
206 struct hdr_field *_p;
207 contact_t *_c;
208 int n = 1;
209 int found_hf_no_star = 0;
210 int found_hf_star = 0;
211 int expires;
212
213 o = luaL_checkudata(L, 1, "siplua.api");
214 if (!o->msg->contact)
215 {
216 lua_pushnil(L);
217 return 1;
218 }
219 lua_newtable(L);
220 _p = o->msg->contact;
221 for (_p = o->msg->contact; _p; _p = _p->next)
222 {
223/* siplua_log(L_DBG, "l_siplua_getContact _p/%p", _p); */
224 if (_p->type == HDR_CONTACT_T)
225 {
226 if (parse_contact(_p) < 0)
227 {
228 return luaL_error(L, "failed to parse Contact body");
229 }
230 if (((contact_body_t *)_p->parsed)->star)
231 {
232 lua_pushinteger(L, n++);
233 lua_newtable(L);
234 lua_pushstring(L, "star");
235 lua_pushboolean(L, 1);
236 lua_rawset(L, -3);
237 lua_pushstring(L, "name");
238 lua_pushstring(L, "*");
239 lua_rawset(L, -3);
240 lua_pushstring(L, "uri");
241 lua_pushstring(L, "*");
242 lua_rawset(L, -3);
243 lua_rawset(L, -3);
244 found_hf_star = 1;
245 }
246 for (_c = ((contact_body_t *)_p->parsed)->contacts; _c; _c = _c->next)
247 {
248/* siplua_log(L_DBG, "l_siplua_getContact _c/%p", _c); */
249 lua_pushinteger(L, n++);
250 lua_newtable(L);
251 lua_pushstring(L, "name");
252 lua_pushlstring(L, _c->name.s, _c->name.len);
253 lua_rawset(L, -3);
254 lua_pushstring(L, "uri");
255 lua_pushlstring(L, _c->uri.s, _c->uri.len);
256 lua_rawset(L, -3);
257/* siplua_log(L_DBG, "contact q/%p expires/%p", _c->q, _c->expires); */
258 if (_c->q)
259 {
260 lua_pushstring(L, "q");

Callers

nothing calls this directly

Calls 3

parse_contactFunction · 0.85
siplua_logFunction · 0.85
sipapi_getExpiresFunction · 0.85

Tested by

no test coverage detected