summaryrefslogtreecommitdiff
path: root/src/libstddjb/env_get2.c
blob: 612cf6a5073b2d8442861ef3683a721af8214512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <skalibs/bytestr.h>
#include <skalibs/env.h>

char const *env_get2 (char const *const *envp, char const *s)
{
  unsigned int i ;
  unsigned int len ;

  if (!s) return 0 ;
  len = str_len(s) ;
  for (i = 0 ; envp[i] ; ++i)
    if (str_start(envp[i], s)
     && (envp[i][len] == '='))
      return envp[i] + len + 1 ;
  return 0 ;
}