-
Notifications
You must be signed in to change notification settings - Fork 12
/
ipc.h
72 lines (54 loc) · 1.54 KB
/
ipc.h
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef IPC_H
#define IPC_H
#include <stdbool.h>
#include "log.h"
#define IPC_RC_SUCCESS 0
#define IPC_RC_WARN 1
#define IPC_RC_ERROR 2
#define IPC_RC_BAD_REQUEST 11
#define IPC_RC_BAD_RESPONSE 12
#define IPC_RC_REQUEST_IN_PROGRESS 13
enum IpcCommand {
GET = 1,
CFG_SET,
CFG_DEL,
CFG_WRITE,
};
struct IpcOperation {
struct IpcRequest *request;
int socket_client;
bool done;
int rc;
bool send_logs; // not for bad or colliding requests
bool send_state; // not for bad requests
};
struct IpcRequest {
enum IpcCommand command;
enum LogThreshold log_threshold; // server marshals >=
struct Cfg *cfg; // for CFG_SET, CFG_DEL
bool yaml; // client print yaml only bar errors
int socket_client; // client and server, set to -1 on failure
bool bad; // used by server on receipt of bad message
};
struct IpcResponseStatus {
bool done;
int rc;
};
struct IpcResponse {
struct IpcResponseStatus status;
struct Cfg *cfg;
struct SList *heads;
struct Lid *lid;
struct SList *log_cap_lines;
};
void ipc_send_request(struct IpcRequest *request);
void ipc_send_operation(struct IpcOperation *operation);
char *ipc_receive_raw(int socket_client);
// receive the entire request sent to the server socket
struct IpcRequest *ipc_receive_request(int socket_server);
// receive all responses, user frees complete yaml
struct SList *ipc_receive_responses(int socket_client, char **yaml);
void ipc_request_free(struct IpcRequest *request);
void ipc_response_free(void *response);
void ipc_operation_free(struct IpcOperation *operation);
#endif // IPC_H