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

Function mod_init

modules/msilo/msilo.c:275–408  ·  view source on GitHub ↗

* init module function */

Source from the content-addressed store, hash-verified

273 * init module function
274 */
275static int mod_init(void)
276{
277 pv_spec_t avp_spec;
278
279 init_db_url( ms_db_url , 0 /*cannot be null*/);
280 ms_db_table.len = strlen (ms_db_table.s);
281 sc_mid.len = strlen(sc_mid.s);
282 sc_from.len = strlen(sc_from.s);
283 sc_to.len = strlen(sc_to.s);
284 sc_uri_user.len = strlen(sc_uri_user.s);
285 sc_uri_host.len = strlen(sc_uri_host.s);
286 sc_body.len = strlen(sc_body.s);
287 sc_ctype.len = strlen(sc_ctype.s);
288 sc_exp_time.len = strlen(sc_exp_time.s);
289 sc_inc_time.len = strlen(sc_inc_time.s);
290 sc_snd_time.len = strlen(sc_snd_time.s);
291 if (ms_snd_time_avp_param.s)
292 ms_snd_time_avp_param.len = strlen(ms_snd_time_avp_param.s);
293
294 LM_DBG("initializing ...\n");
295
296 /* binding to mysql module */
297 if (db_bind_mod(&ms_db_url, &msilo_dbf))
298 {
299 LM_DBG("database module not found\n");
300 return -1;
301 }
302
303 if (!DB_CAPABILITY(msilo_dbf, DB_CAP_ALL)) {
304 LM_ERR("database module does not implement "
305 "all functions needed by the module\n");
306 return -1;
307 }
308
309 if (ms_snd_time_avp_param.s && ms_snd_time_avp_param.len > 0) {
310 if (pv_parse_spec(&ms_snd_time_avp_param, &avp_spec)==0
311 || avp_spec.type!=PVT_AVP) {
312 LM_ERR("malformed or non AVP %.*s AVP definition\n",
313 ms_snd_time_avp_param.len, ms_snd_time_avp_param.s);
314 return -1;
315 }
316
317 if(pv_get_avp_name(0, &(avp_spec.pvp), &ms_snd_time_avp_name,
318 &ms_snd_time_avp_type)!=0)
319 {
320 LM_ERR("[%.*s]- invalid AVP definition\n",
321 ms_snd_time_avp_param.len, ms_snd_time_avp_param.s);
322 return -1;
323 }
324 }
325
326 db_con = msilo_dbf.init(&ms_db_url);
327 if (!db_con)
328 {
329 LM_ERR("failed to connect to the database\n");
330 return -1;
331 }
332

Callers

nothing calls this directly

Calls 8

db_bind_modFunction · 0.85
pv_parse_specFunction · 0.85
pv_get_avp_nameFunction · 0.85
db_check_table_versionFunction · 0.85
load_tm_apiFunction · 0.85
pv_parse_formatFunction · 0.85
msg_list_initFunction · 0.85
register_timerFunction · 0.85

Tested by

no test coverage detected