diff options
Diffstat (limited to 'wrapper/plugin-load.h')
-rw-r--r-- | wrapper/plugin-load.h | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/wrapper/plugin-load.h b/wrapper/plugin-load.h index e3677a6..f214151 100644 --- a/wrapper/plugin-load.h +++ b/wrapper/plugin-load.h @@ -1,5 +1,5 @@ /* wrapper/plugin-load.h -- load rvs plugins into mem - system depens: <stdio.h> <string.h> + system depens: <stdio.h>, GNU <string.h> Copyright (C) 2009 Luke Shumaker This file is part of rvs. @@ -32,49 +32,16 @@ /*- plugin_load ----------------------------------------------------*\ now, load plugin plug_name, \* whose configuration file is plugin_conf */ +extern struct plugin * -plugin_load (const char *plug_name, const char *plugin_conf) -{ - struct plugin *plugin=xmalloc( sizeof(*plugin) ); - plugin->name=stralloc(plug_name); - plugin->next=NULL; - - xchdir(plug_name); - FILE *file = xfopen(plugin_conf,"r"); - plugin->commands=plugin_parse(file); - fclose( file ); - xchdir(".."); - - return plugin; -} +plugin_load (const char *plug_name); /*- load_plugins ---------------------------------------------------*\ Load all the plugins assume we're in rvs's libexecdir, where plugins are \* Use `plugin_conf' as the name of the config file for each plugin */ - +extern struct plugin * -load_plugins (FILE *list, const char *plugin_conf) -{ - struct plugin *first=NULL; /* we return this */ - struct plugin **prev=&first; /* this is the previous plugin->next */ - struct plugin *plugin; /* this is the current plugin */ - - size_t nbytes = 10; - char *plug_name=(char *)xmalloc(nbytes); - while ( getline(&plug_name, &nbytes, list) > 0 ) { - char *del=strchr(plug_name,'\n'); - del[0]='\0'; - /*if (strlen(plug_name)!=0) {*/ - if (plug_name[0]!='\0') {; - plugin=plugin_load(plug_name,plugin_conf); - *prev=plugin;/* this sets the last's `next' */ - prev=&plugin->next; - } - } - - return first; -} - +load_plugins (FILE *list); #endif |