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

#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/env.h>

int env_string (stralloc *sa, char const *const *envp, size_t envlen)
{
  size_t salen = sa->len ;
  size_t i = 0 ;
  for (; i < envlen ; i++)
  {
    if (!stralloc_cats(sa, envp[i]) || !stralloc_0(sa))
    {
      sa->len = salen ;
      return 0 ;
    }
  }
  return 1 ;
}