{
int i, buflen;
char *last, **next, *s;
- ENTRY *match, search;
+ struct env_entry *match, search;
static char *var;
last = (char *)va_arg(ap, unsigned long);
ssize_t len;
if (name) { /* print a single name */
- ENTRY e, *ep;
+ struct env_entry e, *ep;
e.key = name;
e.data = NULL;
{
int i, len;
char *name, *value, *s;
- ENTRY e, *ep;
+ struct env_entry e, *ep;
debug("Initial value for argc=%d\n", argc);
return 0;
}
-static int print_active_callback(ENTRY *entry)
+static int print_active_callback(struct env_entry *entry)
{
struct env_clbk_tbl *clbkp;
int i;
return 0;
}
-static int print_active_flags(ENTRY *entry)
+static int print_active_flags(struct env_entry *entry)
{
enum env_flags_vartype type;
enum env_flags_varaccess access;
char *env_get(const char *name)
{
if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
- ENTRY e, *ep;
+ struct env_entry e, *ep;
WATCHDOG_RESET();
static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- ENTRY e, *ep;
+ struct env_entry e, *ep;
if (argc < 2)
return CMD_RET_USAGE;
struct tee_param *params)
{
struct sandbox_tee_state *state = dev_get_priv(dev);
- ENTRY e, *ep;
+ struct env_entry e, *ep;
char *name;
u32 res;
uint slot;
* This is called specifically when the variable did not exist in the hash
* previously, so the blanket update did not find this variable.
*/
-void env_callback_init(ENTRY *var_entry)
+void env_callback_init(struct env_entry *var_entry)
{
const char *var_name = var_entry->key;
char callback_name[256] = "";
* Called on each existing env var prior to the blanket update since removing
* a callback association should remove its callback.
*/
-static int clear_callback(ENTRY *entry)
+static int clear_callback(struct env_entry *entry)
{
entry->callback = NULL;
*/
static int set_callback(const char *name, const char *value, void *priv)
{
- ENTRY e, *ep;
+ struct env_entry e, *ep;
struct env_clbk_tbl *clbkp;
e.key = name;
int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf,
bool dollar_comp)
{
- ENTRY *match;
+ struct env_entry *match;
int found, idx;
if (dollar_comp) {
* This is called specifically when the variable did not exist in the hash
* previously, so the blanket update did not find this variable.
*/
-void env_flags_init(ENTRY *var_entry)
+void env_flags_init(struct env_entry *var_entry)
{
const char *var_name = var_entry->key;
char flags[ENV_FLAGS_ATTR_MAX_LEN + 1] = "";
* Called on each existing env var prior to the blanket update since removing
* a flag in the flag list should remove its flags.
*/
-static int clear_flags(ENTRY *entry)
+static int clear_flags(struct env_entry *entry)
{
entry->flags = 0;
*/
static int set_flags(const char *name, const char *value, void *priv)
{
- ENTRY e, *ep;
+ struct env_entry e, *ep;
e.key = name;
e.data = NULL;
* overwriting of write-once variables.
*/
-int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
- int flag)
+int env_flags_validate(const struct env_entry *item, const char *newval,
+ enum env_op op, int flag)
{
const char *name;
const char *oldval = NULL;
"serial#:serialno," \
CONFIG_ENV_CALLBACK_LIST_STATIC
-void env_callback_init(ENTRY *var_entry);
+void env_callback_init(struct env_entry *var_entry);
#endif /* __ENV_CALLBACK_H__ */
* When adding a variable to the environment, initialize the flags for that
* variable.
*/
-void env_flags_init(ENTRY *var_entry);
+void env_flags_init(struct env_entry *var_entry);
/*
* Validate the newval for to conform with the requirements defined by its flags
*/
-int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
- int flag);
+int env_flags_validate(const struct env_entry *item, const char *newval,
+ enum env_op op, int flag);
#endif /* USE_HOSTCC */
ENTER
} ACTION;
-typedef struct entry {
+/** struct env_entry - An entry in the environment hashtable */
+struct env_entry {
const char *key;
char *data;
int (*callback)(const char *name, const char *value, enum env_op op,
int flags);
int flags;
-} ENTRY;
+};
/* Opaque type for internal use. */
struct _ENTRY;
* shall force overwriting of write-once variables.
* Must return 0 for approval, 1 for denial.
*/
- int (*change_ok)(const ENTRY *__item, const char *newval, enum env_op,
- int flag);
+ int (*change_ok)(const struct env_entry *__item, const char *newval,
+ enum env_op, int flag);
};
/* Create a new hash table which will contain at most "__nel" elements. */
* NULL. If ACTION is `ENTER' replace existing data (if any) with
* __item.data.
* */
-extern int hsearch_r(ENTRY __item, ACTION __action, ENTRY ** __retval,
- struct hsearch_data *__htab, int __flag);
+extern int hsearch_r(struct env_entry __item, ACTION __action,
+ struct env_entry **__retval, struct hsearch_data *__htab,
+ int __flag);
/*
* Search for an entry matching "__match". Otherwise, Same semantics
* as hsearch_r().
*/
-extern int hmatch_r(const char *__match, int __last_idx, ENTRY ** __retval,
- struct hsearch_data *__htab);
+extern int hmatch_r(const char *__match, int __last_idx,
+ struct env_entry **__retval, struct hsearch_data *__htab);
/* Search and delete entry matching "__key" in internal hash table. */
extern int hdelete_r(const char *__key, struct hsearch_data *__htab,
char * const vars[]);
/* Walk the whole table calling the callback on each element */
-extern int hwalk_r(struct hsearch_data *__htab, int (*callback)(ENTRY *));
+extern int hwalk_r(struct hsearch_data *__htab,
+ int (*callback)(struct env_entry *entry));
/* Flags for himport_r(), hexport_r(), hdelete_r(), and hsearch_r() */
#define H_NOCLEAR (1 << 0) /* do not clear hash table before importing */
typedef struct _ENTRY {
int used;
- ENTRY entry;
+ struct env_entry entry;
} _ENTRY;
-static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
- int idx);
+static void _hdelete(const char *key, struct hsearch_data *htab,
+ struct env_entry *ep, int idx);
/*
* hcreate()
/* free used memory */
for (i = 1; i <= htab->size; ++i) {
if (htab->table[i].used > 0) {
- ENTRY *ep = &htab->table[i].entry;
+ struct env_entry *ep = &htab->table[i].entry;
free((void *)ep->key);
free(ep->data);
* example for functions like hdelete().
*/
-int hmatch_r(const char *match, int last_idx, ENTRY ** retval,
+int hmatch_r(const char *match, int last_idx, struct env_entry **retval,
struct hsearch_data *htab)
{
unsigned int idx;
* Compare an existing entry with the desired key, and overwrite if the action
* is ENTER. This is simply a helper function for hsearch_r().
*/
-static inline int _compare_and_overwrite_entry(ENTRY item, ACTION action,
- ENTRY **retval, struct hsearch_data *htab, int flag,
- unsigned int hval, unsigned int idx)
+static inline int _compare_and_overwrite_entry(struct env_entry item,
+ ACTION action, struct env_entry **retval,
+ struct hsearch_data *htab, int flag, unsigned int hval,
+ unsigned int idx)
{
if (htab->table[idx].used == hval
&& strcmp(item.key, htab->table[idx].entry.key) == 0) {
return -1;
}
-int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
+int hsearch_r(struct env_entry item, ACTION action, struct env_entry **retval,
struct hsearch_data *htab, int flag)
{
unsigned int hval;
* do that.
*/
-static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
- int idx)
+static void _hdelete(const char *key, struct hsearch_data *htab,
+ struct env_entry *ep, int idx)
{
- /* free used ENTRY */
+ /* free used entry */
debug("hdelete: DELETING key \"%s\"\n", key);
free((void *)ep->key);
free(ep->data);
int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
{
- ENTRY e, *ep;
+ struct env_entry e, *ep;
int idx;
debug("hdelete: DELETE key \"%s\"\n", key);
static int cmpkey(const void *p1, const void *p2)
{
- ENTRY *e1 = *(ENTRY **) p1;
- ENTRY *e2 = *(ENTRY **) p2;
+ struct env_entry *e1 = *(struct env_entry **)p1;
+ struct env_entry *e2 = *(struct env_entry **)p2;
return (strcmp(e1->key, e2->key));
}
return 0;
}
-static int match_entry(ENTRY *ep, int flag,
- int argc, char * const argv[])
+static int match_entry(struct env_entry *ep, int flag, int argc,
+ char *const argv[])
{
int arg;
void *priv = NULL;
char **resp, size_t size,
int argc, char * const argv[])
{
- ENTRY *list[htab->size];
+ struct env_entry *list[htab->size];
char *res, *p;
size_t totlen;
int i, n;
for (i = 1, n = 0, totlen = 0; i <= htab->size; ++i) {
if (htab->table[i].used > 0) {
- ENTRY *ep = &htab->table[i].entry;
+ struct env_entry *ep = &htab->table[i].entry;
int found = match_entry(ep, flag, argc, argv);
if ((argc > 0) && (found == 0))
#endif
/* Sort list by keys */
- qsort(list, n, sizeof(ENTRY *), cmpkey);
+ qsort(list, n, sizeof(struct env_entry *), cmpkey);
/* Check if the user supplied buffer size is sufficient */
if (size) {
}
/* Parse environment; allow for '\0' and 'sep' as separators */
do {
- ENTRY e, *rv;
+ struct env_entry e, *rv;
/* skip leading white space */
while (isblank(*dp))
* Walk all of the entries in the hash, calling the callback for each one.
* this allows some generic operation to be performed on each element.
*/
-int hwalk_r(struct hsearch_data *htab, int (*callback)(ENTRY *))
+int hwalk_r(struct hsearch_data *htab, int (*callback)(struct env_entry *entry))
{
int i;
int retval;
struct hsearch_data *htab, size_t size)
{
size_t i;
- ENTRY item;
- ENTRY *ritem;
+ struct env_entry item;
+ struct env_entry *ritem;
char key[20];
for (i = 0; i < size; i++) {
struct hsearch_data *htab, size_t size)
{
size_t i;
- ENTRY item;
- ENTRY *ritem;
+ struct env_entry item;
+ struct env_entry *ritem;
char key[20];
for (i = 0; i < size; i++) {
struct hsearch_data *htab, size_t iterations)
{
size_t i;
- ENTRY item;
- ENTRY *ritem;
+ struct env_entry item;
+ struct env_entry *ritem;
char key[20];
for (i = 0; i < iterations; i++) {