@@ -91,7 +91,7 @@ static PyObject * GeoIP_country_code_by_name_v6_Py(PyObject *self, PyObject *arg
91
91
return NULL ;
92
92
}
93
93
retval = GeoIP_country_code_by_name_v6 (GeoIP -> gi , name );
94
- return Py_BuildValue ("s" , retval );
94
+ return Py_BuildValue ("s" , retval );
95
95
}
96
96
97
97
static PyObject * GeoIP_country_name_by_name_v6_Py (PyObject * self , PyObject * args ) {
@@ -119,12 +119,14 @@ static PyObject * GeoIP_country_code_by_addr_v6_Py(PyObject *self, PyObject *arg
119
119
static PyObject * GeoIP_country_name_by_addr_v6_Py (PyObject * self , PyObject * args ) {
120
120
char * name ;
121
121
const char * retval ;
122
+ PyObject * ret ;
122
123
GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
123
124
if (!PyArg_ParseTuple (args , "s" , & name )) {
124
125
return NULL ;
125
126
}
126
127
retval = GeoIP_country_name_by_addr_v6 (GeoIP -> gi , name );
127
- return Py_BuildValue ("s" , retval );
128
+ ret = Py_BuildValue ("s" , retval );
129
+ return ret ;
128
130
}
129
131
130
132
static PyObject * GeoIP_country_code_by_name_Py (PyObject * self , PyObject * args ) {
@@ -199,6 +201,28 @@ static PyObject * GeoIP_org_by_name_Py(PyObject *self, PyObject *args) {
199
201
return ret ;
200
202
}
201
203
204
+ static PyObject * GeoIP_id_by_addr_Py (PyObject * self , PyObject * args ) {
205
+ char * name ;
206
+ int i ;
207
+ GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
208
+ if (!PyArg_ParseTuple (args , "s" , & name )) {
209
+ return NULL ;
210
+ }
211
+ i = GeoIP_id_by_addr (GeoIP -> gi , name );
212
+ return Py_BuildValue ("i" , i );
213
+ }
214
+
215
+ static PyObject * GeoIP_id_by_name_Py (PyObject * self , PyObject * args ) {
216
+ char * name ;
217
+ int i ;
218
+ GeoIP_GeoIPObject * GeoIP = (GeoIP_GeoIPObject * )self ;
219
+ if (!PyArg_ParseTuple (args , "s" , & name )) {
220
+ return NULL ;
221
+ }
222
+ i = GeoIP_id_by_name (GeoIP -> gi , name );
223
+ return Py_BuildValue ("i" , i );
224
+ }
225
+
202
226
void GeoIP_SetItemString (PyObject * dict , const char * name , const char * value ) {
203
227
PyObject * nameObj ;
204
228
PyObject * valueObj ;
@@ -229,6 +253,30 @@ void GeoIP_SetItemInt(PyObject *dict, const char * name, int value) {
229
253
Py_DECREF (valueObj );
230
254
}
231
255
256
+ void GeoIP_SetConfItemInt (PyObject * dict , const char * name , int value ) {
257
+ PyObject * nameObj ;
258
+ PyObject * valueObj ;
259
+ nameObj = Py_BuildValue ("s" ,name );
260
+ valueObj = value == GEOIP_UNKNOWN_CONF
261
+ ? Py_BuildValue ("" )
262
+ : Py_BuildValue ("i" ,value );
263
+ PyDict_SetItem (dict ,nameObj ,valueObj );
264
+ Py_DECREF (nameObj );
265
+ Py_DECREF (valueObj );
266
+ }
267
+
268
+ void GeoIP_SetAccuracyItemInt (PyObject * dict , const char * name , int value ) {
269
+ PyObject * nameObj ;
270
+ PyObject * valueObj ;
271
+ nameObj = Py_BuildValue ("s" ,name );
272
+ valueObj = value == GEOIP_UNKNOWN_ACCURACY_RADIUS
273
+ ? Py_BuildValue ("" )
274
+ : Py_BuildValue ("i" ,value );
275
+ PyDict_SetItem (dict ,nameObj ,valueObj );
276
+ Py_DECREF (nameObj );
277
+ Py_DECREF (valueObj );
278
+ }
279
+
232
280
static PyObject * GeoIP_region_populate_dict (GeoIPRegion * gir ) {
233
281
PyObject * retval ;
234
282
const char * region_name = NULL ;
@@ -268,6 +316,14 @@ static PyObject * GeoIP_populate_dict(GeoIPRecord *gir) {
268
316
GeoIP_region_name_by_code (gir -> country_code , gir -> region ));
269
317
GeoIP_SetItemString (retval , "time_zone" ,
270
318
GeoIP_time_zone_by_country_and_region (gir -> country_code , gir -> region ));
319
+
320
+ GeoIP_SetConfItemInt (retval , "country_conf" , gir -> country_conf );
321
+ GeoIP_SetConfItemInt (retval , "region_conf" , gir -> region_conf );
322
+ GeoIP_SetConfItemInt (retval , "city_conf" , gir -> city_conf );
323
+ GeoIP_SetConfItemInt (retval , "postal_conf" , gir -> postal_conf );
324
+
325
+ GeoIP_SetAccuracyItemInt (retval , "accuracy_radius" , gir -> accuracy_radius );
326
+
271
327
GeoIPRecord_delete (gir );
272
328
return retval ;
273
329
}
@@ -391,6 +447,8 @@ static PyMethodDef GeoIP_Object_methods[] = {
391
447
{"country_name_by_name_v6" , GeoIP_country_name_by_name_v6_Py , 1 , "Lookup IPv6 Country Name By Name" },
392
448
{"country_code_by_addr_v6" , GeoIP_country_code_by_addr_v6_Py , 1 , "Lookup IPv6 Country Code By IP Address" },
393
449
{"country_name_by_addr_v6" , GeoIP_country_name_by_addr_v6_Py , 1 , "Lookup IPv6 Country Name By IP Address" },
450
+ {"id_by_addr" , GeoIP_id_by_addr_Py , 1 , "Lookup Netspeed By IP Address" },
451
+ {"id_by_name" , GeoIP_id_by_name_Py , 1 , "Lookup Netspeed By Name" },
394
452
{NULL , NULL , 0 , NULL }
395
453
};
396
454
@@ -501,4 +559,19 @@ initGeoIP(void)
501
559
PyDict_SetItemString (d , "GEOIP_CHARSET_UTF8" , tmp );
502
560
Py_DECREF (tmp );
503
561
562
+ tmp = PyInt_FromLong (GEOIP_UNKNOWN_SPEED );
563
+ PyDict_SetItemString (d , "GEOIP_UNKNOWN_SPEED" , tmp );
564
+ Py_DECREF (tmp );
565
+
566
+ tmp = PyInt_FromLong (GEOIP_DIALUP_SPEED );
567
+ PyDict_SetItemString (d , "GEOIP_DIALUP_SPEED" , tmp );
568
+ Py_DECREF (tmp );
569
+
570
+ tmp = PyInt_FromLong (GEOIP_CABLEDSL_SPEED );
571
+ PyDict_SetItemString (d , "GEOIP_CABLEDSL_SPEED" , tmp );
572
+ Py_DECREF (tmp );
573
+
574
+ tmp = PyInt_FromLong (GEOIP_CORPORATE_SPEED );
575
+ PyDict_SetItemString (d , "GEOIP_CORPORATE_SPEED" , tmp );
576
+ Py_DECREF (tmp );
504
577
}
0 commit comments