summaryrefslogtreecommitdiff
path: root/include/search.h
diff options
context:
space:
mode:
authorGerlando Falauto <gerlando.falauto@keymile.com>2012-08-24 00:11:39 +0000
committerTom Rini <trini@ti.com>2012-09-18 12:01:52 -0700
commitc5983592e912835fe9ed00b9d98b05580c460eae (patch)
tree96245807698607969286b6b4d0b2f1b664fdb3e8 /include/search.h
parent348b1f1c6064990210a6797c86514fd358b73062 (diff)
downloadu-boot-imx-c5983592e912835fe9ed00b9d98b05580c460eae.zip
u-boot-imx-c5983592e912835fe9ed00b9d98b05580c460eae.tar.gz
u-boot-imx-c5983592e912835fe9ed00b9d98b05580c460eae.tar.bz2
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 <gerlando.falauto@keymile.com> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'include/search.h')
-rw-r--r--include/search.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/search.h b/include/search.h
index 94d75fc..721c8ac 100644
--- a/include/search.h
+++ b/include/search.h
@@ -57,6 +57,16 @@ struct hsearch_data {
struct _ENTRY *table;
unsigned int size;
unsigned int filled;
+/*
+ * Callback function which will check whether the given change for variable
+ * "name" from "oldval" to "newval" may be applied or not, and possibly apply
+ * such change.
+ * When (flag & H_FORCE) is set, it shall not print out any error message and
+ * shall force overwriting of write-once variables.
+.* Must return 0 for approval, 1 for denial.
+ */
+ int (*apply)(const char *name, const char *oldval,
+ const char *newval, int flag);
};
/* Create a new hashing table which will at most contain NEL elements. */
@@ -97,10 +107,12 @@ extern ssize_t hexport_r(struct hsearch_data *__htab,
/*
* nvars: length of vars array
* vars: array of strings (variable names) to import (nvars == 0 means all)
+ * do_apply: whether to call callback function to check the new argument,
+ * and possibly apply changes (false means accept everything)
*/
extern int himport_r(struct hsearch_data *__htab,
const char *__env, size_t __size, const char __sep,
- int __flag, int nvars, char * const vars[]);
+ int __flag, int nvars, char * const vars[], int do_apply);
/* Flags for himport_r() */
#define H_NOCLEAR (1 << 0) /* do not clear hash table before importing */