Geoip: Add geoip_continent_name() native.
This commit is contained in:
parent
fc19f53ea9
commit
abaee9f4a3
@ -340,6 +340,18 @@ static cell AMX_NATIVE_CALL amx_geoip_continent_code(AMX *amx, cell *params)
|
|||||||
return getContinentId(code);
|
return getContinentId(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// native geoip_continent_name(const ip[], result[], len);
|
||||||
|
static cell AMX_NATIVE_CALL amx_geoip_continent_name(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
char *ip = MF_GetAmxString(amx, params[1], 0, &length);
|
||||||
|
|
||||||
|
const char *path[] = { "continent", "names", "en", NULL };
|
||||||
|
const char *continent = lookupString(stripPort(ip), path, &length);
|
||||||
|
|
||||||
|
return MF_SetAmxString(amx, params[2], continent ? continent : "", length >= params[3] ? params[3] : length); // TODO: make this utf8 safe.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
{
|
{
|
||||||
@ -416,6 +428,7 @@ AMX_NATIVE_INFO geoip_natives[] =
|
|||||||
{ "geoip_distance" , amx_geoip_distance },
|
{ "geoip_distance" , amx_geoip_distance },
|
||||||
|
|
||||||
{ "geoip_continent_code", amx_geoip_continent_code },
|
{ "geoip_continent_code", amx_geoip_continent_code },
|
||||||
|
{ "geoip_continent_name", amx_geoip_continent_name },
|
||||||
|
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
@ -190,4 +190,15 @@ enum Continent
|
|||||||
CONTINENT_OCEANIA,
|
CONTINENT_OCEANIA,
|
||||||
CONTINENT_SOUTH_AMERICA
|
CONTINENT_SOUTH_AMERICA
|
||||||
};
|
};
|
||||||
native Continent:geoip_continent_code(const ip[], result[3]);
|
native Continent:geoip_continent_code(const ip[], result[3]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up the full continent name for the given IP address.
|
||||||
|
*
|
||||||
|
* @param ip The IP address to look up.
|
||||||
|
* @param result The result of the geoip look up.
|
||||||
|
* @param len The maximum length of the result buffer.
|
||||||
|
*
|
||||||
|
* @return The result length on successful lookup, 0 otherwise.
|
||||||
|
*/
|
||||||
|
native geoip_continent_name(const ip[], result[], len);
|
||||||
|
Loading…
Reference in New Issue
Block a user