diff options
author | David Härdeman <david@hardeman.nu> | 2015-07-01 16:59:01 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2015-07-01 16:59:01 +0200 |
commit | b6d82ecee6e38b83776d3a9d4637c51fc5151beb (patch) | |
tree | 6045c7440407e215a83df0e4aa37352440aa752b /utils.h | |
parent | 99f8010565df11645582262f03c186036d4211c5 (diff) |
Add support for actually reading keymaps
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -1,6 +1,8 @@ #ifndef fooutilshfoo #define fooutilshfoo +#include <sys/types.h> +#include <dirent.h> #include <systemd/sd-bus.h> struct list_head { @@ -80,6 +82,17 @@ static inline void sd_bus_close_unrefp(sd_bus **bus) { } #define _cleanup_bus_close_unref_ _cleanup_(sd_bus_close_unrefp) +static inline unsigned +strv_length(char **strv) +{ + unsigned len; + + for (len = 0; strv && *strv; strv++) + len++; + + return len; +} + static inline void strv_free(char **l) { char **k; if (l) { @@ -91,9 +104,20 @@ static inline void strv_free(char **l) { DEFINE_TRIVIAL_CLEANUP_FUNC(char **, strv_free); #define _cleanup_strv_free_ _cleanup_(strv_freep) -DEFINE_TRIVIAL_CLEANUP_FUNC(void *, free); +static inline void freep(void *p) { + free(*(void**) p); +} #define _cleanup_free_ _cleanup_(freep) +DEFINE_TRIVIAL_CLEANUP_FUNC(int, close); +#define _cleanup_close_ _cleanup_(closep) + +DEFINE_TRIVIAL_CLEANUP_FUNC(FILE *, fclose); +#define _cleanup_fclose_ _cleanup_(fclosep) + +DEFINE_TRIVIAL_CLEANUP_FUNC(DIR *, closedir); +#define _cleanup_closedir_ _cleanup_(closedirp) + DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus *, sd_bus_unref); #define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp) |