/* 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 ^_______^ */ unsigned long iptol(char gg[]) { char ip[16]; int i = 0; unsigned long v = 0; strncpy(ip, gg, 16); /* giggidy giggidy, plx */ char *r = strtok(ip, "."); /* mudkipz? nothx! ive quit, lawwwwwwls */ while (r) { v |= (atoi(r) << 8*(3-i++)); /* lulz */ r = strtok(NULL, "."); /* fap fap fap */ } 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 = 4; char *ip_str = (char*)malloc(18), f[5] = ""; while (i--) { /* LOLoop */ sprintf(f, (i==3)?"%d":".%d", (unsigned int)(unsigned char)(ip>>8*i)); strcat(ip_str, f); /* kk. lawls!!!! */ } return ip_str; /* oh u o.o */ } /** * no u. dis is ma codes u cant have any goawai */ 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; }