summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/repo/Makefile.in18
-rw-r--r--plugins/repo/commit.d.sh4
-rw-r--r--plugins/repo/commit.f.sh8
-rw-r--r--plugins/repo/commit.sh29
-rw-r--r--plugins/repo/get.d.sh4
-rw-r--r--plugins/repo/get.f.sh6
-rw-r--r--plugins/repo/get.sh4
-rw-r--r--plugins/repo/plugin.conf3
-rw-r--r--plugins/repo/stdio.sh4
-rw-r--r--plugins/users/Makefile.in18
-rw-r--r--plugins/users/commit.sh8
-rw-r--r--plugins/users/init.sh8
-rw-r--r--plugins/users/login.sh8
-rw-r--r--plugins/users/logout.sh8
-rw-r--r--plugins/users/mkuser.sh19
-rw-r--r--plugins/users/plugin.conf5
-rw-r--r--plugins/users/rmuser.sh8
-rw-r--r--plugins/users/stdio.sh2
-rw-r--r--wrapper/Makefile.in18
-rw-r--r--wrapper/plugin-depend.c146
-rw-r--r--wrapper/plugin-depend.h113
-rw-r--r--wrapper/plugin-find.c103
-rw-r--r--wrapper/plugin-find.h70
-rw-r--r--wrapper/plugin-load.c78
-rw-r--r--wrapper/plugin-load.h43
-rw-r--r--wrapper/plugin-parse.c132
-rw-r--r--wrapper/plugin-parse.h100
-rw-r--r--wrapper/plugin-run.c89
-rw-r--r--wrapper/plugin-run.h47
-rw-r--r--wrapper/plugins.c71
-rw-r--r--wrapper/plugins.h46
-rw-r--r--wrapper/runcom.c26
-rw-r--r--wrapper/rvs.c117
-rw-r--r--wrapper/rvs.h87
-rw-r--r--wrapper/rvs.sh7
-rw-r--r--wrapper/structures.h60
36 files changed, 982 insertions, 535 deletions
diff --git a/plugins/repo/Makefile.in b/plugins/repo/Makefile.in
index 412fb8e..7078bb6 100644
--- a/plugins/repo/Makefile.in
+++ b/plugins/repo/Makefile.in
@@ -1,6 +1,6 @@
#!/usr/bin/make -f
-name = repo
-ver = 0.7beta
+name=repo
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -81,13 +81,13 @@ distclean : clean
# dist #############################################################
-d = $(name)-$(ver)
-dist : $(d).tar.gz
+id = $(name)-$(ver)
+dist : $(id).tar.gz
-$(d).tar.gz : $(d)
+$(id).tar.gz : $(id)
tar -czf $@ $<
-$(d) : distclean
+$(id) : distclean
$(INSTALL) -m 777 -d $@
$(CP) -r $(mysrcdir)/* $@
@@ -97,7 +97,11 @@ b := @
# build shell scripts
$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir)
$(INSTALL_PROGRAM) $< $@
- $(SED) -i 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' $@
+ $(SED) -i \
+ -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \
+ -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \
+ -e 's/$bID@/$(subst /,\/,$(id))/g' \
+ $@
$(dirs) $(libexecdir)/$(rvs) $(myoutdir) :
$(MKDIR) $@
diff --git a/plugins/repo/commit.d.sh b/plugins/repo/commit.d.sh
index e5d2456..9545b08 100644
--- a/plugins/repo/commit.d.sh
+++ b/plugins/repo/commit.d.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs repo commit.d'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,7 +19,7 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
# commit.d DIRNAME
dir="$1"
diff --git a/plugins/repo/commit.f.sh b/plugins/repo/commit.f.sh
index 8a27e95..851c023 100644
--- a/plugins/repo/commit.f.sh
+++ b/plugins/repo/commit.f.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs repo commit.f'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,15 +19,15 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#source "$libexecdir/lib/stdio"
+#source "$libexecdir/@ID@/stdio"
# commit.f FILENAME
file="$1"
#hash=`md5sum $file | sed "s/ .*$//"`
hash=`sha1sum $file | sed "s/ .*$//"`
-if [ ! -f "$REPO/$hash" ]; then
- install -m 644 -o $USER -g $USER -T "$file" "$REPO/$hash"
+if [ ! -f "$REPO/@ID@/$hash" ]; then
+ install -m 644 -o $USER -g $USER -T "$file" "$REPO/@ID@/$hash"
fi
echo "$hash"
diff --git a/plugins/repo/commit.sh b/plugins/repo/commit.sh
index 7ee5934..0baa931 100644
--- a/plugins/repo/commit.sh
+++ b/plugins/repo/commit.sh
@@ -1,15 +1,24 @@
#!@SHELL@
name='rvs repo commit'
-ver='0.7.3'
-# Copyright (C) 2009 Luke Shumaker
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
-
-source "$libexecdir/lib/stdio"
+ver=0.8r61
+# Copyright (C) 2009 Luke Shumaker
+#
+# This file is part of rvs.
+#
+# rvs is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2, or (at your option) any later version.
+#
+# rvs is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rvs; see the file COPYING.
+# If not, write to the Free Software Foundation,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+source "$libexecdir/@ID@/stdio"
# commit FILE
file=${1-.}
diff --git a/plugins/repo/get.d.sh b/plugins/repo/get.d.sh
index 816cd31..4f95a57 100644
--- a/plugins/repo/get.d.sh
+++ b/plugins/repo/get.d.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs repo get.d'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,7 +19,7 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#source "$libexecdir/lib/stdio"
+#source "$libexecdir/@ID@/stdio"
# get.d ID DIRNAME
id="$1"
diff --git a/plugins/repo/get.f.sh b/plugins/repo/get.f.sh
index 4862ccc..bb43099 100644
--- a/plugins/repo/get.f.sh
+++ b/plugins/repo/get.f.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs repo get.f'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,11 +19,11 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#source "$libexecdir/lib/stdio"
+#source "$libexecdir/@ID@/stdio"
# get.f ID FILENAME
id="$1"
file="$2"
-install -T "$REPO/$id" "$file"
+install -T "$REPO/@ID@/$id" "$file"
diff --git a/plugins/repo/get.sh b/plugins/repo/get.sh
index 583428a..a047e87 100644
--- a/plugins/repo/get.sh
+++ b/plugins/repo/get.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs repo get'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,7 +19,7 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
# get ID [FILE]
id="$1"
diff --git a/plugins/repo/plugin.conf b/plugins/repo/plugin.conf
index 648b50e..6028a0f 100644
--- a/plugins/repo/plugin.conf
+++ b/plugins/repo/plugin.conf
@@ -1,4 +1,5 @@
-# repo-0.7beta plugins.conf
+# rvs repo plugins.conf
+# ver=0.8r61
commit
commit.d
commit.f
diff --git a/plugins/repo/stdio.sh b/plugins/repo/stdio.sh
index c1a1b6b..d4fed0e 100644
--- a/plugins/repo/stdio.sh
+++ b/plugins/repo/stdio.sh
@@ -1,6 +1,6 @@
#!@SHELL@
#name='rvs repo stdio'
-#ver='0.7.3'
+#ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -60,7 +60,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
+Originally written by Luke Shumaker <LukeShu@sbcglobal.net>.
__disclaimer__
fi
exit 0
diff --git a/plugins/users/Makefile.in b/plugins/users/Makefile.in
index 4d9df82..0ac9cf5 100644
--- a/plugins/users/Makefile.in
+++ b/plugins/users/Makefile.in
@@ -1,6 +1,6 @@
#!/usr/bin/make -f
-name = users
-ver = 0.7beta
+name=users
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -81,13 +81,13 @@ distclean : clean
# dist #############################################################
-d = $(name)-$(ver)
-dist : $(d).tar.gz
+id = $(name)-$(ver)
+dist : $(id).tar.gz
-$(d).tar.gz : $(d)
+$(id).tar.gz : $(id)
tar -czf $@ $<
-$(d) : distclean
+$(id) : distclean
$(INSTALL) -m 777 -d $@
$(CP) -r $(mysrcdir)/* $@
@@ -97,7 +97,11 @@ b := @
# build shell scripts
$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir)
$(INSTALL_PROGRAM) $< $@
- $(SED) -i 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' $@
+ $(SED) -i \
+ -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \
+ -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \
+ -e 's/$bID@/$(subst /,\/,$(id))/g' \
+ $@
$(dirs) $(libexecdir)/$(rvs) $(myoutdir) :
$(MKDIR) $@
diff --git a/plugins/users/commit.sh b/plugins/users/commit.sh
index ab30ea0..cb2488d 100644
--- a/plugins/users/commit.sh
+++ b/plugins/users/commit.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs users commit'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,11 +19,11 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
ret=`$RVS repo-0.7beta/commit $@`
-if [ -f "$REPO/../user" ]; then
- cp "$REPO/../user" "$REPO/repo/$ret"
+if [ -f "$REPO/@ID@/user" ]; then
+ cp "$REPO/@ID@/user" "$REPO/@ID@/repo/$ret"
echo "$ret"
else
error 'you must be logged in to commit files'
diff --git a/plugins/users/init.sh b/plugins/users/init.sh
index b3347b9..41f7d77 100644
--- a/plugins/users/init.sh
+++ b/plugins/users/init.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs users init'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,10 +19,10 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#source "$libexecdir/lib/stdio"
+#source "$libexecdir/@ID@/stdio"
-mkdir -p "$REPO"/{users,repo}
-cat << __EOF__ > "$REPO/users/Public Domain"
+mkdir -p "$REPO/@ID@"/{users,repo}
+cat << __EOF__ > "$REPO/@ID@/users/Public Domain"
author:anonymous
owner:Public Domain
license:
diff --git a/plugins/users/login.sh b/plugins/users/login.sh
index eee422a..340c7db 100644
--- a/plugins/users/login.sh
+++ b/plugins/users/login.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs users login'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,11 +19,11 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
user="$1"
-if [ -f "$REPO/users/$user" ]; then
- install -m 644 -T "$REPO/users/$user" "$REPO/../user"
+if [ -f "$REPO/@ID@/users/$user" ]; then
+ install -m 644 -T "$REPO/@ID@/users/$user" "$REPO/@ID@/../user"
else
error "User \`$user' does not exist"
fi
diff --git a/plugins/users/logout.sh b/plugins/users/logout.sh
index 41d24a0..43011a1 100644
--- a/plugins/users/logout.sh
+++ b/plugins/users/logout.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs users logout'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,10 +19,10 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
-if [ -f "$REPO/../user" ]; then
- rm "$REPO/../user"
+if [ -f "$REPO/@ID@/../user" ]; then
+ rm "$REPO/@ID@/../user"
else
error 'you must be logged in to logout'
fi
diff --git a/plugins/users/mkuser.sh b/plugins/users/mkuser.sh
index 9296fef..68c16b2 100644
--- a/plugins/users/mkuser.sh
+++ b/plugins/users/mkuser.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs users mkuser'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,20 +19,11 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
-read -p 'username: ' author
-echo "$author"
-read -p 'give copyright to: ' owner
-echo "$owner"
-if [ "$owner" != 'Public Domain' ]; then
- read -p 'use the license: ' license
-else
- license=''
-fi
-cat << __EOF__ > "$REPO/users/$author"
+author="$1"
+touch "$REPO/@ID@/users/$author"
+cat << __EOF__ > "$REPO/@ID@/users/$author"
author:$author
-owner:$owner
-license:$license
__EOF__
diff --git a/plugins/users/plugin.conf b/plugins/users/plugin.conf
index b0e70b2..1224b23 100644
--- a/plugins/users/plugin.conf
+++ b/plugins/users/plugin.conf
@@ -1,5 +1,6 @@
-# users-0.7beta plugins.conf
-commit:repo-0.7beta/commit
+# rvs users plugins.conf
+# ver=0.8r61
+commit:repo-0.8r61/commit
login
logout
mkuser
diff --git a/plugins/users/rmuser.sh b/plugins/users/rmuser.sh
index 7a33de8..a9f566f 100644
--- a/plugins/users/rmuser.sh
+++ b/plugins/users/rmuser.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='rvs users rmuser'
-ver='0.7.3'
+ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -19,11 +19,11 @@ ver='0.7.3'
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-source "$libexecdir/lib/stdio"
+source "$libexecdir/@ID@/stdio"
user="$1"
-if [ -f "$REPO/users/$user" ]; then
- rm "$REPO/users/$user"
+if [ -f "$REPO/@ID@/users/$user" ]; then
+ rm "$REPO/@ID@/users/$user"
else
error "User \`$user' does not exist"
fi
diff --git a/plugins/users/stdio.sh b/plugins/users/stdio.sh
index 1149284..a8bd155 100644
--- a/plugins/users/stdio.sh
+++ b/plugins/users/stdio.sh
@@ -1,6 +1,6 @@
#!@SHELL@
#name='rvs users stdio'
-#ver='0.7.3'
+#ver=0.8r61
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
diff --git a/wrapper/Makefile.in b/wrapper/Makefile.in
index 6bdd8d5..9584a2a 100644
--- a/wrapper/Makefile.in
+++ b/wrapper/Makefile.in
@@ -1,6 +1,6 @@
#!/usr/bin/make -f
name = @name@
-ver = 0.8r57
+ver = 0.8r60
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -44,7 +44,11 @@ INSTALL_DATA ?= $(INSTALL) -m 644
TOUCH ?= touch # This file doesn't use touch
#export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH
-CFLAGS = -DLIBEXECDIR=\"$(libexecdir)/$(rvs)\" -DPLUGIN_CONF=\"plugin.conf\"
+CFLAGS = -g \
+ -DNAME=\"$(name)\" \
+ -DVER=\"$(ver)\" \
+ -Dlibexecdir=\"$(libexecdir)/$(rvs)\" \
+ -Dplugin_conf=\"plugin.conf\"
# phony targets ####################################################
all : rvs runcom
@@ -58,6 +62,16 @@ install : $(RVS) $(RUNCOM)
$(RVS) : rvs $(dir $(RVS))
$(INSTALL_PROGRAM) $< $@
+OBJ = runcom.o rvs.o plugins.o \
+ plugin-depend.o \
+ plugin-find.o \
+ plugin-load.o \
+ plugin-parse.o \
+ plugin-run.o \
+
+runcom: $(OBJ)
+ gcc -o $@ $^
+
$(RUNCOM): runcom $(dir $(RUNCOM))
$(INSTALL_PROGRAM) $< $@
diff --git a/wrapper/plugin-depend.c b/wrapper/plugin-depend.c
new file mode 100644
index 0000000..de21a93
--- /dev/null
+++ b/wrapper/plugin-depend.c
@@ -0,0 +1,146 @@
+/* wrapper/plugin-depend.c -- load a command dependancy tree
+ system depends: <string.h> <error.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <string.h>
+#include <error.h>
+
+#include "rvs.h"
+#include "plugin-find.h"
+
+#include "plugin-depend.h"
+
+/* translates a string in format `plugin/command' into a pointer to the command
+ DON'T plan on using the string again, it will be mutilated!
+ (so we go ahead and free() it and set the pointer to NULL) */
+struct plugin_command *
+plugin_depend_parse (char **string,
+ struct plugin *plugins,
+ struct plugin_command *root)
+{
+ struct plugin_command *command=NULL;
+
+ if (*string==NULL)
+ command=root;
+ else {
+ /* *string is in the format `plugin/command' */
+ /* char *del=delimeter */
+ char *del=strchr(*string,'/');
+ del[0]='\0';
+ /* *string = PLUGIN_NAME */
+ /* &del[1] = COMMAND_NAME */
+ struct plugin *plugin;
+ plugin =plugin_find_plugin(plugins, *string );
+ if (plugin==NULL)
+ error(EXIT_FAILURE,0,"cannot find plugin `%s'",*string);
+ command=plugin_find_plugin_command(plugin->commands, &del[1] );
+ if (command==NULL)
+ error(EXIT_FAILURE,0,
+ "plugin `%s' does not contain command `%s'",
+ *string,&del[1]);
+ xfree(*string);
+ *string=NULL;
+ }
+ return command;
+}
+
+/* used by plugin_depend_add */
+void
+_plugin_depend_add (struct plugin_command *prev,
+ struct plugin_command *next)
+{
+ if (prev->d_next==NULL) {
+ prev->d_next=next;
+ } else {
+ _plugin_depend_add(prev->d_next,next);
+ }
+}
+
+/* plugin_depend_add(depend,depender) */
+void
+plugin_depend_add (struct plugin_command *depend,
+ struct plugin_command *depender)
+{
+ if (depend->d_child==NULL) {
+ depend->d_child=depender;
+ } else {
+ _plugin_depend_add(depend->d_child,depender);
+ }
+}
+
+/* take care of depends for `command' */
+void
+plugin_depend_command (struct plugin_command *command,
+ struct plugin *plugins,
+ struct plugin_command *root, int ind)
+{
+ if (command!=NULL) {
+ if (command->depend == NULL) {
+ /* the depend still needs to be parsed */
+ command->depend=plugin_depend_parse(
+ &(command->depends),plugins,root);
+ }
+ plugin_depend_add(command->depend,command);
+ }
+}
+
+/* take care of commands for a `plugin', and those after it (linked list) */
+void
+plugin_depend_plugin_all (struct plugin *plugin,
+ struct plugin *plugins,
+ struct plugin_command *root)
+{
+ plugin_depend_command(plugin->commands,plugins,root,0);
+ if (plugin->next != NULL) {
+ plugin_depend_plugin_all(plugin->next,plugins,root);
+ }
+}
+
+/* take care of all depends */
+struct plugin_command *
+plugin_depend_all (struct plugin *plugins)
+{
+ struct plugin_command *root=plugin_mk_command();
+
+ plugin_depend_plugin_all(plugins,plugins,root);
+ return root;
+}
+
+void
+_plugin_depend_list (struct plugin_command_list *commands,
+ struct plugin *plugins,
+ struct plugin_command *root,int ind)
+{
+ if (commands!=NULL) {
+ plugin_depend_command(commands->command,plugins,root,ind++);
+ _plugin_depend_list(commands->next,plugins,root,ind++);
+ }
+}
+
+struct plugin_command *
+plugin_depend_list (struct plugin_command_list *commands,
+ struct plugin *plugins)
+{
+ struct plugin_command *root=plugin_mk_command();
+ _plugin_depend_list(commands,plugins,root,0);
+ return root;
+}
+
diff --git a/wrapper/plugin-depend.h b/wrapper/plugin-depend.h
index 6b18bde..580c03f 100644
--- a/wrapper/plugin-depend.h
+++ b/wrapper/plugin-depend.h
@@ -1,5 +1,7 @@
-/* Copyright (C) 2009 Luke Shumaker
- system depends: <string.h> <error.h>
+/* wrapper/plugin-parse.h -- parse rvs plugin config files
+ system depends: <stdio.h> <string.h> <error.h>
+ Copyright (C) 2009 Luke Shumaker
+
This file is part of rvs.
rvs is free software; you can redistribute it and/or modify it
@@ -20,127 +22,62 @@
#ifndef FILE_plugin_depend_h_SEEN
#define FILE_plugin_depend_h_SEEN
-#include <string.h>
-#include <error.h>
-
-#include "rvs.h"
+#include "plugins.h"
#include "plugin-find.h"
/* translates a string in format `plugin/command' into a pointer to the command
DON'T plan on using the string again, it will be mutilated!
(so we go ahead and free() it and set the pointer to NULL) */
+extern
struct plugin_command *
plugin_depend_parse (char **string,
struct plugin *plugins,
- struct plugin_command *root)
-{
- struct plugin_command *command=NULL;
-
- if (*string==NULL)
- command=root;
- else {
- /* *string is in the format `plugin/command' */
- /* char *del=delimeter */
- char *del=strchr(*string,'/');
- del[0]='\0';
- /* *string = PLUGIN_NAME */
- /* &del[1] = COMMAND_NAME */
- struct plugin *plugin;
- plugin =plugin_find_plugin(plugins, *string );
- if (plugin==NULL)
- error(EXIT_FAILURE,0,"cannot find plugin `%s'",*string);
- command=plugin_find_plugin_command(plugin->commands, &del[1] );
- if (command==NULL)
- error(EXIT_FAILURE,0,
- "plugin `%s' does not contain command `%s'",
- *string,&del[1]);
- xfree(*string);
- *string=NULL;
- }
- return command;
-}
+ struct plugin_command *root);
/* used by plugin_depend_add */
+extern
void
_plugin_depend_add (struct plugin_command *prev,
- struct plugin_command *next)
-{
- if (prev->d_next==NULL) {
- prev->d_next=next;
- } else {
- _plugin_depend_add(prev->d_next,next);
- }
-}
+ struct plugin_command *next);
/* plugin_depend_add(depend,depender) */
+extern
void
plugin_depend_add (struct plugin_command *depend,
- struct plugin_command *depender)
-{
- if (depend->d_child==NULL) {
- depend->d_child=depender;
- } else {
- _plugin_depend_add(depend->d_child,depender);
- }
-}
+ struct plugin_command *depender);
/* take care of depends for `command' */
+extern
void
plugin_depend_command (struct plugin_command *command,
struct plugin *plugins,
- struct plugin_command *root, int ind)
-{
- if (command!=NULL) {
- if (command->depend == NULL) {
- /* the depend still needs to be parsed */
- command->depend=plugin_depend_parse(
- &(command->depends),plugins,root);
- }
- plugin_depend_add(command->depend,command);
- }
-}
+ struct plugin_command *root, int ind);
/* take care of commands for a `plugin', and those after it (linked list) */
+extern
void
plugin_depend_plugin_all (struct plugin *plugin,
struct plugin *plugins,
- struct plugin_command *root)
-{
- plugin_depend_command(plugin->commands,plugins,root,0);
- if (plugin->next != NULL) {
- plugin_depend_plugin_all(plugin->next,plugins,root);
- }
-}
-
+ struct plugin_command *root);
+
/* take care of all depends */
+extern
struct plugin_command *
-plugin_depend_all (struct plugin *plugins)
-{
- struct plugin_command *root=plugin_mk_command();
-
- plugin_depend_plugin_all(plugins,plugins,root);
- return root;
-}
+plugin_depend_all (struct plugin *plugins);
+extern
void
_plugin_depend_list (struct plugin_command_list *commands,
struct plugin *plugins,
- struct plugin_command *root,int ind)
-{
- if (commands!=NULL) {
- plugin_depend_command(commands->command,plugins,root,ind++);
- _plugin_depend_list(commands->next,plugins,root,ind++);
- }
-}
+ struct plugin_command *root,int ind);
+extern
struct plugin_command *
plugin_depend_list (struct plugin_command_list *commands,
- struct plugin *plugins)
-{
- struct plugin_command *root=plugin_mk_command();
- _plugin_depend_list(commands,plugins,root,0);
- return root;
-}
+ struct plugin *plugins);
+
+
+
#endif
diff --git a/wrapper/plugin-find.c b/wrapper/plugin-find.c
new file mode 100644
index 0000000..98e16af
--- /dev/null
+++ b/wrapper/plugin-find.c
@@ -0,0 +1,103 @@
+/* wrapper/plugin-find.h -- search functions for rvs plugins
+ system depends: <string.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <string.h> /* only uses `strcmp' */
+
+#include "rvs.h"
+#include "plugins.h"
+
+#include "plugin-find.h"
+
+/* returns first plugin with `name' (duplicates are... unwise) */
+struct plugin *
+plugin_find_plugin(struct plugin *node, char *name)
+{
+
+ if (node==NULL)
+ return node;
+ else {
+ if (strcmp(node->name,name) == 0)
+ return node;
+ else
+ return plugin_find_plugin(node->next,name);
+ }
+}
+
+/* returns plugin `name within plugin `node' */
+struct plugin_command *
+plugin_find_plugin_command(struct plugin_command *node, char *name)
+{
+ if (node==NULL)
+ return node;
+ else {
+ if (strcmp(node->name,name) == 0)
+ return node;
+ else
+ return plugin_find_plugin_command(node->next,name);
+ }
+}
+
+/* returns the first command with `name' it finds */
+struct plugin_command *
+plugin_find_command(struct plugin *plugin, char *name)
+{
+ if (plugin==NULL)
+ return NULL;
+ else {
+ struct plugin_command *ret;
+ ret=plugin_find_plugin_command(plugin->commands,name);
+ if (ret == NULL)
+ ret=plugin_find_command(plugin->next,name);
+ return ret;
+ }
+}
+
+/* returns a linked list of all commands with `name' it finds */
+struct plugin_command_list *
+plugin_find_commands(struct plugin *plugin, char *name)
+{
+ if (plugin==NULL)
+ return NULL;
+ else {
+ struct plugin_command *command;
+ command=plugin_find_command(plugin,name);
+ struct plugin_command_list *node;
+ if (command==NULL)
+ node=plugin_find_commands(plugin->next,name);
+ else {
+ node=xmalloc( sizeof *node );
+ node->command=command;
+ node->next=plugin_find_commands(plugin->next,name);
+ }
+ return node;
+ }
+}
+
+void
+plugin_free_list(struct plugin_command_list *node)
+{
+ if (node!=NULL) {
+ plugin_free_list(node->next);
+ xfree(node);
+ }
+}
+
diff --git a/wrapper/plugin-find.h b/wrapper/plugin-find.h
index 1a5096b..0185117 100644
--- a/wrapper/plugin-find.h
+++ b/wrapper/plugin-find.h
@@ -37,78 +37,28 @@ struct plugin_command_list
/*-----------------------------function-----------------------------*/
/* returns first plugin with `name' (duplicates are... unwise) */
+extern
struct plugin *
-plugin_find_plugin(struct plugin *node, char *name)
-{
-
- if (node==NULL)
- return node;
- else {
- if (strcmp(node->name,name) == 0)
- return node;
- else
- return plugin_find_plugin(node->next,name);
- }
-}
+plugin_find_plugin(struct plugin *node, char *name);
/* returns plugin `name within plugin `node' */
+extern
struct plugin_command *
-plugin_find_plugin_command(struct plugin_command *node, char *name)
-{
- if (node==NULL)
- return node;
- else {
- if (strcmp(node->name,name) == 0)
- return node;
- else
- return plugin_find_plugin_command(node->next,name);
- }
-}
+plugin_find_plugin_command(struct plugin_command *node, char *name);
/* returns the first command with `name' it finds */
+extern
struct plugin_command *
-plugin_find_command(struct plugin *plugin, char *name)
-{
- if (plugin==NULL)
- return NULL;
- else {
- struct plugin_command *ret;
- ret=plugin_find_plugin_command(plugin->commands,name);
- if (ret == NULL)
- ret=plugin_find_command(plugin->next,name);
- return ret;
- }
-}
+plugin_find_command(struct plugin *plugin, char *name);
/* returns a linked list of all commands with `name' it finds */
+extern
struct plugin_command_list *
-plugin_find_commands(struct plugin *plugin, char *name)
-{
- if (plugin==NULL)
- return NULL;
- else {
- struct plugin_command *command;
- command=plugin_find_command(plugin,name);
- struct plugin_command_list *node;
- if (command==NULL)
- node=plugin_find_commands(plugin->next,name);
- else {
- node=xmalloc( sizeof *node );
- node->command=command;
- node->next=plugin_find_commands(plugin->next,name);
- }
- return node;
- }
-}
+plugin_find_commands(struct plugin *plugin, char *name);
+extern
void
-plugin_free_list(struct plugin_command_list *node)
-{
- if (node!=NULL) {
- plugin_free_list(node->next);
- xfree(node);
- }
-}
+plugin_free_list(struct plugin_command_list *node);
#endif
diff --git a/wrapper/plugin-load.c b/wrapper/plugin-load.c
new file mode 100644
index 0000000..142fcd5
--- /dev/null
+++ b/wrapper/plugin-load.c
@@ -0,0 +1,78 @@
+/* wrapper/plugin-load.h -- load rvs plugins into mem
+ system depens: <stdio.h>, GNU <string.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "rvs.h"
+#include "plugins.h"
+#include "plugin-parse.h"
+
+#include "plugin-load.h"
+
+/*- plugin_load ----------------------------------------------------*\
+ now, load plugin plug_name,
+\* whose configuration file is plugin_conf */
+struct plugin *
+plugin_load (const char *plug_name)
+{
+ 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(plugin, file);
+ fclose( file );
+ xchdir("..");
+
+ return plugin;
+}
+
+/*- 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 */
+
+struct plugin *
+load_plugins (FILE *list)
+{
+ 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);
+ *prev=plugin;/* this sets the last's `next' */
+ prev=&plugin->next;
+ }
+ }
+
+ return first;
+}
+
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
diff --git a/wrapper/plugin-parse.c b/wrapper/plugin-parse.c
new file mode 100644
index 0000000..4a35586
--- /dev/null
+++ b/wrapper/plugin-parse.c
@@ -0,0 +1,132 @@
+/* wrapper/plugin-parse.c -- parse rvs plugin config files
+ system depends: <stdio.h> <string.h> <error.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <error.h> /* only used in `plugin_parse_escape' for `error' */
+
+#include "rvs.h"
+#include "plugins.h"
+
+#include "plugin-parse.h"
+
+void
+plugin_parse_comment (FILE *file)
+{
+ char c;
+ while ( (c=getc(file)) != EOF ) {
+ if ( c == '\n' ) {
+ ungetc (c, file);
+ break;
+ }
+ }
+}
+
+char
+plugin_parse_escape(FILE *file)
+{
+ char c=getc(file);
+ switch (c) {
+ case 'n':
+ c = '\n';
+ case '\\':
+ case '#':
+ case ':':
+ break;
+ default:
+ error(EXIT_FAILURE,0,"syntax error");
+ break;
+ }
+ return c;
+}
+
+#define _parse_share(string) \
+ case '#':\
+ plugin_parse_comment(file);\
+ break;\
+ case '\\':\
+ c[0]=plugin_parse_escape(file);\
+ default:\
+ stradds(&nbytes,string,(char *)&c);\
+ break;
+
+char *
+plugin_parse_depend (FILE *file)
+{
+ size_t nbytes = 10;
+ char *string = (char *)xmalloc(nbytes);
+ string[0]='\0';
+
+ char c[2] = " \0";
+ while ( (c[0]=getc(file)) != EOF ) {
+ switch (c[0]) {
+ case '\n':
+ ungetc (c[0], file);
+ return string;
+ break;
+ _parse_share(&string)
+ }
+ }
+ return string;
+}
+
+struct plugin_command *
+plugin_parse (struct plugin *plugin, FILE *file)
+{
+ struct plugin_command *command;
+
+ char c[2] = " \0";
+ c[0]=getc(file);
+
+ if (c[0]==EOF)
+ command=NULL;
+ else {
+ ungetc (c[0], file);
+ command=plugin_mk_command();
+ command->plugin=plugin;
+
+ size_t nbytes = 10;
+ command->name = (char *)xmalloc(nbytes);
+ command->name[0]='\0';
+
+ while ( (c[0]=getc(file)) != EOF ) {
+ switch (c[0]) {
+ case '\n':
+ /*if (strlen(command->name)==0) {*/
+ if (command->name[0]=='\0') {
+ plugin_free_command(command);
+ return plugin_parse(plugin,file);
+ } else
+ command->next=plugin_parse(
+ plugin,file);
+ break;
+ case ':':
+ command->depends=plugin_parse_depend(
+ file);
+ break;
+ _parse_share(&(command->name))
+ }
+ }
+ }
+ return command;
+}
+
diff --git a/wrapper/plugin-parse.h b/wrapper/plugin-parse.h
index 8a565db..67ee06f 100644
--- a/wrapper/plugin-parse.h
+++ b/wrapper/plugin-parse.h
@@ -29,105 +29,21 @@
#include "rvs.h"
#include "plugins.h"
+extern
void
-plugin_parse_comment (FILE *file)
-{
- char c;
- while ( (c=getc(file)) != EOF ) {
- if ( c == '\n' ) {
- ungetc (c, file);
- break;
- }
- }
-}
+plugin_parse_comment (FILE *file);
+extern
char
-plugin_parse_escape(FILE *file)
-{
- char c=getc(file);
- switch (c) {
- case 'n':
- c = '\n';
- case '\\':
- case '#':
- case ':':
- break;
- default:
- error(EXIT_FAILURE,0,"syntax error");
- break;
- }
- return c;
-}
-
-#define _parse_share(string) \
- case '#':\
- plugin_parse_comment(file);\
- break;\
- case '\\':\
- c[0]=plugin_parse_escape(file);\
- default:\
- stradds(&nbytes,string,(char *)&c);\
- break;
+plugin_parse_escape(FILE *file);
+extern
char *
-plugin_parse_depend (FILE *file)
-{
- size_t nbytes = 10;
- char *string = (char *)xmalloc(nbytes);
- string[0]='\0';
-
- char c[2] = " \0";
- while ( (c[0]=getc(file)) != EOF ) {
- switch (c[0]) {
- case '\n':
- ungetc (c[0], file);
- return string;
- break;
- _parse_share(&string)
- }
- }
- return string;
-}
+plugin_parse_depend (FILE *file);
+extern
struct plugin_command *
-plugin_parse (FILE *file)
-{
- struct plugin_command *command;
-
- char c[2] = " \0";
- c[0]=getc(file);
-
- if (c[0]==EOF)
- command=NULL;
- else {
- ungetc (c[0], file);
- command=plugin_mk_command();
-
- size_t nbytes = 10;
- command->name = (char *)xmalloc(nbytes);
- command->name[0]='\0';
-
- while ( (c[0]=getc(file)) != EOF ) {
- switch (c[0]) {
- case '\n':
- /*if (strlen(command->name)==0) {*/
- if (command->name[0]=='\0') {
- plugin_free_command(command);
- return plugin_parse(file);
- } else
- command->next=plugin_parse(
- file);
- break;
- case ':':
- command->depends=plugin_parse_depend(
- file);
- break;
- _parse_share(&(command->name))
- }
- }
- }
- return command;
-}
+plugin_parse (struct plugin *plugin, FILE *file);
#endif
diff --git a/wrapper/plugin-run.c b/wrapper/plugin-run.c
new file mode 100644
index 0000000..26d4480
--- /dev/null
+++ b/wrapper/plugin-run.c
@@ -0,0 +1,89 @@
+/* wrapper/plugin-run.c -- run a heiarchy of commands
+ system depens: <stdio.h> <stdlib.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "rvs.h"
+#include "plugins.h"
+#include "plugin-find.h"
+
+#include "plugin-run.h"
+
+/* this function is an ugly hack */
+char *
+_plugin_sh_mktemp()
+{
+ size_t nbytes = 10;
+ char *string = (char *)malloc(nbytes);
+ string[0]='\0';
+
+ FILE *out=popen("mktemp -t rvs-XXXXXXXXXX","r");
+ char c[2]=" \0";
+ while ( (c[0]=getc(out)) != '\n' ) {
+ stradds(&nbytes,&string,(char *)&c);
+ }
+ pclose(out);
+ return string;
+}
+
+void
+plugin_run_command(struct plugin_command *command, char *args, char *depfile)
+{
+ if (command!=NULL) {
+ char *outfile=_plugin_sh_mktemp();
+ /* make command string:
+ `libexecdir/plugin_name/command < depfile > outfile'
+ */
+ int nbytes=20;
+ char *coms=(char *)xmalloc(nbytes);
+ coms[0]='\0';
+ stradds(&nbytes,&coms,libexecdir);
+ stradds(&nbytes,&coms,"/");
+ stradds(&nbytes,&coms,command->plugin->name);
+ stradds(&nbytes,&coms,"/");
+ stradds(&nbytes,&coms,command->name);
+ stradds(&nbytes,&coms," ");
+ stradds(&nbytes,&coms,args);
+ stradds(&nbytes,&coms," < ");
+ stradds(&nbytes,&coms,depfile);
+ stradds(&nbytes,&coms," > ");
+ stradds(&nbytes,&coms,outfile);
+
+ xsystem(coms);
+ xfree(coms);
+ plugin_run_command(command->d_child,args,outfile);
+ xfree(outfile);
+ plugin_run_command(command->d_next ,args,depfile);
+ }
+}
+
+/* needs to take the root command */
+void
+plugin_run(struct plugin_command *command,char *args)
+{
+ /*plugin_run_command(command->d_child,"/dev/null");*/
+ char *outfile=_plugin_sh_mktemp();
+ plugin_run_command(command->d_child,args,outfile);
+ xfree(outfile);
+}
+
diff --git a/wrapper/plugin-run.h b/wrapper/plugin-run.h
new file mode 100644
index 0000000..99beff4
--- /dev/null
+++ b/wrapper/plugin-run.h
@@ -0,0 +1,47 @@
+/* wrapper/plugin-run.h -- run a heiarchy of commands
+ system depens: <stdio.h> <stdlib.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#ifndef FILE_plugin_run_h_SEEN
+#define FILE_plugin_run_h_SEEN
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "rvs.h"
+#include "plugins.h"
+#include "plugin-find.h"
+
+/* this function is an ugly hack */
+extern
+char *
+_plugin_sh_mktemp();
+
+extern
+void
+plugin_run_command(struct plugin_command *command, char *args, char *depfile);
+
+/* needs to take the root command */
+extern
+void
+plugin_run(struct plugin_command *command, char *args);
+
+#endif
+
diff --git a/wrapper/plugins.c b/wrapper/plugins.c
new file mode 100644
index 0000000..70ce3e1
--- /dev/null
+++ b/wrapper/plugins.c
@@ -0,0 +1,71 @@
+/* wrapper/plugins.c -- struct definitions and basic functions for rvs plugins
+ system depends: this file is truly system-independant
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "rvs.h"
+
+#include "plugins.h"
+
+/* create a blank plugin_command */
+struct plugin_command *
+plugin_mk_command()
+{
+ struct plugin_command *command;
+ command=(struct plugin_command *)xmalloc(sizeof(*command));
+
+ /* node */
+ command->name=NULL;
+ command->plugin=NULL;
+ command->depend=NULL;
+ command->depends=NULL;
+
+ /* linked list */
+ command->next=NULL;
+
+ /* depends */
+ command->d_child=NULL;
+ command->d_next=NULL;
+
+ return command;
+}
+
+void
+plugin_free_command(struct plugin_command *command)
+{
+ if (command!=NULL) {
+ plugin_free_command(command->next);
+ xfree(command->name);
+ xfree(command->depends);
+ xfree(command);
+ }
+}
+
+void
+plugin_free_plugin(struct plugin *plugin)
+{
+ if (plugin!=NULL) {
+ xfree(plugin->name);
+ plugin_free_command(plugin->commands);
+ plugin_free_plugin(plugin->next);
+ xfree(plugin);
+ }
+}
+
diff --git a/wrapper/plugins.h b/wrapper/plugins.h
index c5fb53d..2b5a96e 100644
--- a/wrapper/plugins.h
+++ b/wrapper/plugins.h
@@ -1,7 +1,7 @@
/* wrapper/plugins.h -- struct definitions and basic functions for rvs plugins
system depends: this file is truly system-independant
Copyright (C) 2009 Luke Shumaker
- system depends: this file is completely system-independant
+
This file is part of rvs.
rvs is free software; you can redistribute it and/or modify it
@@ -53,49 +53,17 @@ struct plugin_command
};
/* create a blank plugin_command */
+extern
struct plugin_command *
-plugin_mk_command()
-{
- struct plugin_command *command;
- command=(struct plugin_command *)xmalloc(sizeof(*command));
-
- /* node */
- command->name=NULL;
- command->plugin=NULL;
- command->depend=NULL;
- command->depends=NULL;
-
- /* linked list */
- command->next=NULL;
-
- /* depends */
- command->d_child=NULL;
- command->d_next=NULL;
-
- return command;
-}
+plugin_mk_command();
+extern
void
-plugin_free_command(struct plugin_command *command)
-{
- if (command!=NULL) {
- plugin_free_command(command->next);
- xfree(command->name);
- xfree(command->depends);
- xfree(command);
- }
-}
+plugin_free_command(struct plugin_command *command);
+extern
void
-plugin_free_plugin(struct plugin *plugin)
-{
- if (plugin!=NULL) {
- xfree(plugin->name);
- plugin_free_command(plugin->commands);
- plugin_free_plugin(plugin->next);
- xfree(plugin);
- }
-}
+plugin_free_plugin(struct plugin *plugin);
#endif
diff --git a/wrapper/runcom.c b/wrapper/runcom.c
index d1b1cf4..10e9919 100644
--- a/wrapper/runcom.c
+++ b/wrapper/runcom.c
@@ -1,6 +1,6 @@
-const char *name="rvs";
-const char *ver="0.8c";
-/* Copyright (C) 2009 Luke Shumaker
+/* wrapper/runcom.c -- main program loop
+ system depends: this file is truly system-independant
+ Copyright (C) 2009 Luke Shumaker
This file is part of rvs.
@@ -20,8 +20,8 @@ const char *ver="0.8c";
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-extern const char *libexecdir=LIBEXECDIR;
-const char *plugin_conf=PLUGIN_CONF;
+const char *name=NAME;
+const char *ver=VER;
#include "rvs.h"
#include "plugins.h"
@@ -35,9 +35,10 @@ main ( int argc, char *argv[] )
{
if (argc > 1) {
/*load*/
+ char *cwd=getcwd(NULL,0);
xchdir(libexecdir);
struct plugin *plugins;
- plugins=load_plugins(stdin, plugin_conf);
+ plugins=load_plugins(stdin);
struct plugin_command_list *list;
list=plugin_find_commands(plugins,argv[1]);
if (list==NULL)
@@ -47,7 +48,18 @@ main ( int argc, char *argv[] )
root=plugin_depend_list(list,plugins);
/*do*/
- plugin_run(root);
+ xchdir(cwd);
+ int nbytes=10;
+ char *args=xmalloc(nbytes);
+ args[0]='\0';
+ int i;
+ for (i=2; i<argc; i++) {
+ stradds(&nbytes, &args, "\"" );
+ stradds(&nbytes, &args, argv[i]);
+ stradds(&nbytes, &args, "\" ");
+ }
+
+ plugin_run(root,args);
/*free*/
plugin_free_list(list);
diff --git a/wrapper/rvs.c b/wrapper/rvs.c
new file mode 100644
index 0000000..a2a8a37
--- /dev/null
+++ b/wrapper/rvs.c
@@ -0,0 +1,117 @@
+/* wrapper/rvs.c -- general and machine specific functions for rvs.
+ system depends:<stdio.h> <stdlib.h> <string.h> <unistd.h> <errno.h> <error.h>
+ Copyright (C) 2009 Luke Shumaker
+
+ This file is part of rvs.
+
+ rvs is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ rvs is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with rvs; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <error.h>
+
+#include "rvs.h"
+
+void *
+xmalloc (size_t size)
+{
+ void *value = malloc (size);
+ if (value == NULL) {
+ perror(program_invocation_name);
+ exit(EXIT_FAILURE);
+ }
+ return value;
+}
+
+void *
+xrealloc (void *ptr, size_t size)
+{
+ void *value = realloc (ptr, size);
+ if (value == NULL) {
+ perror(program_invocation_name);
+ exit(EXIT_FAILURE);
+ }
+ return value;
+}
+
+void
+xfree (void *ptr)
+{
+ if (ptr!=NULL)
+ free (ptr);
+}
+
+void
+xsystem (const char *command)
+{
+ int stat=system(command);
+ if (stat!=0) {
+ if (stat==-1) {
+ fprintf(stderr,
+ "%s: unable to launch run command",
+ program_invocation_name);
+ exit(EXIT_FAILURE);
+ } else
+ exit(EXIT_FAILURE);
+ }
+}
+
+/* unistd.h */
+int
+xchdir (const char *filename)
+{
+ int ret=chdir(filename);
+ if (ret != 0)
+ error(EXIT_FAILURE,errno,"%s/",filename);
+ return ret;
+}
+
+/* stdio.h */
+FILE *
+xfopen (const char *filename, const char *opentype)
+{
+ FILE *file = fopen(filename,opentype);
+ /* fopen gives NULL on failure */
+ if ( file == NULL )
+ error(EXIT_FAILURE,errno,"%s",filename);
+ return file;
+}
+
+/* string funtions */
+void
+stradds(size_t *size, char **dest, char *str)
+{
+ if (*size > ( strlen(*dest) + strlen(str) ))
+ strcat(*dest, str);
+ else {
+ *size = strlen(*dest) + strlen(str) + 1;
+ *dest = (char *) xrealloc (*dest, *size);
+ strcat(*dest, str);
+ }
+}
+
+char *
+stralloc (const char *string)
+{
+ char *copy = (char *)xmalloc(strlen(string)+1);
+ strcpy(copy,string);
+ return copy;
+}
+
diff --git a/wrapper/rvs.h b/wrapper/rvs.h
index 57358f2..bdd5c68 100644
--- a/wrapper/rvs.h
+++ b/wrapper/rvs.h
@@ -1,5 +1,5 @@
-/* wrapper/rvs.h -- rvs program header, contains most system-dependand code,
- and general-purose functions.
+/* wrapper/rvs.h -- general and machine specific functions for rvs.
+ system depends:<stdio.h> <stdlib.h> <string.h> <unistd.h> <errno.h> <error.h>
Copyright (C) 2009 Luke Shumaker
This file is part of rvs.
@@ -37,91 +37,40 @@ extern char *program_invocation_short_name;
/*extern int EXIT_SUCCESS;*/
/*extern int EXIT_FAILURE;*/
+extern
void *
-xmalloc (size_t size)
-{
- void *value = malloc (size);
- if (value == NULL) {
- perror(program_invocation_name);
- exit(EXIT_FAILURE);
- }
- return value;
-}
+xmalloc (size_t size);
+extern
void *
-xrealloc (void *ptr, size_t size)
-{
- void *value = realloc (ptr, size);
- if (value == NULL) {
- perror(program_invocation_name);
- exit(EXIT_FAILURE);
- }
- return value;
-}
+xrealloc (void *ptr, size_t size);
+extern
void
-xfree (void *ptr)
-{
- if (ptr!=NULL)
- free (ptr);
-}
+xfree (void *ptr);
+extern
void
-xsystem (const char *command)
-{
- int stat=system(command);
- if (stat!=0) {
- if (stat==-1) {
- fprintf(stderr,
- "%s: unable to launch run command",
- program_invocation_name);
- exit(EXIT_FAILURE);
- } else
- exit(EXIT_FAILURE);
- }
-}
+xsystem (const char *command);
/* unistd.h */
+extern
int
-xchdir (const char *filename)
-{
- int ret=chdir(filename);
- if (ret != 0)
- error(EXIT_FAILURE,errno,"%s/",filename);
- return ret;
-}
+xchdir (const char *filename);
/* stdio.h */
+extern
FILE *
-xfopen (const char *filename, const char *opentype)
-{
- FILE *file = fopen(filename,opentype);
- /* fopen gives NULL on failure */
- if ( file == NULL )
- error(EXIT_FAILURE,errno,"%s",filename);
- return file;
-}
+xfopen (const char *filename, const char *opentype);
/* string funtions */
+extern
void
-stradds(size_t *size, char **dest, char *str)
-{
- if (*size > ( strlen(*dest) + strlen(str) ))
- strcat(*dest, str);
- else {
- *size = strlen(*dest) + strlen(str) + 1;
- *dest = (char *) xrealloc (*dest, *size);
- strcat(*dest, str);
- }
-}
+stradds(size_t *size, char **dest, char *str);
+extern
char *
-stralloc (const char *string)
-{
- char *copy = (char *)xmalloc(strlen(string)+1);
- strcpy(copy,string);
- return copy;
-}
+stralloc (const char *string);
#endif
diff --git a/wrapper/rvs.sh b/wrapper/rvs.sh
index 6f4dbbb..a515f2d 100644
--- a/wrapper/rvs.sh
+++ b/wrapper/rvs.sh
@@ -1,6 +1,6 @@
#!@SHELL@
name='@name@'
-ver='0.8c'
+ver='0.8r61'
# Copyright (C) 2009 Luke Shumaker
#
# This file is part of rvs.
@@ -94,9 +94,10 @@ case "$com" in
'init') _init; exit $?;;
'install') shift; _install $@; exit $?;;
'uninstall') shift; _uninstall $@; exit $?;;
- *) repo=`_repo`
+ *) REPO=`_repo`
if [ "$?" = '0' ]; then
- "$libexecdir/runcom" $@ < $repo/plugins
+ export RVS libexecdir REPO
+ "$libexecdir/runcom" $@ < $REPO/plugins
exit $?
else
_error "cannot find an existing repository"
diff --git a/wrapper/structures.h b/wrapper/structures.h
deleted file mode 100644
index fd53d09..0000000
--- a/wrapper/structures.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (C) 2009 Luke Shumaker
-
- This file is part of rvs.
-
- rvs is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- rvs is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with rvs; see the file COPYING.
- If not, write to the Free Software Foundation,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#ifndef FILE_structures_h_SEEN
-#define FILE_structures_h_SEEN
-
-#include "string.h"
-
-/*----------------------------structures----------------------------*/
-
-/* a generic binary tree emulating a n-ary tree via linked list */
-struct tree_list
-{
- void *node;
- struct tree_list *child;/* left leaf */
- struct tree_list *next; /* right leaf */
-};
-
-/* a generic binary tree */
-struct tree_node
-{
- void *node;
- struct tree_node *left;
- struct tree_node *right;
-};
-
-/*----------------------------functions-----------------------------*/
-
-/* find a node with `name'. in the current layer of tree_list */
-struct tree_list *
-ds_tree_list_find (struct tree_list *node, char *name)
-{
- if (strcmp(node->node,name) == 0)
- return node;
- else {
- if (node->next==NULL)
- return NULL;
- else
- return ds_tree_list_find(node->next,name);
- }
-}
-
-#endif
-