title: expand an IPv6 address so I can print it to stdout
body: <p>I am using getifaddrs() and inet_ntop() to get the ip addresses on the system. When the system is set to IPv6 the address returned is in the shortened version (using :: for zeros). Is there any way to expand that address to a full one?</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>struct ifaddrs *myaddrs, *ifa;
  void *in_addr;
  char buf[64];
  
  if(getifaddrs(&amp;myaddrs) != 0)
  {
      perror("getifaddrs");
      exit(1);
  }
  
  for (ifa = myaddrs; ifa != NULL; ifa = ifa-&gt;ifa_next)
  {
      if (ifa-&gt;ifa_addr == NULL)
          continue;
      if (!(ifa-&gt;ifa_flags &amp; IFF_UP))
          continue;
  
      switch (ifa-&gt;ifa_addr-&gt;sa_family)
      {
          case AF_INET:
          {
              struct sockaddr_in *s4 = (struct sockaddr_in *)ifa-&gt;ifa_addr;
              in_addr = &amp;s4-&gt;sin_addr;
              break;
          }
  
          case AF_INET6:
          {
              struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)ifa-&gt;ifa_addr;
              in_addr = &amp;s6-&gt;sin6_addr;
              break;
          }
  
          default:
              continue;
      }
  
      if (!inet_ntop(ifa-&gt;ifa_addr-&gt;sa_family, in_addr, buf, sizeof(buf)))
      {
          printf("%s: inet_ntop failed!\n", ifa-&gt;ifa_name);
      }
      else
      {
          printf("IP address: %s\n", buf);
      }
  }
  
  freeifaddrs(myaddrs);
  </code></pre>
  
  <p>Code is greatly appreciated.</p>
  
  <p>EDIT:<br>
  Since this is apparently very hard to comprehend I will give you an example:</p>
  
  <p>If I get abcd:12::3 I need to expand it to abcd:0012:0000:0000:0000:0000:0000:0003<br>
  The reason? because it's part of the requirements. Simple as that.</p>