summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-09-14 22:19:48 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:15 -0600
commit1eddff249b2c7ce54544b840562e782501d47924 (patch)
tree2c2f728872a8c8dc8a9e013bc0afac5379eb29e1
parent1aae71a1c7365d56aa6b0549bde6e8af07513f5f (diff)
well, launching plugins is written, too bad it segfaults
-rw-r--r--wrapper/TODO5
-rw-r--r--wrapper/plugin-load.h1
-rw-r--r--wrapper/runcom.c20
-rw-r--r--wrapper/rvs.h22
4 files changed, 36 insertions, 12 deletions
diff --git a/wrapper/TODO b/wrapper/TODO
index 1017c8d..9734938 100644
--- a/wrapper/TODO
+++ b/wrapper/TODO
@@ -1,6 +1,11 @@
#! /bin/more
* actually launch the plugins
+* plugin-run.h:
+ the function _plugin_sh_mktemp() is an ugly hack, it exists
+ because a) it is secure b) it is easier to write a hack using
+ methods I understand, than learn those I don't c) point b
+ especially when I just want to get it working.
~ Luke Shumaker
Happy Hacking!
diff --git a/wrapper/plugin-load.h b/wrapper/plugin-load.h
index 07fa6a7..e3677a6 100644
--- a/wrapper/plugin-load.h
+++ b/wrapper/plugin-load.h
@@ -62,7 +62,6 @@ load_plugins (FILE *list, const char *plugin_conf)
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';
diff --git a/wrapper/runcom.c b/wrapper/runcom.c
index 0e8dad8..d1b1cf4 100644
--- a/wrapper/runcom.c
+++ b/wrapper/runcom.c
@@ -20,21 +20,24 @@ 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;
+
#include "rvs.h"
#include "plugins.h"
#include "plugin-load.h"
#include "plugin-find.h"
#include "plugin-depend.h"
-
-const char *libexecdir=LIBEXECDIR;
-const char *plugin_conf=PLUGIN_CONF;
+#include "plugin-run.h"
int
main ( int argc, char *argv[] )
{
- xchdir(libexecdir);
- struct plugin *plugins=load_plugins(stdin, plugin_conf);
if (argc > 1) {
+ /*load*/
+ xchdir(libexecdir);
+ struct plugin *plugins;
+ plugins=load_plugins(stdin, plugin_conf);
struct plugin_command_list *list;
list=plugin_find_commands(plugins,argv[1]);
if (list==NULL)
@@ -42,10 +45,15 @@ main ( int argc, char *argv[] )
argv[1]);
struct plugin_command *root;
root=plugin_depend_list(list,plugins);
+
+ /*do*/
+ plugin_run(root);
+
+ /*free*/
plugin_free_list(list);
plugin_free_command(root);
+ plugin_free_plugin(plugins);
}
- plugin_free_plugin(plugins);
return 0;
}
diff --git a/wrapper/rvs.h b/wrapper/rvs.h
index 83cde87..57358f2 100644
--- a/wrapper/rvs.h
+++ b/wrapper/rvs.h
@@ -66,14 +66,28 @@ xfree (void *ptr)
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) {
+ if (ret != 0)
error(EXIT_FAILURE,errno,"%s/",filename);
- }
return ret;
}
@@ -83,10 +97,8 @@ xfopen (const char *filename, const char *opentype)
{
FILE *file = fopen(filename,opentype);
/* fopen gives NULL on failure */
- if ( file == NULL ) {
+ if ( file == NULL )
error(EXIT_FAILURE,errno,"%s",filename);
- }
-
return file;
}