blob: bbf56a033be95fdd94eb08f85e88683759acecbb [file] [log] [blame]
Mike Frysinger8fb69662008-02-04 19:26:57 -05001/*
2 * cmd_strings.c - just like `strings` command
3 *
4 * Copyright (c) 2008 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <config.h>
10#include <common.h>
11#include <command.h>
12
13#ifdef CONFIG_CFG_STRINGS
14
15static char *start_addr, *last_addr;
16
17int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
18{
19 if (argc == 1) {
20 printf("Usage:\n%s\n", cmdtp->usage);
21 return 1;
22 }
23
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;
30 }
31
32 char *addr = start_addr;
33 do {
34 printf("%s\n", addr);
35 addr += strlen(addr) + 1;
36 } while (addr[0] && addr < last_addr);
37
38 last_addr = addr + (last_addr - start_addr);
39 start_addr = addr;
40
41 return 0;
42}
43
44U_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");
48
49#endif