// // based on source code from http://www.ols.es/exim/dlext/ by David Saez // #include "local_scan.h" #include #include #include static GeoIP *gi=NULL; int ip2country(uschar **yield, int argc, uschar *argv[]) { uschar *s; if (argc != 1) { *yield = string_copy((uschar *)"Bad number of arguments"); return ERROR; } if (!gi) { gi = GeoIP_new(GEOIP_STANDARD); if (!gi) { *yield = string_copy((uschar *)"Cannot initialize GeoIP"); return ERROR; } } s = (uschar *)GeoIP_country_code_by_addr(gi, (char *)argv[0]); if (!s) { *yield = string_copy((uschar *)"--"); } else { *yield = string_copy(s); } return OK; }