mirror of
https://github.com/u-boot/u-boot.git
synced 2024-12-15 07:43:33 +08:00
30fd4fadb3
Currently just validates variable types as decimal, hexidecimal, boolean, ip address, and mac address. Call env_acl_validate_setenv_params() from setenv() in fw_env.c. If the entry is not found in the env .flags, then look in the static one. This allows the env to override the static definitions, but prevents the need to have every definition in the environment distracting you. Need to build in _ctype for isdigit for Linux. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
96 lines
2.7 KiB
C
96 lines
2.7 KiB
C
/*
|
|
* (C) Copyright 2012
|
|
* Joe Hershberger, National Instruments, joe.hershberger@ni.com
|
|
*
|
|
* See file CREDITS for list of people who contributed to this
|
|
* project.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of
|
|
* the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
* MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef __ENV_FLAGS_H__
|
|
#define __ENV_FLAGS_H__
|
|
|
|
enum env_flags_vartype {
|
|
env_flags_vartype_string,
|
|
env_flags_vartype_decimal,
|
|
env_flags_vartype_hex,
|
|
env_flags_vartype_bool,
|
|
#ifdef CONFIG_CMD_NET
|
|
env_flags_vartype_ipaddr,
|
|
env_flags_vartype_macaddr,
|
|
#endif
|
|
env_flags_vartype_end
|
|
};
|
|
|
|
#define ENV_FLAGS_VAR ".flags"
|
|
#define ENV_FLAGS_ATTR_MAX_LEN 2
|
|
#define ENV_FLAGS_VARTYPE_LOC 0
|
|
|
|
#ifndef CONFIG_ENV_FLAGS_LIST_STATIC
|
|
#define CONFIG_ENV_FLAGS_LIST_STATIC ""
|
|
#endif
|
|
|
|
#define ENV_FLAGS_LIST_STATIC \
|
|
CONFIG_ENV_FLAGS_LIST_STATIC
|
|
|
|
/*
|
|
* Parse the flags string from a .flags attribute list into the vartype enum.
|
|
*/
|
|
enum env_flags_vartype env_flags_parse_vartype(const char *flags);
|
|
|
|
#ifdef USE_HOSTCC
|
|
/*
|
|
* Look up the type of a variable directly from the .flags var.
|
|
*/
|
|
enum env_flags_vartype env_flags_get_type(const char *name);
|
|
/*
|
|
* Validate the newval for its type to conform with the requirements defined by
|
|
* its flags (directly looked at the .flags var).
|
|
*/
|
|
int env_flags_validate_type(const char *name, const char *newval);
|
|
/*
|
|
* Validate the parameters passed to "env set" for type compliance
|
|
*/
|
|
int env_flags_validate_env_set_params(int argc, char * const argv[]);
|
|
|
|
#else /* !USE_HOSTCC */
|
|
|
|
#include <search.h>
|
|
|
|
/*
|
|
* When adding a variable to the environment, initialize the flags for that
|
|
* variable.
|
|
*/
|
|
void env_flags_init(ENTRY *var_entry);
|
|
|
|
/*
|
|
* Validate the newval for to conform with the requirements defined by its flags
|
|
*/
|
|
int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
|
|
int flag);
|
|
|
|
/*
|
|
* These are the binary flags used in the environment entry->flags variable to
|
|
* decribe properties of veriables in the table
|
|
*/
|
|
#define ENV_FLAGS_VARTYPE_BIN_MASK 0x00000007
|
|
/* The actual variable type values use the enum value (within the mask) */
|
|
|
|
#endif /* USE_HOSTCC */
|
|
|
|
#endif /* __ENV_FLAGS_H__ */
|