diff options
author | Ingo Bürk <admin@airblader.de> | 2020-03-31 15:06:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 15:06:51 +0200 |
commit | b4555f53e2b6d83d4fb0f16370d43b49557bdb0b (patch) | |
tree | acd938f6746f5267752f6a7f33d373e1fdf25d61 /src | |
parent | bb3b86947a8287b6f87f96db8b06f1fefe4afd5d (diff) | |
parent | ebaeb8fb2340ace64565a8e56c9ab9010e8dd6d9 (diff) |
Merge pull request #396 from Stunkymonkey/format_placeholder-ipv6_addr
use format_placeholder for ipv6_addr
Diffstat (limited to 'src')
-rw-r--r-- | src/print_ipv6_addr.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/print_ipv6_addr.c b/src/print_ipv6_addr.c index 5a0c38d..8fd8669 100644 --- a/src/print_ipv6_addr.c +++ b/src/print_ipv6_addr.c @@ -118,7 +118,6 @@ static char *get_ipv6_addr(void) { } void print_ipv6_info(yajl_gen json_gen, char *buffer, const char *format_up, const char *format_down) { - const char *walk; char *addr_string = get_ipv6_addr(); char *outwalk = buffer; @@ -131,18 +130,13 @@ void print_ipv6_info(yajl_gen json_gen, char *buffer, const char *format_up, con } START_COLOR("color_good"); - for (walk = format_up; *walk != '\0'; walk++) { - if (*walk != '%') { - *(outwalk++) = *walk; - } else if (BEGINS_WITH(walk + 1, "ip")) { - outwalk += sprintf(outwalk, "%s", addr_string); - walk += strlen("ip"); + placeholder_t placeholders[] = { + {.name = "%ip", .value = addr_string}}; - } else { - *(outwalk++) = '%'; - } - } + const size_t num = sizeof(placeholders) / sizeof(placeholder_t); + buffer = format_placeholders(format_up, &placeholders[0], num); END_COLOR; OUTPUT_FULL_TEXT(buffer); + free(buffer); } |