Merge branch 'master' of git://www.denx.de/git/u-boot-fdt
[u-boot-openmoko.git] / common / cmd_strings.c
blobbbf56a033be95fdd94eb08f85e88683759acecbb
1 /*
2 * cmd_strings.c - just like `strings` command
4 * Copyright (c) 2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
7 */
9 #include <config.h>
10 #include <common.h>
11 #include <command.h>
13 #ifdef CONFIG_CFG_STRINGS
15 static char *start_addr, *last_addr;
17 int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
19 if (argc == 1) {
20 printf("Usage:\n%s\n", cmdtp->usage);
21 return 1;
24 if ((flag & CMD_FLAG_REPEAT) == 0) {
25 start_addr = (char *)simple_strtoul(argv[1], NULL, 16);
26 if (argc > 2)
27 last_addr = (char *)simple_strtoul(argv[2], NULL, 16);
28 else
29 last_addr = (char *)-1;
32 char *addr = start_addr;
33 do {
34 printf("%s\n", addr);
35 addr += strlen(addr) + 1;
36 } while (addr[0] && addr < last_addr);
38 last_addr = addr + (last_addr - start_addr);
39 start_addr = addr;
41 return 0;
44 U_BOOT_CMD(strings, 3, 1, do_strings,
45 "strings - display strings\n",
46 "<addr> [byte count]\n"
47 " - display strings at <addr> for at least [byte count] or first double NUL\n");
49 #endif