| 1691 | } |
| 1692 | |
| 1693 | int |
| 1694 | LibAliasLoadModule(char *path) |
| 1695 | { |
| 1696 | struct dll *t; |
| 1697 | void *handle; |
| 1698 | struct proto_handler *m; |
| 1699 | const char *error; |
| 1700 | moduledata_t *p; |
| 1701 | |
| 1702 | handle = dlopen (path, RTLD_LAZY); |
| 1703 | if (!handle) { |
| 1704 | fprintf(stderr, "%s\n", dlerror()); |
| 1705 | return (EINVAL); |
| 1706 | } |
| 1707 | |
| 1708 | p = dlsym(handle, "alias_mod"); |
| 1709 | if ((error = dlerror()) != NULL) { |
| 1710 | fprintf(stderr, "%s\n", dlerror()); |
| 1711 | return (EINVAL); |
| 1712 | } |
| 1713 | |
| 1714 | t = malloc(sizeof(struct dll)); |
| 1715 | if (t == NULL) |
| 1716 | return (ENOMEM); |
| 1717 | strncpy(t->name, p->name, DLL_LEN); |
| 1718 | t->handle = handle; |
| 1719 | if (attach_dll(t) == EEXIST) { |
| 1720 | free(t); |
| 1721 | fprintf(stderr, "dll conflict\n"); |
| 1722 | return (EEXIST); |
| 1723 | } |
| 1724 | |
| 1725 | m = dlsym(t->handle, "handlers"); |
| 1726 | if ((error = dlerror()) != NULL) { |
| 1727 | fprintf(stderr, "%s\n", error); |
| 1728 | return (EINVAL); |
| 1729 | } |
| 1730 | |
| 1731 | LibAliasAttachHandlers(m); |
| 1732 | return (0); |
| 1733 | } |
| 1734 | |
| 1735 | int |
| 1736 | LibAliasUnLoadAllModule(void) |
no test coverage detected