summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-09-06 04:32:03 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:14 -0600
commitb1e41f328ea871696dae7024a7a1aa6e173f3b26 (patch)
tree2a98eaec8e76ff3123bad63bb650036fae1b2eff
parentea8a13dfa2a25f52cc245a8992fbff5d1e41106d (diff)
it's prollu not worthy of a commit, but I'm going to `hit the hay'.
-rw-r--r--[-rwxr-xr-x]wrapper/Makefile.in0
-rw-r--r--wrapper/plugin-debug.c4
-rw-r--r--wrapper/plugin-depend.c17
-rw-r--r--wrapper/plugin-parse.c15
-rw-r--r--wrapper/plugin.c14
-rw-r--r--wrapper/plugin.h21
-rw-r--r--wrapper/rvs.c3
-rw-r--r--wrapper/rvs.h14
-rw-r--r--wrapper/test.c9
9 files changed, 45 insertions, 52 deletions
diff --git a/wrapper/Makefile.in b/wrapper/Makefile.in
index 85f56f7..85f56f7 100755..100644
--- a/wrapper/Makefile.in
+++ b/wrapper/Makefile.in
diff --git a/wrapper/plugin-debug.c b/wrapper/plugin-debug.c
index a0c8022..793b07d 100644
--- a/wrapper/plugin-debug.c
+++ b/wrapper/plugin-debug.c
@@ -17,8 +17,8 @@
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FILE_plugin-debug.c_SEEN
-#define FILE_plugin-debug.c_SEEN
+#ifndef FILE_plugin_debug_c_SEEN
+#define FILE_plugin_debug_c_SEEN
size_t xstrlen (const char *s)
{
diff --git a/wrapper/plugin-depend.c b/wrapper/plugin-depend.c
index 3dfbf1b..f0e62d7 100644
--- a/wrapper/plugin-depend.c
+++ b/wrapper/plugin-depend.c
@@ -17,8 +17,8 @@
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FILE_plugin-depend.c_SEEN
-#define FILE_plugin-depend.c_SEEN
+#ifndef FILE_plugin_depend_c_SEEN
+#define FILE_plugin_depend_c_SEEN
/* translates a string in syntax `plugin/command' into a pointer to the commnad
DON'T plan on using the string again, it will be mutilated!
@@ -85,20 +85,9 @@ _plugin_depend_plugin(struct plugin *plugin, struct plugin_tree *tree)
void
_plugin_depend(struct plugin_tree *tree)
{
- /* add a blank `root' command for those that don't have depends */
- struct plugin_command *command;
- command=(struct plugin_command *)xmalloc(sizeof(*command));
- command->name=NULL;
- command->plugin=NULL;
- command->p_next=NULL;
- command->depend=NULL;
- command->depends=NULL;
- command->child=NULL;/*<--only variable of any value */
- command->d_next=NULL;
-
+ struct plugin_command *command=mkcommand();
tree->depends=command;
- /* parse all commands */
_plugin_depend_plugin(tree->plugins,tree);
}
diff --git a/wrapper/plugin-parse.c b/wrapper/plugin-parse.c
index 3be7543..7fd04bb 100644
--- a/wrapper/plugin-parse.c
+++ b/wrapper/plugin-parse.c
@@ -17,8 +17,8 @@
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FILE_plugin-parse.c_SEEN
-#define FILE_plugin-parse.c_SEEN
+#ifndef FILE_plugin_parse_c_SEEN
+#define FILE_plugin_parse_c_SEEN
void _plugin_parse_comment (FILE *file)
{
@@ -80,16 +80,7 @@ char *_plugin_parse_depend (FILE *file)
struct plugin_command *_plugin_parse (struct plugin *plugin, FILE *file)
{
- struct plugin_command *command;
- command=(struct plugin_command *)xmalloc(sizeof(*command));
-
- command->plugin=plugin;
- command->p_next=NULL;
-
- command->depend=NULL;
- command->depends=NULL;
- command->child=NULL;
- command->d_next=NULL;
+ struct plugin_command *command=mkcommand();
size_t nbytes = 10;
char *string = (char *)xmalloc(nbytes);
diff --git a/wrapper/plugin.c b/wrapper/plugin.c
index c5d8f38..1851941 100644
--- a/wrapper/plugin.c
+++ b/wrapper/plugin.c
@@ -17,8 +17,8 @@
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FILE_plugin.c_SEEN
-#define FILE_plugin.c_SEEN
+#ifndef FILE_plugin_c_SEEN
+#define FILE_plugin_c_SEEN
#include <stdio.h>
#include <stdlib.h> /* EXIT_FAILURE */
@@ -31,7 +31,7 @@
#include <dirent.h>
#include <sys/stat.h>
-/*#include "rvs.h"*/
+#include "rvs.h"
#include "plugin.h"
/* finds a plugin with `name'. Start looking at `plugin' (linked list) */
@@ -72,7 +72,7 @@ _plugin_find_command(struct plugin_command *command, char *name)
#include "plugin-depend.c"
struct plugin *
-_plugin_load (char *plug_name, char *plugin_conf)
+_plugin_load (const char *plug_name, const char *plugin_conf)
{
struct plugin *plugin=(struct plugin *)xmalloc(sizeof(*plugin));
char *plug_name2 = (char *)xmalloc(strlen(plug_name)+1);
@@ -91,7 +91,7 @@ _plugin_load (char *plug_name, char *plugin_conf)
}
struct plugin_tree *
-load_plugins (char *libexecdir, char *plugin_conf)
+load_plugins (const char *libexecdir, const char *plugin_conf)
{
struct plugin_tree *tree=(struct plugin_tree *)xmalloc(sizeof(*tree));
struct plugin **last=&tree->plugins;
@@ -99,7 +99,7 @@ load_plugins (char *libexecdir, char *plugin_conf)
struct plugin *plugin;
xchdir(libexecdir);
-
+
DIR *cwd;
struct dirent *dirent;
int serr;
@@ -118,8 +118,6 @@ load_plugins (char *libexecdir, char *plugin_conf)
}
closedir (cwd);
- _plugin_depend(tree);
-
xchdir("..");
return tree;
}
diff --git a/wrapper/plugin.h b/wrapper/plugin.h
index 5eff78e..5273866 100644
--- a/wrapper/plugin.h
+++ b/wrapper/plugin.h
@@ -17,8 +17,10 @@
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FILE_plugin.h_SEEN
-#define FILE_plugin.h_SEEN
+#ifndef FILE_plugin_h_SEEN
+#define FILE_plugin_h_SEEN
+
+#include "rvs.h"
struct plugin
{
@@ -43,6 +45,21 @@ struct plugin_command
struct plugin_command *d_next; /* next command w/ same dependancy (linked list) */
};
+struct plugin_command *
+mkcommand()
+{
+ struct plugin_command *command;
+ command=(struct plugin_command *)xmalloc(sizeof(*command));
+ command->name=NULL;
+ command->plugin=NULL;
+ command->p_next=NULL;
+ command->depend=NULL;
+ command->depends=NULL;
+ command->child=NULL;
+ command->d_next=NULL;
+ return command;
+}
+
struct plugin_tree
{
struct plugin *plugins;
diff --git a/wrapper/rvs.c b/wrapper/rvs.c
index 56162ac..7063cce 100644
--- a/wrapper/rvs.c
+++ b/wrapper/rvs.c
@@ -27,9 +27,10 @@ const char *libexecdir="./plugins";
const char *plugin_conf="plugin.conf";
int
-main (void)
+main ( int argc, char *argv[] )
{
struct plugin_tree *plugins=load_plugins(libexecdir,plugin_conf);
+ xfree(plugins);
return 0;
}
diff --git a/wrapper/rvs.h b/wrapper/rvs.h
index adef3b1..8268613 100644
--- a/wrapper/rvs.h
+++ b/wrapper/rvs.h
@@ -17,8 +17,8 @@
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef FILE_rvs.h_SEEN
-#define FILE_rvs.h_SEEN
+#ifndef FILE_rvs_h_SEEN
+#define FILE_rvs_h_SEEN
#include <stdio.h>
#include <dirent.h>
@@ -28,11 +28,15 @@
#include <errno.h>
#include <error.h>
+extern char *program_invocation_name;
+
void *xmalloc (size_t size)
{
void *value = malloc (size);
if (value == NULL)
- error(EXIT_FAILURE,0,"virtual memory exhausted");
+ perror(program_invocation_name);
+ exit(EXIT_FAILURE);
+ /*error(EXIT_FAILURE,0,"virtual memory exhausted");*/
return value;
}
@@ -40,7 +44,9 @@ void *xrealloc (void *ptr, size_t size)
{
void *value = realloc (ptr, size);
if (value == NULL)
- error(EXIT_FAILURE,0,"virtual memory exhausted");
+ perror(program_invocation_name);
+ exit(EXIT_FAILURE);
+ /*error(EXIT_FAILURE,0,"virtual memory exhausted");*/
return value;
}
diff --git a/wrapper/test.c b/wrapper/test.c
deleted file mode 100644
index 3a9abc9..0000000
--- a/wrapper/test.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "plugin.c"
-#include "plugin-debug.c"
-
-int main() {
- struct plugin_tree *plugins=load_plugins("plugins","plugin.conf");
- _plugin_print(plugins);
- return 0;
-}
-