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

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

char const *env_get2 (char const *const *envp, char const *s)
{
  size_t len, i ;
  if (!s) return 0 ;
  len = strlen(s) ;
  for (i = 0 ; envp[i] ; ++i)
    if (str_start(envp[i], s)
     && (envp[i][len] == '='))
      return envp[i] + len + 1 ;
  return 0 ;
}