#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <time.h>
#include <unistd.h>
#include <loc/libloc.h>
FILE* file;
unsigned int version;
+ time_t created_at;
off_t vendor;
off_t description;
db->ctx = loc_ref(ctx);
db->refcount = 1;
+ // Save creation time
+ db->created_at = time(NULL);
+
DEBUG(db->ctx, "Database allocated at %p\n", db);
// Create string pool
return NULL;
}
+LOC_EXPORT time_t loc_database_created_at(struct loc_database* db) {
+ return db->created_at;
+}
+
LOC_EXPORT const char* loc_database_get_vendor(struct loc_database* db) {
return loc_stringpool_get(db->pool, db->vendor);
}
}
// Copy over data
+ db->created_at = be64toh(header.created_at);
db->vendor = ntohl(header.vendor);
db->description = ntohl(header.description);
// Make the header
struct loc_database_header_v0 header;
+ header.created_at = htobe64(db->created_at);
header.vendor = htonl(db->vendor);
header.description = htonl(db->description);
struct loc_database* loc_database_ref(struct loc_database* db);
struct loc_database* loc_database_unref(struct loc_database* db);
+time_t loc_database_created_at(struct loc_database* db);
const char* loc_database_get_vendor(struct loc_database* db);
int loc_database_set_vendor(struct loc_database* db, const char* vendor);
const char* loc_database_get_description(struct loc_database* db);
};
struct loc_database_header_v0 {
+ // UNIX timestamp when the database was created
+ uint64_t created_at;
+
// Vendor who created the database
uint32_t vendor;