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

Function load_module

sr_module.c:422–508  ·  view source on GitHub ↗

returns 0 on success , <0 on error */

Source from the content-addressed store, hash-verified

420
421/* returns 0 on success , <0 on error */
422int load_module(char* name)
423{
424 int i_tmp, len;
425 struct stat statf;
426 struct mpath *mp;
427 int module_warnings_len;
428 char *base_name;
429
430 base_name = basename(name);
431 len = strlen(base_name);
432 if (strstr(base_name, ".so"))
433 len -= 3;
434
435 module_warnings_len = sizeof(module_warnings) / sizeof(module_warnings[0]);
436
437 for (i_tmp = 0; i_tmp < module_warnings_len; i_tmp++) {
438 if (strncmp(base_name, module_warnings[i_tmp].module, len) == 0) {
439 switch (module_warnings[i_tmp].flags)
440 {
441 case MOD_WARN_EXIT:
442 LM_ERR("%s\n", module_warnings[i_tmp].name);
443 return -1;
444
445 case MOD_WARN_SKIP:
446 LM_WARN("%s\n", module_warnings[i_tmp].name);
447 return 0;
448
449 default:
450 break;
451 }
452 }
453 }
454
455 /* if this is a static module, load it directly */
456 if (load_static_module(name) == 0)
457 return 0;
458
459 if (*name=='/' || mpaths==NULL) {
460 LM_DBG("loading module %s\n", name);
461 if (sr_load_module(name)!=0){
462 LM_ERR("failed to load module\n");
463 return -1;
464 }
465 return 0;
466 }
467 for (mp = mpaths; mp; mp = mp->next) {
468 len = strlen(name);
469 if (len + mp->len >= MPATH_LEN)
470 continue;
471 memcpy(mp->buf + mp->len, name, len);
472 mp->buf[mp->len + len] = '\0';
473 if (stat(mp->buf, &statf) == -1 || S_ISDIR(statf.st_mode)) {
474 i_tmp = strlen(mp->buf);
475 if(strchr(name, '/')==NULL &&
476 strncmp(mp->buf+i_tmp-3, ".so", 3)==0)
477 {
478 if(i_tmp+len<MPATH_LEN)
479 {

Callers 2

load_cachedb_modulesFunction · 0.85
init_malloc_testsFunction · 0.85

Calls 3

load_static_moduleFunction · 0.85
sr_load_moduleFunction · 0.85
statClass · 0.70

Tested by 2

load_cachedb_modulesFunction · 0.68
init_malloc_testsFunction · 0.68