diff options
author | Burt P <pburt0@gmail.com> | 2017-07-19 20:46:36 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-07-21 05:14:20 -0700 |
commit | cb445b8b1458cc2e2e09bfe6b4f999f3ed8b684d (patch) | |
tree | 74d0d166ad56a6647c990b7232bda24920da95f7 /includes/dt_util.h | |
parent | f843ee52fe2c230083a63a262ec120c94f97203a (diff) |
device tree: add helper function for appending elements
Cleans up code for lists of mixed-type elements.
appf() is like h_strdup_cprintf() but with a cute name,
logical param order and adds a space when the string is
not empty.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'includes/dt_util.h')
-rw-r--r-- | includes/dt_util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/includes/dt_util.h b/includes/dt_util.h index bf56c293..4bd72133 100644 --- a/includes/dt_util.h +++ b/includes/dt_util.h @@ -72,4 +72,10 @@ char *dtr_maps_info(dtr *); /* returns hardinfo shell section */ const char *dtr_find_device_tree_root(void); +#define sp_sep(STR) (strlen(STR) ? " " : "") +/* appends an element to a string, adding a space if + * the string is not empty. + * ex: ret = appf(ret, "%s=%s\n", name, value); */ +char *appf(char *src, char *fmt, ...); + #endif |