blob: b4572d16b40a9e1cf6ffb153d3d2bd4083d3e7b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* ISC license. */
#include <errno.h>
#include <string.h>
#include <skalibs/env.h>
char const *ucspi_get (char const *s)
{
char const *x = env_get("PROTO") ;
if (x)
{
size_t len = strlen(s) ;
size_t xlen = strlen(x) ;
char tmp[len + xlen + 1] ;
memcpy(tmp, x, xlen) ;
memcpy(tmp + xlen, s, len + 1) ;
x = env_get(tmp) ;
if (!x) errno = ENOENT ;
}
else errno = EINVAL ;
return x ;
}
|