aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/control_cmd.h
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-02-22 11:04:35 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-04-22 09:09:31 +0200
commit3e3c305c8a755f956cb0c5cfea2926b561306041 (patch)
tree9fe1a38fd8eddbe4a55b837b74ce1d015208dfac /openbsc/include/openbsc/control_cmd.h
parent39dcb82e5c5536a75837849d1ef9c59a71a28fd1 (diff)
ctrl: Make it possible to re-use the string get and set routine
This can be used for the description field that requires some special handling for newlines.
Diffstat (limited to 'openbsc/include/openbsc/control_cmd.h')
-rw-r--r--openbsc/include/openbsc/control_cmd.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h
index 9a1035156..cd7b7b6d3 100644
--- a/openbsc/include/openbsc/control_cmd.h
+++ b/openbsc/include/openbsc/control_cmd.h
@@ -129,7 +129,7 @@ static struct ctrl_cmd_element cmd_##cmdname = { \
.verify = &verify_##cmdname, \
}
-#define CTRL_CMD_DEFINE_STRING(cmdname, cmdstr, dtype, element) \
+#define CTRL_HELPER_GET_STRING(cmdname, dtype, element) \
static int get_##cmdname(struct ctrl_cmd *cmd, void *_data) \
{ \
dtype *data = cmd->node; \
@@ -139,13 +139,17 @@ static int get_##cmdname(struct ctrl_cmd *cmd, void *_data) \
return CTRL_CMD_ERROR; \
} \
return CTRL_CMD_REPLY; \
-} \
+}
+#define CTRL_HELPER_SET_STRING(cmdname, dtype, element) \
static int set_##cmdname(struct ctrl_cmd *cmd, void *_data) \
{ \
dtype *data = cmd->node; \
bsc_replace_string(cmd->node, &data->element, cmd->value); \
return get_##cmdname(cmd, _data); \
-} \
+}
+#define CTRL_CMD_DEFINE_STRING(cmdname, cmdstr, dtype, element) \
+ CTRL_HELPER_GET_STRING(cmdname, dtype, element) \
+ CTRL_HELPER_SET_STRING(cmdname, dtype, element) \
static struct ctrl_cmd_element cmd_##cmdname = { \
.name = cmdstr, \
.param = NULL, \