static int redirect_init(void) { regex_t *filter; /* load the TM API */ if (load_tm_api(&rd_tmb)!=0) { LOG(L_ERR, "ERROR:uac_redirect:init: can't load TM API\n"); goto error; } /* init filter */ init_filters(); /* what's the default rule? */ if (def_filter_s) { if ( !strcasecmp(def_filter_s,ACCEPT_RULE_STR) ) { set_default_rule( ACCEPT_RULE ); } else if ( !strcasecmp(def_filter_s,DENY_RULE_STR) ) { set_default_rule( DENY_RULE ); } else { LOG(L_ERR,"ERROR:uac_redirect:init: unknown default " "filter <%s>\n",def_filter_s); } } /* if accept filter specify, compile it */ if (regexp_compile(accept_filter_s, &filter)<0) { LOG(L_ERR,"ERROR:uac_redirect:init: cannot init accept filter\n"); goto error; } add_default_filter( ACCEPT_FILTER, filter); /* if deny filter specify, compile it */ if (regexp_compile(deny_filter_s, &filter)<0) { LOG(L_ERR,"ERROR:uac_redirect:init: cannot init deny filter\n"); goto error; } add_default_filter( DENY_FILTER, filter); return 0; error: return -1; }
static int redirect_init(void) { regex_t *filter; void *p; cmd_function fct; /* load the TM API */ if (load_tm_api(&rd_tmb)!=0) { LM_ERR("failed to load TM API\n"); goto error; } p = (void*)acc_db_table; /* fixup table name */ if(fixup_var_pve_str_12(&p, 1)<0) { LM_ERR("failed to fixup acc db table\n"); goto error; } acc_db_table = p; /* init filter */ init_filters(); /* what's the default rule? */ if (def_filter_s) { if ( !strcasecmp(def_filter_s,ACCEPT_RULE_STR) ) { set_default_rule( ACCEPT_RULE ); } else if ( !strcasecmp(def_filter_s,DENY_RULE_STR) ) { set_default_rule( DENY_RULE ); } else { LM_ERR("unknown default filter <%s>\n",def_filter_s); } } /* if accept filter specify, compile it */ if (regexp_compile(accept_filter_s, &filter)<0) { LM_ERR("failed to init accept filter\n"); goto error; } add_default_filter( ACCEPT_FILTER, filter); /* if deny filter specify, compile it */ if (regexp_compile(deny_filter_s, &filter)<0) { LM_ERR("failed to init deny filter\n"); goto error; } add_default_filter( DENY_FILTER, filter); if(sruid_init(&_redirect_sruid, '-', "rdir", SRUID_INC)<0) return -1; if(rd_acc_fct == 0) { /* import the acc stuff */ if(acc_fct_s != 0 && acc_fct_s[0] == '\0') { fct = find_export(acc_fct_s, 2, REQUEST_ROUTE); if(fct == 0) fct = find_export(acc_fct_s, 1, REQUEST_ROUTE); if(fct == 0) { LM_ERR("cannot import %s function; is acc loaded and" " configured\n", acc_fct_s); return E_UNSPEC; } rd_acc_fct = fct; } } return 0; error: return -1; }