dunst/src/utils.h
Benedikt Heine ac4a0becd2 Count monotonic time with Linux specific clocks
On Linux, CLOCK_MONOTONIC has got a bug. It does not count
onwards during sleep, albeit required by POSIX. This behavior
is reasoned with the requirement for poll().
Also the GLib people are sticking to this behavior in their
g_get_monotonic_time() function.

So we have to use a drop in replacement, which respects CLOCK_BOOTTIME
on Linux, as this is the clock, what would be CLOCK_MONOTONIC on POSIX
systems.
2018-03-20 14:17:03 +01:00

41 lines
1.5 KiB
C

/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
#ifndef DUNST_UTILS_H
#define DUNST_UTILS_H
#include <glib.h>
/* replace all occurrences of the character needle with the character replacement in haystack */
char *string_replace_char(char needle, char replacement, char *haystack);
/* replace all occurrences of needle with replacement in haystack */
char *string_replace_all(const char *needle, const char *replacement, char *haystack);
/* replace <len> characters with <repl> at position <pos> of the string <buf> */
char *string_replace_at(char *buf, int pos, int len, const char *repl);
/* replace needle with replacement in haystack */
char *string_replace(const char *needle, const char *replacement, char *haystack);
char *string_append(char *a, const char *b, const char *sep);
/* strip content between two delimiter characters (inplace) */
void string_strip_delimited(char *str, char a, char b);
/* replace tilde and path-specific values with its equivalents */
char *string_to_path(char *string);
/* convert time units (ms, s, m) to internal gint64 microseconds */
gint64 string_to_time(const char *string);
/**
* Get the current monotonic time. In contrast to `g_get_monotonic_time`,
* this function respects the real monotonic time of the system and
* counts onwards during system sleep.
*
* @returns: A `gint64` monotonic time representation
*/
gint64 time_monotonic_now(void);
#endif
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */