]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/env.h
Merge branch 'lsfd-cmd--dir' of https://github.com/masatake/util-linux
[thirdparty/util-linux.git] / include / env.h
CommitLineData
79feaa60
KZ
1/*
2 * No copyright is claimed. This code is in the public domain; do with
3 * it what you wish.
4 */
035507c8
KZ
5#ifndef UTIL_LINUX_ENV_H
6#define UTIL_LINUX_ENV_H
7
90af3fe3 8#include "c.h"
05d8868d 9#include "nls.h"
90af3fe3 10
e113093c
KZ
11struct ul_env_list;
12
e0b6ab56 13extern void sanitize_env(void);
e113093c
KZ
14extern void __sanitize_env(struct ul_env_list **org);
15
16extern int env_list_setenv(struct ul_env_list *ls);
17extern void env_list_free(struct ul_env_list *ls);
4e9ec856 18extern struct ul_env_list *env_from_fd(int pid);
e113093c 19
035507c8
KZ
20extern char *safe_getenv(const char *arg);
21
05d8868d
KZ
22
23#ifndef XSETENV_EXIT_CODE
24# define XSETENV_EXIT_CODE EXIT_FAILURE
25#endif
26
e0b6ab56 27static inline void xsetenv(char const *name, char const *val, int overwrite)
e557efde 28{
e0b6ab56 29 if (setenv(name, val, overwrite) != 0)
05d8868d 30 err(XSETENV_EXIT_CODE, _("failed to set the %s environment variable"), name);
e557efde
LN
31}
32
5e2bc9d6 33static inline int remove_entry(char **argv, int remove, int last)
ed292a08
SK
34{
35 memmove(argv + remove, argv + remove + 1, sizeof(char *) * (last - remove));
36 return last - 1;
37}
38
035507c8 39#endif /* UTIL_LINUX_ENV_H */