diff options
Diffstat (limited to 'include/util')
-rw-r--r-- | include/util/env.h | 14 | ||||
-rw-r--r-- | include/util/time.h | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/include/util/env.h b/include/util/env.h index 6720fa8..e271f4b 100644 --- a/include/util/env.h +++ b/include/util/env.h @@ -4,8 +4,20 @@ #include <stdbool.h> #include <unistd.h> +/** + * Parse a bool from an environment variable. + * + * On success, the parsed value is returned. On error, false is returned. + */ bool env_parse_bool(const char *option); -ssize_t env_parse_switch(const char *option, const char **switches); +/** + * Pick a choice from an environment variable. + * + * On success, the choice index is returned. On error, zero is returned. + * + * switches is a NULL-terminated array. + */ +size_t env_parse_switch(const char *option, const char **switches); #endif diff --git a/include/util/time.h b/include/util/time.h index 287698d..3f76aa4 100644 --- a/include/util/time.h +++ b/include/util/time.h @@ -1,12 +1,13 @@ #ifndef UTIL_TIME_H #define UTIL_TIME_H +#include <stdint.h> #include <time.h> /** * Get the current time, in milliseconds. */ -uint32_t get_current_time_msec(void); +int64_t get_current_time_msec(void); /** * Convert a timespec to milliseconds. @@ -14,6 +15,11 @@ uint32_t get_current_time_msec(void); int64_t timespec_to_msec(const struct timespec *a); /** + * Convert a timespec to nanoseconds. + */ +int64_t timespec_to_nsec(const struct timespec *a); + +/** * Convert nanoseconds to a timespec. */ void timespec_from_nsec(struct timespec *r, int64_t nsec); |