envlist: Remove unused envlist_parse
envlist_parse, envlist_parse_set, envlist_parse_unset were added
in 2009 but never used, see:
04a6dfebb6
("linux-user: Add generic env variable handling")
Remove them.
Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
d524be28c5
commit
0058f85f20
@ -7,8 +7,6 @@ envlist_t *envlist_create(void);
|
||||
void envlist_free(envlist_t *);
|
||||
int envlist_setenv(envlist_t *, const char *);
|
||||
int envlist_unsetenv(envlist_t *, const char *);
|
||||
int envlist_parse_set(envlist_t *, const char *);
|
||||
int envlist_parse_unset(envlist_t *, const char *);
|
||||
char **envlist_to_environ(const envlist_t *, size_t *);
|
||||
|
||||
#endif /* ENVLIST_H */
|
||||
|
@ -12,9 +12,6 @@ struct envlist {
|
||||
size_t el_count; /* number of entries */
|
||||
};
|
||||
|
||||
static int envlist_parse(envlist_t *envlist,
|
||||
const char *env, int (*)(envlist_t *, const char *));
|
||||
|
||||
/*
|
||||
* Allocates new envlist and returns pointer to it.
|
||||
*/
|
||||
@ -51,72 +48,6 @@ envlist_free(envlist_t *envlist)
|
||||
g_free(envlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses comma separated list of set/modify environment
|
||||
* variable entries and updates given enlist accordingly.
|
||||
*
|
||||
* For example:
|
||||
* envlist_parse(el, "HOME=foo,SHELL=/bin/sh");
|
||||
*
|
||||
* inserts/sets environment variables HOME and SHELL.
|
||||
*
|
||||
* Returns 0 on success, errno otherwise.
|
||||
*/
|
||||
int
|
||||
envlist_parse_set(envlist_t *envlist, const char *env)
|
||||
{
|
||||
return (envlist_parse(envlist, env, &envlist_setenv));
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses comma separated list of unset environment variable
|
||||
* entries and removes given variables from given envlist.
|
||||
*
|
||||
* Returns 0 on success, errno otherwise.
|
||||
*/
|
||||
int
|
||||
envlist_parse_unset(envlist_t *envlist, const char *env)
|
||||
{
|
||||
return (envlist_parse(envlist, env, &envlist_unsetenv));
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses comma separated list of set, modify or unset entries
|
||||
* and calls given callback for each entry.
|
||||
*
|
||||
* Returns 0 in case of success, errno otherwise.
|
||||
*/
|
||||
static int
|
||||
envlist_parse(envlist_t *envlist, const char *env,
|
||||
int (*callback)(envlist_t *, const char *))
|
||||
{
|
||||
char *tmpenv, *envvar;
|
||||
char *envsave = NULL;
|
||||
int ret = 0;
|
||||
assert(callback != NULL);
|
||||
|
||||
if ((envlist == NULL) || (env == NULL))
|
||||
return (EINVAL);
|
||||
|
||||
tmpenv = g_strdup(env);
|
||||
envsave = tmpenv;
|
||||
|
||||
do {
|
||||
envvar = strchr(tmpenv, ',');
|
||||
if (envvar != NULL) {
|
||||
*envvar = '\0';
|
||||
}
|
||||
if ((*callback)(envlist, tmpenv) != 0) {
|
||||
ret = errno;
|
||||
break;
|
||||
}
|
||||
tmpenv = envvar + 1;
|
||||
} while (envvar != NULL);
|
||||
|
||||
g_free(envsave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets environment value to envlist in similar manner
|
||||
* than putenv(3).
|
||||
|
Loading…
Reference in New Issue
Block a user