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

#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>

unsigned int ip6_scanlist (char *out, unsigned int max, char const *s, unsigned int *num)
{
  unsigned int n = 0, w = 0 ;
  for (; s[w] && (n < max) ; n++)
  {
    char ip[16] ;
    register unsigned int i = ip6_scan(s + w, ip) ;
    if (!i) break ;
    byte_copy(out + (n << 4), 16, ip) ;
    w += i ;
    while (byte_chr(",; \t\r\n", 6, s[w]) < 6) w++ ;
  }
  *num = n ;
  return w ;
}