Lines Matching refs:envlist
8 #include "envlist.h"
15 struct envlist {
20 static int envlist_parse(envlist_t *envlist,
24 * Allocates new envlist and returns pointer to that or
30 envlist_t *envlist;
32 if ((envlist = malloc(sizeof (*envlist))) == NULL)
35 QLIST_INIT(&envlist->el_entries);
36 envlist->el_count = 0;
38 return (envlist);
42 * Releases given envlist and its entries.
45 envlist_free(envlist_t *envlist)
49 assert(envlist != NULL);
51 while (envlist->el_entries.lh_first != NULL) {
52 entry = envlist->el_entries.lh_first;
58 free(envlist);
73 envlist_parse_set(envlist_t *envlist, const char *env)
75 return (envlist_parse(envlist, env, &envlist_setenv));
80 * entries and removes given variables from given envlist.
85 envlist_parse_unset(envlist_t *envlist, const char *env)
87 return (envlist_parse(envlist, env, &envlist_unsetenv));
97 envlist_parse(envlist_t *envlist, const char *env,
105 if ((envlist == NULL) || (env == NULL))
117 if ((*callback)(envlist, envvar) != 0) {
129 * Sets environment value to envlist in similar manner
135 envlist_setenv(envlist_t *envlist, const char *env)
141 if ((envlist == NULL) || (env == NULL))
154 for (entry = envlist->el_entries.lh_first; entry != NULL;
165 envlist->el_count++;
174 QLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);
180 * Removes given env value from envlist in similar manner
184 envlist_unsetenv(envlist_t *envlist, const char *env)
189 if ((envlist == NULL) || (env == NULL))
201 for (entry = envlist->el_entries.lh_first; entry != NULL;
211 envlist->el_count--;
217 * Returns given envlist as array of strings (in same form that
220 * array and given envlist are not related (no common references).
227 envlist_to_environ(const envlist_t *envlist, size_t *count)
232 penv = env = malloc((envlist->el_count + 1) * sizeof (char *));
236 for (entry = envlist->el_entries.lh_first; entry != NULL;
243 *count = envlist->el_count;