diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-22 16:44:47 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-22 16:44:47 +0000 |
commit | a8e40d0287f05f6e444035431b1cc7b340fe8d79 (patch) | |
tree | 3d34decfcdfed87f14ab6b467dfd8ca3c7add471 /src | |
parent | 8cd0d07171f8b32553ef0c6936fd5737adcb4bab (diff) | |
download | skalibs-a8e40d0287f05f6e444035431b1cc7b340fe8d79.tar.xz |
Deprecate env_get
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/env.h | 6 | ||||
-rw-r--r-- | src/libstddjb/child_spawn.c | 20 | ||||
-rw-r--r-- | src/libstddjb/child_spawn0.c | 3 | ||||
-rw-r--r-- | src/libstddjb/child_spawn1_internal.c | 6 | ||||
-rw-r--r-- | src/libstddjb/child_spawn2.c | 10 | ||||
-rw-r--r-- | src/libstddjb/env_get.c | 4 | ||||
-rw-r--r-- | src/libstddjb/pathexec_run.c | 4 | ||||
-rw-r--r-- | src/libstddjb/ucspi_get.c | 5 |
8 files changed, 28 insertions, 30 deletions
diff --git a/src/include/skalibs/env.h b/src/include/skalibs/env.h index f0c2dbc..c2569b4 100644 --- a/src/include/skalibs/env.h +++ b/src/include/skalibs/env.h @@ -1,14 +1,14 @@ /* ISC license. */ -#ifndef ENV_H -#define ENV_H +#ifndef SKALIBS_ENV_H +#define SKALIBS_ENV_H #include <sys/types.h> #include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> extern size_t env_len (char const *const *) gccattr_pure ; -extern char const *env_get (char const *) gccattr_pure ; +extern char const *env_get (char const *) gccattr_deprecated ; extern char const *env_get2 (char const *const *, char const *) gccattr_pure ; extern char const *ucspi_get (char const *) gccattr_pure ; extern int env_addmodif (stralloc *, char const *, char const *) ; diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index 62d13cb..82edf8a 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -10,10 +10,6 @@ #include <unistd.h> #include <errno.h> #include <signal.h> -#include <skalibs/types.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> #ifdef SKALIBS_HASPOSIXSPAWN @@ -28,8 +24,10 @@ #endif -#define NOFDVAR "SKALIBS_CHILD_SPAWN_FDS" - +#include <skalibs/types.h> +#include <skalibs/allreadwrite.h> +#include <skalibs/env.h> +#include <skalibs/djbunix.h> /* If n = 0 : child's stdin and stdout are the same as the parent's @@ -48,10 +46,10 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const int p[n ? n : 1][2] ; pid_t pid ; int e ; - size_t m = sizeof(NOFDVAR) ; + size_t m = sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ; unsigned int i = 0 ; char modifs[m + 1 + n * UINT_FMT] ; - memcpy(modifs, NOFDVAR "=", sizeof(NOFDVAR)) ; + memcpy(modifs, SKALIBS_CHILD_SPAWN_FDS_ENVVAR "=", sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR)) ; for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errpi ; } for (i = 0 ; i < n ; i++) if ((ndelay_on(p[i][i & 1]) < 0) || (coe(p[i][i & 1]) < 0)) @@ -94,7 +92,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const if (e) goto erractions ; } { - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; size_t envlen = env_len(envp) ; char const *newenv[envlen + 2] ; if (!env_merge(newenv, envlen+2, envp, envlen, modifs, m)) goto errsp ; @@ -137,8 +135,8 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const syncdie: { - unsigned char c = errno ; - fd_write(syncpipe[1], (char const *)&c, 1) ; + char c = errno ; + fd_write(syncpipe[1], &c, 1) ; } _exit(127) ; } diff --git a/src/libstddjb/child_spawn0.c b/src/libstddjb/child_spawn0.c index a01739a..31d44e2 100644 --- a/src/libstddjb/child_spawn0.c +++ b/src/libstddjb/child_spawn0.c @@ -9,14 +9,13 @@ #include <spawn.h> #include <stdlib.h> #include <skalibs/config.h> -#include <skalibs/env.h> pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const *envp) { posix_spawnattr_t attr ; int e ; pid_t pid ; - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; e = posix_spawnattr_init(&attr) ; if (e) goto err ; { diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c index eea4f09..38a6e60 100644 --- a/src/libstddjb/child_spawn1_internal.c +++ b/src/libstddjb/child_spawn1_internal.c @@ -3,7 +3,6 @@ #include <skalibs/sysdeps.h> #include <unistd.h> #include <errno.h> -#include <skalibs/djbunix.h> #ifdef SKALIBS_HASPOSIXSPAWN @@ -11,7 +10,7 @@ #include <spawn.h> #include <stdlib.h> #include <skalibs/config.h> -#include <skalibs/env.h> +#include <skalibs/djbunix.h> pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) { @@ -19,7 +18,7 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con posix_spawnattr_t attr ; int e ; pid_t pid ; - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; if (coe(p[!(to & 1)]) < 0) { e = errno ; goto err ; } e = posix_spawnattr_init(&attr) ; if (e) goto err ; @@ -69,6 +68,7 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con #include <skalibs/allreadwrite.h> #include <skalibs/strerr2.h> #include <skalibs/sig.h> +#include <skalibs/djbunix.h> pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) { diff --git a/src/libstddjb/child_spawn2.c b/src/libstddjb/child_spawn2.c index 0f08b3d..01f144d 100644 --- a/src/libstddjb/child_spawn2.c +++ b/src/libstddjb/child_spawn2.c @@ -9,14 +9,12 @@ #include <unistd.h> #include <errno.h> #include <signal.h> -#include <skalibs/djbunix.h> #ifdef SKALIBS_HASPOSIXSPAWN #include <stdlib.h> #include <spawn.h> #include <skalibs/config.h> -#include <skalibs/env.h> #else @@ -27,6 +25,8 @@ #endif +#include <skalibs/djbunix.h> + pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const *envp, int *fds) { #ifdef SKALIBS_HASPOSIXSPAWN @@ -65,7 +65,7 @@ pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const e = posix_spawn_file_actions_addclose(&actions, p[0][1]) ; if (e) goto erractions ; { - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; if (!haspath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) < 0)) { e = errno ; goto erractions ; @@ -98,8 +98,8 @@ pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const syncdie: { - unsigned char c = errno ; - fd_write(syncpipe[1], (char const *)&c, 1) ; + char c = errno ; + fd_write(syncpipe[1], &c, 1) ; } _exit(127) ; } diff --git a/src/libstddjb/env_get.c b/src/libstddjb/env_get.c index f523f45..d809461 100644 --- a/src/libstddjb/env_get.c +++ b/src/libstddjb/env_get.c @@ -1,9 +1,9 @@ /* ISC license. */ -#include <skalibs/env.h> +#include <stdlib.h> #include <skalibs/posixplz.h> char const *env_get (char const *s) { - return env_get2((char const **)environ, s) ; + return getenv(s) ; } diff --git a/src/libstddjb/pathexec_run.c b/src/libstddjb/pathexec_run.c index ff3211d..5888ba2 100644 --- a/src/libstddjb/pathexec_run.c +++ b/src/libstddjb/pathexec_run.c @@ -1,13 +1,13 @@ /* ISC license. */ +#include <stdlib.h> #include <skalibs/config.h> -#include <skalibs/env.h> #include <skalibs/posixplz.h> #include <skalibs/djbunix.h> void pathexec_run (char const *file, char const *const *argv, char const *const *envp) { - char const *path = env_get("PATH") ; + char const *path = getenv("PATH") ; if (!path) path = SKALIBS_DEFAULTPATH ; execvep(file, argv, envp, path) ; } diff --git a/src/libstddjb/ucspi_get.c b/src/libstddjb/ucspi_get.c index b4572d1..71fd14b 100644 --- a/src/libstddjb/ucspi_get.c +++ b/src/libstddjb/ucspi_get.c @@ -2,11 +2,12 @@ #include <errno.h> #include <string.h> +#include <stdlib.h> #include <skalibs/env.h> char const *ucspi_get (char const *s) { - char const *x = env_get("PROTO") ; + char const *x = getenv("PROTO") ; if (x) { size_t len = strlen(s) ; @@ -14,7 +15,7 @@ char const *ucspi_get (char const *s) char tmp[len + xlen + 1] ; memcpy(tmp, x, xlen) ; memcpy(tmp + xlen, s, len + 1) ; - x = env_get(tmp) ; + x = getenv(tmp) ; if (!x) errno = ENOENT ; } else errno = EINVAL ; |