20#define STR_EMPTY(s) (!s || (*s == '\0'))
23#define STR_FULL(s) !(STR_EMPTY(s))
26#define STR_EQ(a, b) (g_strcmp0(a, b) == 0)
29#define STRN_EQ(a, b, n) (strncmp(a, b, n) == 0)
32#define STR_CASEQ(a, b) (strcasecmp(a, b) == 0)
35#define STR_NN(s) (s == NULL ? "(null)" : s)
38#define STR_TO(...) _STR_TO(__VA_ARGS__)
39#define _STR_TO(...) "" # __VA_ARGS__
42#define ASSERT_OR_RET(expr, val) \
43 do { if (!(expr)) return val; } while(0)
46#define S2US(s) (((gint64)(s)) * G_USEC_PER_SEC)
49#define US2S(s) (((gint64)(s)) / G_USEC_PER_SEC)
55#define BOOL2G(x) ((x) ? TRUE : FALSE)
209bool safe_setenv(
const char* key,
const char* value);
228const char *get_section_deprecation_message(
const char *s);
290void add_paths_from_env(GPtrArray *arr,
char *env_name,
char *subdir,
char *alternative);
gint64 modification_time(const char *path)
Get the modification time of the file at path.
gint64 time_monotonic_now(void)
Get the current monotonic time.
bool safe_setenv(const char *key, const char *value)
Try to set an environment variable safely.
char * string_replace_at(char *buf, int pos, int len, const char *repl)
Replace a substring inside a string with another string.
bool string_is_int(const char *str)
Check if string contains digits.
bool is_like_path(const char *string)
Check if the strings looks like a path.
FILE * fopen_verbose(const char *const path)
Open files verbosely.
bool safe_string_to_long_long(long long *in, const char *str)
Same as safe_string_to_int, but then for a long.
const char * user_get_home(void)
Retrieve the HOME directory of the user running dunst.
int string_array_length(char **s)
Returns the length of a string array, -1 if the input is NULL.
bool is_readable_file(const char *const path)
Check if file is readable.
gint64 time_now(void)
Get the current real time.
char * string_strip_brackets(const char *s)
Strips a string of it's brackets if the first and last character are a bracket.
bool safe_string_to_double(double *in, const char *str)
Same as safe_string_to_int, but then for a double.
bool safe_string_to_int(int *in, const char *str)
Convert string to int in a safe way.
void string_strip_delimited(char *str, char a, char b)
Strip content between two delimiter characters.
char * string_to_path(char *string)
Replace tilde and path-specific values with it's equivalents.
char * string_strip_quotes(const char *value)
Strip quotes from a string, ignoring inner quotes.
bool is_deprecated_section(const char *s)
This function tells if a section is deprecated.
char * string_replace_all(const char *needle, const char *replacement, char *haystack)
Replace all occurences of a substring.
bool is_special_section(const char *s)
Some sections are handled differently in dunst.
char * string_append(char *a, const char *b, const char *sep)
Append b to string a, then concatenate both with sep (if they are non-empty).
void add_paths_from_env(GPtrArray *arr, char *env_name, char *subdir, char *alternative)
Adds the contents of env_name with subdir to the array, interpreting the environment variable as a co...
char ** string_to_array(const char *string, const char *delimiter)
Parse a string into a dynamic array of tokens, using the delimiter string.
char * string_replace_char(char needle, char replacement, char *haystack)
Replaces all occurrences of the char needle with the char replacement in haystack.
gint64 string_to_time(const char *string)
Convert time units (ms, s, m) to the internal gint64 microseconds format.