From ecb5f954132e39ed7148c4fb8b7f725ae9a8b5cf Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 9 Aug 2001 21:39:34 +0000 Subject: 2001-08-09 Keith Outwater * monitor/mon-command.c: Add support for partial command matching. The monitor used to have this functionality before it was overhauled to support addition of user commands. --- cpukit/libmisc/monitor/mon-command.c | 53 +++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'cpukit/libmisc/monitor') diff --git a/cpukit/libmisc/monitor/mon-command.c b/cpukit/libmisc/monitor/mon-command.c index 9f7a70c3aa..3bd76467c8 100644 --- a/cpukit/libmisc/monitor/mon-command.c +++ b/cpukit/libmisc/monitor/mon-command.c @@ -12,8 +12,15 @@ #include #include +#include /* + * 2001-01-30 KJO (vac4050@cae597.rsc.raytheon.com): + * Fixed rtems_monitor_command_lookup() to accept partial + * commands to uniqeness. Added support for setting + * the monitor prompt via an environment variable: + * RTEMS_MONITOR_PROMPT + * * CCJ: 26-3-2000, adding command history and command line * editing. This code is donated from My Right Boot and not * covered by GPL, only the RTEMS license. @@ -461,17 +468,23 @@ rtems_monitor_command_read(char *command, int *argc, char **argv) { + char *env_prompt; + + env_prompt = getenv("RTEMS_MONITOR_PROMPT"); + /* * put node number in the prompt if we are multiprocessing */ - if (!rtems_configuration_get_user_multiprocessing_table ()) - sprintf (monitor_prompt, "%s", MONITOR_PROMPT); + sprintf (monitor_prompt, "%s", + (env_prompt == NULL) ? MONITOR_PROMPT: env_prompt); else if (rtems_monitor_default_node != rtems_monitor_node) sprintf (monitor_prompt, "%d-%s-%d", rtems_monitor_node, - MONITOR_PROMPT, rtems_monitor_default_node); + (env_prompt == NULL) ? MONITOR_PROMPT : env_prompt, + rtems_monitor_default_node); else - sprintf (monitor_prompt, "%d-%s", rtems_monitor_node, MONITOR_PROMPT); + sprintf (monitor_prompt, "%d-%s", rtems_monitor_node, + (env_prompt == NULL) ? MONITOR_PROMPT : env_prompt); #if defined(RTEMS_UNIX) /* RTEMS on unix gets so many interrupt system calls this is hosed */ @@ -498,27 +511,47 @@ rtems_monitor_command_lookup( char **argv ) { - char *command; + int command_length; + rtems_monitor_command_entry_t *found_it = NULL; - command = argv[0]; + command_length = strlen (argv[0]); - if ((table == 0) || (command == 0)) + if ((table == 0) || (argv[0] == 0)) return 0; while (table) { if (table->command) { - if (STREQ (command, table->command)) /* exact match */ + + /* + * Check for ambiguity + */ + if (!strncmp (table->command, argv[0], command_length)) { - if (table->command_function == 0) + if (found_it) + { return 0; - return table; + } + + else + found_it = table; } } table = table->next; } + /* + * No ambiguity (the possible partial command was unique after all) + */ + if (found_it) + { + if (table->command_function == 0) + return 0; + + return found_it; + } + return 0; } -- cgit v1.2.3