mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 15:28:50 +00:00
command.c: Expose the core of do_help as _do_help to the rest of u-boot.
Other commands implementing subcommands can reuse this code nicely. Signed-off-by: Detlev Zundel <dzu@denx.de> Signed-off-by: Andreas Pfefferle <ap@denx.de>
This commit is contained in:
parent
4e325fbfa4
commit
2dce551e10
2 changed files with 16 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* (C) Copyright 2000-2003
|
* (C) Copyright 2000-2009
|
||||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||||
*
|
*
|
||||||
* See file CREDITS for list of people who contributed to this
|
* See file CREDITS for list of people who contributed to this
|
||||||
|
@ -233,20 +233,19 @@ U_BOOT_CMD(
|
||||||
* Use puts() instead of printf() to avoid printf buffer overflow
|
* Use puts() instead of printf() to avoid printf buffer overflow
|
||||||
* for long help messages
|
* for long help messages
|
||||||
*/
|
*/
|
||||||
int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
|
||||||
|
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
|
||||||
|
flag, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
|
|
||||||
if (argc == 1) { /*show list of commands */
|
if (argc == 1) { /*show list of commands */
|
||||||
|
|
||||||
int cmd_items = &__u_boot_cmd_end -
|
|
||||||
&__u_boot_cmd_start; /* pointer arith! */
|
|
||||||
cmd_tbl_t *cmd_array[cmd_items];
|
cmd_tbl_t *cmd_array[cmd_items];
|
||||||
int i, j, swaps;
|
int i, j, swaps;
|
||||||
|
|
||||||
/* Make array of commands from .uboot_cmd section */
|
/* Make array of commands from .uboot_cmd section */
|
||||||
cmdtp = &__u_boot_cmd_start;
|
cmdtp = cmd_start;
|
||||||
for (i = 0; i < cmd_items; i++) {
|
for (i = 0; i < cmd_items; i++) {
|
||||||
cmd_array[i] = cmdtp++;
|
cmd_array[i] = cmdtp++;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +285,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||||
* command help (long version)
|
* command help (long version)
|
||||||
*/
|
*/
|
||||||
for (i = 1; i < argc; ++i) {
|
for (i = 1; i < argc; ++i) {
|
||||||
if ((cmdtp = find_cmd (argv[i])) != NULL) {
|
if ((cmdtp = find_cmd_tbl (argv[i], cmd_start, cmd_items )) != NULL) {
|
||||||
#ifdef CONFIG_SYS_LONGHELP
|
#ifdef CONFIG_SYS_LONGHELP
|
||||||
/* found - print (long) help info */
|
/* found - print (long) help info */
|
||||||
puts (cmdtp->name);
|
puts (cmdtp->name);
|
||||||
|
@ -313,6 +312,13 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
return _do_help(&__u_boot_cmd_start,
|
||||||
|
&__u_boot_cmd_end - &__u_boot_cmd_start,
|
||||||
|
cmdtp, flag, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
help, CONFIG_SYS_MAXARGS, 1, do_help,
|
help, CONFIG_SYS_MAXARGS, 1, do_help,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* (C) Copyright 2000
|
* (C) Copyright 2000-2009
|
||||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||||
*
|
*
|
||||||
* See file CREDITS for list of people who contributed to this
|
* See file CREDITS for list of people who contributed to this
|
||||||
|
@ -66,6 +66,8 @@ extern cmd_tbl_t __u_boot_cmd_end;
|
||||||
|
|
||||||
|
|
||||||
/* common/command.c */
|
/* common/command.c */
|
||||||
|
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
|
||||||
|
flag, int argc, char *argv[]);
|
||||||
cmd_tbl_t *find_cmd(const char *cmd);
|
cmd_tbl_t *find_cmd(const char *cmd);
|
||||||
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
|
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue