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

Function msg_get_pseudoVar

modules/python/python_msgobj.c:368–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368static PyObject *
369msg_get_pseudoVar(msgobject *self, PyObject *args)
370{
371 str hmodel,rval;
372 pv_elem_t *model;
373 int buf_size = 4096;
374 char *out;
375 PyObject * res;
376
377 if (self->msg == NULL) {
378 PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
379 Py_INCREF(Py_None);
380 return Py_None;
381 }
382
383 if(!PyArg_ParseTuple(args, "s", &hmodel.s)){
384 Py_INCREF(Py_None);
385 return Py_None;
386 }
387
388 hmodel.len = strlen(hmodel.s);
389 if (pv_parse_format(&hmodel, &model) < 0)
390 {
391 Py_INCREF(Py_None);
392 return Py_None;
393 }
394
395 out = pkg_malloc(buf_size);
396 if (!out)
397 {
398 PyErr_SetString(PyExc_RuntimeError, "Not enough memor");
399 Py_INCREF(Py_None);
400 return Py_None;
401 }
402
403 rval.len = pv_printf(self->msg, model, out, &buf_size) ;
404 rval.s = out;
405 rval.len = strlen(rval.s);
406 res = PyUnicode_FromStringAndSize(rval.s, rval.len);
407 pkg_free(out);
408 pv_elem_free_all(model);
409 return res;
410}
411
412static PyObject *
413msg_set_pseudoVar(msgobject *self, PyObject *args)

Callers

nothing calls this directly

Calls 3

pv_parse_formatFunction · 0.85
pv_printfFunction · 0.85
pv_elem_free_allFunction · 0.85

Tested by

no test coverage detected