19.08.2012, 20:59
Puedes utilizar la funcion de JernejL:
y comparar con los valores obtenidos para evitar el transpaso y comparacion de strcmp que seria algo diferente y menos optimo.
pawn Код:
// please note that this is NOT a perfect inet_aton function, but you will not be able to output the number as a unsigned integer as pawn uses signed int32 only.
// (by specification the returned type of inet_aton should be UNSIGNED int 32)
// example conversion failures:
// 127.0.0.1 -> 2130706433
// 128.68.103.132 -> -2143000700
stock inet_aton(ip[]) {
new ipv = strval(ip) << 24, pos = 0;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]) << 16;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]) << 8;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]);
return ipv;
}