[U-Boot] [RFC PATCH] env: Add a setenv that allows passing flags

Joe Hershberger joe.hershberger at ni.com
Tue Jun 14 21:39:59 CEST 2016


In some cases an interactive feature will be implemented using the
programmatic APIs, so the developer will want "interactive" behavior as
a result, so provide an API that will allow that to be specified.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---

 cmd/nvedit.c     | 11 ++++++++---
 include/common.h |  5 +++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index b67563b..c7c24e3 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -284,7 +284,7 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
 	return 0;
 }
 
-int setenv(const char *varname, const char *varvalue)
+int setenv_w_flags(const char *varname, const char *varvalue, int flags)
 {
 	const char * const argv[4] = { "setenv", varname, varvalue, NULL };
 
@@ -293,9 +293,14 @@ int setenv(const char *varname, const char *varvalue)
 		return 1;
 
 	if (varvalue == NULL || varvalue[0] == '\0')
-		return _do_env_set(0, 2, (char * const *)argv, H_PROGRAMMATIC);
+		return _do_env_set(0, 2, (char * const *)argv, flags);
 	else
-		return _do_env_set(0, 3, (char * const *)argv, H_PROGRAMMATIC);
+		return _do_env_set(0, 3, (char * const *)argv, flags);
+}
+
+int setenv(const char *varname, const char *varvalue)
+{
+	return setenv_w_flags(varname, varvalue, H_PROGRAMMATIC);
 }
 
 /**
diff --git a/include/common.h b/include/common.h
index f9f4605..199e0e2 100644
--- a/include/common.h
+++ b/include/common.h
@@ -377,8 +377,9 @@ ulong getenv_hex(const char *varname, ulong default_val);
  * Return -1 if variable does not exist (default to true)
  */
 int getenv_yesno(const char *var);
-int	saveenv	     (void);
-int	setenv	     (const char *, const char *);
+int saveenv(void);
+int setenv_w_flags(const char *varname, const char *varvalue, int flags);
+int setenv(const char *varname, const char *varvalue);
 int setenv_ulong(const char *varname, ulong value);
 int setenv_hex(const char *varname, ulong value);
 /**
-- 
1.7.11.5



More information about the U-Boot mailing list