summaryrefslogtreecommitdiff
path: root/klibc/klibc/getenv.c
blob: 84fc94c00e2f4d9cd11afca25943441a180af99d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * getenv.c
 */

#include <stdlib.h>
#include <string.h>
#include <unistd.h>

char *getenv(const char *name)
{
  char **p, *q;
  int len = strlen(name);

  for ( p = environ ; (q = *p) ; p++ ) {
    if ( !strncmp(name, q, len) && q[len] == '=' ) {
      return q+(len+1);
    }
  }

  return NULL;
}