| 337 | }; |
| 338 | |
| 339 | static int load_static_module(char *path) |
| 340 | { |
| 341 | int len = strlen(path); |
| 342 | char *end = path + len; |
| 343 | struct sr_module* t; |
| 344 | unsigned int i; |
| 345 | |
| 346 | /* eliminate the .so, if found */ |
| 347 | if (len > 3 && strncmp(end - 3, ".so", 3)==0) { |
| 348 | end -= 3; |
| 349 | len -= 3; |
| 350 | } |
| 351 | /* we check whether the protocol is found within the static_modules */ |
| 352 | for (i = 0; i < (sizeof(static_modules)/sizeof(static_modules[0])); i++) { |
| 353 | if (len >= static_modules[i].name.len && |
| 354 | /* the path ends in the module's name */ |
| 355 | memcmp(end - static_modules[i].name.len, |
| 356 | static_modules[i].name.s, static_modules[i].name.len) == 0 && |
| 357 | /* check if the previous char is '/' or nothing */ |
| 358 | (len == static_modules[i].name.len || (*(end-len-1) == '/'))) { |
| 359 | |
| 360 | /* yey, found the module - check if it was loaded twice */ |
| 361 | for(t=modules;t; t=t->next){ |
| 362 | if (t->handle==static_modules[i].exp){ |
| 363 | LM_WARN("attempting to load the same module twice (%s)\n", path); |
| 364 | return 0; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | /* version control */ |
| 369 | if (!version_control(static_modules[i].exp, path)) { |
| 370 | exit(0); |
| 371 | } |
| 372 | |
| 373 | /* launch register */ |
| 374 | if (register_module(static_modules[i].exp, path, static_modules[i].exp)<0) |
| 375 | return -1; |
| 376 | return 0; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | return -1; |
| 381 | } |
| 382 | |
| 383 | void add_mpath(const char *new_mpath) |
| 384 | { |
no test coverage detected