#define _10_IN_ADDR_ARPA "10.in-addr.arpa" #define _168_IN_ADDR_ARPA "168.192.in-addr.arpa" #define _10_LEN 15 #define _168_LEN 20 uint8_t octs[4]; char conv_host[15]; bzero(conv_host, sizeof(conv_host)); if(!memcmp(zone + strlen(zone) - _10_LEN, _10_IN_ADDR_ARPA, _10_LEN)) { if(sscanf(zone, "%hhu.%hhu.%hhu.%hhu.", &octs[0], &octs[1], &octs[2], &octs[3]) == 4) { sprintf(conv_host, "%hhu.%hhu.%hhu", octs[0], octs[1], octs[2]); record = conv_host; zone = _10_IN_ADDR_ARPA; } } else if(!memcmp(zone + strlen(zone) - _168_LEN, _168_IN_ADDR_ARPA, _168_LEN)) { if(sscanf(zone, "%hhu.%hhu.%hhu.%hhu.", &octs[0], &octs[1], &octs[2], &octs[3]) == 4) { sprintf(conv_host, "%hhu.%hhu", octs[0], octs[1]); record = conv_host; zone = _168_IN_ADDR_ARPA; } }