Lines Matching +full:entry +full:- +full:name
5 * SPDX-License-Identifier: GPL-2.0+
26 * entry = name[:attributes]
27 * list = entry[,list]
30 int (*callback)(const char *name, const char *attributes, void *priv), in env_attr_walk() argument
33 const char *entry, *entry_end; in env_attr_walk() local
34 char *name, *attributes; in env_attr_walk() local
40 entry = attr_list; in env_attr_walk()
44 entry_end = strchr(entry, ENV_ATTR_LIST_DELIM); in env_attr_walk()
45 /* check if this is the last entry in the list */ in env_attr_walk()
47 int entry_len = strlen(entry); in env_attr_walk()
51 * allocate memory to copy the entry into since in env_attr_walk()
53 * white-space before calling the callback in env_attr_walk()
58 strcpy(entry_cpy, entry); in env_attr_walk()
60 return -ENOMEM; in env_attr_walk()
63 int entry_len = entry_end - entry; in env_attr_walk()
67 * allocate memory to copy the entry into since in env_attr_walk()
69 * white-space before calling the callback in env_attr_walk()
73 /* copy just this entry and null term */ in env_attr_walk()
74 strncpy(entry_cpy, entry, entry_len); in env_attr_walk()
77 return -ENOMEM; in env_attr_walk()
86 /* replace the ':' with '\0' to term name */ in env_attr_walk()
88 /* remove white-space from attributes */ in env_attr_walk()
91 /* remove white-space from name */ in env_attr_walk()
92 name = strim(entry_cpy); in env_attr_walk()
94 /* only call the callback if there is a name */ in env_attr_walk()
95 if (strlen(name) != 0) { in env_attr_walk()
98 retval = callback(name, attributes, priv); in env_attr_walk()
107 entry = entry_end + 1; in env_attr_walk()
120 static int regex_callback(const char *name, const char *attributes, void *priv) in regex_callback() argument
125 char regex[strlen(name) + 3]; in regex_callback()
128 sprintf(regex, "^%s$", name); in regex_callback()
132 if (slre_match(&slre, cbp->searched_for, in regex_callback()
133 strlen(cbp->searched_for), caps)) { in regex_callback()
134 free(cbp->regex); in regex_callback()
136 retval = -EINVAL; in regex_callback()
139 cbp->regex = malloc(strlen(regex) + 1); in regex_callback()
140 if (cbp->regex) { in regex_callback()
141 strcpy(cbp->regex, regex); in regex_callback()
143 retval = -ENOMEM; in regex_callback()
147 free(cbp->attributes); in regex_callback()
148 cbp->attributes = malloc(strlen(attributes) + 1); in regex_callback()
149 if (cbp->attributes) { in regex_callback()
150 strcpy(cbp->attributes, attributes); in regex_callback()
152 retval = -ENOMEM; in regex_callback()
153 free(cbp->regex); in regex_callback()
154 cbp->regex = NULL; in regex_callback()
160 retval = -EINVAL; in regex_callback()
167 * Retrieve the attributes string associated with a single name in the list
170 int env_attr_lookup(const char *attr_list, const char *name, char *attributes) in env_attr_lookup() argument
174 return -EINVAL; in env_attr_lookup()
177 return -EINVAL; in env_attr_lookup()
182 priv.searched_for = name; in env_attr_lookup()
196 return -ENOENT; /* not found in list */ in env_attr_lookup()
201 * Search for the last exactly matching name in an attribute list
227 prevch = match - 1; in reverse_name_search()
232 prevch--; in reverse_name_search()
241 prevch != searched - 1) in reverse_name_search()
257 * Retrieve the attributes string associated with a single name in the list
260 int env_attr_lookup(const char *attr_list, const char *name, char *attributes) in env_attr_lookup() argument
262 const char *entry = NULL; in env_attr_lookup() local
267 return -EINVAL; in env_attr_lookup()
270 return -EINVAL; in env_attr_lookup()
272 entry_len = reverse_name_search(attr_list, name, &entry); in env_attr_lookup()
273 if (entry != NULL) { in env_attr_lookup()
276 /* skip the name */ in env_attr_lookup()
277 entry += entry_len; in env_attr_lookup()
279 while (*entry == ' ') in env_attr_lookup()
280 entry++; in env_attr_lookup()
281 if (*entry != ENV_ATTR_SEP) in env_attr_lookup()
289 entry += 1; in env_attr_lookup()
291 while (*entry == ' ') in env_attr_lookup()
292 entry++; in env_attr_lookup()
294 delim = strpbrk(entry, delims); in env_attr_lookup()
296 len = strlen(entry); in env_attr_lookup()
298 len = delim - entry; in env_attr_lookup()
299 memcpy(attributes, entry, len); in env_attr_lookup()
308 return -ENOENT; in env_attr_lookup()