summaryrefslogtreecommitdiff
path: root/include/env_flags.h
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:32 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:56 -0700
commit30fd4fadb319d7c6d43d949e2d30ffaea46a60cf (patch)
treecedfa8c38a45f3f6afe046a999003e56a609c84d /include/env_flags.h
parent2598090b7e17f8bdca95b22e7f27217054730e02 (diff)
tools/env: Add environment variable flags support
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>
Diffstat (limited to 'include/env_flags.h')
-rw-r--r--include/env_flags.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/env_flags.h b/include/env_flags.h
index bf25f2746b..33334464d4 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -52,6 +52,23 @@ enum env_flags_vartype {
*/
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>
/*
@@ -73,4 +90,6 @@ int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
#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__ */