2008-02-05 08:26:57 +08:00
|
|
|
/*
|
|
|
|
* cmd_strings.c - just like `strings` command
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Analog Devices Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the GPL-2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
|
|
|
|
static char *start_addr, *last_addr;
|
|
|
|
|
2020-05-11 01:40:03 +08:00
|
|
|
int do_strings(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2008-02-05 08:26:57 +08:00
|
|
|
{
|
2010-07-17 07:06:04 +08:00
|
|
|
if (argc == 1)
|
2011-12-10 16:44:01 +08:00
|
|
|
return CMD_RET_USAGE;
|
2008-02-05 08:26:57 +08:00
|
|
|
|
|
|
|
if ((flag & CMD_FLAG_REPEAT) == 0) {
|
2021-07-24 23:03:29 +08:00
|
|
|
start_addr = (char *)hextoul(argv[1], NULL);
|
2008-02-05 08:26:57 +08:00
|
|
|
if (argc > 2)
|
2021-07-24 23:03:29 +08:00
|
|
|
last_addr = (char *)hextoul(argv[2], NULL);
|
2008-02-05 08:26:57 +08:00
|
|
|
else
|
|
|
|
last_addr = (char *)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *addr = start_addr;
|
|
|
|
do {
|
2008-11-05 05:03:46 +08:00
|
|
|
puts(addr);
|
|
|
|
puts("\n");
|
2008-02-05 08:26:57 +08:00
|
|
|
addr += strlen(addr) + 1;
|
|
|
|
} while (addr[0] && addr < last_addr);
|
|
|
|
|
|
|
|
last_addr = addr + (last_addr - start_addr);
|
|
|
|
start_addr = addr;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-31 21:01:53 +08:00
|
|
|
U_BOOT_CMD(
|
|
|
|
strings, 3, 1, do_strings,
|
2009-01-28 08:03:12 +08:00
|
|
|
"display strings",
|
2008-02-05 08:26:57 +08:00
|
|
|
"<addr> [byte count]\n"
|
2009-05-24 23:06:54 +08:00
|
|
|
" - display strings at <addr> for at least [byte count] or first double NUL"
|
|
|
|
);
|