From b1e41f328ea871696dae7024a7a1aa6e173f3b26 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 6 Sep 2009 04:32:03 -0400 Subject: it's prollu not worthy of a commit, but I'm going to `hit the hay'. --- wrapper/Makefile.in | 0 wrapper/plugin-debug.c | 4 ++-- wrapper/plugin-depend.c | 17 +++-------------- wrapper/plugin-parse.c | 15 +++------------ wrapper/plugin.c | 14 ++++++-------- wrapper/plugin.h | 21 +++++++++++++++++++-- wrapper/rvs.c | 3 ++- wrapper/rvs.h | 14 ++++++++++---- wrapper/test.c | 9 --------- 9 files changed, 45 insertions(+), 52 deletions(-) mode change 100755 => 100644 wrapper/Makefile.in delete mode 100644 wrapper/test.c diff --git a/wrapper/Makefile.in b/wrapper/Makefile.in old mode 100755 new mode 100644 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 #include /* EXIT_FAILURE */ @@ -31,7 +31,7 @@ #include #include -/*#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 #include @@ -28,11 +28,15 @@ #include #include +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; -} - -- cgit v1.2.3