about summary refs log tree commit diff
path: root/src/libenvexec/env_addmodif.c
blob: ddd1be34c4007d9229a06abbd541419a09880e08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

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

int env_addmodif (stralloc *sa, char const *s, char const *t)
{
  size_t oldlen = sa->len ;
  if (!s) return 1 ;
  if (!stralloc_cats(sa, s)) return 0 ;
  if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t)))
   || !stralloc_0(sa))
  {
    sa->len = oldlen ;
    return 0 ;
  }
  return 1 ;
}