diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-05-14 04:16:35 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-05-14 04:16:35 +0000 |
commit | 64bc6412188b141c010ac3b8e813b837dd991e80 (patch) | |
tree | ffa12b79ea4b13191754f54b872eb1a4f9e3a04b /libc/stdlib/getenv.c |
Initial revision
Diffstat (limited to 'libc/stdlib/getenv.c')
-rw-r--r-- | libc/stdlib/getenv.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libc/stdlib/getenv.c b/libc/stdlib/getenv.c new file mode 100644 index 000000000..1ed83a622 --- /dev/null +++ b/libc/stdlib/getenv.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include <string.h> +#include <stdlib.h> +#include <malloc.h> + +extern char ** environ; + +char * +getenv(var) +const char * var; +{ + char **p; + int len; + + len = strlen(var); + + if (!environ) + return 0; + + for(p=environ; *p; p++) + { + if( memcmp(var, *p, len) == 0 && (*p)[len] == '=' ) + return *p + len + 1; + } + return 0; +} + + |