| 244 | |
| 245 | |
| 246 | int init_global(void){//str *info_set_mapping){ |
| 247 | |
| 248 | |
| 249 | |
| 250 | int i, j; |
| 251 | char *s, *p; |
| 252 | int count = -1; |
| 253 | |
| 254 | for(i=0; i< db_urls_count; i++){ |
| 255 | |
| 256 | s = db_urls_list[i]; |
| 257 | LM_DBG("line = %s\n", s); |
| 258 | |
| 259 | if(s && strlen(s) && s[0]!='#'){ |
| 260 | |
| 261 | if(strncmp("define", s, strlen("define")) == 0){ |
| 262 | s += strlen("define")+1; |
| 263 | p = strchr(s, ' '); |
| 264 | /* set1=FAILOVER */ |
| 265 | *p = 0; |
| 266 | p++; |
| 267 | LM_DBG("set_mode = {%s}, mode = {%s}\n", s, p); |
| 268 | add_set(s, p); |
| 269 | /*LM_ERR("done\n"); */ |
| 270 | count++; |
| 271 | } |
| 272 | else{ |
| 273 | if (count == -1) { |
| 274 | LM_ERR("db_virtual module cannot start with no DB sets defined!\n"); |
| 275 | return -1; |
| 276 | } |
| 277 | |
| 278 | /* mysql:........ */ |
| 279 | LM_DBG("db = %s\n", s); |
| 280 | add_url(count, s); |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | if (!global) { |
| 286 | LM_ERR("db_virtual module cannot start with no DB URLs defined!\n"); |
| 287 | return -1; |
| 288 | } |
| 289 | |
| 290 | for(i = 0; i< global->size; i++) |
| 291 | for(j=0; j<global->set_list[i].size; j++){ |
| 292 | |
| 293 | global->set_list[i].db_list[j].dbf.cap = 0; |
| 294 | |
| 295 | if(db_bind_mod(&global->set_list[i].db_list[j].db_url, |
| 296 | &global->set_list[i].db_list[j].dbf)){ |
| 297 | LM_ERR("cant bind db : %.*s", |
| 298 | global->set_list[i].db_list[j].db_url.len, |
| 299 | global->set_list[i].db_list[j].db_url.s); |
| 300 | goto error; |
| 301 | } |
| 302 | } |
| 303 |
no test coverage detected