aboutsummaryrefslogtreecommitdiff
path: root/ip4_fmt.c
blob: bbad4c75bd061386be7890eb895fd682f401125e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "fmt.h"
#include "ip4.h"

unsigned int ip4_fmt(char *s,const char ip[4])
{
  unsigned int len;
  unsigned int i;
 
  len = 0;
  i = fmt_ulong(s,(unsigned long) (unsigned char) ip[0]); len += i; if (s) s += i;
  if (s) *s++ = '.'; ++len;
  i = fmt_ulong(s,(unsigned long) (unsigned char) ip[1]); len += i; if (s) s += i;
  if (s) *s++ = '.'; ++len;
  i = fmt_ulong(s,(unsigned long) (unsigned char) ip[2]); len += i; if (s) s += i;
  if (s) *s++ = '.'; ++len;
  i = fmt_ulong(s,(unsigned long) (unsigned char) ip[3]); len += i; if (s) s += i;
  return len;
}