summaryrefslogtreecommitdiff
path: root/wrapper/plugin-depend.c
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper/plugin-depend.c')
-rw-r--r--wrapper/plugin-depend.c36
1 files changed, 27 insertions, 9 deletions
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 */