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

Function msg_call_function

modules/python/python_msgobj.c:232–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static PyObject *
233msg_call_function(msgobject *self, PyObject *args)
234{
235 int i, rval;
236 char *fname;
237 char *pargs[MAX_CMD_PARAMS];
238 const cmd_export_t *fexport;
239 struct action *act;
240 action_elem_t elems[MAX_ACTION_ELEMS];
241 const struct cmd_param *param;
242 int n = 0;
243 str s;
244 pv_spec_t *specs[MAX_CMD_PARAMS];
245
246 if (self->msg == NULL) {
247 PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
248 Py_INCREF(Py_None);
249 return Py_None;
250 }
251
252 i = PySequence_Size(args);
253 if (i < 1 || i > MAX_CMD_PARAMS+1) {
254 PyErr_SetString(PyExc_RuntimeError, "call_function() should "
255 "have from 1 to 9 arguments");
256 Py_INCREF(Py_None);
257 return Py_None;
258 }
259
260 for (i=0; i < MAX_CMD_PARAMS; i++)
261 pargs[i] = (char*)-1; /* mark params as not given */
262
263 if(!PyArg_ParseTuple(args, "s|zzzzzzzz:call_function", &fname,
264 &pargs[0], &pargs[1], &pargs[2], &pargs[3],
265 &pargs[4], &pargs[5], &pargs[6], &pargs[7])) {
266 PyErr_SetString(PyExc_RuntimeError,
267 "failed to parse arguments from python");
268 Py_INCREF(Py_None);
269 return Py_None;
270 }
271
272 fexport = find_cmd_export_t(fname, 0);
273 if (fexport == NULL) {
274 PyErr_SetString(PyExc_RuntimeError, "no such function");
275 Py_INCREF(Py_None);
276 return Py_None;
277 }
278
279 for (i=0; i < MAX_CMD_PARAMS; i++) {
280 if (pargs[i] != (char*)-1) {
281 n++;
282 if (pargs[i] == NULL) /* given as 'None' in Python */
283 elems[i+1].type = NULLV_ST;
284 else
285 elems[i+1].type = NOSUBTYPE;
286 }
287 specs[i] = NULL;
288 }
289

Callers

nothing calls this directly

Calls 7

find_cmd_export_tFunction · 0.85
check_cmd_call_paramsFunction · 0.85
str2sintFunction · 0.85
pv_parse_specFunction · 0.85
mk_actionFunction · 0.85
py_do_actionFunction · 0.85
pv_spec_freeFunction · 0.85

Tested by

no test coverage detected