/***** * * Copyright (C) 2002 Vincent Glaume * All Rights Reserved * * This file is part of the Prelude program. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * *****/ #include #include #include #include #include #include #include #include #include "plugin-island.h" static LIST_HEAD(island_plugins_list); static int subscribe(plugin_container_t *pc) { log(LOG_INFO, "- Subscribing %s to active islanding plugins.\n", pc->plugin->name); return plugin_add(pc, &island_plugins_list, NULL); } static void unsubscribe(plugin_container_t *pc) { log(LOG_INFO, "- Un-subscribing %s from active islanding plugins.\n", pc->plugin->name); plugin_del(pc); } int island_plugins_run(cm_island_msg_t *isl_msg) { int ret = 0; struct list_head *tmp; plugin_container_t *pc; list_for_each(tmp, &island_plugins_list) { pc = list_entry(tmp, plugin_container_t, ext_list); plugin_run_with_return_value(pc, plugin_island_t, run, ret, isl_msg); } return ret; } int island_plugins_init(const char *dirname, int argc, char **argv) { int ret; ret = access(dirname, F_OK); if ( ret < 0 ) { if ( errno == ENOENT ) return 0; log(LOG_ERR, "can't access %s.\n", dirname); return -1; } ret = plugin_load_from_dir(dirname, argc, argv, subscribe, unsubscribe); if ( ret < 0 && errno != ENOENT ) { log(LOG_ERR, "couldn't load plugin subsystem.\n"); return -1; } return ret; } int island_plugins_available(void) { return list_empty(&island_plugins_list) ? -1 : 0; }