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

Function check_cmd_call_params

cmds.c:43–63  ·  view source on GitHub ↗

Checks if the module function is called with the right number of parameters * and all mandatory parameters are given * Return: * 0 - correct call * -1 - too few parameters * -2 - too many parameters * -3 - mandatory parameter omitted */

Source from the content-addressed store, hash-verified

41 * -3 - mandatory parameter omitted
42 */
43int check_cmd_call_params(const cmd_export_t *cmd, action_elem_t *elems, int no_params)
44{
45 const struct cmd_param *param;
46 int n=0, m=0, i;
47
48 for (param=cmd->params; param->flags; param++, n++)
49 if (!(param->flags & CMD_PARAM_OPT))
50 m = n+1;
51
52 if (no_params < m) /* check the minimum number of arguments for the call,
53 * including optional params that must be explicitly omitted */
54 return -1;
55 else if (no_params > n)
56 return -2;
57
58 for (i=1, param=cmd->params; i<=no_params; i++, param++)
59 if (!(param->flags & CMD_PARAM_OPT) && elems[i].type == NULLV_ST)
60 return -3;
61
62 return 0;
63}
64
65/* simillar function to check_cmd_call_params but for async cmds */
66int check_acmd_call_params(const acmd_export_t *acmd, action_elem_t *elems, int no_params)

Callers 2

msg_call_functionFunction · 0.85
l_siplua_moduleFuncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected