summaryrefslogtreecommitdiffstats
path: root/common/cmd_source.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-03-30 21:30:55 +0000
committerWolfgang Denk <wd@denx.de>2012-08-09 22:06:03 +0200
commitd51004a832a9784f4c6af5482d4dace6bfd938c4 (patch)
tree0817bdb51d21cd55b64e8eecdc5de7fd06e1a058 /common/cmd_source.c
parent213adf6dffe44d909db0efc5ecbdc047bb029438 (diff)
downloadtalos-obmc-uboot-d51004a832a9784f4c6af5482d4dace6bfd938c4.tar.gz
talos-obmc-uboot-d51004a832a9784f4c6af5482d4dace6bfd938c4.zip
Add run_command_list() to run a list of commands
This new function runs a list of commands separated by semicolon or newline. We move this out of cmd_source so that it can be used by other code. The PXE code also uses the new function. Suggested-by: Michael Walle <michael@walle.cc> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/cmd_source.c')
-rw-r--r--common/cmd_source.c49
1 files changed, 1 insertions, 48 deletions
diff --git a/common/cmd_source.c b/common/cmd_source.c
index 32fff5cec8..c4cde982a5 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -39,9 +39,6 @@
#if defined(CONFIG_8xx)
#include <mpc8xx.h>
#endif
-#ifdef CONFIG_SYS_HUSH_PARSER
-#include <hush.h>
-#endif
int
source (ulong addr, const char *fit_uname)
@@ -49,8 +46,6 @@ source (ulong addr, const char *fit_uname)
ulong len;
image_header_t *hdr;
ulong *data;
- char *cmd;
- int rcode = 0;
int verify;
#if defined(CONFIG_FIT)
const void* fit_hdr;
@@ -151,49 +146,7 @@ source (ulong addr, const char *fit_uname)
}
debug ("** Script length: %ld\n", len);
-
- if ((cmd = malloc (len + 1)) == NULL) {
- return 1;
- }
-
- /* make sure cmd is null terminated */
- memmove (cmd, (char *)data, len);
- *(cmd + len) = 0;
-
-#ifdef CONFIG_SYS_HUSH_PARSER /*?? */
- rcode = parse_string_outer (cmd, FLAG_PARSE_SEMICOLON);
-#else
- {
- char *line = cmd;
- char *next = cmd;
-
- /*
- * break into individual lines,
- * and execute each line;
- * terminate on error.
- */
- while (*next) {
- if (*next == '\n') {
- *next = '\0';
- /* run only non-empty commands */
- if (*line) {
- debug ("** exec: \"%s\"\n",
- line);
- if (run_command(line, 0) < 0) {
- rcode = 1;
- break;
- }
- }
- line = next + 1;
- }
- ++next;
- }
- if (rcode == 0 && *line)
- rcode = (run_command(line, 0) >= 0);
- }
-#endif
- free (cmd);
- return rcode;
+ return run_command_list((char *)data, len, 0);
}
/**************************************************/
OpenPOWER on IntegriCloud