From cc7c91c8ea38ac4cd226469481c2f6d63805331b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 9 Jun 2023 00:10:02 +0200 Subject: msg: add msg_send_from_argv shortcut --- src/msg.c | 17 +++++++++++++++++ src/msg.h | 2 ++ 2 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 7bce01d..0e75c75 100644 --- a/src/msg.c +++ b/src/msg.c @@ -170,6 +170,23 @@ destroy_buf: return ret; } +int msg_send_from_argv(int fd, const char **argv) +{ + struct msg *msg = NULL; + int ret = 0; + + ret = msg_from_argv(&msg, argv); + if (ret < 0) + return ret; + + ret = msg_send(fd, msg); + msg_free(msg); + if (ret < 0) + return ret; + + return ret; +} + int msg_recv(int fd, struct msg **_msg) { struct buf *buf = NULL; diff --git a/src/msg.h b/src/msg.h index 64da9b8..d81134d 100644 --- a/src/msg.h +++ b/src/msg.h @@ -30,6 +30,8 @@ int msg_is_error(const struct msg *); int msg_recv(int fd, struct msg **); int msg_send(int fd, const struct msg *); +int msg_send_from_argv(int fd, const char **argv); + int msg_communicate(int fd, const struct msg *, struct msg **response); int msg_connect_and_communicate(const char *host, const char *port, const struct msg *, struct msg **); -- cgit v1.2.3