1/* 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 13static char *start_addr, *last_addr; 14 15int do_strings(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) 16{ 17 if (argc == 1) 18 return CMD_RET_USAGE; 19 20 if ((flag & CMD_FLAG_REPEAT) == 0) { 21 start_addr = (char *)hextoul(argv[1], NULL); 22 if (argc > 2) 23 last_addr = (char *)hextoul(argv[2], NULL); 24 else 25 last_addr = (char *)-1; 26 } 27 28 char *addr = start_addr; 29 do { 30 puts(addr); 31 puts("\n"); 32 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( 42 strings, 3, 1, do_strings, 43 "display strings", 44 "<addr> [byte count]\n" 45 " - display strings at <addr> for at least [byte count] or first double NUL" 46); 47