@@ -129,7 +129,7 @@ static PyObject * GeoIP_country_name_by_addr_Py(PyObject *self, PyObject *args)
129
129
130
130
static PyObject * GeoIP_org_by_addr_Py (PyObject * self , PyObject * args ) {
131
131
char * name ;
132
- const char * org ;
132
+ char * org ;
133
133
PyObject * ret ;
134
134
GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
135
135
if (!PyArg_ParseTuple (args , "s" , & name )) {
@@ -143,7 +143,7 @@ static PyObject * GeoIP_org_by_addr_Py(PyObject *self, PyObject *args) {
143
143
144
144
static PyObject * GeoIP_org_by_name_Py (PyObject * self , PyObject * args ) {
145
145
char * name ;
146
- const char * org ;
146
+ char * org ;
147
147
PyObject * ret ;
148
148
GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
149
149
if (!PyArg_ParseTuple (args , "s" , & name )) {
@@ -308,6 +308,26 @@ static PyObject * GeoIP_range_by_ip_Py(PyObject *self, PyObject *args) {
308
308
return retval ;
309
309
}
310
310
311
+ static PyObject * GeoIP_charset_Py (PyObject * self , PyObject * args ) {
312
+ GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
313
+ return Py_BuildValue ("i" , GeoIP_charset (GeoIP -> gi ) );
314
+ }
315
+
316
+ static PyObject * GeoIP_set_charset_Py (PyObject * self , PyObject * args ) {
317
+ GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
318
+ int charset ;
319
+ if (!PyArg_ParseTuple (args , "i" , & charset )) {
320
+ return NULL ;
321
+ }
322
+ return Py_BuildValue ("i" , GeoIP_set_charset (GeoIP -> gi , charset ));
323
+
324
+ }
325
+
326
+ static PyObject * GeoIP_last_netmask_Py (PyObject * self , PyObject * args ) {
327
+ GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
328
+ return Py_BuildValue ("i" , GeoIP_last_netmask (GeoIP -> gi ) );
329
+ }
330
+
311
331
static PyMethodDef GeoIP_Object_methods [] = {
312
332
{"country_code_by_name" , GeoIP_country_code_by_name_Py , 1 , "Lookup Country Code By Name" },
313
333
{"country_name_by_name" , GeoIP_country_name_by_name_Py , 1 , "Lookup Country Name By Name" },
@@ -320,6 +340,9 @@ static PyMethodDef GeoIP_Object_methods[] = {
320
340
{"record_by_addr" , GeoIP_record_by_addr_Py , 1 , "Lookup City Region By IP Address" },
321
341
{"record_by_name" , GeoIP_record_by_name_Py , 1 , "Lookup City Region By Name" },
322
342
{"range_by_ip" , GeoIP_range_by_ip_Py , 1 , "Lookup start and end IP's for a given IP" },
343
+ {"charset" , GeoIP_charset_Py , 1 , "Return the current charset ( either GEOIP_CHARSET_ISO_8859_1 or GEOIP_CHARSET_UTF8 )" },
344
+ {"set_charset" , GeoIP_set_charset_Py , 1 , "Set the charset for city records" },
345
+ {"last_netmask" , GeoIP_last_netmask_Py , 1 , "return the netmask depth of the last lookup" },
323
346
{NULL , NULL , 0 , NULL }
324
347
};
325
348
@@ -421,4 +444,13 @@ initGeoIP(void)
421
444
tmp = PyInt_FromLong (GEOIP_INDEX_CACHE );
422
445
PyDict_SetItemString (d , "GEOIP_INDEX_CACHE" , tmp );
423
446
Py_DECREF (tmp );
447
+
448
+ tmp = PyInt_FromLong (GEOIP_CHARSET_ISO_8859_1 );
449
+ PyDict_SetItemString (d , "GEOIP_CHARSET_ISO_8859_1" , tmp );
450
+ Py_DECREF (tmp );
451
+
452
+ tmp = PyInt_FromLong (GEOIP_CHARSET_UTF8 );
453
+ PyDict_SetItemString (d , "GEOIP_CHARSET_UTF8" , tmp );
454
+ Py_DECREF (tmp );
455
+
424
456
}
0 commit comments