1 #define PERL_NO_GET_CONTEXT
11 #include <loc/libloc.h>
12 #include <loc/database.h>
13 #include <loc/network.h>
16 MODULE = Location PACKAGE = Location
30 FILE* f = fopen(file, "r");
32 croak("Could not open file for reading: %s\n", file);
35 struct loc_database *db;
36 err = loc_database_new(ctx, &db, f);
38 croak("Could not open database: %s\n", file);
46 get_country_code(db, address)
47 struct loc_database *db;
52 const char * country_code;
54 struct loc_network *network;
55 err = loc_database_lookup_from_string(db, address, &network);
57 croak("Could not look up for %s\n", address);
60 country_code = loc_network_get_country_code(network);
62 loc_network_unref(network);
65 croak("Could not get the country code\n");
68 RETVAL = strdup(country_code);
75 database_get_vendor(db)
76 struct loc_database *db;
81 vendor = loc_database_get_vendor(db);
84 croak("Could not retrieve vendor\n");
87 RETVAL = strdup(vendor);
93 struct loc_database *db ;
95 loc_database_unref(db);