libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
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 */
52
53 /* LWS_WRITE_CLOSE is handled by lws_close_reason() */
56
57 /* Same as write_http but we know this write ends the transaction */
59
60 /* HTTP2 */
61
71
72 /****** add new things just above ---^ ******/
73
74 /* flags */
75
83
86
91
96};
97
98/* used with LWS_CALLBACK_CHILD_WRITE_VIA_PARENT */
99
101 struct lws *wsi;
102 unsigned char *buf;
103 size_t len;
105};
106
107
209lws_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
227static LWS_INLINE int
228lws_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
236
237 if (!is_end)
238 r |= LWS_WRITE_NO_FIN;
239
240 return r;
241}
242
258
#define LWS_INLINE
#define LWS_EXTERN
#define LWS_WARN_UNUSED_RESULT
#define LWS_VISIBLE
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_raw_transaction_completed(struct lws *wsi)
struct lws * wsi
Definition lws-write.h:101
unsigned char * buf
Definition lws-write.h:102
lws_write_protocol
Definition lws-write.h:36
@ LWS_WRITE_CONTINUATION
Definition lws-write.h:47
@ LWS_WRITE_NO_FIN
Definition lws-write.h:84
@ LWS_WRITE_CLIENT_IGNORE_XOR_MASK
Definition lws-write.h:92
@ LWS_WRITE_H2_STREAM_END
Definition lws-write.h:87
@ LWS_WRITE_PING
Definition lws-write.h:54
@ LWS_WRITE_TEXT
Definition lws-write.h:37
@ LWS_WRITE_PONG
Definition lws-write.h:55
@ LWS_WRITE_HTTP
Definition lws-write.h:50
@ LWS_WRITE_HTTP_FINAL
Definition lws-write.h:58
@ LWS_WRITE_BINARY
Definition lws-write.h:42
@ LWS_WRITE_BUFLIST
Definition lws-write.h:76
@ LWS_WRITE_HTTP_HEADERS_CONTINUATION
Definition lws-write.h:68
@ LWS_WRITE_HTTP_HEADERS
Definition lws-write.h:62
enum lws_write_protocol wp
Definition lws-write.h:104
LWS_VISIBLE LWS_EXTERN int lws_write(struct lws *wsi, unsigned char *buf, size_t len, enum lws_write_protocol protocol)