summaryrefslogtreecommitdiffstats
path: root/openbsc/src/libctrl/control_cmd.c
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-03-17 15:37:54 +0100
committerHarald Welte <laforge@gnumonks.org>2011-07-13 14:07:10 +0200
commitfc5391f54e5d522c97bfda139e9089ab9141e10a (patch)
treef420f56a641a3b57dd049d233697c94eb73a1e76 /openbsc/src/libctrl/control_cmd.c
parentbc07090af2b6e31ac66d6d4150ac65df00ac7d1d (diff)
libctrl: Add ctrl_cmd_cpy() to copy a command
Diffstat (limited to 'openbsc/src/libctrl/control_cmd.c')
-rw-r--r--openbsc/src/libctrl/control_cmd.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c
index 06af3b320..b5cff6859 100644
--- a/openbsc/src/libctrl/control_cmd.c
+++ b/openbsc/src/libctrl/control_cmd.c
@@ -237,6 +237,42 @@ int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd)
return 0;
}
+struct ctrl_cmd *ctrl_cmd_cpy(void *ctx, struct ctrl_cmd *cmd)
+{
+ struct ctrl_cmd *cmd2;
+
+ cmd2 = talloc_zero(ctx, struct ctrl_cmd);
+ if (!cmd2)
+ return NULL;
+
+ cmd2->type = cmd->type;
+ if (cmd->id) {
+ cmd2->id = talloc_strdup(cmd2, cmd->id);
+ if (!cmd2->id)
+ goto err;
+ }
+ if (cmd->variable) {
+ cmd2->variable = talloc_strdup(cmd2, cmd->variable);
+ if (!cmd2->variable)
+ goto err;
+ }
+ if (cmd->value) {
+ cmd2->value = talloc_strdup(cmd2, cmd->value);
+ if (!cmd2->value)
+ goto err;
+ }
+ if (cmd->reply) {
+ cmd2->reply = talloc_strdup(cmd2, cmd->reply);
+ if (!cmd2->reply)
+ goto err;
+ }
+
+ return cmd2;
+err:
+ talloc_free(cmd2);
+ return NULL;
+}
+
struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg)
{
char *str, *tmp, *saveptr = NULL;