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

Function py_do_action

modules/python/python_msgobj.c:189–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189static int py_do_action(struct sip_msg* msg, struct action *act,
190 const cmd_export_t *cmd, int *retval)
191{
192 void* cmdp[MAX_CMD_PARAMS];
193 pv_value_t tmp_vals[MAX_CMD_PARAMS];
194 int i;
195 const struct cmd_param *param;
196 gparam_p gp;
197
198 if (fix_cmd(cmd->params, act->elem) < 0) {
199 PyErr_SetString(PyExc_RuntimeError, "failed to fix command");
200 return -1;
201 }
202
203 if (get_cmd_fixups(msg, cmd->params, act->elem, cmdp, tmp_vals) < 0) {
204 PyErr_SetString(PyExc_RuntimeError, "failed to get fixups for command");
205 return -1;
206 }
207
208 *retval = cmd->function(msg,
209 cmdp[0],cmdp[1],cmdp[2],
210 cmdp[3],cmdp[4],cmdp[5],
211 cmdp[6],cmdp[7]);
212
213 for (param=cmd->params, i=1; param->flags; param++, i++) {
214 gp = (gparam_p)act->elem[i].u.data;
215 if (!gp)
216 continue;
217
218 if (param->free_fixup && param->free_fixup(&cmdp[i-1]) < 0) {
219 PyErr_SetString(PyExc_RuntimeError, "failed to free fixups");
220 return -1;
221 }
222
223 if (param->flags & CMD_PARAM_REGEX && gp->type != GPARAM_TYPE_PVS) {
224 regfree((regex_t*)cmdp[i-1]);
225 pkg_free(cmdp[i-1]);
226 }
227 }
228
229 return 0;
230}
231
232static PyObject *
233msg_call_function(msgobject *self, PyObject *args)

Callers 1

msg_call_functionFunction · 0.85

Calls 2

fix_cmdFunction · 0.85
get_cmd_fixupsFunction · 0.85

Tested by

no test coverage detected