| libwebsockets.h (2.1.0) | | libwebsockets.h (2.1.1) |
| | |
| 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 |
| | #define LWS_FORMAT(string_index) |
| | |
| #ifdef LWS_DLL | | #ifdef LWS_DLL |
| #ifdef LWS_INTERNAL | | #ifdef LWS_INTERNAL |
| #define LWS_EXTERN extern __declspec(dllexport) | | #define LWS_EXTERN extern __declspec(dllexport) |
| #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 188 ¶ | | skipping to change at line 189 ¶ |
| | |
| /* warn_unused_result attribute only supported by GCC 3.4 or later */ | | /* warn_unused_result attribute only supported by GCC 3.4 or later */ |
| #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) | | #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
| #define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | | #define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| #else | | #else |
| #define LWS_WARN_UNUSED_RESULT | | #define LWS_WARN_UNUSED_RESULT |
| #endif | | #endif |
| | |
| #define LWS_VISIBLE __attribute__((visibility("default"))) | | #define LWS_VISIBLE __attribute__((visibility("default"))) |
| #define LWS_WARN_DEPRECATED __attribute__ ((deprecated)) | | #define LWS_WARN_DEPRECATED __attribute__ ((deprecated)) |
| | #define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_inde
x, string_index+1))) |
| #else | | #else |
| #define LWS_VISIBLE | | #define LWS_VISIBLE |
| #define LWS_WARN_UNUSED_RESULT | | #define LWS_WARN_UNUSED_RESULT |
| #define LWS_WARN_DEPRECATED | | #define LWS_WARN_DEPRECATED |
| | #define LWS_FORMAT(string_index) |
| #endif | | #endif |
| | |
| #if defined(__ANDROID__) | | #if defined(__ANDROID__) |
| #include <unistd.h> | | #include <unistd.h> |
| #define getdtablesize() sysconf(_SC_OPEN_MAX) | | #define getdtablesize() sysconf(_SC_OPEN_MAX) |
| #endif | | #endif |
| | |
| #endif | | #endif |
| | |
| #ifdef LWS_USE_LIBEV | | #ifdef LWS_USE_LIBEV |
| | |
| skipping to change at line 282 ¶ | | skipping to change at line 285 ¶ |
| LLL_DEBUG = 1 << 4, | | LLL_DEBUG = 1 << 4, |
| LLL_PARSER = 1 << 5, | | LLL_PARSER = 1 << 5, |
| LLL_HEADER = 1 << 6, | | LLL_HEADER = 1 << 6, |
| LLL_EXT = 1 << 7, | | LLL_EXT = 1 << 7, |
| LLL_CLIENT = 1 << 8, | | LLL_CLIENT = 1 << 8, |
| LLL_LATENCY = 1 << 9, | | LLL_LATENCY = 1 << 9, |
| | |
| LLL_COUNT = 10 /* set to count of valid flags */ | | LLL_COUNT = 10 /* set to count of valid flags */ |
| }; | | }; |
| | |
| LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...); | | LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...) L
WS_FORMAT(2); |
| LWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_li
st vl); | | LWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_li
st vl); |
| /** | | /** |
| * lwsl_timestamp: generate logging timestamp string | | * lwsl_timestamp: generate logging timestamp string |
| * | | * |
| * \param level: logging level | | * \param level: logging level |
| * \param p: char * buffer to take timestamp | | * \param p: char * buffer to take timestamp |
| * \param len: length of p | | * \param len: length of p |
| * | | * |
| * returns length written in p | | * returns length written in p |
| */ | | */ |
| | |
| skipping to change at line 474 ¶ | | skipping to change at line 477 ¶ |
| | |
| struct lws_vhost; | | struct lws_vhost; |
| | |
| lws_sockfd_type esp8266_create_tcp_listen_socket(struct lws_vhost *vh); | | lws_sockfd_type esp8266_create_tcp_listen_socket(struct lws_vhost *vh); |
| void esp8266_tcp_stream_accept(lws_sockfd_type fd, struct lws *wsi); | | void esp8266_tcp_stream_accept(lws_sockfd_type fd, struct lws *wsi); |
| | |
| #include <os_type.h> | | #include <os_type.h> |
| #include <osapi.h> | | #include <osapi.h> |
| #include "ets_sys.h" | | #include "ets_sys.h" |
| | |
| int ets_snprintf(char *str, size_t size, const char *format, ...); | | int ets_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMA
T(3); |
| #define snprintf ets_snprintf | | #define snprintf ets_snprintf |
| | |
| typedef os_timer_t uv_timer_t; | | typedef os_timer_t uv_timer_t; |
| typedef void uv_cb_t(uv_timer_t *); | | typedef void uv_cb_t(uv_timer_t *); |
| | |
| void os_timer_disarm(void *); | | void os_timer_disarm(void *); |
| void os_timer_setfn(os_timer_t *, os_timer_func_t *, void *); | | void os_timer_setfn(os_timer_t *, os_timer_func_t *, void *); |
| | |
| void ets_timer_arm_new(os_timer_t *, int, int, int); | | void ets_timer_arm_new(os_timer_t *, int, int, int); |
| | |
| | |
| skipping to change at line 1212 ¶ | | skipping to change at line 1215 ¶ |
| 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 1737 ¶ | | skipping to change at line 1740 ¶ |
| * 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 2247 ¶ | | skipping to change at line 2250 ¶ |
| * 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 3258 ¶ | | skipping to change at line 3265 ¶ |
| * 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 |
| | |
| skipping to change at line 3609 ¶ | | skipping to change at line 3630 ¶ |
| * | | * |
| * \param str: destination buffer | | * \param str: destination buffer |
| * \param size: bytes left in destination buffer | | * \param size: bytes left in destination buffer |
| * \param format: format string | | * \param format: format string |
| * \param ...: args for format | | * \param ...: args for format |
| * | | * |
| * This lets you correctly truncate buffers by concatenating lengths, if yo
u | | * This lets you correctly truncate buffers by concatenating lengths, if yo
u |
| * reach the limit the reported length doesn't exceed the limit. | | * reach the limit the reported length doesn't exceed the limit. |
| */ | | */ |
| LWS_VISIBLE LWS_EXTERN int | | LWS_VISIBLE LWS_EXTERN int |
| lws_snprintf(char *str, size_t size, const char *format, ...); | | lws_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3)
; |
| | |
| /** | | /** |
| * lws_get_random(): fill a buffer with platform random data | | * lws_get_random(): fill a buffer with platform random data |
| * | | * |
| * \param context: the lws context | | * \param context: the lws context |
| * \param buf: buffer to fill | | * \param buf: buffer to fill |
| * \param len: how much to fill | | * \param len: how much to fill |
| * | | * |
| * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if | | * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if |
| * it's interested to see if the frame it's dealing with was sent in binary | | * it's interested to see if the frame it's dealing with was sent in binary |
| | |
| End of changes. 14 change blocks. |
| 13 lines changed or deleted | | 38 lines changed or added |
|