From 64bc6412188b141c010ac3b8e813b837dd991e80 Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Sun, 14 May 2000 04:16:35 +0000 Subject: Initial revision --- libc/stdlib/getenv.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 libc/stdlib/getenv.c (limited to 'libc/stdlib/getenv.c') 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 + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include +#include +#include + +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; +} + + -- cgit v1.2.3