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

#include <stdint.h>
#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 ;
}