/* Lulz, convert ip_to_int, int_to_ip lulz lulz */ /* copyright jesus, he made this happen u kno????? kthxbai */ #include #include #include /* no.. waiiiii ur kidding me amirite???? */ /** * kk diz random func maeks an string ip into an long.. liek so * random ppl kan ews it u know ^_______^ */ long iptol(char gg[]) { char ip[16], *r; int i = 0; unsigned long ips[4], v = 0; strncpy(ip, gg, 16); /* giggidy giggidy, plx */ r = strtok(ip, "."); /* mudkipz? nothx! ive quit, lawwwwwwls */ while (r != NULL) { v |= (atoi(r) << 8*(3-i)); /* lulz */ r = strtok(NULL, "."); /* fap fap fap */ i++; } return v; /* kthxbai */ } /** * plx diz maeks a long ip into a string loooool >_< * i herd this func leiks mudkipz :o */ char *ltoip(unsigned long ip) { int i, len = 0; char *ip_str = (char*)malloc(18), f[5] = ""; for (i = 3; i >= 0; i--) { /* LOLoop */ sprintf(f, (i==3)?"%d":".%d", (unsigned int)(unsigned char)(ip>>8*i)); strcat(ip_str, f); /* kk. lawls!!!! */ len += strlen(f); } return ip_str; /* oh u o.o */ } int main(int argc, char* argv[]) { printf("%d\n", iptol("100.100.0.5")); printf("%s\n", ltoip(iptol("240.240.255.127"))); return 0; }