| 1712 | static int check_expr(struct expr* exp, int r_type); |
| 1713 | |
| 1714 | static int check_actions(struct action *a, int r_type) |
| 1715 | { |
| 1716 | struct action *aitem; |
| 1717 | const cmd_export_t *fct; |
| 1718 | int n; |
| 1719 | |
| 1720 | for( ; a ; a=a->next ) { |
| 1721 | switch (a->type) { |
| 1722 | case ROUTE_T: |
| 1723 | /* this route is already on the current path ? */ |
| 1724 | for( n=0 ; n<rcheck_stack_p ; n++ ) { |
| 1725 | if (rcheck_stack[n]==(int)a->elem[0].u.number) |
| 1726 | break; |
| 1727 | } |
| 1728 | if (n!=rcheck_stack_p) |
| 1729 | break; |
| 1730 | if (++rcheck_stack_p==RT_NO) { |
| 1731 | LM_CRIT("stack overflow (%d)\n", rcheck_stack_p); |
| 1732 | goto error; |
| 1733 | } |
| 1734 | rcheck_stack[rcheck_stack_p] = a->elem[0].u.number; |
| 1735 | if (check_actions(sroutes->request[a->elem[0].u.number].a, |
| 1736 | r_type)!=0) |
| 1737 | goto error; |
| 1738 | rcheck_stack_p--; |
| 1739 | break; |
| 1740 | case IF_T: |
| 1741 | if (check_expr((struct expr*)a->elem[0].u.data, r_type) < 0) |
| 1742 | goto error; |
| 1743 | if (check_actions((struct action*)a->elem[1].u.data, r_type)!=0) |
| 1744 | goto error; |
| 1745 | if (check_actions((struct action*)a->elem[2].u.data, r_type)!=0) |
| 1746 | goto error; |
| 1747 | break; |
| 1748 | case WHILE_T: |
| 1749 | if (check_actions((struct action*)a->elem[1].u.data, r_type)!=0) |
| 1750 | goto error; |
| 1751 | break; |
| 1752 | case FOR_EACH_T: |
| 1753 | if (check_actions((struct action*)a->elem[2].u.data, r_type)!=0) |
| 1754 | goto error; |
| 1755 | break; |
| 1756 | case SWITCH_T: |
| 1757 | aitem = (struct action*)a->elem[1].u.data; |
| 1758 | for( ; aitem ; aitem=aitem->next ) { |
| 1759 | n = check_actions((struct action*)aitem->elem[1].u.data, |
| 1760 | r_type); |
| 1761 | if (n!=0) goto error; |
| 1762 | } |
| 1763 | break; |
| 1764 | case CMD_T: |
| 1765 | /* do check :D */ |
| 1766 | fct = (const cmd_export_t*)(a->elem[0].u.data_const); |
| 1767 | if ( (fct->flags&r_type)!=r_type ) { |
| 1768 | rcheck_status = -1; |
| 1769 | LM_ERR("script function " |
| 1770 | "\"%s\" (types=%d) does not support route type " |
| 1771 | "(%d)\n",fct->name, fct->flags, r_type); |
no test coverage detected