1 #define PERL_NO_GET_CONTEXT
10 #include <loc/libloc.h>
11 #include <loc/database.h>
12 #include <loc/network.h>
15 MODULE = Location PACKAGE = Location
29 FILE* f = fopen(file, "r");
31 croak("Could not open file for reading: %s\n", file);
34 struct loc_database *db;
35 err = loc_database_new(ctx, &db, f);
37 croak("Could not open database: %s\n", file);
45 get_country_code(db, address)
46 struct loc_database *db;
51 const char * country_code;
53 struct loc_network *network;
54 err = loc_database_lookup_from_string(db, address, &network);
56 croak("Could not look up for %s\n", address);
59 country_code = loc_network_get_country_code(network);
61 loc_network_unref(network);
64 croak("Could not get the country code\n");
67 RETVAL = strdup(country_code);
74 database_get_vendor(db)
75 struct loc_database *db;
80 vendor = loc_database_get_vendor(db);
83 croak("Could not retrieve vendor\n");
86 RETVAL = strdup(vendor);
92 struct loc_database *db ;
94 loc_database_unref(db);