bump version to 1.0.28
[uclibc-ng.git] / libc / stdlib / getenv.c
blob9b04d0fabf5401ec1395758a07c4bfff9be260c7
1 /* getenv.c for uClibc
2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 #include <string.h>
8 #include <unistd.h>
9 #include <stdlib.h>
12 /* IEEE Std 1003.1-2001 says getenv need not be thread safe, so
13 * don't bother locking access to __environ */
14 char *getenv(const char *var)
16 int len;
17 char **ep;
19 if (!(ep=__environ))
20 return NULL;
21 len = strlen(var);
22 while(*ep) {
23 if (memcmp(var, *ep, len) == 0 && (*ep)[len] == '=') {
24 return *ep + len + 1;
26 ep++;
28 return NULL;
30 libc_hidden_weak(getenv)