Skip to content

Commit

Permalink
- new functions added to help a module to check if its functions are …
Browse files Browse the repository at this point in the history
…used from the script (we cannot rely on the fixup functions as we have functions without parameters or need for fixup). Such function is needed for fixing dependencies between modules (to follow up)
  • Loading branch information
bogdan-iancu committed Sep 4, 2013
1 parent bc3c8e8 commit da85c3a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
50 changes: 50 additions & 0 deletions route.c
Expand Up @@ -2181,6 +2181,56 @@ void print_rl(void)
}
}


int is_script_func_used( char *name, int param_no)
{
unsigned int i;

for( i=0; i<RT_NO ; i++ )
if (rlist[i].a && is_mod_func_used(rlist[i].a,name,param_no) )
return 1;

for( i=0; i<ONREPLY_RT_NO ; i++ )
if (onreply_rlist[i].a &&
is_mod_func_used(onreply_rlist[i].a,name,param_no) )
return 1;

for( i=0; i<FAILURE_RT_NO ; i++ )
if (failure_rlist[i].a &&
is_mod_func_used(failure_rlist[i].a,name,param_no) )
return 1;

for( i=0; i<BRANCH_RT_NO ; i++ )
if (branch_rlist[i].a &&
is_mod_func_used(branch_rlist[i].a,name,param_no) )
return 1;

for( i=0; i<TIMER_RT_NO ; i++ )
if (timer_rlist[i].a &&
is_mod_func_used(timer_rlist[i].a,name,param_no) )
return 1;

for( i=0; i<EVENT_RT_NO ; i++ )
if (event_rlist[i].a &&
is_mod_func_used(event_rlist[i].a,name,param_no) )
return 1;

if (error_rlist.a &&
is_mod_func_used(error_rlist.a,name,param_no) )
return 1;

if (local_rlist.a &&
is_mod_func_used(local_rlist.a,name,param_no) )
return 1;

if (startup_rlist.a &&
is_mod_func_used(startup_rlist.a,name,param_no) )
return 1;

return 0;
}


int run_startup_route(void)
{
struct sip_msg req;
Expand Down
3 changes: 3 additions & 0 deletions route.h
Expand Up @@ -109,4 +109,7 @@ int eval_expr(struct expr* e, struct sip_msg* msg, pv_value_t *val);

int run_startup_route(void);

int is_script_func_used( char *name, int param_no);


#endif
16 changes: 16 additions & 0 deletions route_struct.c
Expand Up @@ -635,3 +635,19 @@ void print_actions(struct action* a)
}


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;
}
a = a->next;
}

return 0;
}
1 change: 1 addition & 0 deletions route_struct.h
Expand Up @@ -156,6 +156,7 @@ struct action* append_action(struct action* a, struct action* b);
void print_action(struct action* a);
void print_expr(struct expr* exp);
void print_actions(struct action* a);
int is_mod_func_used(struct action *a, char *name, int param_no);



Expand Down

0 comments on commit da85c3a

Please sign in to comment.