aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/msg.h
blob: 44ebf44c20d6e3208186a1afb7877e1791d0bb69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2022 Egor Tensin <Egor.Tensin@gmail.com>
 * This file is part of the "cimple" project.
 * For details, see https://github.com/egor-tensin/cimple.
 * Distributed under the MIT License.
 */

#ifndef __MSG_H__
#define __MSG_H__

#include <stddef.h>

struct msg;

int msg_from_argv(struct msg **, const char **argv);
void msg_free(struct msg *);

int msg_copy(struct msg **, const struct msg *);

size_t msg_get_length(const struct msg *);
const char **msg_get_strings(const struct msg *);
const char *msg_get_first_string(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 *);

int msg_recv(int fd, struct msg **);

int msg_send(int fd, const struct msg *);
int msg_send_argv(int fd, const char **argv);

int msg_talk(int fd, const struct msg *, struct msg **response);
int msg_talk_argv(int fd, const char **argv, struct msg **response);

int msg_connect_and_talk(const char *host, const char *port, const struct msg *, struct msg **);
int msg_connect_and_talk_argv(const char *host, const char *port, const char **argv,
                              struct msg **response);

void msg_dump(const struct msg *);

#endif