From 3420365915d2a9ca75c7ec18d72ff7c1955de757 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 6 Sep 2009 21:02:08 -0400 Subject: I'm going to come out and say it, I fucked it up :( --- wrapper/plugin-depend.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'wrapper/plugin-depend.c') diff --git a/wrapper/plugin-depend.c b/wrapper/plugin-depend.c index 11a87eb..d562489 100644 --- a/wrapper/plugin-depend.c +++ b/wrapper/plugin-depend.c @@ -20,18 +20,36 @@ #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 +/* 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) */ + (so we go ahead and free() it and set the pointer to NULL) */ struct plugin_command * -_plugin_depend_parse (char *string, struct plugin_command *root) +_plugin_depend_parse (char **string, struct plugin_command *root) { - char *c=strchr(string,'/'); - c[0]='\0'; - return _plugin_find_command( - _plugin_find_plugin(root,string)->child, - &c[1]); - xfree(string); + struct plugin_command *command=NULL; + + if (*string==NULL) + *string=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(root, *string ); + if (plugin==NULL) + error(EXIT_FAILURE,0,"cannot find plugin `%s'",*string); + command=_plugin_find_plugin_command(plugin->child, &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 */ -- cgit v1.2.3-54-g00ecf