示例#1
0
int is_mod_func_used(struct action *a, char *name, int param_no)
{
	cmd_export_t *cmd;
	while(a) {
		if (a->type==MODULE_T) {
			/* first param is the name of the function */
			cmd = (cmd_export_t*)a->elem[0].u.data;
			if (strcasecmp(cmd->name, name)==0 &&
			(param_no==cmd->param_no || param_no==-1) )
				return 1;
		}

		/* follow all leads from actions than may have sub-blocks of instructions */
		if (a->elem[0].type==ACTIONS_ST)
				if (is_mod_func_used((struct action*)a->elem[0].u.data,name,param_no)==1)
					return 1;

		if (a->elem[1].type==ACTIONS_ST)
				if (is_mod_func_used((struct action*)a->elem[1].u.data,name,param_no)==1)
					return 1;

		if (a->elem[2].type==ACTIONS_ST)
				if (is_mod_func_used((struct action*)a->elem[2].u.data,name,param_no)==1)
					return 1;

		a = a->next;
	}

	return 0;
}
示例#2
0
int is_mod_func_used(struct action *a, char *name, int param_no)
{
	cmd_export_t *cmd;
	while(a) {
		if (a->type==MODULE_T) {
			/* first param is the name of the function */
			cmd = (cmd_export_t*)a->elem[0].u.data;
			if (strcasecmp(cmd->name, name)==0 &&
			(param_no==cmd->param_no || param_no==-1) ) {
				LM_DBG("function %s found to be used in script\n",name);
				return 1;
			}
		}

		if (a->type==IF_T || a->type==WHILE_T)
			if (is_mod_func_in_expr((struct expr*)a->elem[0].u.data,
			name,param_no)==1)
				return 1;

		/* follow all leads from actions than may have 
		 * sub-blocks of instructions */
		if (a->elem[0].type==ACTIONS_ST)
				if (is_mod_func_used((struct action*)a->elem[0].u.data,
				name,param_no)==1)
					return 1;

		if (a->elem[1].type==ACTIONS_ST)
				if (is_mod_func_used((struct action*)a->elem[1].u.data,
				name,param_no)==1)
					return 1;

		if (a->elem[2].type==ACTIONS_ST)
				if (is_mod_func_used((struct action*)a->elem[2].u.data,
				name,param_no)==1)
					return 1;

		a = a->next;
	}

	return 0;
}
示例#3
0
static int is_mod_func_in_expr(struct expr *e, char *name, int param_no)
{
	if (e->type==ELEM_T) {
		if (e->left.type==ACTION_O)
			if (is_mod_func_used((struct action*)e->right.v.data,name,param_no)==1)
				return 1;
	} else if (e->type==EXP_T) {
		if (e->left.v.expr && is_mod_func_in_expr(e->left.v.expr,name,param_no)==1)
			return 1;
		if (e->right.v.expr && is_mod_func_in_expr(e->right.v.expr,name,param_no)==1)
			return 1;
	}
	return 0;
}