Changeset 583:093d1f9455b5

Show
Ignore:
Timestamp:
06/05/08 17:12:48 (7 months ago)
Author:
Maxime Petazzoni <maxime.petazzoni@…>
Branch:
default
Message:

Fix the RCMD find command bug.

Location:
nxos/base/lib/rcmd
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • nxos/base/lib/rcmd/_rcmd.c

    r558 r583  
    1 /* Copyright (C) 2007 the NxOS developers 
     1/* Copyright (c) 2007-2008 the NxOS developers 
    22 * 
    33 * See AUTHORS for a full list of the developers. 
     
    3636}; 
    3737 
    38 rcmd_err_t nx__rcmd_find_command(const char *line, rcmd_command_def *command) { 
     38rcmd_err_t nx__rcmd_find_command(char *line, rcmd_command_def *command) { 
    3939  U32 i = 0; 
     40  char *sep; 
     41 
     42  sep = strchr(line, RCMD_TOKEN_SEPARATOR); 
     43  if (sep) { 
     44    *sep = '\0'; 
     45  } 
    4046 
    4147  while (rcmd_commands[i].name) { 
    4248    if (streq(line, rcmd_commands[i].name)) { 
    4349      *command = rcmd_commands[i]; 
     50      *sep = RCMD_TOKEN_SEPARATOR; 
    4451      return RCMD_ERR_NO_ERROR; 
    4552    } 
     
    4855  } 
    4956 
     57  *sep = RCMD_TOKEN_SEPARATOR; 
    5058  return RCMD_ERR_COMMAND_NOT_FOUND; 
    5159} 
  • nxos/base/lib/rcmd/_rcmd.h

    r551 r583  
    33 */ 
    44 
    5 /* Copyright (C) 2007 the NxOS developers 
     5/* Copyright (c) 2007-2008 the NxOS developers 
    66 * 
    77 * See AUTHORS for a full list of the developers. 
     
    4040 * @return An appropriate @a rcmd_err_t error code. 
    4141 */ 
    42 rcmd_err_t nx__rcmd_find_command(const char *line, rcmd_command_def *command); 
     42rcmd_err_t nx__rcmd_find_command(char *line, rcmd_command_def *command); 
    4343 
    4444rcmd_err_t nx__rcmd_move(char *line); 
  • nxos/base/lib/rcmd/rcmd.c

    r551 r583  
    1 /* Copyright (C) 2007 the NxOS developers 
     1/* Copyright (c) 2007-2008 the NxOS developers 
    22 * 
    33 * See AUTHORS for a full list of the developers. 
     
    1111#include "base/assert.h" 
    1212#include "base/fs.h" 
     13#include "base/display.h" 
    1314#include "base/lib/rcmd/rcmd.h" 
    1415#include "base/lib/rcmd/_rcmd.h" 
     
    2324  } 
    2425 
    25   err = nx__rcmd_find_command(line, &command); 
     26  /* Call the command actuator on a copy of the command line so 
     27   * it can mess around with it if it wants to. 
     28   */ 
     29  memcpy(cmdline, line, strlen(line)); 
     30 
     31  err = nx__rcmd_find_command(cmdline, &command); 
    2632  if (err != RCMD_ERR_NO_ERROR) { 
    2733    return err; 
    2834  } 
    2935 
    30   /* Call the command actuator on a copy of the command line so 
    31    * it can mess around with it if it wants to. 
    32    */ 
    33   memcpy(cmdline, line, strlen(line)); 
    3436  return command.actuator(cmdline); 
    3537} 
     
    3739void nx_rcmd_parse(char *file) { 
    3840  rcmd_err_t err, result; 
     41  fs_err_t fserr; 
    3942  fs_fd_t fd; 
    4043  int n = 0; 
    4144 
    42   if (nx_fs_open(file, FS_FILE_MODE_OPEN, &fd) != FS_ERR_NO_ERROR) { 
     45  fserr = nx_fs_open(file, FS_FILE_MODE_OPEN, &fd); 
     46  if (fserr != FS_ERR_NO_ERROR) { 
     47    nx_display_uint(fserr); 
     48    nx_display_end_line(); 
    4349    nx__rcmd_error(RCMD_ERR_READ_ERROR, file, 0); 
    4450    return; 
  • nxos/base/lib/rcmd/rcmd.h

    r551 r583  
    33 */ 
    44 
    5 /* Copyright (C) 2007 the NxOS developers 
     5/* Copyright (c) 2007-2008 the NxOS developers 
    66 * 
    77 * See AUTHORS for a full list of the developers.