diff options
author | nicm <nicm> | 2021-02-22 08:18:13 +0000 |
---|---|---|
committer | nicm <nicm> | 2021-02-22 08:18:13 +0000 |
commit | 6876381276ff2c2a40d304ada27651fdaf1cd8a7 (patch) | |
tree | 1b38398f851f7062ea015584b660a327c5939165 /format.c | |
parent | e858270006a9041b9016ed9e6cc12d622ac8fe31 (diff) | |
download | rtmux-6876381276ff2c2a40d304ada27651fdaf1cd8a7.tar.gz rtmux-6876381276ff2c2a40d304ada27651fdaf1cd8a7.tar.bz2 rtmux-6876381276ff2c2a40d304ada27651fdaf1cd8a7.zip |
Move config file path expansion much earlier, keep the list of paths
around rather than freeing later, and add a config_files format variable
containing it. Suggested by kn@ a while back.
Diffstat (limited to 'format.c')
-rw-r--r-- | format.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -1412,6 +1412,26 @@ format_cb_client_written(struct format_tree *ft) return (NULL); } +/* Callback for config_files. */ +static void * +format_cb_config_files(__unused struct format_tree *ft) +{ + char *s = NULL; + size_t slen = 0; + u_int i; + size_t n; + + for (i = 0; i < cfg_nfiles; i++) { + n = strlen(cfg_files[i]) + 1; + s = xrealloc(s, slen + n + 1); + slen += xsnprintf(s + slen, n + 1, "%s,", cfg_files[i]); + } + if (s == NULL) + return (xstrdup("")); + s[slen - 1] = '\0'; + return (s); +} + /* Callback for cursor_flag. */ static void * format_cb_cursor_flag(struct format_tree *ft) @@ -2569,6 +2589,9 @@ static const struct format_table_entry format_table[] = { { "client_written", FORMAT_TABLE_STRING, format_cb_client_written }, + { "config_files", FORMAT_TABLE_STRING, + format_cb_config_files + }, { "cursor_character", FORMAT_TABLE_STRING, format_cb_cursor_character }, |