* This function is responsible for : * - load api from modules dialog and rr * - open database connection and test the version of the tables in the database * - initialize polling routing timer * - initialize the module linked lists db_esrn_domain and calls_eme * - initialize lock: ref_lock */
| 216 | * - initialize lock: ref_lock |
| 217 | */ |
| 218 | static int mod_init(void) { |
| 219 | |
| 220 | LM_DBG("Initializing module\n"); |
| 221 | |
| 222 | table_name.len = strlen(table_name.s); |
| 223 | table_report.len = strlen(table_report.s); |
| 224 | table_provider.len = strlen(table_provider.s); |
| 225 | |
| 226 | // checks for mandatory fields |
| 227 | mandatory_parm = shm_malloc(2); |
| 228 | mandatory_parm[0] = '1'; |
| 229 | mandatory_parm[1] = 0; |
| 230 | |
| 231 | inicialized = shm_malloc(2); |
| 232 | inicialized[0] = '0'; |
| 233 | inicialized[1] = 0; |
| 234 | |
| 235 | LM_DBG(" ---fill parameters not config with blank_space \n"); |
| 236 | if (fill_blank_space() == -1) |
| 237 | return -1; |
| 238 | |
| 239 | if ( load_dlg_api( &dlgb ) != 0 ) { |
| 240 | LM_ERR("failed to load DLG api\n"); |
| 241 | return -1; |
| 242 | } |
| 243 | |
| 244 | if (load_tm_api(&eme_tm)!=0) { |
| 245 | LM_ERR( "can't load TM API\n"); |
| 246 | return -1; |
| 247 | } |
| 248 | |
| 249 | if (load_rr_api(&rr_api) != 0) { |
| 250 | LM_ERR("failed to load rr API\n"); |
| 251 | return -1; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | empty = shm_malloc(sizeof (char)); |
| 256 | memset(empty, '\0', 1); |
| 257 | |
| 258 | if(call_origin == NULL) |
| 259 | call_origin = empty; |
| 260 | |
| 261 | if (db_url.s) { |
| 262 | db_url.len = strlen(db_url.s); |
| 263 | LM_DBG("We have db_url = %.*s\n", db_url.len, db_url.s); |
| 264 | |
| 265 | /* Find a database module */ |
| 266 | if (db_bind_mod(&db_url, &db_funcs) < 0) { |
| 267 | LM_ERR("Unable to bind to a database driver\n"); |
| 268 | return -1; |
| 269 | } |
| 270 | |
| 271 | /* open a test connection */ |
| 272 | if ((db_con = db_funcs.init(&db_url)) == 0) { |
| 273 | LM_ERR("cannot init connection to DB\n"); |
| 274 | return -1; |
| 275 | } |
nothing calls this directly
no test coverage detected