"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/test-geoip-city.c" between
GeoIP-1.6.11.tar.gz and GeoIP-1.6.12.tar.gz

About: GeoIP is a C library that enables the user to find the country that any IP address or hostname originates from (contains an initial free GeoIP Country database).

test-geoip-city.c  (GeoIP-1.6.11):test-geoip-city.c  (GeoIP-1.6.12)
skipping to change at line 18 skipping to change at line 18
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "GeoIP.h" #include "GeoIP.h"
#include "GeoIPCity.h" #include "GeoIPCity.h"
static const char *_mk_NA(const char *p) static const char *_mk_NA(const char *p) { return p ? p : "N/A"; }
{
return p ? p : "N/A";
}
int main(int argc, char *argv[]) int main(int argc, char *argv[]) {
{
FILE *f; FILE *f;
GeoIP *gi; GeoIP *gi;
GeoIPRecord *gir; GeoIPRecord *gir;
char host[50]; char host[50];
const char *time_zone = NULL; const char *time_zone = NULL;
char **ret; char **ret;
gi = GeoIP_open("../data/GeoIPCity.dat", GEOIP_INDEX_CACHE); gi = GeoIP_open("../data/GeoIPCity.dat", GEOIP_INDEX_CACHE);
if (gi == NULL) { if (gi == NULL) {
skipping to change at line 57 skipping to change at line 53
if (f == NULL) { if (f == NULL) {
fprintf(stderr, "Error opening city_test.txt\n"); fprintf(stderr, "Error opening city_test.txt\n");
exit(1); exit(1);
} }
while (fscanf(f, "%s", host) != EOF) { while (fscanf(f, "%s", host) != EOF) {
gir = GeoIP_record_by_name(gi, (const char *)host); gir = GeoIP_record_by_name(gi, (const char *)host);
if (gir != NULL) { if (gir != NULL) {
ret = GeoIP_range_by_ip(gi, (const char *)host); ret = GeoIP_range_by_ip(gi, (const char *)host);
time_zone = time_zone = GeoIP_time_zone_by_country_and_region(gir->country_code,
GeoIP_time_zone_by_country_and_region(gir->country_code, gir->region);
gir->region); printf("%s\t%s\t%s\t%s\t%s\t%s\t%f\t%f\t%d\t%d\t%s\t%s\t%s\n",
printf("%s\t%s\t%s\t%s\t%s\t%s\t%f\t%f\t%d\t%d\t%s\t%s\t%s\n", host, host,
_mk_NA(gir->country_code), _mk_NA(gir->region), _mk_NA(gir->country_code),
_mk_NA(GeoIP_region_name_by_code _mk_NA(gir->region),
(gir->country_code, _mk_NA(GeoIP_region_name_by_code(gir->country_code,
gir->region)), _mk_NA(gir->city), gir->region)),
_mk_NA(gir->postal_code), gir->latitude, gir->longitude, _mk_NA(gir->city),
gir->metro_code, gir->area_code, _mk_NA(time_zone), ret[0], _mk_NA(gir->postal_code),
gir->latitude,
gir->longitude,
gir->metro_code,
gir->area_code,
_mk_NA(time_zone),
ret[0],
ret[1]); ret[1]);
GeoIP_range_by_ip_delete(ret); GeoIP_range_by_ip_delete(ret);
GeoIPRecord_delete(gir); GeoIPRecord_delete(gir);
} }
} }
GeoIP_delete(gi); GeoIP_delete(gi);
fclose(f); fclose(f);
return 0; return 0;
} }
 End of changes. 4 change blocks. 
17 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)