libwebsockets
Lightweight C library for HTML5 websockets
lws-write.h
Go to the documentation of this file.
1
/*
2
* libwebsockets - small server side websockets and web server implementation
3
*
4
* Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*/
24
30
#define LWS_WRITE_RAW LWS_WRITE_HTTP
31
32
/*
33
* NOTE: These public enums are part of the abi. If you want to add one,
34
* add it at where specified so existing users are unaffected.
35
*/
36
enum
lws_write_protocol
{
37
LWS_WRITE_TEXT
= 0,
42
LWS_WRITE_BINARY
= 1,
47
LWS_WRITE_CONTINUATION
= 2,
50
LWS_WRITE_HTTP
= 3,
53
/* LWS_WRITE_CLOSE is handled by lws_close_reason() */
54
LWS_WRITE_PING
= 5,
55
LWS_WRITE_PONG
= 6,
56
57
/* Same as write_http but we know this write ends the transaction */
58
LWS_WRITE_HTTP_FINAL
= 7,
59
60
/* HTTP2 */
61
62
LWS_WRITE_HTTP_HEADERS
= 8,
68
LWS_WRITE_HTTP_HEADERS_CONTINUATION
= 9,
72
/****** add new things just above ---^ ******/
73
74
/* flags */
75
76
LWS_WRITE_BUFLIST
= 0x20,
84
LWS_WRITE_NO_FIN
= 0x40,
87
LWS_WRITE_H2_STREAM_END
= 0x80,
92
LWS_WRITE_CLIENT_IGNORE_XOR_MASK
= 0x80
96
};
97
98
/* used with LWS_CALLBACK_CHILD_WRITE_VIA_PARENT */
99
100
struct
lws_write_passthru
{
101
struct
lws *
wsi
;
102
unsigned
char
*
buf
;
103
size_t
len
;
104
enum
lws_write_protocol
wp
;
105
};
106
107
208
LWS_VISIBLE
LWS_EXTERN
int
209
lws_write
(
struct
lws *wsi,
unsigned
char
*buf,
size_t
len,
210
enum
lws_write_protocol
protocol);
211
212
/* helper for case where buffer may be const */
213
#define lws_write_http(wsi, buf, len) \
214
lws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP)
215
227
static
LWS_INLINE
int
228
lws_write_ws_flags(
int
initial,
int
is_start,
int
is_end)
229
{
230
int
r;
231
232
if
(is_start)
233
r = initial;
234
else
235
r =
LWS_WRITE_CONTINUATION
;
236
237
if
(!is_end)
238
r |=
LWS_WRITE_NO_FIN
;
239
240
return
r;
241
}
242
256
LWS_VISIBLE
LWS_EXTERN
int
LWS_WARN_UNUSED_RESULT
257
lws_raw_transaction_completed
(
struct
lws *wsi);
258
LWS_INLINE
#define LWS_INLINE
Definition:
libwebsockets.h:161
LWS_EXTERN
#define LWS_EXTERN
Definition:
libwebsockets.h:225
LWS_WARN_UNUSED_RESULT
#define LWS_WARN_UNUSED_RESULT
Definition:
libwebsockets.h:221
LWS_VISIBLE
#define LWS_VISIBLE
Definition:
libwebsockets.h:220
lws_raw_transaction_completed
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_raw_transaction_completed(struct lws *wsi)
lws_write_passthru::wsi
struct lws * wsi
Definition:
lws-write.h:101
lws_write_passthru::buf
unsigned char * buf
Definition:
lws-write.h:102
lws_write_protocol
lws_write_protocol
Definition:
lws-write.h:36
LWS_WRITE_CONTINUATION
@ LWS_WRITE_CONTINUATION
Definition:
lws-write.h:47
LWS_WRITE_NO_FIN
@ LWS_WRITE_NO_FIN
Definition:
lws-write.h:84
LWS_WRITE_CLIENT_IGNORE_XOR_MASK
@ LWS_WRITE_CLIENT_IGNORE_XOR_MASK
Definition:
lws-write.h:92
LWS_WRITE_H2_STREAM_END
@ LWS_WRITE_H2_STREAM_END
Definition:
lws-write.h:87
LWS_WRITE_PING
@ LWS_WRITE_PING
Definition:
lws-write.h:54
LWS_WRITE_TEXT
@ LWS_WRITE_TEXT
Definition:
lws-write.h:37
LWS_WRITE_PONG
@ LWS_WRITE_PONG
Definition:
lws-write.h:55
LWS_WRITE_HTTP
@ LWS_WRITE_HTTP
Definition:
lws-write.h:50
LWS_WRITE_HTTP_FINAL
@ LWS_WRITE_HTTP_FINAL
Definition:
lws-write.h:58
LWS_WRITE_BINARY
@ LWS_WRITE_BINARY
Definition:
lws-write.h:42
LWS_WRITE_BUFLIST
@ LWS_WRITE_BUFLIST
Definition:
lws-write.h:76
LWS_WRITE_HTTP_HEADERS_CONTINUATION
@ LWS_WRITE_HTTP_HEADERS_CONTINUATION
Definition:
lws-write.h:68
LWS_WRITE_HTTP_HEADERS
@ LWS_WRITE_HTTP_HEADERS
Definition:
lws-write.h:62
lws_write_passthru::len
size_t len
Definition:
lws-write.h:103
lws_write_passthru::wp
enum lws_write_protocol wp
Definition:
lws-write.h:104
lws_write
LWS_VISIBLE LWS_EXTERN int lws_write(struct lws *wsi, unsigned char *buf, size_t len, enum lws_write_protocol protocol)
lws_write_passthru
Definition:
lws-write.h:100
include
libwebsockets
lws-write.h
Generated on Wed Dec 18 2024 07:29:37 for libwebsockets by
1.9.1