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

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

size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num)
{
  size_t n = 0, w = 0 ;
  for (; s[w] && (n < max) ; n++)
  {
    size_t i = ip4_scanu32(s + w, out + n) ;
    if (!i) break ;
    w += i ;
    while (memchr(",:; \t\r\n", s[w], 7)) w++ ;
  }
  *num = n ;
  return w ;
}