/[pdpsoft]/trunk/grid-mw-security/ees/src/plugin_manager/plugin_manager.c
ViewVC logotype

Diff of /trunk/grid-mw-security/ees/src/plugin_manager/plugin_manager.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 871 by aramv, Mon Oct 5 16:21:21 2009 UTC revision 872 by aramv, Tue Oct 6 15:02:24 2009 UTC
# Line 9  void set_running_plugin(lcmaps_plugindl_ Line 9  void set_running_plugin(lcmaps_plugindl_
9    _running_plugin = plugin;    _running_plugin = plugin;
10  }  }
11    
12  EES_RC add_plugin(int argc, char* argv[]){  EES_RC addPlugin(int argc, char* argv[]){
13    lcmaps_plugindl_t *last_plugin = NULL, *current_plugin = NULL;    lcmaps_plugindl_t *last_plugin = NULL, *current_plugin = NULL;
14    /* PluginInit returns NULL if plugin failed to load. */    /* prepare_plugin returns NULL if plugin failed to load. */
15    if((current_plugin = PluginPrepare(argc, argv)) != NULL){    if((current_plugin = prepare_plugin(argc, argv)) != NULL){
16      if(plugin_list == NULL){      if(plugin_list == NULL){
17        plugin_list = current_plugin;        plugin_list = current_plugin;
18      } else {      } else {
# Line 82  lcmaps_proc_t get_procsymbol(void* handl Line 82  lcmaps_proc_t get_procsymbol(void* handl
82  }  }
83    
84  EES_RC print_lcmaps_plugin(int debug_lvl, lcmaps_plugindl_t *plugin){  EES_RC print_lcmaps_plugin(int debug_lvl, lcmaps_plugindl_t *plugin){
85          eef_log(debug_lvl, "plugin name               : %s\n", plugin->pluginname);    int i = 0;
86      /*eef_log(debug_lvl, "plugin name               : %s\n", plugin->pluginname);*/
87      /*eef_log(debug_lvl, "plugin argc               : %i\n", plugin->init_argc);*/
88      for(i = 0; i < plugin->init_argc; i++){
89        eef_log(debug_lvl, "plugin argv[%i]            : %s\n", i, plugin->init_argv[i]);
90      }
91          return EES_SUCCESS;          return EES_SUCCESS;
92  }  }
93    
# Line 99  lcmaps_plugindl_t* get_plugin(char* plug Line 104  lcmaps_plugindl_t* get_plugin(char* plug
104  }  }
105    
106    
107  lcmaps_plugindl_t * PluginPrepare(int argc, char** argv){  lcmaps_plugindl_t * prepare_plugin(int argc, char** argv){
108          lcmaps_plugindl_t * current_plugin = NULL;          lcmaps_plugindl_t * current_plugin = NULL;
109    int i = 0;    int i = 0;
110    
# Line 109  lcmaps_plugindl_t * PluginPrepare(int ar Line 114  lcmaps_plugindl_t * PluginPrepare(int ar
114    } else {    } else {
115    
116      strncpy(current_plugin->pluginname, argv[0], FILENAME_MAX);      strncpy(current_plugin->pluginname, argv[0], FILENAME_MAX);
     /*current_plugin->pluginname = argv[0];*/  
     /**(current_plugin->pluginargs) = *argv[0];*/  
   
117      current_plugin->init_argc = argc;      current_plugin->init_argc = argc;
118      for(i = 0; i < argc; i++){      for(i = 0; i < argc; i++){
119        current_plugin->init_argv[i] = (char*) strdup(argv[i]);        current_plugin->init_argv[i] = (char*) strdup(argv[i]);
120      }      }
121    
122        /* cleanup */
123      for(i = 0; i < argc; i++){      for(i = 0; i < argc; i++){
124        free(argv[i]);        free(argv[i]);
125      }      }
126      free(argv);      free(argv);
127    
128      print_lcmaps_plugin(LOG_INFO, current_plugin);      /* print information */
129        print_lcmaps_plugin(LOG_DEBUG, current_plugin);
130    
131      /* return plugin struct */      /* return plugin struct */
132      return current_plugin;      return current_plugin;
# Line 129  lcmaps_plugindl_t * PluginPrepare(int ar Line 134  lcmaps_plugindl_t * PluginPrepare(int ar
134    return NULL;    return NULL;
135  }  }
136    
137  EES_RC PluginInit(lcmaps_plugindl_t* plugin){  EES_RC initialize_plugin(lcmaps_plugindl_t* plugin){
138    const char* local_module_dir = get_modules_path();    const char* local_module_dir = get_modules_path();
139    size_t max_plugin_name = FILENAME_MAX - strlen(local_module_dir);    size_t max_plugin_name = FILENAME_MAX - strlen(local_module_dir);
140    
141    if(strlen(local_module_dir) >= FILENAME_MAX){    if(strlen(local_module_dir) >= FILENAME_MAX){
142      return EES_FAILURE;      return EES_FAILURE;
143    }    }
144    printf("Using modules path: %s\n", local_module_dir);    eef_log(LOG_DEBUG, "Using modules path: %s\n", local_module_dir);
145          memset(abs_plugin_path, 0, FILENAME_MAX);          memset(abs_plugin_path, 0, FILENAME_MAX);
146    
147          /*TODO maak safe(r) */          /*TODO maak safe(r) */
# Line 152  EES_RC PluginInit(lcmaps_plugindl_t* plu Line 157  EES_RC PluginInit(lcmaps_plugindl_t* plu
157    /* load plugin handle */    /* load plugin handle */
158    plugin->handle = dlopen(abs_plugin_path, RTLD_NOW);    plugin->handle = dlopen(abs_plugin_path, RTLD_NOW);
159    
160    printf("Opening: %s\n", abs_plugin_path);    eef_log(LOG_DEBUG,"Opening: %s\n", abs_plugin_path);
161    
162    bzero(abs_plugin_path, strlen(abs_plugin_path) + 1);    bzero(abs_plugin_path, strlen(abs_plugin_path) + 1);
163    
# Line 201  EES_RC PluginInit(lcmaps_plugindl_t* plu Line 206  EES_RC PluginInit(lcmaps_plugindl_t* plu
206  EES_RC initializePlugins(void){  EES_RC initializePlugins(void){
207    lcmaps_plugindl_t *node = plugin_list;    lcmaps_plugindl_t *node = plugin_list;
208    while(node != NULL){    while(node != NULL){
209      if(PluginInit(node) == EES_FAILURE){      if(initialize_plugin(node) == EES_FAILURE){
210        return EES_FAILURE;        return EES_FAILURE;
211      }      }
212      node = node->next;      node = node->next;

Legend:
Removed from v.871  
changed lines
  Added in v.872

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28