MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mi_trie_remove_code_2

Function mi_trie_remove_code_2

modules/trie/trie.c:1146–1195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1144}
1145
1146mi_response_t *mi_trie_remove_code_2(const mi_params_t *params,struct mi_handler *async_hdl)
1147{
1148 struct head_db *partition;
1149 str number;
1150 unsigned int matched_len;
1151 trie_info_t *route;
1152 mi_response_t *resp;
1153 mi_item_t *code_arr;
1154 int no_codes,i;
1155
1156 resp = mi_trie_get_partition(params,&partition);
1157 if (resp)
1158 return resp;
1159
1160 if (get_mi_array_param(params, "number", &code_arr, &no_codes) < 0)
1161 return init_mi_param_error();
1162
1163 lock_start_read( partition->ref_lock );
1164
1165 if (partition->rdata == NULL) {
1166 lock_stop_read( partition->ref_lock );
1167 return init_mi_error(400, MI_SSTR("No data"));
1168 }
1169
1170 for (i = 0; i < no_codes; i++) {
1171 if (get_mi_arr_param_string(code_arr, i,
1172 &number.s, &number.len) < 0) {
1173 lock_stop_read( partition->ref_lock );
1174 return init_mi_param_error();
1175 }
1176
1177 route = get_trie_prefix(((partition->rdata))->pt,
1178 &number, &matched_len,1);
1179 if (route == NULL) {
1180 LM_ERR("Failed to find DID to delete [%.*s]\n",number.len,number.s);
1181 continue;
1182 }
1183
1184 if (matched_len != number.len) {
1185 LM_ERR("Failed to find entry to delete [%.*s]\n",number.len,number.s);
1186 continue;
1187 }
1188
1189 route->enabled = 0;
1190 }
1191
1192 lock_stop_read( partition->ref_lock );
1193
1194 return init_mi_result_ok();
1195}
1196
1197mi_response_t *mi_trie_upsert_code_3(const mi_params_t *params,struct mi_handler *async_hdl)
1198{

Callers

nothing calls this directly

Calls 6

mi_trie_get_partitionFunction · 0.85
get_mi_array_paramFunction · 0.85
init_mi_param_errorFunction · 0.85
init_mi_errorFunction · 0.85
get_mi_arr_param_stringFunction · 0.85
get_trie_prefixFunction · 0.85

Tested by

no test coverage detected