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

Function mod_init

modules/emergency/emergency_methods.c:218–362  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

216 * - initialize lock: ref_lock
217 */
218static 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 }

Callers

nothing calls this directly

Calls 11

shm_mallocFunction · 0.85
fill_blank_spaceFunction · 0.85
load_dlg_apiFunction · 0.85
load_tm_apiFunction · 0.85
load_rr_apiFunction · 0.85
db_bind_modFunction · 0.85
db_check_table_versionFunction · 0.85
register_timerFunction · 0.85
lock_init_rwFunction · 0.85
new_ehtableFunction · 0.85
new_shtableFunction · 0.70

Tested by

no test coverage detected