]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
1 | --- getenv.c.bsdnew 2009-11-13 15:14:36.000000000 -0800 |
2 | +++ getenv.c 2009-11-13 15:14:50.000000000 -0800 | |
3 | @@ -36,8 +36,9 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/ | |
9385eb3d A |
4 | #include <stdlib.h> |
5 | #include <stddef.h> | |
6 | #include <string.h> | |
7 | +#include <crt_externs.h> | |
8 | ||
3d9156a7 | 9 | -inline char *__findenv(const char *, int *); |
224c7076 | 10 | +__private_extern__ char *__findenv(const char *, int *, char **); |
9385eb3d | 11 | |
3d9156a7 A |
12 | /* |
13 | * __findenv -- | |
1f2f436a | 14 | @@ -48,12 +49,12 @@ inline char *__findenv(const char *, int |
224c7076 A |
15 | * |
16 | * This routine *should* be a static; don't use it. | |
17 | */ | |
18 | -inline char * | |
19 | -__findenv(name, offset) | |
20 | +__private_extern__ char * | |
21 | +__findenv(name, offset, environ) | |
9385eb3d A |
22 | const char *name; |
23 | int *offset; | |
224c7076 | 24 | + char **environ; |
9385eb3d A |
25 | { |
26 | - extern char **environ; | |
9385eb3d A |
27 | int len, i; |
28 | const char *np; | |
29 | char **p, *cp; | |
1f2f436a | 30 | @@ -76,6 +77,19 @@ __findenv(name, offset) |
224c7076 A |
31 | } |
32 | ||
33 | /* | |
34 | + * _getenvp -- SPI using an arbitrary pointer to string array (the array must | |
35 | + * have been created with malloc) and an env state, created by _allocenvstate(). | |
36 | + * Returns ptr to value associated with name, if any, else NULL. | |
37 | + */ | |
38 | +char * | |
39 | +_getenvp(const char *name, char ***envp, void *state __unused) | |
40 | +{ | |
41 | + int offset; | |
42 | + | |
43 | + return (__findenv(name, &offset, *envp)); | |
44 | +} | |
45 | + | |
46 | +/* | |
47 | * getenv -- | |
48 | * Returns ptr to value associated with name, if any, else NULL. | |
49 | */ | |
1f2f436a | 50 | @@ -85,5 +99,5 @@ getenv(name) |
224c7076 A |
51 | { |
52 | int offset; | |
53 | ||
54 | - return (__findenv(name, &offset)); | |
55 | + return (__findenv(name, &offset, *_NSGetEnviron())); | |
56 | } |