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>
diff --git a/include/env_flags.h b/include/env_flags.h
index bf25f27..3333446 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -52,6 +52,23 @@
*/
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 @@
#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__ */