summaryrefslogtreecommitdiff
path: root/wrapper/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper/plugin.c')
-rw-r--r--wrapper/plugin.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/wrapper/plugin.c b/wrapper/plugin.c
index 6a38035..6301bbb 100644
--- a/wrapper/plugin.c
+++ b/wrapper/plugin.c
@@ -20,58 +20,43 @@
#ifndef FILE_plugin_c_SEEN
#define FILE_plugin_c_SEEN
-#include <stdlib.h> /* EXIT_FAILURE */
-#include <unistd.h> /* file acces */
-#include <string.h>
-
-#include <dirent.h>
-#include <sys/stat.h>
-
#include "rvs.h"
#include "plugin.h"
#include "plugin-parse.c"
-/*#include "plugin-depend.c"*/
+
+/* directory listing for load_plugins */
+/* there seriously has to be a better way to do this */
+#include <string.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/stat.h>
/* assume we're in rvs's libexecdir, where plugins are
now, load plugin plug_name,
- whose configuration file is plugin_conf
-*/
-struct tree_list *
+ whose configuration file is plugin_conf */
+struct plugin *
_plugin_load (const char *plug_name, const char *plugin_conf)
{
- struct tree_list *plugin=xmalloc( sizeof(*plugin) );
- plugin->node=stralloc(plug_name);
+ struct plugin *plugin=xmalloc( sizeof(*plugin) );
+ plugin->name=stralloc(plug_name);
plugin->next=NULL;
- plugin->child=NULL;
-
xchdir(plug_name);
FILE *file = xfopen(plugin_conf,"r");
-
- struct tree_list **last=&plugin->child;
-
- struct plugin_command *command;
- while ( (command=_plugin_parse(file))!=NULL ) {
- command->plugin=plugin;
-
- struct tree_list *com=xmalloc( sizeof(*com) );
- com->node=command;
- *last=com;/* this sets the last's `next' */
- last=&com->next;
- }
-
+ plugin->commands=_plugin_parse(file);
fclose( file );
+
xchdir("..");
return plugin;
}
/* load all the plugins in libexecdir, using the config file plugin_conf */
-struct tree_list *
+struct plugin *
load_plugins (const char *libexecdir, const char *plugin_conf)
{
- struct tree_list *first=NULL;
- struct tree_list **last=&first;
- struct tree_list *plugin;
+ 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 */
xchdir(libexecdir);
@@ -87,8 +72,8 @@ load_plugins (const char *libexecdir, const char *plugin_conf)
serr = stat(dirent->d_name, &sbuf);
if (!serr && S_ISDIR(sbuf.st_mode)) {
plugin=_plugin_load(dirent->d_name,plugin_conf);
- *last=plugin;/* this sets the last's `next' */
- last=&plugin->next;
+ *prev=plugin;/* this sets the last's `next' */
+ prev=&plugin->next;
}
}
}