examples/zolertia/tutorial/99-apps/mqtt-node/internals/mqtt-res.c
static int
ipaddr_sprintf(char *buf, uint8_t buf_len, const uip_ipaddr_t *addr)
{
  uint16_t a;
  uint8_t len = 0;
  int i, f;
  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
    a = (addr->u8[i] << 8) + addr->u8[i + 1];
    if(a == 0 && f >= 0) {
      if(f++ == 0) {
        len += snprintf(&buf[len], buf_len - len, "::");
      }
    } else {
      if(f > 0) {
        f = -1;
      } else if(i > 0) {
        len += snprintf(&buf[len], buf_len - len, ":");
      }
      len += snprintf(&buf[len], buf_len - len, "%x", a);
    }
  }

  return len;
}
/*---------------------------------------------------------------------------*/
/* Converts the IPv6 address to string */
Converts the IPv6 address to string
Converts the IPv6 address to string
static int
ipaddr_sprintf(char *buf, uint8_t buf_len, const uip_ipaddr_t *addr)
{
  uint16_t a;
  uint8_t len = 0;
  int i, f;
  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
    a = (addr->u8[i] << 8) + addr->u8[i + 1];
    if(a == 0 && f >= 0) {
      if(f++ == 0) {
        len += snprintf(&buf[len], buf_len - len, "::");
      }
    } else {
      if(f > 0) {
        f = -1;
      } else if(i > 0) {
        len += snprintf(&buf[len], buf_len - len, ":");
      }
      len += snprintf(&buf[len], buf_len - len, "%x", a);
    }
  }
  return len;
}
static int ipaddr_sprintf ( char * buf , uint8_t buf_len , const uip_ipaddr_t * addr ) { uint16_t a ; uint8_t len = 0 ; int i , f ; for ( i = 0 , f = 0 ; i < sizeof ( uip_ipaddr_t ) ; i += 2 ) { a = ( addr -> u8 [ i ] << 8 ) + addr -> u8 [ i + 1 ] ; if ( a == 0 && f >= 0 ) { if ( f ++ == 0 ) { len += snprintf ( & buf [ len ] , buf_len - len , " " ) ; } } else { if ( f > 0 ) { f = -1 ; } else if ( i > 0 ) { len += snprintf ( & buf [ len ] , buf_len - len , " " ) ; } len += snprintf ( & buf [ len ] , buf_len - len , " " , a ) ; } } return len ; }
Converts the IPv6 address to string
Converts the IPv6 address to string