Octstr *gw_regex_subst_real(const Octstr *re, const Octstr *os, const Octstr *rule, const char *file, long line, const char *func) { Octstr *result; regex_t *regexp; regmatch_t pmatch[REGEX_MAX_SUB_MATCH]; int rc; char *rsub; /* compile */ regexp = gw_regex_comp_real(re, REG_EXTENDED|REG_ICASE, file, line, func); if (regexp == NULL) return 0; /* execute and match */ rc = gw_regex_exec_real(regexp, os, REGEX_MAX_SUB_MATCH, &pmatch[0], 0, file, line, func); gw_regex_destroy(regexp); /* substitute via rule if matched */ if (rc != 0) return NULL; rsub = gw_regex_sub(octstr_get_cstr(rule), octstr_get_cstr(os), REGEX_MAX_SUB_MATCH, &pmatch[0]); if (rsub == NULL) return NULL; result = octstr_create(rsub); gw_free(rsub); return result; }
int smscconn_destroy(SMSCConn *conn) { if (conn == NULL) return 0; if (conn->status != SMSCCONN_DEAD) return -1; mutex_lock(conn->flow_mutex); counter_destroy(conn->received); counter_destroy(conn->received_dlr); counter_destroy(conn->sent); counter_destroy(conn->sent_dlr); counter_destroy(conn->failed); load_destroy(conn->incoming_sms_load); load_destroy(conn->incoming_dlr_load); load_destroy(conn->outgoing_sms_load); load_destroy(conn->outgoing_dlr_load); octstr_destroy(conn->name); octstr_destroy(conn->id); octstr_destroy(conn->admin_id); gwlist_destroy(conn->allowed_smsc_id, octstr_destroy_item); gwlist_destroy(conn->denied_smsc_id, octstr_destroy_item); gwlist_destroy(conn->preferred_smsc_id, octstr_destroy_item); octstr_destroy(conn->denied_prefix); octstr_destroy(conn->allowed_prefix); octstr_destroy(conn->preferred_prefix); octstr_destroy(conn->unified_prefix); octstr_destroy(conn->our_host); octstr_destroy(conn->log_file); if (conn->denied_smsc_id_regex != NULL) gw_regex_destroy(conn->denied_smsc_id_regex); if (conn->allowed_smsc_id_regex != NULL) gw_regex_destroy(conn->allowed_smsc_id_regex); if (conn->preferred_prefix_regex != NULL) gw_regex_destroy(conn->preferred_prefix_regex); if (conn->denied_prefix_regex != NULL) gw_regex_destroy(conn->denied_prefix_regex); if (conn->allowed_prefix_regex != NULL) gw_regex_destroy(conn->allowed_prefix_regex); octstr_destroy(conn->reroute_to_smsc); dict_destroy(conn->reroute_by_receiver); mutex_unlock(conn->flow_mutex); mutex_destroy(conn->flow_mutex); gw_free(conn); return 0; }
/* * Free one URLTranslation. */ static void destroy_onetrans(void *p) { URLTranslation *ot; ot = p; if (ot != NULL) { octstr_destroy(ot->dlr_url); octstr_destroy(ot->pattern); octstr_destroy(ot->prefix); octstr_destroy(ot->suffix); octstr_destroy(ot->default_sender); octstr_destroy(ot->faked_sender); octstr_destroy(ot->split_chars); octstr_destroy(ot->split_suffix); octstr_destroy(ot->header); octstr_destroy(ot->footer); octstr_destroy(ot->alt_charset); gwlist_destroy(ot->accepted_smsc, octstr_destroy_item); gwlist_destroy(ot->accepted_account, octstr_destroy_item); octstr_destroy(ot->name); octstr_destroy(ot->username); octstr_destroy(ot->password); octstr_destroy(ot->forced_smsc); octstr_destroy(ot->default_smsc); octstr_destroy(ot->allow_ip); octstr_destroy(ot->deny_ip); octstr_destroy(ot->allowed_prefix); octstr_destroy(ot->denied_prefix); octstr_destroy(ot->allowed_recv_prefix); octstr_destroy(ot->denied_recv_prefix); numhash_destroy(ot->white_list); numhash_destroy(ot->black_list); if (ot->keyword_regex != NULL) gw_regex_destroy(ot->keyword_regex); if (ot->accepted_smsc_regex != NULL) gw_regex_destroy(ot->accepted_smsc_regex); if (ot->accepted_account_regex != NULL) gw_regex_destroy(ot->accepted_account_regex); if (ot->allowed_prefix_regex != NULL) gw_regex_destroy(ot->allowed_prefix_regex); if (ot->denied_prefix_regex != NULL) gw_regex_destroy(ot->denied_prefix_regex); if (ot->allowed_receiver_prefix_regex != NULL) gw_regex_destroy(ot->allowed_receiver_prefix_regex); if (ot->denied_receiver_prefix_regex != NULL) gw_regex_destroy(ot->denied_receiver_prefix_regex); if (ot->white_list_regex != NULL) gw_regex_destroy(ot->white_list_regex); if (ot->black_list_regex != NULL) gw_regex_destroy(ot->black_list_regex); gw_free(ot); } }
int gw_regex_match_real(const Octstr *re, const Octstr *os, const char *file, long line, const char *func) { regex_t *regexp; int rc; /* compile */ regexp = gw_regex_comp_real(re, REG_EXTENDED|REG_ICASE, file, line, func); if (regexp == NULL) return 0; /* execute and match */ rc = gw_regex_exec_real(regexp, os, 0, NULL, 0, file, line, func); gw_regex_destroy(regexp); return (rc == 0) ? 1 : 0; }
void smpp_route_destroy(SMPPRoute *smpp_route) { octstr_destroy(smpp_route->system_id); octstr_destroy(smpp_route->smsc_id); gw_regex_destroy(smpp_route->regex); gw_free(smpp_route); }