/[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 588 by aramv, Tue Jul 21 16:06:57 2009 UTC revision 589 by aramv, Wed Jul 22 10:16:59 2009 UTC
# Line 43  NG_RC clean_plugin_list(lcmaps_plugindl_ Line 43  NG_RC clean_plugin_list(lcmaps_plugindl_
43          plugin_entry=list;          plugin_entry=list;
44    int i;    int i;
45    
46          while(plugin_entry){          while(plugin_entry!=NULL){
47                  if((plugin_next = plugin_entry->next)){      if(plugin_entry->handle != NULL){
48        if(dlclose(plugin_entry->handle)){        if((dlclose(plugin_entry->handle))){
49          ng_log(0, "ees.clean_plugin_list(): dlclose error %s\n", dlerror());          ng_log(0, "ees.clean_plugin_list(): dlclose error %s\n", dlerror());
50          return NG_FAILURE;          return NG_FAILURE;
51        }        }
       for(i = 0; i < plugin_entry->init_argc; i++){  
         free(plugin_entry->init_argv[i]);  
       }  
       /*free(plugin_entry->init_argv);*/  
       free(plugin_entry);  
       plugin_entry = plugin_next;  
52      }      }
53        /*free(plugin_entry->pluginname);*/
54        for(i = 0; i < plugin_entry->init_argc; i++){
55          free(plugin_entry->init_argv[i]);
56        }
57        /*free(plugin_entry->init_argv);*/
58        plugin_next = plugin_entry->next;
59        free(plugin_entry);
60        plugin_entry = plugin_next;
61          }          }
62          list = plugin_entry = plugin_next = NULL;          list = plugin_entry = plugin_next = NULL;
63          return NG_SUCCESS;          return NG_SUCCESS;
# Line 90  lcmaps_plugindl_t * PluginInit(int argc, Line 92  lcmaps_plugindl_t * PluginInit(int argc,
92          /* current plugin struct */          /* current plugin struct */
93          if(!(current_plugin = calloc(1,sizeof(lcmaps_plugindl_t)))){          if(!(current_plugin = calloc(1,sizeof(lcmaps_plugindl_t)))){
94      goto fail_startPluginManager;      goto fail_startPluginManager;
95    }    } else {
96    
97          ng_log(LOG_ERR, "Loading plugin %s\n", &abs_plugin_path);      ng_log(LOG_ERR, "Loading plugin %s\n", &abs_plugin_path);
98    
99          /* load plugin handle */      /* load plugin handle */
100          current_plugin->handle = dlopen(abs_plugin_path, RTLD_NOW);      current_plugin->handle = dlopen(abs_plugin_path, RTLD_NOW);
101    
102          strncpy(current_plugin->pluginname, argv[0], LCMAPS_MAXPATHLEN);      /* this is a bit silly */
         /*current_plugin->pluginname = argv[0];*/  
         /**(current_plugin->pluginargs) = *argv[0];*/  
103    
104          if(!current_plugin->handle){      if(argc < LCMAPS_MAXARGS){
105                  ng_log(LOG_ERR, "%s", dlerror());        max_args = argc;
106                  goto fail_startPluginManager;      } else {
107          }        max_args = LCMAPS_MAXARGS;
108        }
         if(dlerror()){  
                 ng_log(LOG_ERR, "%s", errno);  
                 goto fail_startPluginManager;  
         }  
109    
110    /* this is a bit silly */      strncpy(current_plugin->pluginname, argv[0], LCMAPS_MAXPATHLEN);
111        /*current_plugin->pluginname = argv[0];*/
112        /**(current_plugin->pluginargs) = *argv[0];*/
113    
114        current_plugin->init_argc = max_args;
115        for(i = 0; i < max_args; i++){
116          current_plugin->init_argv[i] = strdup(argv[i]);
117        }
118        for(i = 0; i < argc; i++){
119          free(argv[i]);
120        }
121        free(argv);
122    
123    if(argc < LCMAPS_MAXARGS){      if(!current_plugin->handle){
124      max_args = argc;        ng_log(LOG_ERR, "%s", dlerror());
125    } else {        goto fail_startPluginManager;
126      max_args = LCMAPS_MAXARGS;      }
   }  
127    
128    current_plugin->init_argc = max_args;      if(dlerror()){
129    for(i = 0; i < max_args; i++){        ng_log(LOG_ERR, "%s", errno);
130      current_plugin->init_argv[i] = strdup(argv[i]);        goto fail_startPluginManager;
131    }      }
   for(i = 0; i < argc; i++){  
     printf("This arg %i is: %s\n", i, argv[i]);  
     free(argv[i]);  
   }  
   free(argv);  
132    
133          current_plugin->procs[INITPROC] = NULL;      current_plugin->procs[INITPROC] = NULL;
134    
135          /* link function pointers */      /* link function pointers */
136          current_plugin->procs[INITPROC] = get_procsymbol(current_plugin->handle, "plugin_initialize");      current_plugin->procs[INITPROC] = get_procsymbol(current_plugin->handle, "plugin_initialize");
137          if(current_plugin->procs[INITPROC] == NULL){      if(current_plugin->procs[INITPROC] == NULL){
138                  ng_log(LOG_ERR,"ees.mod-PluginInit(): plugin %s not compliant\n", current_plugin->pluginname);        ng_log(LOG_ERR,"ees.mod-PluginInit(): plugin %s not compliant\n", current_plugin->pluginname);
139                  goto fail_startPluginManager;        goto fail_startPluginManager;
140          }      }
141    
142    current_plugin->procs[RUNPROC] = get_procsymbol(current_plugin->handle, "plugin_run");      current_plugin->procs[RUNPROC] = get_procsymbol(current_plugin->handle, "plugin_run");
143    if(current_plugin->procs[RUNPROC] == NULL){      if(current_plugin->procs[RUNPROC] == NULL){
144      ng_log(LOG_ERR, "ees.runPlugin\n");        ng_log(LOG_ERR, "ees.runPlugin\n");
145                  goto fail_startPluginManager;        goto fail_startPluginManager;
146    }      }
147    
148    current_plugin->procs[TERMPROC] = get_procsymbol(current_plugin->handle, "plugin_terminate");      current_plugin->procs[TERMPROC] = get_procsymbol(current_plugin->handle, "plugin_terminate");
149    if(current_plugin->procs[TERMPROC] == NULL){      if(current_plugin->procs[TERMPROC] == NULL){
150      ng_log(LOG_ERR, "ees.termPlugin\n");        ng_log(LOG_ERR, "ees.termPlugin\n");
151                  goto fail_startPluginManager;        goto fail_startPluginManager;
152    }      }
153    
154    set_running_plugin(current_plugin);      set_running_plugin(current_plugin);
155    
156          init_fnc_ptr = current_plugin->procs[INITPROC];      init_fnc_ptr = current_plugin->procs[INITPROC];
157    
158    /* call function pointer */      /* call function pointer */
159          if(init_fnc_ptr(argc, argv) == NG_PL_FAILURE){      if(init_fnc_ptr(current_plugin->init_argc, current_plugin->init_argv) == NG_PL_FAILURE){
160      goto fail_startPluginManager;        goto fail_startPluginManager;
161    }      }
162    
163          print_lcmaps_plugin(0, current_plugin);      print_lcmaps_plugin(0, current_plugin);
164    
165          /* return plugin struct */      /* return plugin struct */
166          return current_plugin;      return current_plugin;
167      }
168    
169          fail_startPluginManager:          fail_startPluginManager:
170                  clean_plugin_list(current_plugin);                  clean_plugin_list(current_plugin);
# Line 208  NG_RC termPlugin(char* plugin_name){ Line 210  NG_RC termPlugin(char* plugin_name){
210  }  }
211    
212  NG_RC stopPluginManager(){  NG_RC stopPluginManager(){
213          clean_plugin_list(plugin_list);          return clean_plugin_list(plugin_list);
         return NG_SUCCESS;  
214  }  }

Legend:
Removed from v.588  
changed lines
  Added in v.589

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