Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include <headers.h>#include <datatypes.h>#include <options.h>#include <utils.h>
int split_ip( char *text, u8b *dest, int place ){ int dotcount;
/* Don't touch this, unless you like pointer aritmethic */
*dest = 0;
if( !text ) return -1;
for( dotcount = 0; (dotcount < place) && ( text ); text++ ) if( *text == '.' ) dotcount++;
if( !text ) return -2;
while(( *text != '.' ) && ( *text != '\0' )) { *dest *= 10; *dest += (u8b)(*text-48); /* 48 is not a hack, is just the code of 0 */ text++; }
return 0;}
int get_ip( char *text, u32b *dest ){ /* Don't touch this, unless you like pointer aritmethic */
*dest = 0;
if( !text ) return -1;
while( *text != '\0' ) { if( *text == '.' ) { *dest = *dest << 8; text++; continue; } *dest *= 10; *dest += (u8b)(*text-48); /* 48 is not a hack, is just the code of 0 */ text++; }
return 0;}