"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/bad_databases_t.c" between
libmaxminddb-1.5.0.tar.gz and libmaxminddb-1.5.2.tar.gz

About: libmaxminddb is a library that provides functions for working with MaxMind DB files (free GeoLite 2 or commercial GeoIP2).

bad_databases_t.c  (libmaxminddb-1.5.0):bad_databases_t.c  (libmaxminddb-1.5.2)
// This test currently does not work on Windows as nftw is // This test currently does not work on Windows as nftw is
// not available. // not available.
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 500
#include <ftw.h> #include <ftw.h>
#include <libgen.h> #include <libgen.h>
#include <unistd.h> #include <unistd.h>
#include "maxminddb_test_helper.h" #include "maxminddb_test_helper.h"
int test_read(const char *path, const struct stat *UNUSED( int test_read(const char *path,
sbuf), int flags, struct FTW *UNUSED(ftw)) const struct stat *UNUSED(sbuf),
{ int flags,
struct FTW *UNUSED(ftw)) {
// Check if path is a regular file) // Check if path is a regular file)
if (flags != FTW_F) { if (flags != FTW_F) {
return 0; return 0;
} }
MMDB_s *mmdb = (MMDB_s *)calloc(1, sizeof(MMDB_s)); MMDB_s *mmdb = (MMDB_s *)calloc(1, sizeof(MMDB_s));
if (NULL == mmdb) { if (NULL == mmdb) {
BAIL_OUT("could not allocate memory for our MMDB_s struct"); BAIL_OUT("could not allocate memory for our MMDB_s struct");
} }
skipping to change at line 39 skipping to change at line 40
free(mmdb); free(mmdb);
return 0; return 0;
} }
int gai_error, mmdb_error; int gai_error, mmdb_error;
MMDB_lookup_string(mmdb, "1.1.1.1", &gai_error, &mmdb_error); MMDB_lookup_string(mmdb, "1.1.1.1", &gai_error, &mmdb_error);
if (gai_error != 0) { if (gai_error != 0) {
BAIL_OUT("could not parse IP address"); BAIL_OUT("could not parse IP address");
} }
cmp_ok(mmdb_error, "!=", MMDB_SUCCESS, "opening %s returned an error", cmp_ok(
path); mmdb_error, "!=", MMDB_SUCCESS, "opening %s returned an error", path);
MMDB_close(mmdb); MMDB_close(mmdb);
free(mmdb); free(mmdb);
return 0; return 0;
} }
int main(void) int main(void) {
{
char *test_db_dir; char *test_db_dir;
#ifdef _WIN32 #ifdef _WIN32
test_db_dir = "../t/maxmind-db/bad-data"; test_db_dir = "../t/maxmind-db/bad-data";
#else #else
char cwd[500]; char cwd[500];
char *UNUSED(tmp) = getcwd(cwd, 500); char *UNUSED(tmp) = getcwd(cwd, 500);
if (strcmp(basename(cwd), "t") == 0) { if (strcmp(basename(cwd), "t") == 0) {
test_db_dir = "./maxmind-db/bad-data"; test_db_dir = "./maxmind-db/bad-data";
} else { } else {
 End of changes. 3 change blocks. 
7 lines changed or deleted 7 lines changed or added

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