summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-09-13 17:55:03 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:15 -0600
commitaba23c26fabcc7961a55d6526bb28c92fb9c4ecd (patch)
treeabfa2a1db96aab3ecb48fa7532047c2729a17725
parent3e100e9de3cec5ec5e9a641e782ae47ca095233d (diff)
fix Makefiles a bit
redo the ugly kludge in load_plugins(...) in wrapper/plugin-load.h
-rw-r--r--Makefile.in6
-rw-r--r--wrapper/Makefile.in7
-rw-r--r--wrapper/TODO9
-rw-r--r--wrapper/plugin-load.h53
-rw-r--r--wrapper/plugin-parse.h5
-rw-r--r--wrapper/runcom.c3
-rw-r--r--wrapper/rvs.sh4
7 files changed, 35 insertions, 52 deletions
diff --git a/Makefile.in b/Makefile.in
index e72005a..e72adb6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -27,7 +27,7 @@ exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
-dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/
+dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)
export srcdir prefix exec_prefix bindir sbindir libexecdir
# programs #########################################################
@@ -49,12 +49,12 @@ plugins = $(patsubst $(srcdir)/plugins/%,%, \
$(shell find $(srcdir)/plugins/* -maxdepth 0 -type d))
build-plugins = $(addprefix p-,$(plugins))
-#install-plugins = $(addprefix install-p-,$(plugins))
+install-plugins = $(addprefix install-p-,$(plugins))
uninstall-plugins = $(addprefix uninstall-p-,$(plugins))
clean-plugins = $(addprefix clean-p-,$(plugins))
distclean-plugins = $(addprefix distclean-p-,$(plugins))
dist-plugins = $(addprefix dist-p-,$(plugins))
-$(info $(build-plugins))
+
# phony targets ####################################################
all : wrapper $(build-plugins)
.PHONY : install uninstall clean distclean dist libexec \
diff --git a/wrapper/Makefile.in b/wrapper/Makefile.in
index a6eef15..594b0c0 100644
--- a/wrapper/Makefile.in
+++ b/wrapper/Makefile.in
@@ -27,7 +27,7 @@ exec_prefix ?= @exec_prefix@
bindir ?= @bindir@
sbindir ?= @sbindir@
libexecdir ?= @libexecdir@
-dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/
+dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)
#export srcdir prefix exec_prefix bindir sbindir libexecdir
# programs #########################################################
@@ -93,3 +93,8 @@ $(d) : distclean
$(INSTALL) -m 777 -d $@
$(CP) -r $(srcdir)/* $@
+# implicit rules ###################################################
+
+$(dirs) $(libexecdir)/$(rvs) :
+ $(MKDIR) $@
+
diff --git a/wrapper/TODO b/wrapper/TODO
index 6d1bd2a..1017c8d 100644
--- a/wrapper/TODO
+++ b/wrapper/TODO
@@ -1,15 +1,6 @@
#! /bin/more
-* add propper option handling via GNU getopt
* actually launch the plugins
-* plugin-load.h:
- The function `load_plugins' must loop through sub-directories in the
- directory `libexecdir'. They way it does this is an ugly kludge, and
- should be rewritten.
- The way it does it requires dissproportionatly many system libraries,
- all increasing the odds that it won't run on another system. This isn't
- as much of a concern if it was using them, but they can't all be
- nescessary: <string.h> <unistd.h> <dirent.h> <sys/stat.h> <error.h>
~ Luke Shumaker
Happy Hacking!
diff --git a/wrapper/plugin-load.h b/wrapper/plugin-load.h
index cb7399d..07fa6a7 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: <string.h> <unistd.h> <dirent.h> <sys/stat.h> <error.h>
+ system depens: <stdio.h> <string.h>
Copyright (C) 2009 Luke Shumaker
This file is part of rvs.
@@ -22,12 +22,14 @@
#ifndef FILE_plugin_load_h_SEEN
#define FILE_plugin_load_h_SEEN
+#include <stdio.h>
+#include <string.h>
+
#include "rvs.h"
#include "plugins.h"
#include "plugin-parse.h"
/*- plugin_load ----------------------------------------------------*\
- assume we're in rvs's libexecdir, where plugins are
now, load plugin plug_name,
\* whose configuration file is plugin_conf */
struct plugin *
@@ -47,48 +49,31 @@ plugin_load (const char *plug_name, const char *plugin_conf)
}
/*- load_plugins ---------------------------------------------------*\
- Load all the plugins in `libexecdir'
- Use `plugin_conf' as the name of the config file for each plugin
- Note that the method we use to loop through all the directories in
- `libexecdir' is a horible kludge, uses a ton of system functions,
-\* and generally needs to be rewritten. */
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <error.h>
+ 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 */
struct plugin *
-load_plugins (const char *libexecdir, const char *plugin_conf)
+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 */
- xchdir(libexecdir);
-
- /* Yeah, I know this next bit is pretty ugly. */
- DIR *cwd;
- struct dirent *dirent;
- int serr;
- struct stat sbuf;
- const char *dirname="./";
- cwd = opendir (dirname);
- if (cwd == NULL) error(EXIT_FAILURE,errno,"%s/",dirname);
- while ( (dirent = readdir (cwd)) != NULL ) {
- if ((strcmp(dirent->d_name,"." )!=0)&&
- (strcmp(dirent->d_name,"..")!=0)) {
- serr = stat(dirent->d_name, &sbuf);
- if (!serr && S_ISDIR(sbuf.st_mode)) {
- plugin=plugin_load(dirent->d_name,plugin_conf);
- *prev=plugin;/* this sets the last's `next' */
- prev=&plugin->next;
- }
+ size_t nbytes = 10;
+ char *plug_name=(char *)xmalloc(nbytes);
+ plug_name[0]='\0';
+ 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;
}
}
- closedir (cwd);
- xchdir("..");
return first;
}
diff --git a/wrapper/plugin-parse.h b/wrapper/plugin-parse.h
index e4bfe2b..8a565db 100644
--- a/wrapper/plugin-parse.h
+++ b/wrapper/plugin-parse.h
@@ -1,5 +1,5 @@
/* wrapper/plugin-parse.c -- parse rvs plugin config files
- system depends: <stdio.h> <error.h>
+ system depends: <stdio.h> <string.h> <error.h>
Copyright (C) 2009 Luke Shumaker
This file is part of rvs.
@@ -23,6 +23,7 @@
#define FILE_plugin_parse_h_SEEN
#include <stdio.h>
+#include <string.h>
#include <error.h> /* only used in `plugin_parse_escape' for `error' */
#include "rvs.h"
@@ -110,7 +111,7 @@ plugin_parse (FILE *file)
switch (c[0]) {
case '\n':
/*if (strlen(command->name)==0) {*/
- if (c[0]=='\n') {
+ if (command->name[0]=='\0') {
plugin_free_command(command);
return plugin_parse(file);
} else
diff --git a/wrapper/runcom.c b/wrapper/runcom.c
index f581a45..dd843dc 100644
--- a/wrapper/runcom.c
+++ b/wrapper/runcom.c
@@ -32,7 +32,8 @@ const char *plugin_conf=PLUGIN_CONF;
int
main ( int argc, char *argv[] )
{
- struct plugin *plugins=load_plugins(libexecdir,plugin_conf);
+ xchdir(libexecdir);
+ struct plugin *plugins=load_plugins(stdin, plugin_conf);
if (argc > 1) {
struct plugin_command_list *list;
list=plugin_find_commands(plugins,argv[1]);
diff --git a/wrapper/rvs.sh b/wrapper/rvs.sh
index d7fc753..4d87170 100644
--- a/wrapper/rvs.sh
+++ b/wrapper/rvs.sh
@@ -50,7 +50,7 @@ _init() {
if [ -z "$repo" ]; then
repo=".$name"
install -d "$repo"
- install -T $libexecdir/plugins $repo/plugins
+ install -m644 -T $libexecdir/plugins $repo/plugins
while read plugin; do
echo "initializing plugin \`$plugin'"
install -d "$repo/$plugin"
@@ -97,7 +97,7 @@ case "$com" in
*) repo=`_repo`
if [ "$?" = '0' ]; then
shift
- $libexecdir/runcom $@
+ "$libexecdir/runcom" $@ < $repo/plugins
exit $?
else
_error "cannot find an existing repository"