From abdd7a28ede091f06325b3e5b8a77fc9130e6ee3 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 19 Oct 2017 02:40:01 +0200 Subject: add osmo_talloc_asprintf() and ctrl_cmd_reply_printf() Add macro to append to a CTRL commands' reply string, ctrl_cmd_reply_printf(). The talloc_asprintf() part of it is generic enough to qualify for a separate macro, osmo_talloc_asprintf(). The idea is to not have to decide for each bit added to a string whether the string is already allocated or not, but simply be able to issue printf commands and let the macro worry about initial allocation or reallocation. This originally came from osmo-hlr change I1bd62ae0d4eefde7e1517db15a2155640a1bab58, where it was requested to move this bit to libosmocore. Change-Id: Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005 --- include/osmocom/ctrl/control_cmd.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/osmocom/ctrl') diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h index 77532e66..4372e257 100644 --- a/include/osmocom/ctrl/control_cmd.h +++ b/include/osmocom/ctrl/control_cmd.h @@ -66,6 +66,9 @@ struct ctrl_cmd { char *reply; }; +#define ctrl_cmd_reply_printf(cmd, fmt, args ...) \ + osmo_talloc_asprintf(cmd, cmd->reply, fmt, ## args) + struct ctrl_cmd_struct { int nr_commands; char **command; -- cgit v1.2.3