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