From f471fbdf27462b82febe4e8db8358ab3380d2a28 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 13 May 2023 08:59:43 +0200 Subject: add command module to handle request-response communications --- src/msg.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/msg.h') diff --git a/src/msg.h b/src/msg.h index 2260016..2f631fc 100644 --- a/src/msg.h +++ b/src/msg.h @@ -8,26 +8,28 @@ #ifndef __MSG_H__ #define __MSG_H__ -struct msg { - int argc; - char **argv; -}; +#include -int msg_success(struct msg *); -int msg_error(struct msg *); +struct msg; + +size_t msg_get_length(const struct msg *); +const char **msg_get_words(const struct msg *); + +int msg_success(struct msg **); +int msg_error(struct msg **); int msg_is_success(const struct msg *); int msg_is_error(const struct msg *); -struct msg *msg_copy(const struct msg *); -void msg_free(const struct msg *); +int msg_copy(struct msg **, const struct msg *); +void msg_free(struct msg *); -int msg_from_argv(struct msg *, const char **argv); +int msg_from_argv(struct msg **, const char **argv); -int msg_recv(int fd, struct msg *); +int msg_recv(int fd, struct msg **); int msg_send(int fd, const struct msg *); -int msg_send_and_wait(int fd, const struct msg *, struct msg *response); +int msg_send_and_wait(int fd, const struct msg *, struct msg **response); void msg_dump(const struct msg *); -- cgit v1.3