16aff3115Swdenk /* 26aff3115Swdenk * (C) Copyright 2000 36aff3115Swdenk * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 46aff3115Swdenk * 56aff3115Swdenk * See file CREDITS for list of people who contributed to this 66aff3115Swdenk * project. 76aff3115Swdenk * 86aff3115Swdenk * This program is free software; you can redistribute it and/or 96aff3115Swdenk * modify it under the terms of the GNU General Public License as 106aff3115Swdenk * published by the Free Software Foundation; either version 2 of 116aff3115Swdenk * the License, or (at your option) any later version. 126aff3115Swdenk * 136aff3115Swdenk * This program is distributed in the hope that it will be useful, 146aff3115Swdenk * but WITHOUT ANY WARRANTY; without even the implied warranty of 156aff3115Swdenk * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 166aff3115Swdenk * GNU General Public License for more details. 176aff3115Swdenk * 186aff3115Swdenk * You should have received a copy of the GNU General Public License 196aff3115Swdenk * along with this program; if not, write to the Free Software 206aff3115Swdenk * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 216aff3115Swdenk * MA 02111-1307 USA 226aff3115Swdenk */ 236aff3115Swdenk 246aff3115Swdenk /* 25*3bac3513Swdenk * Command line user interface to firmware (=U-Boot) environment. 266aff3115Swdenk * 276aff3115Swdenk * Implements: 286aff3115Swdenk * fw_printenv [ name ... ] 296aff3115Swdenk * - prints the values of the environment variables 306aff3115Swdenk * "name", or the whole environment if no names are 316aff3115Swdenk * specified 326aff3115Swdenk * fw_setenv name [ value ... ] 336aff3115Swdenk * - If a name without any values is given, the variable 346aff3115Swdenk * with this name is deleted from the environment; 356aff3115Swdenk * otherwise, all "value" arguments are concatenated, 366aff3115Swdenk * separated by sinlge blank characters, and the 376aff3115Swdenk * resulting string is assigned to the environment 386aff3115Swdenk * variable "name" 396aff3115Swdenk */ 406aff3115Swdenk 416aff3115Swdenk #include <stdio.h> 426aff3115Swdenk #include <string.h> 436aff3115Swdenk #include <stdlib.h> 446aff3115Swdenk #include "fw_env.h" 456aff3115Swdenk 466aff3115Swdenk #define CMD_PRINTENV "fw_printenv" 476aff3115Swdenk #define CMD_SETENV "fw_setenv" 486aff3115Swdenk 496aff3115Swdenk int 506aff3115Swdenk main(int argc, char *argv[]) 516aff3115Swdenk { 526aff3115Swdenk char *p; 536aff3115Swdenk char *cmdname = *argv; 546aff3115Swdenk 556aff3115Swdenk if ((p = strrchr (cmdname, '/')) != NULL) { 566aff3115Swdenk cmdname = p + 1; 576aff3115Swdenk } 586aff3115Swdenk 596aff3115Swdenk if (strcmp(cmdname, CMD_PRINTENV) == 0) { 606aff3115Swdenk 616aff3115Swdenk fw_printenv (argc, argv); 626aff3115Swdenk 636aff3115Swdenk return (EXIT_SUCCESS); 646aff3115Swdenk 656aff3115Swdenk } else if (strcmp(cmdname, CMD_SETENV) == 0) { 666aff3115Swdenk 676aff3115Swdenk if (fw_setenv (argc, argv) != 0) 686aff3115Swdenk return (EXIT_FAILURE); 696aff3115Swdenk 706aff3115Swdenk return (EXIT_SUCCESS); 716aff3115Swdenk } 726aff3115Swdenk 736aff3115Swdenk fprintf (stderr, 746aff3115Swdenk "Identity crisis - may be called as `" CMD_PRINTENV 756aff3115Swdenk "' or as `" CMD_SETENV "' but not as `%s'\n", 766aff3115Swdenk cmdname); 776aff3115Swdenk return (EXIT_FAILURE); 786aff3115Swdenk } 79