Name
loc_database_new, loc_database_open, loc_database_ref, loc_database_unref, loc_database_created_at, loc_database_get_vendor, loc_database_get_description, loc_database_get_license - Open a location database
Synopsis
#include <libloc/libloc.h>
#include <libloc/database.h>
struct loc_database;
int loc_database_new(struct loc_ctx* ctx,
struct loc_database** database, FILE* f);
int loc_database_open(struct loc_ctx* ctx,
struct loc_database** database, const char* path);
Reference Counting:
struct loc_database* loc_database_ref(struct loc_database* db);
struct loc_database* loc_database_unref(struct loc_database* db);
Access some data:
time_t loc_database_created_at(struct loc_database* db);
const char* loc_database_get_vendor(struct loc_database* db);
const char* loc_database_get_description(struct loc_database* db);
const char* loc_database_get_license(struct loc_database* db);
Description
loc_database_new() opens a new database from the given file handle. The file handle can be closed after this operation because the function duplicates the underlying file descriptor.
loc_database_open() opens the database at the given path. A database that has been opened like this knows where its file is.
If the database could be opened successfully, zero is returned. Otherwise a negative error number (see errno(3)) is returned, for example -ENOMSG if the file is not a database, -ENOTSUP if it has a version that is not supported, or -EFAULT if parts of it are missing. errno itself is not being set.
Various meta-data about the database can be retrieved with loc_database_created_at(), loc_database_get_vendor(), loc_database_get_description(), and loc_database_get_license().
See Also
Authors
Michael Tremer