07.02.2011, 18:26
Quote:
He spelled correctly, unlike you.
Bold = typo Italic = bad forumlated sentence. But let's not go to far into grammar. |
Oh and let's not even bring up the badly formulated sentence!
Anyways,
I might aswell share these functions I wrote a while back.
pawn Код:
// Macro to create a numeric IP; ex: MAKE_NUMERIC_IP(127,0,0,1)
#define MAKE_NUMERIC_IP(%0,%1,%2,%3) \
( ( ( ( %0 ) << 24 ) | ( ( %1 ) << 16 ) | ( ( %2 ) << 8 ) ) | ( %3 ) )
stock GetNumericIP( const szIP[ ] ) // Converts a dot-decimal notated IP into a numeric representation.
{
new
aiOctets[ 4 ]
;
sscanf( szIP, "p<.>a<i>[4]", aiOctets );
return ( ( aiOctets[ 0 ] << 24 ) | ( aiOctets[ 1 ] << 16 ) | ( aiOctets[ 2 ] << 8 ) ) | aiOctets[ 3 ];
}
stock GetDotDecimalIP( iIP ) // Converts a numeric IP into a dot-decimal notation.
{
new
szBuffer[ 16 ]
;
format(
szBuffer,
sizeof( szBuffer ),
"%d.%d.%d.%d",
( iIP & ( 255 << 24 ) ) >>> 24,
( iIP & ( 255 << 16 ) ) >>> 16,
( iIP & ( 255 << 8 ) ) >>> 8,
( iIP & ( 255 ) )
);
return szBuffer;
}