From c5983592e912835fe9ed00b9d98b05580c460eae Mon Sep 17 00:00:00 2001 From: Gerlando Falauto Date: Fri, 24 Aug 2012 00:11:39 +0000 Subject: env: add check/apply logic to himport_r() Change hashtable so that a callback function will decide whether a variable can be overwritten, and possibly apply the changes. So add a new field to struct hsearch_data: o "apply" callback function to check whether a variable can be overwritten, and possibly immediately apply the changes; when NULL, no check is performed. And a new argument to himport_r(): o "do_apply": whether to call the apply callback function NOTE: This patch does not change the current behavior. Signed-off-by: Gerlando Falauto Reviewed-by: Marek Vasut --- include/environment.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/environment.h') diff --git a/include/environment.h b/include/environment.h index ae3f7b6aed..90fb1302b1 100644 --- a/include/environment.h +++ b/include/environment.h @@ -184,6 +184,15 @@ void set_default_env(const char *s); /* Import from binary representation into hash table */ int env_import(const char *buf, int check); +/* + * Check if variable "name" can be changed from oldval to newval, + * and if so, apply the changes (e.g. baudrate). + * When (flag & H_FORCE) is set, it does not print out any error + * message and forces overwriting of write-once variables. + */ +int env_check_apply(const char *name, const char *oldval, + const char *newval, int flag); + #endif /* DO_DEPS_ONLY */ #endif /* _ENVIRONMENT_H_ */ -- cgit v1.2.1