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
|
package vendor_curl
import c "core:c/libc"
ws_frame :: struct {
age: c.int, /* zero */
flags: ws_flags, /* See the CURLWS_* defines */
offset: off_t, /* the offset of this data into the frame */
bytesleft: off_t, /* number of pending bytes left of the payload */
len: c.size_t, /* size of the current data chunk */
}
ws_flags :: distinct bit_set[ws_flag; c.uint]
ws_flag :: enum c.uint {
/* flag bits */
TEXT = 0,
BINARY = 1,
CONT = 2,
CLOSE = 3,
PING = 4,
OFFSET = 5,
/* flags for curl_ws_send() */
PONG = 6,
}
WS_TEXT :: ws_flags{.TEXT}
WS_BINARY :: ws_flags{.BINARY}
WS_CONT :: ws_flags{.CONT}
WS_CLOSE :: ws_flags{.CLOSE}
WS_PING :: ws_flags{.PING}
WS_OFFSET :: ws_flags{.OFFSET}
WS_PONG :: ws_flags{.PONG}
/* bits for the CURLOPT_WS_OPTIONS bitmask: */
WS_RAW_MODE :: 1<<0
WS_NOAUTOPONG :: 1<<1
@(default_calling_convention="c", link_prefix="curl_")
foreign lib {
/*
* NAME curl_ws_recv()
*
* DESCRIPTION
*
* Receives data from the websocket connection. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/
ws_recv :: proc(curl: ^CURL, buffer: rawptr, buflen: c.size_t, recv: ^c.size_t, metap: ^^ws_frame) -> code ---
/*
* NAME curl_ws_send()
*
* DESCRIPTION
*
* Sends data over the websocket connection. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/
ws_send :: proc(curl: ^CURL, buffer: rawptr,
buflen: c.size_t, sent: ^c.size_t,
fragsize: off_t,
flags: ws_flags) -> code ---
/*
* NAME curl_ws_start_frame()
*
* DESCRIPTION
*
* Buffers a websocket frame header with the given flags and length.
* Errors when a previous frame is not complete, e.g. not all its
* payload has been added.
*/
ws_start_frame :: proc(curl: ^CURL,
flags: c.uint,
frame_len: off_t) -> code ---
ws_meta :: proc(curl: ^CURL) -> ^ws_frame ---
}
|