DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
IP2Location C Library
IP2Location C Library enables the user to find the Country, Region, City, Latitude, Longitude, ZIP code, Time Zone, ISP, Domain name, Connection type, Area code and Weather station code of the location that any IP address or hostname originates from. This API is meant to allow easy integration between your program written in C language and the IP2Location Binary (.BIN) data file. Free download the code and data file at http://www.ip2location.com/download/C-IP2Location-3.0.0.tar.gz . It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Locationâ„¢ binary databases for applications written in C or supporting static/dynamic library. Get more geolocation information at http://www.ip2location.com .
#include <IP2Location.h> IP2Location *IP2LocationObj = IP2Location_open("../data/IP-COUNTRY-SAMPLE.BIN"); IP2LocationRecord *record = IP2Location_get_all(IP2LocationObj, "126.96.36.199"); printf("%s %s %s %s %s %f %f %s %s %s %s\n, record->country_short, record->country_long, record->region, record->city, record->isp, record->latitude, record->longitude, record->domain, record->zipcode, record->timezone, record->netspeed, record->iddcode, record->areacode, record->weatherstationcode, record->weatherstationname); IP2Location_free_record(record); IP2Location_close(IP2LocationObj);