Changeset 583:093d1f9455b5
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r558
|
r583
|
|
| 1 | | /* Copyright (C) 2007 the NxOS developers |
| | 1 | /* Copyright (c) 2007-2008 the NxOS developers |
| 2 | 2 | * |
| 3 | 3 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | | rcmd_err_t nx__rcmd_find_command(const char *line, rcmd_command_def *command) { |
| | 38 | rcmd_err_t nx__rcmd_find_command(char *line, rcmd_command_def *command) { |
| 39 | 39 | U32 i = 0; |
| | 40 | char *sep; |
| | 41 | |
| | 42 | sep = strchr(line, RCMD_TOKEN_SEPARATOR); |
| | 43 | if (sep) { |
| | 44 | *sep = '\0'; |
| | 45 | } |
| 40 | 46 | |
| 41 | 47 | while (rcmd_commands[i].name) { |
| 42 | 48 | if (streq(line, rcmd_commands[i].name)) { |
| 43 | 49 | *command = rcmd_commands[i]; |
| | 50 | *sep = RCMD_TOKEN_SEPARATOR; |
| 44 | 51 | return RCMD_ERR_NO_ERROR; |
| 45 | 52 | } |
| … |
… |
|
| 48 | 55 | } |
| 49 | 56 | |
| | 57 | *sep = RCMD_TOKEN_SEPARATOR; |
| 50 | 58 | return RCMD_ERR_COMMAND_NOT_FOUND; |
| 51 | 59 | } |
-
|
r551
|
r583
|
|
| 3 | 3 | */ |
| 4 | 4 | |
| 5 | | /* Copyright (C) 2007 the NxOS developers |
| | 5 | /* Copyright (c) 2007-2008 the NxOS developers |
| 6 | 6 | * |
| 7 | 7 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 40 | 40 | * @return An appropriate @a rcmd_err_t error code. |
| 41 | 41 | */ |
| 42 | | rcmd_err_t nx__rcmd_find_command(const char *line, rcmd_command_def *command); |
| | 42 | rcmd_err_t nx__rcmd_find_command(char *line, rcmd_command_def *command); |
| 43 | 43 | |
| 44 | 44 | rcmd_err_t nx__rcmd_move(char *line); |
-
|
r551
|
r583
|
|
| 1 | | /* Copyright (C) 2007 the NxOS developers |
| | 1 | /* Copyright (c) 2007-2008 the NxOS developers |
| 2 | 2 | * |
| 3 | 3 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 11 | 11 | #include "base/assert.h" |
| 12 | 12 | #include "base/fs.h" |
| | 13 | #include "base/display.h" |
| 13 | 14 | #include "base/lib/rcmd/rcmd.h" |
| 14 | 15 | #include "base/lib/rcmd/_rcmd.h" |
| … |
… |
|
| 23 | 24 | } |
| 24 | 25 | |
| 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); |
| 26 | 32 | if (err != RCMD_ERR_NO_ERROR) { |
| 27 | 33 | return err; |
| 28 | 34 | } |
| 29 | 35 | |
| 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)); |
| 34 | 36 | return command.actuator(cmdline); |
| 35 | 37 | } |
| … |
… |
|
| 37 | 39 | void nx_rcmd_parse(char *file) { |
| 38 | 40 | rcmd_err_t err, result; |
| | 41 | fs_err_t fserr; |
| 39 | 42 | fs_fd_t fd; |
| 40 | 43 | int n = 0; |
| 41 | 44 | |
| 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(); |
| 43 | 49 | nx__rcmd_error(RCMD_ERR_READ_ERROR, file, 0); |
| 44 | 50 | return; |
-
|
r551
|
r583
|
|
| 3 | 3 | */ |
| 4 | 4 | |
| 5 | | /* Copyright (C) 2007 the NxOS developers |
| | 5 | /* Copyright (c) 2007-2008 the NxOS developers |
| 6 | 6 | * |
| 7 | 7 | * See AUTHORS for a full list of the developers. |