blob: 144a6c18d7eed900d81bab6c3ac3e72d11a22ae0 [file] [log] [blame]
Mike Frysinger30942b12008-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
Mike Frysinger30942b12008-02-04 19:26:57 -050013static char *start_addr, *last_addr;
14
Wolfgang Denk54841ab2010-06-28 22:00:46 +020015int do_strings(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Mike Frysinger30942b12008-02-04 19:26:57 -050016{
Wolfgang Denk47e26b12010-07-17 01:06:04 +020017 if (argc == 1)
18 return cmd_usage(cmdtp);
Mike Frysinger30942b12008-02-04 19:26:57 -050019
20 if ((flag & CMD_FLAG_REPEAT) == 0) {
21 start_addr = (char *)simple_strtoul(argv[1], NULL, 16);
22 if (argc > 2)
23 last_addr = (char *)simple_strtoul(argv[2], NULL, 16);
24 else
25 last_addr = (char *)-1;
26 }
27
28 char *addr = start_addr;
29 do {
Mike Frysinger774ce722008-11-04 16:03:46 -050030 puts(addr);
31 puts("\n");
Mike Frysinger30942b12008-02-04 19:26:57 -050032 addr += strlen(addr) + 1;
33 } while (addr[0] && addr < last_addr);
34
35 last_addr = addr + (last_addr - start_addr);
36 start_addr = addr;
37
38 return 0;
39}
40
41U_BOOT_CMD(strings, 3, 1, do_strings,
Peter Tyser2fb26042009-01-27 18:03:12 -060042 "display strings",
Mike Frysinger30942b12008-02-04 19:26:57 -050043 "<addr> [byte count]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020044 " - display strings at <addr> for at least [byte count] or first double NUL"
45);