blob: 6e18cd46c0ab3f43de727f0a653f6ce7d033436b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* ISC license. */
#include <errno.h>
#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <skalibs/stralloc.h>
#include <bcnm/wpactrl.h>
size_t wpactrl_flags_scan (char const *t, stralloc *sa)
{
size_t sabase = sa->len ;
int wasnull = !sa->s ;
char const *s = t ;
while (*s == '[')
{
size_t pos ;
s++;
pos = str_chr(s, ']') ;
if (!s[pos]) goto eproto ;
if (!stralloc_catb(sa, s, pos) || !stralloc_0(sa)) goto err ;
s += pos + 1 ;
}
return s - t ;
eproto:
errno = EPROTO ;
err:
if (wasnull) stralloc_free(sa) ;
else sa->len = sabase ;
return 0 ;
}
|