diff options
author | Arne Schwabe | 2023-11-21 11:42:54 +0100 |
---|---|---|
committer | Gert Doering | 2023-11-21 20:13:09 +0100 |
commit | 57172d84096cc03e4a5a0658b9abb15d4173859d (patch) | |
tree | 372ef4489010186a6f00ffeb35813e0f92e53bda | |
parent | 78e0c5f2f57a18e8ea60951696a458a4b3ff3621 (diff) | |
download | openvpn-57172d84096cc03e4a5a0658b9abb15d4173859d.zip openvpn-57172d84096cc03e4a5a0658b9abb15d4173859d.tar.gz |
Introduce report_command_status helper function
Instead of repeating near identical code several times
in manage.c, use a small helper function instead.
Change-Id: I91f739f5cb43386b2ce767cf3603a76e6b93e216
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20231121104254.15701-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27525.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
-rw-r--r-- | src/openvpn/manage.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index feb62b2..27b6f90 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -284,6 +284,24 @@ man_prompt(struct management *man) #endif } + +/** + * Small function to report the success or failure of a command to + * the management interface + */ +static void +report_command_status(const bool status, const char *command) +{ + if (status) + { + msg(M_CLIENT, "SUCCESS: %s command succeeded", command); + } + else + { + msg(M_CLIENT, "ERROR: %s command failed", command); + } +} + static void man_delete_unix_socket(struct management *man) { @@ -974,14 +992,7 @@ in_extra_dispatch(struct management *man) NULL, man->connection.in_extra); man->connection.in_extra = NULL; - if (status) - { - msg(M_CLIENT, "SUCCESS: client-auth command succeeded"); - } - else - { - msg(M_CLIENT, "ERROR: client-auth command failed"); - } + report_command_status(status, "client-auth"); } else { @@ -1260,14 +1271,7 @@ man_proxy(struct management *man, const char **p) if (man->persist.callback.proxy_cmd) { const bool status = (*man->persist.callback.proxy_cmd)(man->persist.callback.arg, p); - if (status) - { - msg(M_CLIENT, "SUCCESS: proxy command succeeded"); - } - else - { - msg(M_CLIENT, "ERROR: proxy command failed"); - } + report_command_status(status, "proxy"); } else { @@ -1281,14 +1285,7 @@ man_remote(struct management *man, const char **p) if (man->persist.callback.remote_cmd) { const bool status = (*man->persist.callback.remote_cmd)(man->persist.callback.arg, p); - if (status) - { - msg(M_CLIENT, "SUCCESS: remote command succeeded"); - } - else - { - msg(M_CLIENT, "ERROR: remote command failed"); - } + report_command_status(status, "remote"); } else { |