-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathpython_cffi.slurp
More file actions
312 lines (247 loc) · 9.92 KB
/
Copy pathpython_cffi.slurp
File metadata and controls
312 lines (247 loc) · 9.92 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
# Python cffi compatible file slurp
malamute_cdefs = list ()
# Custom setup for malamute
malamute_cdefs.append ('''
typedef struct _mlm_proto_t mlm_proto_t;
typedef struct _zsock_t zsock_t;
typedef struct _zframe_t zframe_t;
typedef struct _zmsg_t zmsg_t;
typedef struct _mlm_client_t mlm_client_t;
typedef struct _zactor_t zactor_t;
// CLASS: mlm_proto
// Create a new empty mlm_proto
mlm_proto_t *
mlm_proto_new (void);
// Destroy a mlm_proto instance
void
mlm_proto_destroy (mlm_proto_t **self_p);
// Receive a mlm_proto from the socket. Returns 0 if OK, -1 if
// there was an error. Blocks if there is no message waiting.
int
mlm_proto_recv (mlm_proto_t *self, zsock_t *input);
// Send the mlm_proto to the output socket, does not destroy it
int
mlm_proto_send (mlm_proto_t *self, zsock_t *output);
// Print contents of message to stdout
void
mlm_proto_print (mlm_proto_t *self);
// Get the message routing id, as a frame
zframe_t *
mlm_proto_routing_id (mlm_proto_t *self);
// Set the message routing id from a frame
void
mlm_proto_set_routing_id (mlm_proto_t *self, zframe_t *routing_id);
// Get the mlm_proto message id
int
mlm_proto_id (mlm_proto_t *self);
// Set the mlm_proto message id
void
mlm_proto_set_id (mlm_proto_t *self, int id);
// Get the mlm_proto message id as printable text
const char *
mlm_proto_command (mlm_proto_t *self);
// Get the address field
const char *
mlm_proto_address (mlm_proto_t *self);
// Set the address field
void
mlm_proto_set_address (mlm_proto_t *self, const char *address);
// Get the stream field
const char *
mlm_proto_stream (mlm_proto_t *self);
// Set the stream field
void
mlm_proto_set_stream (mlm_proto_t *self, const char *stream);
// Get the pattern field
const char *
mlm_proto_pattern (mlm_proto_t *self);
// Set the pattern field
void
mlm_proto_set_pattern (mlm_proto_t *self, const char *pattern);
// Get the subject field
const char *
mlm_proto_subject (mlm_proto_t *self);
// Set the subject field
void
mlm_proto_set_subject (mlm_proto_t *self, const char *subject);
// Get a copy of the content field
zmsg_t *
mlm_proto_content (mlm_proto_t *self);
// Get the content field and transfer ownership to caller
zmsg_t *
mlm_proto_get_content (mlm_proto_t *self);
//
void
mlm_proto_set_content (mlm_proto_t *self, zmsg_t **content_p);
// Get the sender field
const char *
mlm_proto_sender (mlm_proto_t *self);
// Set the sender field
void
mlm_proto_set_sender (mlm_proto_t *self, const char *sender);
// Get the tracker field
const char *
mlm_proto_tracker (mlm_proto_t *self);
// Set the tracker field
void
mlm_proto_set_tracker (mlm_proto_t *self, const char *tracker);
// Get the timeout field
uint32_t
mlm_proto_timeout (mlm_proto_t *self);
// Set the timeout field
void
mlm_proto_set_timeout (mlm_proto_t *self, uint32_t timeout);
// Get the status_code field
uint16_t
mlm_proto_status_code (mlm_proto_t *self);
// Set the status_code field
void
mlm_proto_set_status_code (mlm_proto_t *self, uint16_t status_code);
// Get the status_reason field
const char *
mlm_proto_status_reason (mlm_proto_t *self);
// Set the status_reason field
void
mlm_proto_set_status_reason (mlm_proto_t *self, const char *status_reason);
// Get the amount field
uint16_t
mlm_proto_amount (mlm_proto_t *self);
// Set the amount field
void
mlm_proto_set_amount (mlm_proto_t *self, uint16_t amount);
// Self test of this class.
void
mlm_proto_test (bool verbose);
// CLASS: mlm_client
// Create a new mlm_client, return the reference if successful,
// or NULL if construction failed due to lack of available memory.
mlm_client_t *
mlm_client_new (void);
// Destroy the mlm_client and free all memory used by the object.
void
mlm_client_destroy (mlm_client_t **self_p);
// Return actor, when caller wants to work with multiple actors and/or
// input sockets asynchronously.
zactor_t *
mlm_client_actor (mlm_client_t *self);
// Return message pipe for asynchronous message I/O. In the high-volume case,
// we send methods and get replies to the actor, in a synchronous manner, and
// we send/recv high volume message data to a second pipe, the msgpipe. In
// the low-volume case we can do everything over the actor pipe, if traffic
// is never ambiguous.
zsock_t *
mlm_client_msgpipe (mlm_client_t *self);
// Return true if client is currently connected, else false. Note that the
// client will automatically re-connect if the server dies and restarts after
// a successful first connection.
bool
mlm_client_connected (mlm_client_t *self);
// Set PLAIN authentication username and password. If you do not call this, the
// client will use NULL authentication. TODO: add "set curve auth".
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_set_plain_auth (mlm_client_t *self, const char *username, const char *password);
// Connect to server endpoint, with specified timeout in msecs (zero means wait
// forever). Constructor succeeds if connection is successful. The caller may
// specify its address.
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_connect (mlm_client_t *self, const char *endpoint, uint32_t timeout, const char *address);
// Prepare to publish to a specified stream. After this, all messages are sent to
// this stream exclusively.
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_set_producer (mlm_client_t *self, const char *stream);
// Consume messages with matching subjects. The pattern is a regular expression
// using the CZMQ zrex syntax. The most useful elements are: ^ and $ to match the
// start and end, . to match any character, \s and \S to match whitespace and
// non-whitespace, \d and \D to match a digit and non-digit, \a and \A to match
// alphabetic and non-alphabetic, \w and \W to match alphanumeric and
// non-alphanumeric, + for one or more repetitions, * for zero or more repetitions,
// and ( ) to create groups. Returns 0 if subscription was successful, else -1.
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_set_consumer (mlm_client_t *self, const char *stream, const char *pattern);
// Remove all subscriptions to a stream
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_remove_consumer (mlm_client_t *self, const char *stream);
// Offer a particular named service, where the pattern matches request subjects
// using the CZMQ zrex syntax.
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_set_worker (mlm_client_t *self, const char *address, const char *pattern);
// Send STREAM SEND message to server, takes ownership of message
// and destroys message when done sending it.
int
mlm_client_send (mlm_client_t *self, const char *subject, zmsg_t **content);
// Send MAILBOX SEND message to server, takes ownership of message
// and destroys message when done sending it.
int
mlm_client_sendto (mlm_client_t *self, const char *address, const char *subject, const char *tracker, uint32_t timeout, zmsg_t **content);
// Send SERVICE SEND message to server, takes ownership of message
// and destroys message when done sending it.
int
mlm_client_sendfor (mlm_client_t *self, const char *address, const char *subject, const char *tracker, uint32_t timeout, zmsg_t **content);
// Receive message from server; caller destroys message when done
zmsg_t *
mlm_client_recv (mlm_client_t *self);
// Return last received command. Can be one of these values:
// "STREAM DELIVER"
// "MAILBOX DELIVER"
// "SERVICE DELIVER"
const char *
mlm_client_command (mlm_client_t *self);
// Return last received status
int
mlm_client_status (mlm_client_t *self);
// Return last received reason
const char *
mlm_client_reason (mlm_client_t *self);
// Return last received address
const char *
mlm_client_address (mlm_client_t *self);
// Return last received sender
const char *
mlm_client_sender (mlm_client_t *self);
// Return last received subject
const char *
mlm_client_subject (mlm_client_t *self);
// Return last received content
zmsg_t *
mlm_client_content (mlm_client_t *self);
// Return last received tracker
const char *
mlm_client_tracker (mlm_client_t *self);
// Send multipart string message to stream, end list with NULL
// Returns 0 if OK, -1 if failed due to lack of memory or other error.
int
mlm_client_sendx (mlm_client_t *self, const char *subject, const char *content, ...);
// Send multipart string to mailbox, end list with NULL
// Returns 0 if OK, -1 if failed due to lack of memory or other error.
int
mlm_client_sendtox (mlm_client_t *self, const char *address, const char *subject, const char *content, ...);
// Send multipart string to service, end list with NULL
// Returns 0 if OK, -1 if failed due to lack of memory or other error.
int
mlm_client_sendforx (mlm_client_t *self, const char *address, const char *subject, const char *content, ...);
// Receive a subject and string content from the server. The content may be
// 1 or more string frames. This method is orthogonal to the sendx methods.
// End the string arguments with NULL. If there are not enough frames in
// the received message, remaining strings are set to NULL. Returns number
// of string contents received, or -1 in case of error. Free the returned
// subject and content strings when finished with them. To get the type of
// the command, use mlm_client_command ().
int
mlm_client_recvx (mlm_client_t *self, char **subject_p, char **string_p, ...);
// Enable verbose tracing (animation) of state machine activity.
void
mlm_client_set_verbose (mlm_client_t *self, bool verbose);
// Self test of this class.
void
mlm_client_test (bool verbose);
''')