Geoip: Add geoip_timezone() native.
This commit is contained in:
parent
c11f721ad4
commit
b439753ac5
@ -218,6 +218,18 @@ static cell AMX_NATIVE_CALL amx_geoip_region_name(AMX *amx, cell *params)
|
|||||||
return MF_SetAmxString(amx, params[2], region ? region : "", length >= params[3] ? params[3] : length); // TODO: make this utf8 safe.
|
return MF_SetAmxString(amx, params[2], region ? region : "", length >= params[3] ? params[3] : length); // TODO: make this utf8 safe.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// native geoip_timezone(const ip[], result[], len);
|
||||||
|
static cell AMX_NATIVE_CALL amx_geoip_timezone(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
char *ip = MF_GetAmxString(amx, params[1], 0, &length);
|
||||||
|
|
||||||
|
const char *path[] = { "location", "time_zone", NULL };
|
||||||
|
const char *timezone = lookupByIp(stripPort(ip), path, &length);
|
||||||
|
|
||||||
|
return MF_SetAmxString(amx, params[2], timezone ? timezone : "", length >= params[3] ? params[3] : length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
{
|
{
|
||||||
@ -288,6 +300,8 @@ AMX_NATIVE_INFO geoip_natives[] =
|
|||||||
{ "geoip_region_code", amx_geoip_region_code },
|
{ "geoip_region_code", amx_geoip_region_code },
|
||||||
{ "geoip_region_name", amx_geoip_region_name },
|
{ "geoip_region_name", amx_geoip_region_name },
|
||||||
|
|
||||||
|
{ "geoip_timezone", amx_geoip_timezone },
|
||||||
|
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -121,3 +121,15 @@ native geoip_region_code(const ip[], result[], len);
|
|||||||
* @return The result length on successful lookup, 0 otherwise.
|
* @return The result length on successful lookup, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
native geoip_region_name(const ip[], result[], len);
|
native geoip_region_name(const ip[], result[], len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up the full time zone for the given IP address.
|
||||||
|
* e.g. America/Los_Angeles, Europe/Paris.
|
||||||
|
*
|
||||||
|
* @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_timezone(const ip[], result[], len);
|
Loading…
Reference in New Issue
Block a user