ip4_scan.c (414B)
1 /* ISC license. */ 2 3 #include <skalibs/types.h> 4 #include <skalibs/fmtscan.h> 5 6 size_t ip4_scan (char const *s, char *ip) 7 { 8 size_t len = 0 ; 9 unsigned int j = 0 ; 10 for (; j < 4 ; j++) 11 { 12 unsigned int u ; 13 size_t i = uint_scan(s, &u) ; 14 if (!i) return 0 ; 15 ip[j] = (char)u ; 16 s += i ; 17 len += i ; 18 if (j == 3) break ; 19 if (*s != '.') return 0 ; 20 ++s ; 21 ++len ; 22 } 23 return len ; 24 }