From 67d3b5846d84d4a2e5a31d4e268bc9d51495d7e0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 3 Sep 2009 19:38:20 -0400 Subject: the C implementation properly loads the plugins, then creates a dependancy tree --- c/plugin-debug.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 11 deletions(-) (limited to 'c/plugin-debug.c') diff --git a/c/plugin-debug.c b/c/plugin-debug.c index 50e5497..553237d 100644 --- a/c/plugin-debug.c +++ b/c/plugin-debug.c @@ -18,23 +18,70 @@ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -void print_commands(struct plugin_command *command) +size_t xstrlen (const char *s) { - printf(" - %s\n",command->name); - if (command->depends != NULL) { - printf(" depend: %s\n",command->depends); + printf("xstrlen(%p)\n",s); + size_t size=0; + while (s[size] != '\0') { + printf("%i = %p `%c'\n",size,&s[size],s[size]); + size++; } - if (command->p_next != NULL) { - print_commands(command->p_next); + return size; +} + +void _plugin_print_plugin_command(struct plugin_command *command) +{ + if (command != NULL) { + printf(" - %s\n",command->name); + if (command->depends != NULL) + printf(" depend string: %s\n",command->depends); + if (command->depend->plugin == NULL) { + puts (" depend: "); + } else { + printf(" depend: %s / %s\n", + command->depend->plugin->name, + command->depend->name); + } + _plugin_print_plugin_command(command->p_next); + } +} + +void _plugin_print_plugin(struct plugin *plugin) +{ + if (plugin != NULL) { + printf(" %s\n",plugin->name); + _plugin_print_plugin_command(plugin->child); + _plugin_print_plugin(plugin->next); } } -void print_plugins(struct plugin *plugin) +void _plugin_print_depend(struct plugin_command *command,size_t indent) { - printf("%s\n",plugin->name); - print_commands(plugin->child); - if (plugin->next != NULL) { - print_plugins(plugin->next); + int i=0; + while (i < indent) { + printf(" "); + i++; } + if (command->name == NULL) { + puts(""); + } else { + printf("%s / %s\n", + command->plugin->name, + command->name); + } + if (command->child != NULL) { + _plugin_print_depend(command->child,indent+1); + } + if (command->d_next != NULL) { + _plugin_print_depend(command->d_next,indent); + } +} + +void _plugin_print(struct plugin_tree *tree) +{ + puts("Plugins:"); + _plugin_print_plugin(tree->plugins); + puts("\nDepends:"); + _plugin_print_depend(tree->depends,0); } -- cgit v1.2.3-54-g00ecf