| libwebsockets.h (2.1.0) | | libwebsockets.h (current) | |
| | | | |
| skipping to change at line 127 ¶ | | skipping to change at line 127 ¶ | |
| #ifndef _WIN32_WCE | | #ifndef _WIN32_WCE | |
| #include <fcntl.h> | | #include <fcntl.h> | |
| #else | | #else | |
| #define _O_RDONLY 0x0000 | | #define _O_RDONLY 0x0000 | |
| #define O_RDONLY _O_RDONLY | | #define O_RDONLY _O_RDONLY | |
| #endif | | #endif | |
| | | | |
| // Visual studio older than 2015 and WIN_CE has only _stricmp | | // Visual studio older than 2015 and WIN_CE has only _stricmp | |
| #if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE) | | #if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE) | |
| #define strcasecmp _stricmp | | #define strcasecmp _stricmp | |
|
| #else | | #elif !defined(__MINGW32__) | |
| #define strcasecmp stricmp | | #define strcasecmp stricmp | |
| #endif | | #endif | |
| #define getdtablesize() 30000 | | #define getdtablesize() 30000 | |
| | | | |
| #define LWS_INLINE __inline | | #define LWS_INLINE __inline | |
| #define LWS_VISIBLE | | #define LWS_VISIBLE | |
| #define LWS_WARN_UNUSED_RESULT | | #define LWS_WARN_UNUSED_RESULT | |
| #define LWS_WARN_DEPRECATED | | #define LWS_WARN_DEPRECATED | |
| | | | |
| #ifdef LWS_DLL | | #ifdef LWS_DLL | |
| | | | |
| skipping to change at line 150 ¶ | | skipping to change at line 150 ¶ | |
| #else | | #else | |
| #define LWS_EXTERN extern __declspec(dllimport) | | #define LWS_EXTERN extern __declspec(dllimport) | |
| #endif | | #endif | |
| #else | | #else | |
| #define LWS_EXTERN | | #define LWS_EXTERN | |
| #endif | | #endif | |
| | | | |
| #define LWS_INVALID_FILE INVALID_HANDLE_VALUE | | #define LWS_INVALID_FILE INVALID_HANDLE_VALUE | |
| #define LWS_O_RDONLY _O_RDONLY | | #define LWS_O_RDONLY _O_RDONLY | |
| | | | |
|
| #if !defined(_MSC_VER) || _MSC_VER < 1900 /* Visual Studio 2015 already def
ines this in <stdio.h> */ | | #if !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER < 1900) /* Vis
ual Studio 2015 already defines this in <stdio.h> */ | |
| #define lws_snprintf _snprintf | | #define lws_snprintf _snprintf | |
| #endif | | #endif | |
| | | | |
| #ifndef __func__ | | #ifndef __func__ | |
| #define __func__ __FUNCTION__ | | #define __func__ __FUNCTION__ | |
| #endif | | #endif | |
| | | | |
| #else /* NOT WIN32 */ | | #else /* NOT WIN32 */ | |
| #include <unistd.h> | | #include <unistd.h> | |
| | | | |
| | | | |
| skipping to change at line 1212 ¶ | | skipping to change at line 1212 ¶ | |
| const char *opt_name, const char *opt_val); | | const char *opt_name, const char *opt_val); | |
| | | | |
| #ifndef LWS_NO_EXTENSIONS | | #ifndef LWS_NO_EXTENSIONS | |
| /* lws_get_internal_extensions() - DEPRECATED | | /* lws_get_internal_extensions() - DEPRECATED | |
| * | | * | |
| * \Deprecated There is no longer a set internal extensions table. The tab
le is provided | | * \Deprecated There is no longer a set internal extensions table. The tab
le is provided | |
| * by user code along with application-specific settings. See the test | | * by user code along with application-specific settings. See the test | |
| * client and server for how to do. | | * client and server for how to do. | |
| */ | | */ | |
| static LWS_INLINE LWS_WARN_DEPRECATED const struct lws_extension * | | static LWS_INLINE LWS_WARN_DEPRECATED const struct lws_extension * | |
|
| lws_get_internal_extensions() { return NULL; } | | lws_get_internal_extensions(void) { return NULL; } | |
| | | | |
| /** | | /** | |
| * lws_ext_parse_options() - deal with parsing negotiated extension options | | * lws_ext_parse_options() - deal with parsing negotiated extension options | |
| * | | * | |
| * \param ext: related extension struct | | * \param ext: related extension struct | |
| * \param wsi: websocket connection | | * \param wsi: websocket connection | |
| * \param ext_user: per-connection extension private data | | * \param ext_user: per-connection extension private data | |
| * \param opts: list of supported options | | * \param opts: list of supported options | |
| * \param o: option string to parse | | * \param o: option string to parse | |
| * \param len: length | | * \param len: length | |
| | | | |
| skipping to change at line 1701 ¶ | | skipping to change at line 1701 ¶ | |
| * so a connection which always sends or receives something at inter
vals | | * so a connection which always sends or receives something at inter
vals | |
| * less than the interval given here will never send PINGs / expect | | * less than the interval given here will never send PINGs / expect | |
| * PONGs. Conversely as soon as the ws connection is established, a
n | | * PONGs. Conversely as soon as the ws connection is established, a
n | |
| * idle connection will do the PING / PONG roundtrip as soon as | | * idle connection will do the PING / PONG roundtrip as soon as | |
| * ws_ping_pong_interval seconds has passed without traffic | | * ws_ping_pong_interval seconds has passed without traffic | |
| */ | | */ | |
| const struct lws_protocol_vhost_options *headers; | | const struct lws_protocol_vhost_options *headers; | |
| /**< VHOST: pointer to optional linked list of per-vhost | | /**< VHOST: pointer to optional linked list of per-vhost | |
| * canned headers that are added to server responses */ | | * canned headers that are added to server responses */ | |
| | | | |
|
| | | const struct lws_protocol_vhost_options *reject_service_keywords; | |
| | | /**< CONTEXT: Optional list of keywords and rejection codes + text. | |
| | | * | |
| | | * The keywords are checked for existing in the user agent string. | |
| | | * | |
| | | * Eg, "badrobot" "404 Not Found" | |
| | | */ | |
| | | | |
| /* Add new things just above here ---^ | | /* Add new things just above here ---^ | |
| * This is part of the ABI, don't needlessly break compatibility | | * This is part of the ABI, don't needlessly break compatibility | |
| * | | * | |
| * The below is to ensure later library versions with new | | * The below is to ensure later library versions with new | |
| * members added above will see 0 (default) even if the app | | * members added above will see 0 (default) even if the app | |
| * was not built against the newer headers. | | * was not built against the newer headers. | |
| */ | | */ | |
| | | | |
| void *_unused[8]; /**< dummy */ | | void *_unused[8]; /**< dummy */ | |
| }; | | }; | |
| | | | |
| skipping to change at line 1737 ¶ | | skipping to change at line 1745 ¶ | |
| * server's sockets serviced. This must be done in the same process | | * server's sockets serviced. This must be done in the same process | |
| * context as the initialization call. | | * context as the initialization call. | |
| * | | * | |
| * The protocol callback functions are called for a handful of events | | * The protocol callback functions are called for a handful of events | |
| * including http requests coming in, websocket connections becoming | | * including http requests coming in, websocket connections becoming | |
| * established, and data arriving; it's also called periodically to all
ow | | * established, and data arriving; it's also called periodically to all
ow | |
| * async transmission. | | * async transmission. | |
| * | | * | |
| * HTTP requests are sent always to the FIRST protocol in protocol, sin
ce | | * HTTP requests are sent always to the FIRST protocol in protocol, sin
ce | |
| * at that time websocket protocol has not been negotiated. Other | | * at that time websocket protocol has not been negotiated. Other | |
|
| * protocols after the first one never see any HTTP callack activity. | | * protocols after the first one never see any HTTP callback activity. | |
| * | | * | |
| * The server created is a simple http server by default; part of the | | * The server created is a simple http server by default; part of the | |
| * websocket standard is upgrading this http connection to a websocket
one. | | * websocket standard is upgrading this http connection to a websocket
one. | |
| * | | * | |
| * This allows the same server to provide files like scripts and favico
n / | | * This allows the same server to provide files like scripts and favico
n / | |
| * images or whatever over http and dynamic data over websockets all in | | * images or whatever over http and dynamic data over websockets all in | |
| * one place; they're all handled in the user callback. | | * one place; they're all handled in the user callback. | |
| */ | | */ | |
| LWS_VISIBLE LWS_EXTERN struct lws_context * | | LWS_VISIBLE LWS_EXTERN struct lws_context * | |
| lws_create_context(struct lws_context_creation_info *info); | | lws_create_context(struct lws_context_creation_info *info); | |
| | | | |
| skipping to change at line 1967 ¶ | | skipping to change at line 1975 ¶ | |
| ///@{ | | ///@{ | |
| | | | |
| /** enum lws_client_connect_ssl_connection_flags - flags that may be used | | /** enum lws_client_connect_ssl_connection_flags - flags that may be used | |
| * with struct lws_client_connect_info ssl_connection member to control if | | * with struct lws_client_connect_info ssl_connection member to control if | |
| * and how SSL checks apply to the client connection being created | | * and how SSL checks apply to the client connection being created | |
| */ | | */ | |
| | | | |
| enum lws_client_connect_ssl_connection_flags { | | enum lws_client_connect_ssl_connection_flags { | |
| LCCSCF_USE_SSL = (1 << 0), | | LCCSCF_USE_SSL = (1 << 0), | |
| LCCSCF_ALLOW_SELFSIGNED = (1 << 1), | | LCCSCF_ALLOW_SELFSIGNED = (1 << 1), | |
|
| LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2) | | LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2), | |
| | | LCCSCF_ALLOW_EXPIRED = (1 << 3) | |
| }; | | }; | |
| | | | |
| /** struct lws_client_connect_info - parameters to connect with when using | | /** struct lws_client_connect_info - parameters to connect with when using | |
| * lws_client_connect_via_info() */ | | * lws_client_connect_via_info() */ | |
| | | | |
| struct lws_client_connect_info { | | struct lws_client_connect_info { | |
| struct lws_context *context; | | struct lws_context *context; | |
| /**< lws context to create connection in */ | | /**< lws context to create connection in */ | |
| const char *address; | | const char *address; | |
| /**< remote address to connect to */ | | /**< remote address to connect to */ | |
| | | | |
| skipping to change at line 2129 ¶ | | skipping to change at line 2138 ¶ | |
| * LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with | | * LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with | |
| * the same info struct. | | * the same info struct. | |
| */ | | */ | |
| LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int | |
| lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, | | lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, | |
| struct lws_vhost *vhost); | | struct lws_vhost *vhost); | |
| | | | |
| LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int | |
| lws_http_client_read(struct lws *wsi, char **buf, int *len); | | lws_http_client_read(struct lws *wsi, char **buf, int *len); | |
| | | | |
|
| | | /** | |
| | | * lws_http_client_http_response() - get last HTTP response code | |
| | | * | |
| | | * \param wsi: client connection | |
| | | * | |
| | | * Returns the last server response code, eg, 200 for client http connectio | |
| | | ns. | |
| | | */ | |
| | | LWS_VISIBLE LWS_EXTERN unsigned int | |
| | | lws_http_client_http_response(struct lws *wsi); | |
| | | | |
| LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void | |
| lws_client_http_body_pending(struct lws *wsi, int something_left_to_send); | | lws_client_http_body_pending(struct lws *wsi, int something_left_to_send); | |
| | | | |
| /** | | /** | |
| * lws_client_http_body_pending() - control if client connection neeeds to
send body | | * lws_client_http_body_pending() - control if client connection neeeds to
send body | |
| * | | * | |
| * \param wsi: client connection | | * \param wsi: client connection | |
| * \param something_left_to_send: nonzero if need to send more body, 0 (def
ault) | | * \param something_left_to_send: nonzero if need to send more body, 0 (def
ault) | |
| * if nothing more to send | | * if nothing more to send | |
| * | | * | |
| | | | |
| skipping to change at line 2247 ¶ | | skipping to change at line 2266 ¶ | |
| * so the wait in poll() is ended. That's useful because poll() doesn'
t | | * so the wait in poll() is ended. That's useful because poll() doesn'
t | |
| * attend to changes in POLLIN/OUT/ERR until it re-enters the wait. | | * attend to changes in POLLIN/OUT/ERR until it re-enters the wait. | |
| */ | | */ | |
| LWS_VISIBLE LWS_EXTERN void | | LWS_VISIBLE LWS_EXTERN void | |
| lws_cancel_service(struct lws_context *context); | | lws_cancel_service(struct lws_context *context); | |
| | | | |
| /** | | /** | |
| * lws_service_fd() - Service polled socket with something waiting | | * lws_service_fd() - Service polled socket with something waiting | |
| * \param context: Websocket context | | * \param context: Websocket context | |
| * \param pollfd: The pollfd entry describing the socket fd and which
events | | * \param pollfd: The pollfd entry describing the socket fd and which
events | |
|
| * happened. | | * happened, or NULL to tell lws to do only timeout servicing. | |
| * | | * | |
| * This function takes a pollfd that has POLLIN or POLLOUT activity and | | * This function takes a pollfd that has POLLIN or POLLOUT activity and | |
| * services it according to the state of the associated | | * services it according to the state of the associated | |
| * struct lws. | | * struct lws. | |
| * | | * | |
| * The one call deals with all "service" that might happen on a socket | | * The one call deals with all "service" that might happen on a socket | |
| * including listen accepts, http files as well as websocket protocol. | | * including listen accepts, http files as well as websocket protocol. | |
| * | | * | |
| * If a pollfd says it has something, you can just pass it to | | * If a pollfd says it has something, you can just pass it to | |
| * lws_service_fd() whether it is a socket handled by lws or not. | | * lws_service_fd() whether it is a socket handled by lws or not. | |
| * If it sees it is a lws socket, the traffic will be handled and | | * If it sees it is a lws socket, the traffic will be handled and | |
| * pollfd->revents will be zeroed now. | | * pollfd->revents will be zeroed now. | |
| * | | * | |
| * If the socket is foreign to lws, it leaves revents alone. So you can | | * If the socket is foreign to lws, it leaves revents alone. So you can | |
| * see if you should service yourself by checking the pollfd revents | | * see if you should service yourself by checking the pollfd revents | |
| * after letting lws try to service it. | | * after letting lws try to service it. | |
|
| | | * | |
| | | * You should also call this with pollfd = NULL to just allow the | |
| | | * once-per-second global timeout checks; if less than a second since the l | |
| | | ast | |
| | | * check it returns immediately then. | |
| */ | | */ | |
| LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int | |
| lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd); | | lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd); | |
| | | | |
| /** | | /** | |
| * lws_service_fd_tsi() - Service polled socket in specific service thread | | * lws_service_fd_tsi() - Service polled socket in specific service thread | |
| * \param context: Websocket context | | * \param context: Websocket context | |
| * \param pollfd: The pollfd entry describing the socket fd and which
events | | * \param pollfd: The pollfd entry describing the socket fd and which
events | |
| * happened. | | * happened. | |
| * \param tsi: thread service index | | * \param tsi: thread service index | |
| | | | |
| skipping to change at line 2295 ¶ | | skipping to change at line 2318 ¶ | |
| * to 1 if you don't really have a poll timeout. | | * to 1 if you don't really have a poll timeout. | |
| * \param tsi: thread service index | | * \param tsi: thread service index | |
| * | | * | |
| * Under some conditions connections may need service even though there is
no | | * Under some conditions connections may need service even though there is
no | |
| * pending network action on them, this is "forced service". For default | | * pending network action on them, this is "forced service". For default | |
| * poll() and libuv / libev, the library takes care of calling this and | | * poll() and libuv / libev, the library takes care of calling this and | |
| * dealing with it for you. But for external poll() integration, you need | | * dealing with it for you. But for external poll() integration, you need | |
| * access to the apis. | | * access to the apis. | |
| * | | * | |
| * If anybody needs "forced service", returned timeout is zero. In that ca
se, | | * If anybody needs "forced service", returned timeout is zero. In that ca
se, | |
|
| * you can call lws_plat_service_tsi() with a timeout of -1 to only service | | * you can call lws_service_tsi() with a timeout of -1 to only service | |
| * guys who need forced service. | | * guys who need forced service. | |
| */ | | */ | |
| LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int | |
| lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int
tsi); | | lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int
tsi); | |
| | | | |
|
| /** | | /* Backwards compatibility */ | |
| * lws_plat_service_tsi() - Lowlevel platform-specific service api | | #define lws_plat_service_tsi lws_service_tsi | |
| * \param context: Websocket context | | | |
| * \param timeout_ms: The original poll timeout value. You can just set t | | | |
| his | | | |
| * to 1 if you don't really have a poll timeout. | | | |
| * \param tsi: thread service index | | | |
| * | | | |
| * For default poll() and libuv/ev, lws takes care of using this for you. a | | | |
| nd | | | |
| * you can ignore it. | | | |
| * | | | |
| * But for external poll() integration, you need access to this api to serv | | | |
| ice | | | |
| * connections that need to be serviced but have no pending network activit | | | |
| y. | | | |
| * | | | |
| * See lws_service_adjust_timeout() for more info. | | | |
| */ | | | |
| LWS_EXTERN LWS_VISIBLE int | | | |
| lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi); | | | |
| | | | |
| ///@} | | ///@} | |
| | | | |
| /*! \defgroup http HTTP | | /*! \defgroup http HTTP | |
| | | | |
| Modules related to handling HTTP | | Modules related to handling HTTP | |
| */ | | */ | |
| //@{ | | //@{ | |
| | | | |
| /*! \defgroup httpft HTTP File transfer | | /*! \defgroup httpft HTTP File transfer | |
| | | | |
| skipping to change at line 3258 ¶ | | skipping to change at line 3266 ¶ | |
| * Pad LWS_PRE to the CPU word size, so that word references | | * Pad LWS_PRE to the CPU word size, so that word references | |
| * to the address immediately after the padding won't cause an unaligned ac
cess | | * to the address immediately after the padding won't cause an unaligned ac
cess | |
| * error. Sometimes for performance reasons the recommended padding is even | | * error. Sometimes for performance reasons the recommended padding is even | |
| * larger than sizeof(void *). | | * larger than sizeof(void *). | |
| * | | * | |
| * In the case of sending using websocket protocol, be sure to allocate | | * In the case of sending using websocket protocol, be sure to allocate | |
| * valid storage before and after buf as explained above. This scheme | | * valid storage before and after buf as explained above. This scheme | |
| * allows maximum efficiency of sending data and protocol in a single | | * allows maximum efficiency of sending data and protocol in a single | |
| * packet while not burdening the user code with any protocol knowledge
. | | * packet while not burdening the user code with any protocol knowledge
. | |
| * | | * | |
|
| * Return may be -1 for a fatal error needing connection close, or a | | * Return may be -1 for a fatal error needing connection close, or the | |
| * positive number reflecting the amount of bytes actually sent. This | | * number of bytes sent. | |
| * can be less than the requested number of bytes due to OS memory | | * | |
| * pressure at any given time. | | * Truncated Writes | |
| | | * ================ | |
| | | * | |
| | | * The OS may not accept everything you asked to write on the connection. | |
| | | * | |
| | | * Posix defines POLLOUT indication from poll() to show that the connection | |
| | | * will accept more write data, but it doesn't specifiy how much. It may j | |
| | | ust | |
| | | * accept one byte of whatever you wanted to send. | |
| | | * | |
| | | * LWS will buffer the remainder automatically, and send it out autonomousl | |
| | | y. | |
| | | * | |
| | | * During that time, WRITABLE callbacks will be suppressed. | |
| | | * | |
| | | * This is to handle corner cases where unexpectedly the OS refuses what we | |
| | | * usually expect it to accept. You should try to send in chunks that are | |
| | | * almost always accepted in order to avoid the inefficiency of the bufferi | |
| | | ng. | |
| */ | | */ | |
| LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int | |
| lws_write(struct lws *wsi, unsigned char *buf, size_t len, | | lws_write(struct lws *wsi, unsigned char *buf, size_t len, | |
| enum lws_write_protocol protocol); | | enum lws_write_protocol protocol); | |
| | | | |
| /* helper for case where buffer may be const */ | | /* helper for case where buffer may be const */ | |
| #define lws_write_http(wsi, buf, len) \ | | #define lws_write_http(wsi, buf, len) \ | |
| lws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP) | | lws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP) | |
|
| | | | |
| ///@} | | ///@} | |
| | | | |
| /** \defgroup callback-when-writeable Callback when writeable | | /** \defgroup callback-when-writeable Callback when writeable | |
| * | | * | |
| * ##Callback When Writeable | | * ##Callback When Writeable | |
| * | | * | |
| * lws can only write data on a connection when it is able to accept more | | * lws can only write data on a connection when it is able to accept more | |
| * data without blocking. | | * data without blocking. | |
| * | | * | |
| * So a basic requirement is we should only use the lws_write() apis when t
he | | * So a basic requirement is we should only use the lws_write() apis when t
he | |
| | | | |
End of changes. 13 change blocks. |
| 33 lines changed or deleted | | 56 lines changed or added | |
|