PluginStruct *release_plugin (Handle PluginHandle) { PluginStruct *ps (pluginTable.lookup (PluginHandle)); if (ps) { update_obs (PluginDiscoverRemove, PluginHandle); } ps = (pluginTable.remove (PluginHandle)); if (ps && ps->info && ps->plugin) { if (started) { LevelStruct *ls (levelsHead); while (ls) { if (ps->info->uses_level (ls->Level)) { ps->plugin->update_plugin_state (PluginStateStop, ls->Level); } ls = ls->next; } ls = levelsHead; while (ls) { if (ps->info->uses_level (ls->Level)) { ps->plugin->update_plugin_state (PluginStateShutdown, ls->Level); } ls = ls->next; } } if (discovered) { remove_all_plugins (ps->plugin); if (ps->HasInterface) { remove_plugin (ps->plugin); interfaceTable.remove (PluginHandle); } } } LevelStruct *ls = levelsHead; while (ls) { ls->table.remove (PluginHandle); ls = ls->next; } return ps; }
void on_plugin_remove_button_clicked (GtkButton *button, gpointer user_data) { KTPluginInfoEntry *plugin; GtkWidget *question_dialog; gint response; GtkTreeSelection *selection; GtkTreeIter iter; GtkTreeModel *model; plugin = get_selected_plugin(); if (plugin != NULL) { question_dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("Do you really want to remove the plugin \"%s\"?"), plugin->info.name); /* * Block the interaction with the other windows, so that * the user can only use this window */ gtk_grab_add (question_dialog); response = gtk_dialog_run(GTK_DIALOG(question_dialog)); gtk_widget_destroy (question_dialog); /* If the user pressed the "Yes"-button */ if (response == GTK_RESPONSE_YES) { remove_plugin (plugin, &plugin_list); reload_plugin_treeview (KTGUI_plugin_treeview(), &plugin_list); reload_plugin_list (KTGUI_plugin_combo_list(), GTK_OBJECT( KTGUI_plugin_combo_entry() ), on_plugin_combo_entry_changed, &plugin_list); selection = gtk_tree_view_get_selection( KTGUI_key_treeview() ); /* If a key is selected */ if (gtk_tree_selection_get_selected(selection, &model, &iter)) { /* Reselect it */ gtk_tree_selection_unselect_iter (selection, &iter); gtk_tree_selection_select_iter (selection, &iter); } } } }
static void remove_from_output_plugins(hs_output_plugins* plugins, const char* name) { const size_t tlen = strlen(hs_output_dir) + 1; pthread_mutex_lock(&plugins->list_lock); for (int i = 0; i < plugins->list_cap; ++i) { if (!plugins->list[i]) continue; char* pos = plugins->list[i]->sb->name + tlen; if (strstr(name, pos) && strlen(pos) == strlen(name) - HS_EXT_LEN) { remove_plugin(plugins, i); break; } } pthread_mutex_unlock(&plugins->list_lock); }
static void add_to_output_plugins(hs_output_plugins* plugins, hs_output_plugin* p) { bool added = false; int idx = -1; pthread_mutex_lock(&plugins->list_lock); for (int i = 0; i < plugins->list_cap; ++i) { if (!plugins->list[i]) { idx = i; } else if (strcmp(plugins->list[i]->sb->name, p->sb->name) == 0) { idx = i; remove_plugin(plugins, idx); add_plugin(plugins, p, idx); added = true; break; } } if (!added && idx != -1) add_plugin(plugins, p, idx); if (idx == -1) { // todo probably don't want to grow it by 1 ++plugins->list_cap; hs_output_plugin** tmp = realloc(plugins->list, sizeof(hs_output_plugin*) * plugins->list_cap); idx = plugins->list_cap - 1; if (tmp) { plugins->list = tmp; add_plugin(plugins, p, idx); } else { hs_log(g_module, 0, "plugins realloc failed"); exit(EXIT_FAILURE); } } pthread_mutex_unlock(&plugins->list_lock); assert(p->list_index >= 0); hs_config* cfg = p->plugins->cfg; // sync the output and read checkpoints // the read and output checkpoints can differ to allow for batching hs_lookup_input_checkpoint(&cfg->cp_reader, hs_input_dir, p->sb->name, cfg->output_path, &p->input.ib.cp); p->cur.input.id = p->cp.input.id = p->input.ib.cp.id; p->cur.input.offset = p->cp.input.offset = p->input.ib.cp.offset; hs_lookup_input_checkpoint(&cfg->cp_reader, hs_analysis_dir, p->sb->name, cfg->output_path, &p->analysis.ib.cp); p->cur.analysis.id = p->cp.analysis.id = p->analysis.ib.cp.id; p->cur.analysis.offset = p->cp.analysis.offset = p->analysis.ib.cp.offset; int ret = pthread_create(&p->thread, NULL, input_thread, (void*)p); if (ret) { perror("pthread_create failed"); exit(EXIT_FAILURE); } }
int main(int argc, char *argv[]) { int c, cmd, ret; conf_info_t info = {0}; char *config = DEFAULT_INTERNAL; xmlKeepBlanksDefault(0); xmlTreeIndentString = "\t"; if (argc < 2) { usage(argv[0]); return 1; } cmd = command_decode(argv[1]); /* parse params */ while ((c = getopt_long(argc, argv, OPTSTRING, long_opts, NULL)) != -1) { switch (c) { case 'h': usage(argv[0]); return 0; case 'c': config = optarg; break; case 'p': switch (optarg[0]) { case 'i': case 'I': info.type = PL_INPUT; break; case 'm': case 'M': info.type = PL_INTERMEDIATE; break; case 'o': case 'O': info.type = PL_OUTPUT; break; default: fprintf(stderr, "Unknown plugin type '%c'\n", optarg[0]); return 1; } break; case 'n': info.name = optarg; break; case 's': info.sofile = optarg; break; case 't': info.thread = optarg; break; case 'f': info.force = 1; break; default: return 1; } } ret = open_xml(&info, config); if (ret != 0) { return 1; } switch (cmd) { case CMD_ADD: ret = add_plugin(&info); break; case CMD_REMOVE: ret = remove_plugin(&info); break; case CMD_LIST: ret = list_plugins(&info); break; default: fprintf(stderr, "Unknown command '%s'\n", argv[1]); ret = 1; break; } if (ret == 0 && cmd != CMD_LIST) { save_xml(&info, config); } close_xml(&info); return ret; }