2 * (C) Copyright 2000-2008
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * Command line user interface to firmware (=U-Boot) environment.
28 * fw_printenv [[ -n name ] | [ name ... ]]
29 * - prints the value of a single environment variable
30 * "name", the ``name=value'' pairs of one or more
31 * environment variables "name", or the whole
32 * environment if no names are specified.
33 * fw_setenv name [ value ... ]
34 * - If a name without any values is given, the variable
35 * with this name is deleted from the environment;
36 * otherwise, all "value" arguments are concatenated,
37 * separated by single blank characters, and the
38 * resulting string is assigned to the environment
47 #define CMD_PRINTENV "fw_printenv"
48 #define CMD_SETENV "fw_setenv"
51 main(int argc, char *argv[])
54 char *cmdname = *argv;
56 if ((p = strrchr (cmdname, '/')) != NULL) {
60 if (strcmp(cmdname, CMD_PRINTENV) == 0) {
62 if (fw_printenv (argc, argv) != 0)
63 return (EXIT_FAILURE);
65 return (EXIT_SUCCESS);
67 } else if (strcmp(cmdname, CMD_SETENV) == 0) {
69 if (fw_setenv (argc, argv) != 0)
70 return (EXIT_FAILURE);
72 return (EXIT_SUCCESS);
77 "Identity crisis - may be called as `" CMD_PRINTENV
78 "' or as `" CMD_SETENV "' but not as `%s'\n",
80 return (EXIT_FAILURE);