Skip to content

Commit

Permalink
Removed old code from bsd.c, forgot to update local.dst with changes …
Browse files Browse the repository at this point in the history
…that were in local.c
  • Loading branch information
ray73864 committed May 3, 2020
1 parent b392572 commit 773dbb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 48 deletions.
39 changes: 0 additions & 39 deletions src/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,47 +932,8 @@ void load_plugins() {

DIR* pluginsDir;
struct dirent* in_file;
FILE *entry_file;
void* testPlugin;
char plugin_name[256];
int i = 0;
/**
plugins = (void*)calloc(1, sizeof(void*));
if(plugins == NULL) {
do_rawlog(LT_ERR, "Could not allocate memory for plugins");
return;
}
if (NULL != (pluginsDir = opendir("../plugins"))) {
while ((in_file = readdir(pluginsDir)))
{
if (!strcmp(in_file->d_name, ".")) continue;
if (!strcmp(in_file->d_name, "..")) continue;
if (!strstr(in_file->d_name, ".so")) continue;
do_rawlog(LT_ERR, in_file->d_name);
snprintf(plugin_name, sizeof(plugin_name), "../plugins/%s", in_file->d_name);
testPlugin = dlopen(plugin_name, RTLD_LAZY);
if (testPlugin == NULL) continue;
plugin_init* f = dlsym(testPlugin, "plugin_init");
if (f == NULL) continue;
plugins = realloc(plugins, 1 * sizeof(void*));
if(plugins == NULL) {
do_rawlog(LT_ERR, "Could not increase amount of allocated memory for more plugins!");
break;
}
plugins[i] = testPlugin;
plugin_count++;
f();
}
}
**/

plugin_head = NULL;
plugin_last = NULL;
Expand Down
24 changes: 15 additions & 9 deletions src/local.dst
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ local_dump_database(void)
void
local_shutdown(void)
{
for (int i = 0; i < plugin_count; i++) {
if (plugins[i] == NULL) break;
dlclose(plugins[i]);
while(plugin_head != NULL) {
dlclose(plugin_head->handle);
if (plugin_head->prev != NULL) { free(plugin_head->prev); }
plugin_head = plugin_head->next;
}

free(plugins);
}

/* Called when the MUSH is performing a dbck database check,
Expand All @@ -136,12 +135,19 @@ local_timer(void *data __attribute__((__unused__)))
{
typedef int plugin_timer();

for (int i = 0; i < plugin_count; i++) {
if (plugins[i] == NULL) break;
plugin_timer* f = dlsym(plugins[i], "plugin_timer");
if (f == NULL) continue;
struct penn_plugins* temp = plugin_head;

while(temp->next != NULL) {
plugin_timer* f = dlsym(temp->handle, "plugin_timer");
if (f == NULL) {
temp = temp->next;
continue;
}
do_rawlog(LT_ERR, "Running timer for %s", temp->name);
f();
temp = temp->next;
}

/* The callback has to be set back up or it'll only run once. */
return false;
}
Expand Down

0 comments on commit 773dbb1

Please sign in to comment.