From: Pierre-Alexandre Meyer Date: Wed, 25 Mar 2009 05:37:53 +0000 (-0700) Subject: hdt: Execute hdt default callbacks in each mode if needed X-Git-Tag: syslinux-3.80-pre1~63 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfdfe37709aaeb6c1b97344b453f78a14bd7df86;p=platform%2Fupstream%2Fsyslinux.git hdt: Execute hdt default callbacks in each mode if needed Impact: One can switch modes without going back through hdt Given a command `dmi> show foo', the ordering of callbacks is now the following: 1/ execute module 'foo' of commands set 'show' of mode dmi 2/ execute default callback of commands set 'show' of mode dmi 3/ [NEW] execute module 'foo' of commands set 'show' of mode hdt (2/ is executed if 1/ doesn't exist, 3/ is executed if 2/ doesn't exist either, if 3/ doesn't exist an error is displayed). This allows for instance to switch between modes without exiting first to hdt. Signed-off-by: Pierre-Alexandre Meyer --- diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 12bbb98..18c023d 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -429,13 +429,17 @@ static void exec_command(char *line, /* Execute the callback */ if (current_module != NULL) return current_module->exec(argc, argv, hardware); + else if (current_mode->show_modules != NULL && + current_mode->show_modules->default_callback != NULL) + return current_mode->show_modules + ->default_callback(argc, + argv, + hardware); else { - if (current_mode->show_modules != NULL && - current_mode->show_modules->default_callback != NULL) - return current_mode->show_modules - ->default_callback(argc, - argv, - hardware); + find_cli_callback_descr(module, hdt_mode.show_modules, + ¤t_module); + if (current_module != NULL) + return current_module->exec(argc, argv, hardware); } } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) { dprintf("CLI DEBUG: %s command detected\n", CLI_SET); @@ -444,13 +448,17 @@ static void exec_command(char *line, /* Execute the callback */ if (current_module != NULL) return current_module->exec(argc, argv, hardware); + else if (current_mode->set_modules != NULL && + current_mode->set_modules->default_callback != NULL) + return current_mode->set_modules + ->default_callback(argc, + argv, + hardware); else { - if (current_mode->set_modules != NULL && - current_mode->set_modules->default_callback != NULL) - return current_mode->set_modules - ->default_callback(argc, - argv, - hardware); + find_cli_callback_descr(module, hdt_mode.set_modules, + ¤t_module); + if (current_module != NULL) + return current_module->exec(argc, argv, hardware); } } dprintf("CLI DEBUG: callback not found!\n", argc);