rpc.h
Go to the documentation of this file.
1 #ifndef MPACK_RPC_H
2 #define MPACK_RPC_H
3 
4 #include "mpack_core.h"
5 #include "object.h"
6 
7 #ifndef MPACK_RPC_MAX_REQUESTS
8 # define MPACK_RPC_MAX_REQUESTS 32
9 #endif
10 
11 enum {
16 };
17 
18 enum {
24 };
25 
26 typedef struct mpack_rpc_header_s {
28  int index;
30 
31 typedef struct mpack_rpc_message_s {
32  mpack_uint32_t id;
35 
37  int used;
39 };
40 
41 #define MPACK_RPC_SESSION_STRUCT(c) \
42  struct { \
43  mpack_tokbuf_t reader, writer; \
44  mpack_rpc_header_t receive, send; \
45  mpack_uint32_t request_id, capacity; \
46  struct mpack_rpc_slot_s slots[c]; \
47  }
48 
49 /* Some compilers warn against anonymous structs:
50  * https://github.com/libmpack/libmpack/issues/6 */
51 typedef MPACK_RPC_SESSION_STRUCT(1) mpack_rpc_one_session_t;
52 
53 #define MPACK_RPC_SESSION_STRUCT_SIZE(c) \
54  (sizeof(struct mpack_rpc_slot_s) * (c - 1) + \
55  sizeof(mpack_rpc_one_session_t))
56 
57 typedef MPACK_RPC_SESSION_STRUCT(MPACK_RPC_MAX_REQUESTS) mpack_rpc_session_t;
58 
59 MPACK_API void mpack_rpc_session_init(mpack_rpc_session_t *s, mpack_uint32_t c)
61 
62 MPACK_API int mpack_rpc_receive_tok(mpack_rpc_session_t *s, mpack_token_t t,
64 MPACK_API int mpack_rpc_request_tok(mpack_rpc_session_t *s, mpack_token_t *t,
66 MPACK_API int mpack_rpc_reply_tok(mpack_rpc_session_t *s, mpack_token_t *t,
67  mpack_uint32_t i) FUNUSED FNONULL;
68 MPACK_API int mpack_rpc_notify_tok(mpack_rpc_session_t *s, mpack_token_t *t)
70 
71 MPACK_API int mpack_rpc_receive(mpack_rpc_session_t *s, const char **b,
72  size_t *bl, mpack_rpc_message_t *m) FUNUSED FNONULL;
73 MPACK_API int mpack_rpc_request(mpack_rpc_session_t *s, char **b, size_t *bl,
74  mpack_data_t d) FUNUSED FNONULL_ARG((1,2,3));
75 MPACK_API int mpack_rpc_reply(mpack_rpc_session_t *s, char **b, size_t *bl,
76  mpack_uint32_t i) FNONULL FUNUSED;
77 MPACK_API int mpack_rpc_notify(mpack_rpc_session_t *s, char **b, size_t *bl)
79 
80 MPACK_API void mpack_rpc_session_copy(mpack_rpc_session_t *d,
81  mpack_rpc_session_t *s) FUNUSED FNONULL;
82 
83 #endif /* MPACK_RPC_H */
mpack_rpc_reply_tok
MPACK_API int MPACK_API int mpack_rpc_reply_tok(mpack_rpc_session_t *s, mpack_token_t *t, mpack_uint32_t i) FUNUSED FNONULL
Definition: rpc.c:129
MPACK_NOMEM
@ MPACK_NOMEM
Definition: object.h:21
mpack_rpc_request_tok
MPACK_API int mpack_rpc_request_tok(mpack_rpc_session_t *s, mpack_token_t *t, mpack_data_t d) FUNUSED FNONULL_ARG((1
mpack_rpc_message_s::data
mpack_data_t data
Definition: rpc.h:33
mpack_rpc_notify_tok
MPACK_API int mpack_rpc_notify_tok(mpack_rpc_session_t *s, mpack_token_t *t) FUNUSED FNONULL
Definition: rpc.c:154
mpack_rpc_session_init
MPACK_API void mpack_rpc_session_init(mpack_rpc_session_t *s, mpack_uint32_t c) FUNUSED FNONULL
Definition: rpc.c:21
i
static void int i
Definition: edit.c:2997
MPACK_RPC_RESPONSE
@ MPACK_RPC_RESPONSE
Definition: rpc.h:13
mpack_rpc_reply
MPACK_API int MPACK_API int mpack_rpc_reply(mpack_rpc_session_t *s, char **b, size_t *bl, mpack_uint32_t i) FNONULL FUNUSED
Definition: rpc.c:205
FNONULL
#define FNONULL
Definition: mpack_core.h:19
mpack_rpc_request
MPACK_API int mpack_rpc_request(mpack_rpc_session_t *s, char **b, size_t *bl, mpack_data_t d) FUNUSED FNONULL_ARG((1
mpack_core.h
mpack_rpc_notify
MPACK_API int mpack_rpc_notify(mpack_rpc_session_t *s, char **b, size_t *bl) FNONULL FUNUSED
Definition: rpc.c:223
MPACK_RPC_REQUEST
@ MPACK_RPC_REQUEST
Definition: rpc.h:12
MPACK_RPC_EMSGID
@ MPACK_RPC_EMSGID
Definition: rpc.h:22
MPACK_RPC_ERROR
@ MPACK_RPC_ERROR
Definition: rpc.h:15
MPACK_RPC_SESSION_STRUCT
#define MPACK_RPC_SESSION_STRUCT(c)
Definition: rpc.h:41
mpack_rpc_header_t
struct mpack_rpc_header_s mpack_rpc_header_t
mpack_rpc_header_s::toks
mpack_token_t toks[3]
Definition: rpc.h:27
m
matchitem_T * m
Definition: window.c:6683
FUNUSED
#define FUNUSED
Definition: mpack_core.h:21
mpack_rpc_slot_s::used
int used
Definition: rpc.h:37
mpack_rpc_receive
MPACK_API int mpack_rpc_receive(mpack_rpc_session_t *s, const char **b, size_t *bl, mpack_rpc_message_t *m) FUNUSED FNONULL
Definition: rpc.c:170
mpack_rpc_header_s
Definition: rpc.h:26
mpack_rpc_slot_s::msg
mpack_rpc_message_t msg
Definition: rpc.h:38
s
char_u * s
Definition: eval.c:764
mpack_rpc_message_s::id
mpack_uint32_t id
Definition: rpc.h:32
MPACK_RPC_EARRAYL
@ MPACK_RPC_EARRAYL
Definition: rpc.h:20
t
nfa_thread_T * t
Definition: regexp_nfa.c:5069
msg
err msg
Definition: helpers.c:1039
mpack_data_t
Definition: object.h:27
FNONULL_ARG
#define FNONULL_ARG(x)
Definition: mpack_core.h:20
mpack_rpc_session_copy
MPACK_API void mpack_rpc_session_copy(mpack_rpc_session_t *d, mpack_rpc_session_t *s) FUNUSED FNONULL
Definition: rpc.c:241
mpack_rpc_message_s
Definition: rpc.h:31
mpack_rpc_receive_tok
MPACK_API int mpack_rpc_receive_tok(mpack_rpc_session_t *s, mpack_token_t t, mpack_rpc_message_t *msg) FUNUSED FNONULL
Definition: rpc.c:34
MPACK_RPC_ETYPE
@ MPACK_RPC_ETYPE
Definition: rpc.h:21
mpack_rpc_message_t
struct mpack_rpc_message_s mpack_rpc_message_t
mpack_rpc_slot_s
Definition: rpc.h:36
mpack_rpc_header_s::index
int index
Definition: rpc.h:28
mpack_token_s
Definition: mpack_core.h:61
MPACK_RPC_ERESPID
@ MPACK_RPC_ERESPID
Definition: rpc.h:23
MPACK_RPC_EARRAY
@ MPACK_RPC_EARRAY
Definition: rpc.h:19
MPACK_RPC_MAX_REQUESTS
#define MPACK_RPC_MAX_REQUESTS
Definition: rpc.h:8
MPACK_API
#define MPACK_API
Definition: mpack_core.h:5
object.h
MPACK_RPC_NOTIFICATION
@ MPACK_RPC_NOTIFICATION
Definition: rpc.h:14