Changeset ecb5f95 in rtems


Ignore:
Timestamp:
08/09/01 21:39:34 (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
4f088ae
Parents:
ff19ae5
Message:

2001-08-09 Keith Outwater <vac4050@…>

  • 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.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/libmisc/ChangeLog

    rff19ae5 recb5f95  
     12001-08-09      Keith Outwater <vac4050@cae597.rsc.raytheon.com>
     2
     3        * monitor/mon-command.c: Add support for partial command matching.
     4        The monitor used to have this functionality before it was overhauled
     5        to support addition of user commands.
     6
    172001-06-14      Joel Sherrill <joel@OARcorp.com>
    28
  • c/src/libmisc/monitor/mon-command.c

    rff19ae5 recb5f95  
    1313#include <stdio.h>
    1414#include <string.h>
    15 
    16 /*
     15#include <stdlib.h>
     16
     17/*
     18 * 2001-01-30 KJO (vac4050@cae597.rsc.raytheon.com):
     19 *  Fixed rtems_monitor_command_lookup() to accept partial
     20 *  commands to uniqeness.  Added support for setting
     21 *  the monitor prompt via an environment variable:
     22 *  RTEMS_MONITOR_PROMPT
     23 *
    1724 * CCJ: 26-3-2000, adding command history and command line
    1825 * editing. This code is donated from My Right Boot and not
     
    462469                           char **argv)
    463470{
     471        char *env_prompt;
     472
     473        env_prompt = getenv("RTEMS_MONITOR_PROMPT");
     474
    464475  /*
    465476   * put node number in the prompt if we are multiprocessing
    466477   */
    467 
    468478  if (!rtems_configuration_get_user_multiprocessing_table ())
    469     sprintf (monitor_prompt, "%s", MONITOR_PROMPT);
     479    sprintf (monitor_prompt, "%s", 
     480             (env_prompt == NULL) ? MONITOR_PROMPT: env_prompt);
    470481  else if (rtems_monitor_default_node != rtems_monitor_node)
    471482    sprintf (monitor_prompt, "%d-%s-%d", rtems_monitor_node,
    472              MONITOR_PROMPT, rtems_monitor_default_node);
     483             (env_prompt == NULL) ? MONITOR_PROMPT : env_prompt,
     484             rtems_monitor_default_node);
    473485  else
    474     sprintf (monitor_prompt, "%d-%s", rtems_monitor_node, MONITOR_PROMPT);
     486    sprintf (monitor_prompt, "%d-%s", rtems_monitor_node,
     487             (env_prompt == NULL) ? MONITOR_PROMPT : env_prompt);
    475488
    476489#if defined(RTEMS_UNIX)
     
    499512)
    500513{
    501   char *command;
    502 
    503   command = argv[0];
    504 
    505   if ((table == 0) || (command == 0))
     514  int command_length;
     515  rtems_monitor_command_entry_t *found_it = NULL;
     516
     517  command_length = strlen (argv[0]);
     518
     519  if ((table == 0) || (argv[0] == 0))
    506520    return 0;
    507521   
     
    510524    if (table->command)
    511525    {
    512       if (STREQ (command, table->command))  /* exact match */
     526
     527      /*
     528       * Check for ambiguity
     529       */
     530      if (!strncmp (table->command, argv[0], command_length))
    513531      {
    514         if (table->command_function == 0)
     532        if (found_it)
     533        {
    515534          return 0;
    516         return table;
     535        }
     536       
     537        else
     538          found_it = table;
    517539      }
    518540    }
    519541    table = table->next;
     542  }
     543
     544  /*
     545   * No ambiguity (the possible partial command was unique after all)
     546   */
     547  if (found_it)
     548  {
     549    if (table->command_function == 0)
     550      return 0;
     551
     552    return found_it;
    520553  }
    521554
  • cpukit/libmisc/ChangeLog

    rff19ae5 recb5f95  
     12001-08-09      Keith Outwater <vac4050@cae597.rsc.raytheon.com>
     2
     3        * monitor/mon-command.c: Add support for partial command matching.
     4        The monitor used to have this functionality before it was overhauled
     5        to support addition of user commands.
     6
    172001-06-14      Joel Sherrill <joel@OARcorp.com>
    28
  • cpukit/libmisc/monitor/mon-command.c

    rff19ae5 recb5f95  
    1313#include <stdio.h>
    1414#include <string.h>
    15 
    16 /*
     15#include <stdlib.h>
     16
     17/*
     18 * 2001-01-30 KJO (vac4050@cae597.rsc.raytheon.com):
     19 *  Fixed rtems_monitor_command_lookup() to accept partial
     20 *  commands to uniqeness.  Added support for setting
     21 *  the monitor prompt via an environment variable:
     22 *  RTEMS_MONITOR_PROMPT
     23 *
    1724 * CCJ: 26-3-2000, adding command history and command line
    1825 * editing. This code is donated from My Right Boot and not
     
    462469                           char **argv)
    463470{
     471        char *env_prompt;
     472
     473        env_prompt = getenv("RTEMS_MONITOR_PROMPT");
     474
    464475  /*
    465476   * put node number in the prompt if we are multiprocessing
    466477   */
    467 
    468478  if (!rtems_configuration_get_user_multiprocessing_table ())
    469     sprintf (monitor_prompt, "%s", MONITOR_PROMPT);
     479    sprintf (monitor_prompt, "%s", 
     480             (env_prompt == NULL) ? MONITOR_PROMPT: env_prompt);
    470481  else if (rtems_monitor_default_node != rtems_monitor_node)
    471482    sprintf (monitor_prompt, "%d-%s-%d", rtems_monitor_node,
    472              MONITOR_PROMPT, rtems_monitor_default_node);
     483             (env_prompt == NULL) ? MONITOR_PROMPT : env_prompt,
     484             rtems_monitor_default_node);
    473485  else
    474     sprintf (monitor_prompt, "%d-%s", rtems_monitor_node, MONITOR_PROMPT);
     486    sprintf (monitor_prompt, "%d-%s", rtems_monitor_node,
     487             (env_prompt == NULL) ? MONITOR_PROMPT : env_prompt);
    475488
    476489#if defined(RTEMS_UNIX)
     
    499512)
    500513{
    501   char *command;
    502 
    503   command = argv[0];
    504 
    505   if ((table == 0) || (command == 0))
     514  int command_length;
     515  rtems_monitor_command_entry_t *found_it = NULL;
     516
     517  command_length = strlen (argv[0]);
     518
     519  if ((table == 0) || (argv[0] == 0))
    506520    return 0;
    507521   
     
    510524    if (table->command)
    511525    {
    512       if (STREQ (command, table->command))  /* exact match */
     526
     527      /*
     528       * Check for ambiguity
     529       */
     530      if (!strncmp (table->command, argv[0], command_length))
    513531      {
    514         if (table->command_function == 0)
     532        if (found_it)
     533        {
    515534          return 0;
    516         return table;
     535        }
     536       
     537        else
     538          found_it = table;
    517539      }
    518540    }
    519541    table = table->next;
     542  }
     543
     544  /*
     545   * No ambiguity (the possible partial command was unique after all)
     546   */
     547  if (found_it)
     548  {
     549    if (table->command_function == 0)
     550      return 0;
     551
     552    return found_it;
    520553  }
    521554
Note: See TracChangeset for help on using the changeset viewer.