diff --git a/include/libp2p/db/datastore.h b/include/libp2p/db/datastore.h index 120d8d8..012c7ec 100644 --- a/include/libp2p/db/datastore.h +++ b/include/libp2p/db/datastore.h @@ -6,7 +6,7 @@ * Interface to data storage */ -enum DatastoreCursorOp { CURSOR_FIRST, CURSOR_NEXT }; +enum DatastoreCursorOp { CURSOR_FIRST, CURSOR_NEXT, CURSOR_LAST, CURSOR_PREVIOUS }; struct Datastore { char* type; diff --git a/include/libp2p/os/utils.h b/include/libp2p/os/utils.h index 214a741..9e2b0e0 100644 --- a/include/libp2p/os/utils.h +++ b/include/libp2p/os/utils.h @@ -77,4 +77,10 @@ int os_utils_directory_exists(const char* path); */ int os_utils_is_directory(const char* file_name); +/*** + * Get the current time in GMT (UTC) as seconds since epoch + * @returns seconds since epoch + */ +unsigned long long os_utils_gmtime(); + #endif /* utils_h */ diff --git a/os/utils.c b/os/utils.c index 2a15724..8779fdc 100644 --- a/os/utils.c +++ b/os/utils.c @@ -10,6 +10,7 @@ #include #include #include +#include /** * get an environment varible from the os @@ -180,3 +181,13 @@ int os_utils_file_size(const char* path) { fclose(in_file); return file_size; } + +/*** + * Get the current time in GMT (UTC) as seconds since epoch + * @returns seconds since epoch + */ +unsigned long long os_utils_gmtime() { + time_t local = time(NULL); + struct tm *gmt = gmtime(&local); + return (unsigned long long)mktime(gmt); +}