int proxenet_perl_initialize_vm(plugin_t* plugin) { interpreter_t *interpreter; interpreter = plugin->interpreter; /* In order to perl_parse nothing */ char *args[2] = { "", "/dev/null" }; /* checks */ if (!interpreter->ready){ #ifdef DEBUG xlog(LOG_DEBUG, "[Perl] %s\n", "Initializing VM"); #endif /* vm init */ my_perl = perl_alloc(); perl_construct(my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; if (!my_perl) { xlog(LOG_ERROR, "[Perl] %s\n", "failed init-ing vm"); return -1; } interpreter->vm = (void*) my_perl; interpreter->ready = true; perl_parse(my_perl, NULL, 2, args, (char **)NULL); } return proxenet_perl_load_file(plugin); }
void proxenet_initialize_plugins() { plugin_t *plugin = plugins_list; plugin_t *prec_plugin = NULL; plugin_t *next_plugin = NULL; while(plugin) { /* plugin already loaded, move on */ if(plugin->state == ACTIVE){ plugin = plugin->next; continue; } switch (plugin->type) { #ifdef _PYTHON_PLUGIN case _PYTHON_: if (!proxenet_python_initialize_vm(plugin) && !proxenet_python_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif #ifdef _C_PLUGIN case _C_: if (!proxenet_c_initialize_vm(plugin) && !proxenet_c_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif #ifdef _RUBY_PLUGIN case _RUBY_: if (!proxenet_ruby_initialize_vm(plugin) && !proxenet_ruby_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif #ifdef _PERL_PLUGIN case _PERL_: if (!proxenet_perl_initialize_vm(plugin) && !proxenet_perl_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif #ifdef _LUA_PLUGIN case _LUA_: if (!proxenet_lua_initialize_vm(plugin) && !proxenet_lua_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif #ifdef _TCL_PLUGIN case _TCL_: if (!proxenet_tcl_initialize_vm(plugin) && !proxenet_tcl_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif #ifdef _JAVA_PLUGIN case _JAVA_: if (!proxenet_java_initialize_vm(plugin) && !proxenet_java_load_file(plugin)) proxenet_plugin_set_state(plugin, ACTIVE); break; #endif default: break; } if (plugin->state == ACTIVE){ if (cfg->verbose > 1) xlog(LOG_INFO, "Successfully initialized '%s'\n", plugin->filename); prec_plugin = plugin; plugin = plugin->next; continue; } proxenet_plugin_set_state(plugin, INACTIVE); if(prec_plugin) prec_plugin->next = plugin->next; else plugins_list = plugin->next; if (cfg->verbose > 1) xlog(LOG_ERROR, "Removing '%s' from plugin list\n", plugin->filename); next_plugin = plugin->next; proxenet_free_plugin(plugin); plugin = next_plugin; } }