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

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

int env_make (char const **v, unsigned int argc, char const *s, unsigned int len)
{
  while (argc--)
  {
    register unsigned int n = str_len(s) + 1 ;
    if (n > len) return (errno = EINVAL, 0) ;
    *v++ = s ; s += n ; len -= n ;
  }
  return 1 ;
}