Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1571481737, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"cca3352ec47bf9648155afbc76fed210", "oid":{ "oid": "fb31602ff9aeb88267fb8132d48df31195782ae5", "alias": [ "refs/tags/v3.0.1"]},"blobname": "lib/libwebsockets.h", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010-2018 Andy Green \u003candy@warmcat.com\u003e\n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation:\n * version 2.1 of the License.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n * MA 02110-1301 USA\n */\n\n/** @file */\n\n#ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C\n#define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C\n\n#ifdef __cplusplus\n#include \u003ccstddef\u003e\n#include \u003ccstdarg\u003e\n\nextern \u0022C\u0022 {\n#else\n#include \u003cstdarg.h\u003e\n#endif\n\n#include \u003cstring.h\u003e\n#include \u003cstdlib.h\u003e\n\n#include \u0022lws_config.h\u0022\n\n/*\n * CARE: everything using cmake defines needs to be below here\n */\n\n#if defined(LWS_HAS_INTPTR_T)\n#include \u003cstdint.h\u003e\n#define lws_intptr_t intptr_t\n#else\ntypedef unsigned long long lws_intptr_t;\n#endif\n\n#if defined(WIN32) || defined(_WIN32)\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n\n#include \u003cwinsock2.h\u003e\n#include \u003cws2tcpip.h\u003e\n#include \u003cstddef.h\u003e\n#include \u003cbasetsd.h\u003e\n#include \u003cio.h\u003e\n#ifndef _WIN32_WCE\n#include \u003cfcntl.h\u003e\n#else\n#define _O_RDONLY\t0x0000\n#define O_RDONLY\t_O_RDONLY\n#endif\n\n#define LWS_INLINE __inline\n#define LWS_VISIBLE\n#define LWS_WARN_UNUSED_RESULT\n#define LWS_WARN_DEPRECATED\n#define LWS_FORMAT(string_index)\n\n#ifdef LWS_DLL\n#ifdef LWS_INTERNAL\n#define LWS_EXTERN extern __declspec(dllexport)\n#else\n#define LWS_EXTERN extern __declspec(dllimport)\n#endif\n#else\n#define LWS_EXTERN\n#endif\n\n#define LWS_INVALID_FILE INVALID_HANDLE_VALUE\n#define LWS_O_RDONLY _O_RDONLY\n#define LWS_O_WRONLY _O_WRONLY\n#define LWS_O_CREAT _O_CREAT\n#define LWS_O_TRUNC _O_TRUNC\n\n#ifndef __func__\n#define __func__ __FUNCTION__\n#endif\n\n#else /* NOT WIN32 */\n#include \u003cunistd.h\u003e\n#if defined(LWS_HAVE_SYS_CAPABILITY_H) \u0026\u0026 defined(LWS_HAVE_LIBCAP)\n#include \u003csys/capability.h\u003e\n#endif\n\n#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__QNX__) || defined(__OpenBSD__)\n#include \u003csys/socket.h\u003e\n#include \u003cnetinet/in.h\u003e\n#endif\n\n#define LWS_INLINE inline\n#define LWS_O_RDONLY O_RDONLY\n#define LWS_O_WRONLY O_WRONLY\n#define LWS_O_CREAT O_CREAT\n#define LWS_O_TRUNC O_TRUNC\n\n#if !defined(LWS_PLAT_OPTEE) \u0026\u0026 !defined(OPTEE_TA) \u0026\u0026 !defined(LWS_WITH_ESP32)\n#include \u003cpoll.h\u003e\n#include \u003cnetdb.h\u003e\n#define LWS_INVALID_FILE -1\n#else\n#define getdtablesize() (30)\n#if defined(LWS_WITH_ESP32)\n#define LWS_INVALID_FILE NULL\n#else\n#define LWS_INVALID_FILE NULL\n#endif\n#endif\n\n#if defined(__GNUC__)\n\n/* warn_unused_result attribute only supported by GCC 3.4 or later */\n#if __GNUC__ \u003e\u003d 4 || (__GNUC__ \u003d\u003d 3 \u0026\u0026 __GNUC_MINOR__ \u003e\u003d 4)\n#define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n#define LWS_WARN_UNUSED_RESULT\n#endif\n\n#define LWS_VISIBLE __attribute__((visibility(\u0022default\u0022)))\n#define LWS_WARN_DEPRECATED __attribute__ ((deprecated))\n#define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))\n#else\n#define LWS_VISIBLE\n#define LWS_WARN_UNUSED_RESULT\n#define LWS_WARN_DEPRECATED\n#define LWS_FORMAT(string_index)\n#endif\n\n#if defined(__ANDROID__)\n#include \u003cnetinet/in.h\u003e\n#include \u003cunistd.h\u003e\n#define getdtablesize() sysconf(_SC_OPEN_MAX)\n#endif\n\n#endif\n\n#if defined(LWS_WITH_LIBEV)\n#include \u003cev.h\u003e\n#endif /* LWS_WITH_LIBEV */\n#ifdef LWS_WITH_LIBUV\n#include \u003cuv.h\u003e\n#ifdef LWS_HAVE_UV_VERSION_H\n#include \u003cuv-version.h\u003e\n#endif\n#ifdef LWS_HAVE_NEW_UV_VERSION_H\n#include \u003cuv/version.h\u003e\n#endif\n#endif /* LWS_WITH_LIBUV */\n#if defined(LWS_WITH_LIBEVENT)\n#include \u003cevent2/event.h\u003e\n#endif /* LWS_WITH_LIBEVENT */\n\n#ifndef LWS_EXTERN\n#define LWS_EXTERN extern\n#endif\n\n#ifdef _WIN32\n#define random rand\n#else\n#if !defined(OPTEE_TA)\n#include \u003csys/time.h\u003e\n#include \u003cunistd.h\u003e\n#endif\n#endif\n\n#if defined(LWS_WITH_TLS)\n\n#ifdef USE_WOLFSSL\n#ifdef USE_OLD_CYASSL\n#ifdef _WIN32\n/*\n * Include user-controlled settings for windows from\n * \u003cwolfssl-root\u003e/IDE/WIN/user_settings.h\n */\n#include \u003cIDE/WIN/user_settings.h\u003e\n#include \u003ccyassl/ctaocrypt/settings.h\u003e\n#else\n#include \u003ccyassl/options.h\u003e\n#endif\n#include \u003ccyassl/openssl/ssl.h\u003e\n#include \u003ccyassl/error-ssl.h\u003e\n\n#else\n#ifdef _WIN32\n/*\n * Include user-controlled settings for windows from\n * \u003cwolfssl-root\u003e/IDE/WIN/user_settings.h\n */\n#include \u003cIDE/WIN/user_settings.h\u003e\n#include \u003cwolfssl/wolfcrypt/settings.h\u003e\n#else\n#include \u003cwolfssl/options.h\u003e\n#endif\n#include \u003cwolfssl/openssl/ssl.h\u003e\n#include \u003cwolfssl/error-ssl.h\u003e\n#endif /* not USE_OLD_CYASSL */\n#else\n#if defined(LWS_WITH_MBEDTLS)\n#if defined(LWS_WITH_ESP32)\n/* this filepath is passed to us but without quotes or \u003c\u003e */\n#undef MBEDTLS_CONFIG_FILE\n#define MBEDTLS_CONFIG_FILE \u003cmbedtls/esp_config.h\u003e\n#endif\n#include \u003cmbedtls/ssl.h\u003e\n#else\n#include \u003copenssl/ssl.h\u003e\n#if !defined(LWS_WITH_MBEDTLS)\n#include \u003copenssl/err.h\u003e\n#endif\n#endif\n#endif /* not USE_WOLFSSL */\n#endif\n\n/*\n * Helpers for pthread mutex in user code... if lws is built for\n * multiple service threads, these resolve to pthread mutex\n * operations. In the case LWS_MAX_SMP is 1 (the default), they\n * are all NOPs and no pthread type or api is referenced.\n */\n\n#if LWS_MAX_SMP \u003e 1\n\n#include \u003cpthread.h\u003e\n\n#define lws_pthread_mutex(name) pthread_mutex_t name;\n\nstatic LWS_INLINE void\nlws_pthread_mutex_init(pthread_mutex_t *lock)\n{\n\tpthread_mutex_init(lock, NULL);\n}\n\nstatic LWS_INLINE void\nlws_pthread_mutex_destroy(pthread_mutex_t *lock)\n{\n\tpthread_mutex_destroy(lock);\n}\n\nstatic LWS_INLINE void\nlws_pthread_mutex_lock(pthread_mutex_t *lock)\n{\n\tpthread_mutex_lock(lock);\n}\n\nstatic LWS_INLINE void\nlws_pthread_mutex_unlock(pthread_mutex_t *lock)\n{\n\tpthread_mutex_unlock(lock);\n}\n\n#else\n#define lws_pthread_mutex(name)\n#define lws_pthread_mutex_init(_a)\n#define lws_pthread_mutex_destroy(_a)\n#define lws_pthread_mutex_lock(_a)\n#define lws_pthread_mutex_unlock(_a)\n#endif\n\n\n#define CONTEXT_PORT_NO_LISTEN -1\n#define CONTEXT_PORT_NO_LISTEN_SERVER -2\n\n/** \u005cdefgroup log Logging\n *\n * ##Logging\n *\n * Lws provides flexible and filterable logging facilities, which can be\n * used inside lws and in user code.\n *\n * Log categories may be individually filtered bitwise, and directed to built-in\n * sinks for syslog-compatible logging, or a user-defined function.\n */\n///@{\n\nenum lws_log_levels {\n\tLLL_ERR \u003d 1 \u003c\u003c 0,\n\tLLL_WARN \u003d 1 \u003c\u003c 1,\n\tLLL_NOTICE \u003d 1 \u003c\u003c 2,\n\tLLL_INFO \u003d 1 \u003c\u003c 3,\n\tLLL_DEBUG \u003d 1 \u003c\u003c 4,\n\tLLL_PARSER \u003d 1 \u003c\u003c 5,\n\tLLL_HEADER \u003d 1 \u003c\u003c 6,\n\tLLL_EXT \u003d 1 \u003c\u003c 7,\n\tLLL_CLIENT \u003d 1 \u003c\u003c 8,\n\tLLL_LATENCY \u003d 1 \u003c\u003c 9,\n\tLLL_USER \u003d 1 \u003c\u003c 10,\n\n\tLLL_COUNT \u003d 11 /* set to count of valid flags */\n};\n\nLWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...) LWS_FORMAT(2);\nLWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_list vl);\n/**\n * lwsl_timestamp: generate logging timestamp string\n *\n * \u005cparam level:\tlogging level\n * \u005cparam p:\t\tchar * buffer to take timestamp\n * \u005cparam len:\tlength of p\n *\n * returns length written in p\n */\nLWS_VISIBLE LWS_EXTERN int\nlwsl_timestamp(int level, char *p, int len);\n\n/* these guys are unconditionally included */\n\n#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)\n#define lwsl_user(...) _lws_log(LLL_USER, __VA_ARGS__)\n\n#if !defined(LWS_WITH_NO_LOGS)\n/* notice and warn are usually included by being compiled in */\n#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__)\n#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)\n#endif\n/*\n * weaker logging can be deselected by telling CMake to build in RELEASE mode\n * that gets rid of the overhead of checking while keeping _warn and _err\n * active\n */\n\n#ifdef _DEBUG\n#if defined(LWS_WITH_NO_LOGS)\n/* notice, warn and log are always compiled in */\n#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__)\n#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)\n#endif\n#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__)\n#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__)\n#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__)\n#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__)\n#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__)\n#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__)\n#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__)\n\n#else /* no debug */\n#if defined(LWS_WITH_NO_LOGS)\n#define lwsl_warn(...) do {} while(0)\n#define lwsl_notice(...) do {} while(0)\n#endif\n#define lwsl_info(...) do {} while(0)\n#define lwsl_debug(...) do {} while(0)\n#define lwsl_parser(...) do {} while(0)\n#define lwsl_header(...) do {} while(0)\n#define lwsl_ext(...) do {} while(0)\n#define lwsl_client(...) do {} while(0)\n#define lwsl_latency(...) do {} while(0)\n\n#endif\n\n#define lwsl_hexdump_err(...) lwsl_hexdump_level(LLL_ERR, __VA_ARGS__)\n#define lwsl_hexdump_warn(...) lwsl_hexdump_level(LLL_WARN, __VA_ARGS__)\n#define lwsl_hexdump_notice(...) lwsl_hexdump_level(LLL_NOTICE, __VA_ARGS__)\n#define lwsl_hexdump_info(...) lwsl_hexdump_level(LLL_INFO, __VA_ARGS__)\n#define lwsl_hexdump_debug(...) lwsl_hexdump_level(LLL_DEBUG, __VA_ARGS__)\n\n/**\n * lwsl_hexdump_level() - helper to hexdump a buffer at a selected debug level\n *\n * \u005cparam level: one of LLL_ constants\n * \u005cparam vbuf: buffer start to dump\n * \u005cparam len: length of buffer to dump\n *\n * If \u005cp level is visible, does a nice hexdump -C style dump of \u005cp vbuf for\n * \u005cp len bytes. This can be extremely convenient while debugging.\n */\nLWS_VISIBLE LWS_EXTERN void\nlwsl_hexdump_level(int level, const void *vbuf, size_t len);\n\n/**\n * lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only)\n *\n * \u005cparam buf: buffer start to dump\n * \u005cparam len: length of buffer to dump\n *\n * Calls through to lwsl_hexdump_level(LLL_DEBUG, ... for compatability.\n * It's better to use lwsl_hexdump_level(level, ... directly so you can control\n * the visibility.\n */\nLWS_VISIBLE LWS_EXTERN void\nlwsl_hexdump(const void *buf, size_t len);\n\n/**\n * lws_is_be() - returns nonzero if the platform is Big Endian\n */\nstatic LWS_INLINE int lws_is_be(void) {\n\tconst int probe \u003d ~0xff;\n\n\treturn *(const char *)\u0026probe;\n}\n\n/**\n * lws_set_log_level() - Set the logging bitfield\n * \u005cparam level:\tOR together the LLL_ debug contexts you want output from\n * \u005cparam log_emit_function:\tNULL to leave it as it is, or a user-supplied\n *\t\t\tfunction to perform log string emission instead of\n *\t\t\tthe default stderr one.\n *\n *\tlog level defaults to \u0022err\u0022, \u0022warn\u0022 and \u0022notice\u0022 contexts enabled and\n *\temission on stderr. If stderr is a tty (according to isatty()) then\n *\tthe output is coloured according to the log level using ANSI escapes.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_log_level(int level,\n\t\t void (*log_emit_function)(int level, const char *line));\n\n/**\n * lwsl_emit_syslog() - helper log emit function writes to system log\n *\n * \u005cparam level: one of LLL_ log level indexes\n * \u005cparam line: log string\n *\n * You use this by passing the function pointer to lws_set_log_level(), to set\n * it as the log emit function, it is not called directly.\n */\nLWS_VISIBLE LWS_EXTERN void\nlwsl_emit_syslog(int level, const char *line);\n\n/**\n * lwsl_visible() - returns true if the log level should be printed\n *\n * \u005cparam level: one of LLL_ log level indexes\n *\n * This is useful if you have to do work to generate the log content, you\n * can skip the work if the log level used to print it is not actually\n * enabled at runtime.\n */\nLWS_VISIBLE LWS_EXTERN int\nlwsl_visible(int level);\n\n///@}\n\n\n#include \u003cstddef.h\u003e\n\n#ifndef lws_container_of\n#define lws_container_of(P,T,M)\t((T *)((char *)(P) - offsetof(T, M)))\n#endif\n\nstruct lws;\n\ntypedef int64_t lws_usec_t;\n\n/* api change list for user code to test against */\n\n#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG\n\n/* the struct lws_protocols has the id field present */\n#define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD\n\n/* you can call lws_get_peer_write_allowance */\n#define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE\n\n/* extra parameter introduced in 917f43ab821 */\n#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN\n\n/* File operations stuff exists */\n#define LWS_FEATURE_FOPS\n\n\n#if defined(_WIN32)\ntypedef SOCKET lws_sockfd_type;\ntypedef HANDLE lws_filefd_type;\n\nstruct lws_pollfd {\n\tlws_sockfd_type fd; /**\u003c file descriptor */\n\tSHORT events; /**\u003c which events to respond to */\n\tSHORT revents; /**\u003c which events happened */\n};\n#define LWS_POLLHUP (FD_CLOSE)\n#define LWS_POLLIN (FD_READ | FD_ACCEPT)\n#define LWS_POLLOUT (FD_WRITE)\n#else\n\n\n#if defined(LWS_WITH_ESP32)\n\ntypedef int lws_sockfd_type;\ntypedef int lws_filefd_type;\n\nstruct pollfd {\n\tlws_sockfd_type fd; /**\u003c fd related to */\n\tshort events; /**\u003c which POLL... events to respond to */\n\tshort revents; /**\u003c which POLL... events occurred */\n};\n#define POLLIN\t\t0x0001\n#define POLLPRI\t\t0x0002\n#define POLLOUT\t\t0x0004\n#define POLLERR\t\t0x0008\n#define POLLHUP\t\t0x0010\n#define POLLNVAL\t0x0020\n\n#include \u003cfreertos/FreeRTOS.h\u003e\n#include \u003cfreertos/event_groups.h\u003e\n#include \u003cstring.h\u003e\n#include \u0022esp_wifi.h\u0022\n#include \u0022esp_system.h\u0022\n#include \u0022esp_event.h\u0022\n#include \u0022esp_event_loop.h\u0022\n#include \u0022nvs.h\u0022\n#include \u0022driver/gpio.h\u0022\n#include \u0022esp_spi_flash.h\u0022\n#include \u0022freertos/timers.h\u0022\n\n#if !defined(CONFIG_FREERTOS_HZ)\n#define CONFIG_FREERTOS_HZ 100\n#endif\n\ntypedef TimerHandle_t uv_timer_t;\ntypedef void uv_cb_t(uv_timer_t *);\ntypedef void * uv_handle_t;\n\nstruct timer_mapping {\n\tuv_cb_t *cb;\n\tuv_timer_t *t;\n};\n\n#define UV_VERSION_MAJOR 1\n\n#define lws_uv_getloop(a, b) (NULL)\n\nstatic LWS_INLINE void uv_timer_init(void *l, uv_timer_t *t)\n{\n\t(void)l;\n\t*t \u003d NULL;\n}\n\nextern void esp32_uvtimer_cb(TimerHandle_t t);\n\nstatic LWS_INLINE void uv_timer_start(uv_timer_t *t, uv_cb_t *cb, int first, int rep)\n{\n\tstruct timer_mapping *tm \u003d (struct timer_mapping *)malloc(sizeof(*tm));\n\n\tif (!tm)\n\t\treturn;\n\n\ttm-\u003et \u003d t;\n\ttm-\u003ecb \u003d cb;\n\n\t*t \u003d xTimerCreate(\u0022x\u0022, pdMS_TO_TICKS(first), !!rep, tm,\n\t\t\t (TimerCallbackFunction_t)esp32_uvtimer_cb);\n\txTimerStart(*t, 0);\n}\n\nstatic LWS_INLINE void uv_timer_stop(uv_timer_t *t)\n{\n\txTimerStop(*t, 0);\n}\n\nstatic LWS_INLINE void uv_close(uv_handle_t *h, void *v)\n{\n\tfree(pvTimerGetTimerID((uv_timer_t)h));\n\txTimerDelete(*(uv_timer_t *)h, 0);\n}\n\n/* ESP32 helper declarations */\n\n#include \u003cmdns.h\u003e\n#include \u003cesp_partition.h\u003e\n\n#define LWS_PLUGIN_STATIC\n#define LWS_MAGIC_REBOOT_TYPE_ADS 0x50001ffc\n#define LWS_MAGIC_REBOOT_TYPE_REQ_FACTORY 0xb00bcafe\n#define LWS_MAGIC_REBOOT_TYPE_FORCED_FACTORY 0xfaceb00b\n#define LWS_MAGIC_REBOOT_TYPE_FORCED_FACTORY_BUTTON 0xf0cedfac\n\n\n/* user code provides these */\n\nextern void\nlws_esp32_identify_physical_device(void);\n\n/* lws-plat-esp32 provides these */\n\ntypedef void (*lws_cb_scan_done)(uint16_t count, wifi_ap_record_t *recs, void *arg);\n\nenum genled_state {\n\tLWSESP32_GENLED__INIT,\n\tLWSESP32_GENLED__LOST_NETWORK,\n\tLWSESP32_GENLED__NO_NETWORK,\n\tLWSESP32_GENLED__CONN_AP,\n\tLWSESP32_GENLED__GOT_IP,\n\tLWSESP32_GENLED__OK,\n};\n\nstruct lws_group_member {\n\tstruct lws_group_member *next;\n\tuint64_t last_seen;\n\tchar model[16];\n\tchar role[16];\n\tchar host[32];\n\tchar mac[20];\n\tint width, height;\n\tstruct ip4_addr addr;\n\tstruct ip6_addr addrv6;\n\tuint8_t\tflags;\n};\n\n#define LWS_SYSTEM_GROUP_MEMBER_ADD\t\t1\n#define LWS_SYSTEM_GROUP_MEMBER_CHANGE\t\t2\n#define LWS_SYSTEM_GROUP_MEMBER_REMOVE\t\t3\n\n#define LWS_GROUP_FLAG_SELF 1\n\nstruct lws_esp32 {\n\tchar sta_ip[16];\n\tchar sta_mask[16];\n\tchar sta_gw[16];\n\tchar serial[16];\n\tchar opts[16];\n\tchar model[16];\n\tchar group[16];\n\tchar role[16];\n\tchar ssid[4][64];\n\tchar password[4][64];\n\tchar active_ssid[64];\n\tchar access_pw[16];\n\tchar hostname[32];\n\tchar mac[20];\n\tchar le_dns[64];\n\tchar le_email[64];\n \tchar region;\n \tchar inet;\n\tchar conn_ap;\n\n\tenum genled_state genled;\n\tuint64_t genled_t;\n\n\tlws_cb_scan_done scan_consumer;\n\tvoid *scan_consumer_arg;\n\tstruct lws_group_member *first;\n\tint extant_group_members;\n\n\tchar acme;\n\tchar upload;\n\n\tvolatile char button_is_down;\n};\n\nstruct lws_esp32_image {\n\tuint32_t romfs;\n\tuint32_t romfs_len;\n\tuint32_t json;\n\tuint32_t json_len;\n};\n\nextern struct lws_esp32 lws_esp32;\nstruct lws_vhost;\n\nextern esp_err_t\nlws_esp32_event_passthru(void *ctx, system_event_t *event);\nextern void\nlws_esp32_wlan_config(void);\nextern void\nlws_esp32_wlan_start_ap(void);\nextern void\nlws_esp32_wlan_start_station(void);\nstruct lws_context_creation_info;\nextern void\nlws_esp32_set_creation_defaults(struct lws_context_creation_info *info);\nextern struct lws_context *\nlws_esp32_init(struct lws_context_creation_info *, struct lws_vhost **pvh);\nextern int\nlws_esp32_wlan_nvs_get(int retry);\nextern esp_err_t\nlws_nvs_set_str(nvs_handle handle, const char* key, const char* value);\nextern void\nlws_esp32_restart_guided(uint32_t type);\nextern const esp_partition_t *\nlws_esp_ota_get_boot_partition(void);\nextern int\nlws_esp32_get_image_info(const esp_partition_t *part, struct lws_esp32_image *i, char *json, int json_len);\nextern int\nlws_esp32_leds_network_indication(void);\n\nextern uint32_t lws_esp32_get_reboot_type(void);\nextern uint16_t lws_esp32_sine_interp(int n);\n\n/* required in external code by esp32 plat (may just return if no leds) */\nextern void lws_esp32_leds_timer_cb(TimerHandle_t th);\n#else\ntypedef int lws_sockfd_type;\ntypedef int lws_filefd_type;\n#endif\n\n#define lws_pollfd pollfd\n#define LWS_POLLHUP (POLLHUP|POLLERR)\n#define LWS_POLLIN (POLLIN)\n#define LWS_POLLOUT (POLLOUT)\n#endif\n\n\n#if (defined(WIN32) || defined(_WIN32)) \u0026\u0026 !defined(__MINGW32__)\n/* ... */\n#define ssize_t SSIZE_T\n#endif\n\n#if defined(WIN32) \u0026\u0026 defined(LWS_HAVE__STAT32I64)\n#include \u003csys/types.h\u003e\n#include \u003csys/stat.h\u003e\n#endif\n\n#if defined(LWS_HAVE_STDINT_H)\n#include \u003cstdint.h\u003e\n#else\n#if defined(WIN32) || defined(_WIN32)\n/* !!! \u003e:-[ */\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int16 uint16_t;\ntypedef unsigned __int8 uint8_t;\n#else\ntypedef unsigned int uint32_t;\ntypedef unsigned short uint16_t;\ntypedef unsigned char uint8_t;\n#endif\n#endif\n\ntypedef unsigned long long lws_filepos_t;\ntypedef long long lws_fileofs_t;\ntypedef uint32_t lws_fop_flags_t;\n\n/** struct lws_pollargs - argument structure for all external poll related calls\n * passed in via 'in' */\nstruct lws_pollargs {\n\tlws_sockfd_type fd;\t/**\u003c applicable socket descriptor */\n\tint events;\t\t/**\u003c the new event mask */\n\tint prev_events;\t/**\u003c the previous event mask */\n};\n\nstruct lws_tokens;\nstruct lws_token_limits;\n\n/*! \u005cdefgroup wsclose Websocket Close\n *\n * ##Websocket close frame control\n *\n * When we close a ws connection, we can send a reason code and a short\n * UTF-8 description back with the close packet.\n */\n///@{\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\n/** enum lws_close_status - RFC6455 close status codes */\nenum lws_close_status {\n\tLWS_CLOSE_STATUS_NOSTATUS\t\t\t\t\u003d 0,\n\tLWS_CLOSE_STATUS_NORMAL\t\t\t\t\t\u003d 1000,\n\t/**\u003c 1000 indicates a normal closure, meaning that the purpose for\n which the connection was established has been fulfilled. */\n\tLWS_CLOSE_STATUS_GOINGAWAY\t\t\t\t\u003d 1001,\n\t/**\u003c 1001 indicates that an endpoint is \u0022going away\u0022, such as a server\n going down or a browser having navigated away from a page. */\n\tLWS_CLOSE_STATUS_PROTOCOL_ERR\t\t\t\t\u003d 1002,\n\t/**\u003c 1002 indicates that an endpoint is terminating the connection due\n to a protocol error. */\n\tLWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE\t\t\t\u003d 1003,\n\t/**\u003c 1003 indicates that an endpoint is terminating the connection\n because it has received a type of data it cannot accept (e.g., an\n endpoint that understands only text data MAY send this if it\n receives a binary message). */\n\tLWS_CLOSE_STATUS_RESERVED\t\t\t\t\u003d 1004,\n\t/**\u003c Reserved. The specific meaning might be defined in the future. */\n\tLWS_CLOSE_STATUS_NO_STATUS\t\t\t\t\u003d 1005,\n\t/**\u003c 1005 is a reserved value and MUST NOT be set as a status code in a\n Close control frame by an endpoint. It is designated for use in\n applications expecting a status code to indicate that no status\n code was actually present. */\n\tLWS_CLOSE_STATUS_ABNORMAL_CLOSE\t\t\t\t\u003d 1006,\n\t/**\u003c 1006 is a reserved value and MUST NOT be set as a status code in a\n Close control frame by an endpoint. It is designated for use in\n applications expecting a status code to indicate that the\n connection was closed abnormally, e.g., without sending or\n receiving a Close control frame. */\n\tLWS_CLOSE_STATUS_INVALID_PAYLOAD\t\t\t\u003d 1007,\n\t/**\u003c 1007 indicates that an endpoint is terminating the connection\n because it has received data within a message that was not\n consistent with the type of the message (e.g., non-UTF-8 [RFC3629]\n data within a text message). */\n\tLWS_CLOSE_STATUS_POLICY_VIOLATION\t\t\t\u003d 1008,\n\t/**\u003c 1008 indicates that an endpoint is terminating the connection\n because it has received a message that violates its policy. This\n is a generic status code that can be returned when there is no\n other more suitable status code (e.g., 1003 or 1009) or if there\n is a need to hide specific details about the policy. */\n\tLWS_CLOSE_STATUS_MESSAGE_TOO_LARGE\t\t\t\u003d 1009,\n\t/**\u003c 1009 indicates that an endpoint is terminating the connection\n because it has received a message that is too big for it to\n process. */\n\tLWS_CLOSE_STATUS_EXTENSION_REQUIRED\t\t\t\u003d 1010,\n\t/**\u003c 1010 indicates that an endpoint (client) is terminating the\n connection because it has expected the server to negotiate one or\n more extension, but the server didn't return them in the response\n message of the WebSocket handshake. The list of extensions that\n are needed SHOULD appear in the /reason/ part of the Close frame.\n Note that this status code is not used by the server, because it\n can fail the WebSocket handshake instead */\n\tLWS_CLOSE_STATUS_UNEXPECTED_CONDITION\t\t\t\u003d 1011,\n\t/**\u003c 1011 indicates that a server is terminating the connection because\n it encountered an unexpected condition that prevented it from\n fulfilling the request. */\n\tLWS_CLOSE_STATUS_TLS_FAILURE\t\t\t\t\u003d 1015,\n\t/**\u003c 1015 is a reserved value and MUST NOT be set as a status code in a\n Close control frame by an endpoint. It is designated for use in\n applications expecting a status code to indicate that the\n connection was closed due to a failure to perform a TLS handshake\n (e.g., the server certificate can't be verified). */\n\n\tLWS_CLOSE_STATUS_CLIENT_TRANSACTION_DONE\t\t\u003d 2000,\n\n\t/****** add new things just above ---^ ******/\n\n\tLWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY\t\t\u003d 9999,\n};\n\n/**\n * lws_close_reason - Set reason and aux data to send with Close packet\n *\t\tIf you are going to return nonzero from the callback\n *\t\trequesting the connection to close, you can optionally\n *\t\tcall this to set the reason the peer will be told if\n *\t\tpossible.\n *\n * \u005cparam wsi:\tThe websocket connection to set the close reason on\n * \u005cparam status:\tA valid close status from websocket standard\n * \u005cparam buf:\tNULL or buffer containing up to 124 bytes of auxiliary data\n * \u005cparam len:\tLength of data in \u005cparam buf to send\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_close_reason(struct lws *wsi, enum lws_close_status status,\n\t\t unsigned char *buf, size_t len);\n\n///@}\n\nstruct lws;\nstruct lws_context;\n/* needed even with extensions disabled for create context */\nstruct lws_extension;\n\n\n/*! \u005cdefgroup usercb User Callback\n *\n * ##User protocol callback\n *\n * The protocol callback is the primary way lws interacts with\n * user code. For one of a list of a few dozen reasons the callback gets\n * called at some event to be handled.\n *\n * All of the events can be ignored, returning 0 is taken as \u0022OK\u0022 and returning\n * nonzero in most cases indicates that the connection should be closed.\n */\n///@{\n\nstruct lws_ssl_info {\n\tint where;\n\tint ret;\n};\n\nenum lws_cert_update_state {\n\tLWS_CUS_IDLE,\n\tLWS_CUS_STARTING,\n\tLWS_CUS_SUCCESS,\n\tLWS_CUS_FAILED,\n\n\tLWS_CUS_CREATE_KEYS,\n\tLWS_CUS_REG,\n\tLWS_CUS_AUTH,\n\tLWS_CUS_CHALLENGE,\n\tLWS_CUS_CREATE_REQ,\n\tLWS_CUS_REQ,\n\tLWS_CUS_CONFIRM,\n\tLWS_CUS_ISSUE,\n};\n\nenum {\n\tLWS_TLS_REQ_ELEMENT_COUNTRY,\n\tLWS_TLS_REQ_ELEMENT_STATE,\n\tLWS_TLS_REQ_ELEMENT_LOCALITY,\n\tLWS_TLS_REQ_ELEMENT_ORGANIZATION,\n\tLWS_TLS_REQ_ELEMENT_COMMON_NAME,\n\tLWS_TLS_REQ_ELEMENT_EMAIL,\n\n\tLWS_TLS_REQ_ELEMENT_COUNT,\n\n\tLWS_TLS_SET_DIR_URL \u003d LWS_TLS_REQ_ELEMENT_COUNT,\n\tLWS_TLS_SET_AUTH_PATH,\n\tLWS_TLS_SET_CERT_PATH,\n\tLWS_TLS_SET_KEY_PATH,\n\n\tLWS_TLS_TOTAL_COUNT\n};\n\nstruct lws_acme_cert_aging_args {\n\tstruct lws_vhost *vh;\n\tconst char *element_overrides[LWS_TLS_TOTAL_COUNT]; /* NULL \u003d use pvo */\n};\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\n/** enum lws_callback_reasons - reason you're getting a protocol callback */\nenum lws_callback_reasons {\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to wsi and protocol binding lifecycle -----\n\t */\n\n\tLWS_CALLBACK_PROTOCOL_INIT\t\t\t\t\u003d 27,\n\t/**\u003c One-time call per protocol, per-vhost using it, so it can\n\t * do initial setup / allocations etc */\n\n\tLWS_CALLBACK_PROTOCOL_DESTROY\t\t\t\t\u003d 28,\n\t/**\u003c One-time call per protocol, per-vhost using it, indicating\n\t * this protocol won't get used at all after this callback, the\n\t * vhost is getting destroyed. Take the opportunity to\n\t * deallocate everything that was allocated by the protocol. */\n\n\tLWS_CALLBACK_WSI_CREATE\t\t\t\t\t\u003d 29,\n\t/**\u003c outermost (earliest) wsi create notification to protocols[0] */\n\n\tLWS_CALLBACK_WSI_DESTROY\t\t\t\t\u003d 30,\n\t/**\u003c outermost (latest) wsi destroy notification to protocols[0] */\n\n\tLWS_CALLBACK_HTTP_BIND_PROTOCOL\t\t\t\t\u003d 49,\n\t/**\u003c By default, all HTTP handling is done in protocols[0].\n\t * However you can bind different protocols (by name) to\n\t * different parts of the URL space using callback mounts. This\n\t * callback occurs in the new protocol when a wsi is bound\n\t * to that protocol. Any protocol allocation related to the\n\t * http transaction processing should be created then.\n\t * These specific callbacks are necessary because with HTTP/1.1,\n\t * a single connection may perform at series of different\n\t * transactions at different URLs, thus the lifetime of the\n\t * protocol bind is just for one transaction, not connection. */\n\n\tLWS_CALLBACK_HTTP_DROP_PROTOCOL\t\t\t\t\u003d 50,\n\t/**\u003c This is called when a transaction is unbound from a protocol.\n\t * It indicates the connection completed its transaction and may\n\t * do something different now. Any protocol allocation related\n\t * to the http transaction processing should be destroyed. */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to Server TLS -----\n\t */\n\n\tLWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS\t\u003d 21,\n\t/**\u003c if configured for\n\t * including OpenSSL support, this callback allows your user code\n\t * to perform extra SSL_CTX_load_verify_locations() or similar\n\t * calls to direct OpenSSL where to find certificates the client\n\t * can use to confirm the remote server identity. user is the\n\t * OpenSSL SSL_CTX* */\n\n\tLWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS\t\u003d 22,\n\t/**\u003c if configured for\n\t * including OpenSSL support, this callback allows your user code\n\t * to load extra certificates into the server which allow it to\n\t * verify the validity of certificates returned by clients. user\n\t * is the server's OpenSSL SSL_CTX* and in is the lws_vhost */\n\n\tLWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION\t\u003d 23,\n\t/**\u003c if the libwebsockets vhost was created with the option\n\t * LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this\n\t * callback is generated during OpenSSL verification of the cert\n\t * sent from the client. It is sent to protocol[0] callback as\n\t * no protocol has been negotiated on the connection yet.\n\t * Notice that the libwebsockets context and wsi are both NULL\n\t * during this callback. See\n\t * http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html\n\t * to understand more detail about the OpenSSL callback that\n\t * generates this libwebsockets callback and the meanings of the\n\t * arguments passed. In this callback, user is the x509_ctx,\n\t * in is the ssl pointer and len is preverify_ok\n\t * Notice that this callback maintains libwebsocket return\n\t * conventions, return 0 to mean the cert is OK or 1 to fail it.\n\t * This also means that if you don't handle this callback then\n\t * the default callback action of returning 0 allows the client\n\t * certificates. */\n\n\tLWS_CALLBACK_OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY\t\u003d 37,\n\t/**\u003c if configured for including OpenSSL support but no private key\n\t * file has been specified (ssl_private_key_filepath is NULL), this is\n\t * called to allow the user to set the private key directly via\n\t * libopenssl and perform further operations if required; this might be\n\t * useful in situations where the private key is not directly accessible\n\t * by the OS, for example if it is stored on a smartcard.\n\t * user is the server's OpenSSL SSL_CTX* */\n\n\tLWS_CALLBACK_SSL_INFO\t\t\t\t\t\u003d 67,\n\t/**\u003c SSL connections only. An event you registered an\n\t * interest in at the vhost has occurred on a connection\n\t * using the vhost. in is a pointer to a\n\t * struct lws_ssl_info containing information about the\n\t * event*/\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to Client TLS -----\n\t */\n\n\tLWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION \u003d 58,\n\t/**\u003c Similar to LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION\n\t * this callback is called during OpenSSL verification of the cert\n\t * sent from the server to the client. It is sent to protocol[0]\n\t * callback as no protocol has been negotiated on the connection yet.\n\t * Notice that the wsi is set because lws_client_connect_via_info was\n\t * successful.\n\t *\n\t * See http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html\n\t * to understand more detail about the OpenSSL callback that\n\t * generates this libwebsockets callback and the meanings of the\n\t * arguments passed. In this callback, user is the x509_ctx,\n\t * in is the ssl pointer and len is preverify_ok.\n\t *\n\t * THIS IS NOT RECOMMENDED BUT if a cert validation error shall be\n\t * overruled and cert shall be accepted as ok,\n\t * X509_STORE_CTX_set_error((X509_STORE_CTX*)user, X509_V_OK); must be\n\t * called and return value must be 0 to mean the cert is OK;\n\t * returning 1 will fail the cert in any case.\n\t *\n\t * This also means that if you don't handle this callback then\n\t * the default callback action of returning 0 will not accept the\n\t * certificate in case of a validation error decided by the SSL lib.\n\t *\n\t * This is expected and secure behaviour when validating certificates.\n\t *\n\t * Note: LCCSCF_ALLOW_SELFSIGNED and\n\t * LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK still work without this\n\t * callback being implemented.\n\t */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to HTTP Server -----\n\t */\n\n\tLWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED\t\t\u003d 19,\n\t/**\u003c A new client has been accepted by the ws server. This\n\t * callback allows setting any relevant property to it. Because this\n\t * happens immediately after the instantiation of a new client,\n\t * there's no websocket protocol selected yet so this callback is\n\t * issued only to protocol 0. Only wsi is defined, pointing to the\n\t * new client, and the return value is ignored. */\n\n\tLWS_CALLBACK_HTTP\t\t\t\t\t\u003d 12,\n\t/**\u003c an http request has come from a client that is not\n\t * asking to upgrade the connection to a websocket\n\t * one. This is a chance to serve http content,\n\t * for example, to send a script to the client\n\t * which will then open the websockets connection.\n\t * in points to the URI path requested and\n\t * lws_serve_http_file() makes it very\n\t * simple to send back a file to the client.\n\t * Normally after sending the file you are done\n\t * with the http connection, since the rest of the\n\t * activity will come by websockets from the script\n\t * that was delivered by http, so you will want to\n\t * return 1; to close and free up the connection. */\n\n\tLWS_CALLBACK_HTTP_BODY\t\t\t\t\t\u003d 13,\n\t/**\u003c the next len bytes data from the http\n\t * request body HTTP connection is now available in in. */\n\n\tLWS_CALLBACK_HTTP_BODY_COMPLETION\t\t\t\u003d 14,\n\t/**\u003c the expected amount of http request body has been delivered */\n\n\tLWS_CALLBACK_HTTP_FILE_COMPLETION\t\t\t\u003d 15,\n\t/**\u003c a file requested to be sent down http link has completed. */\n\n\tLWS_CALLBACK_HTTP_WRITEABLE\t\t\t\t\u003d 16,\n\t/**\u003c you can write more down the http protocol link now. */\n\n\tLWS_CALLBACK_CLOSED_HTTP\t\t\t\t\u003d 5,\n\t/**\u003c when a HTTP (non-websocket) session ends */\n\n\tLWS_CALLBACK_FILTER_HTTP_CONNECTION\t\t\t\u003d 18,\n\t/**\u003c called when the request has\n\t * been received and parsed from the client, but the response is\n\t * not sent yet. Return non-zero to disallow the connection.\n\t * user is a pointer to the connection user space allocation,\n\t * in is the URI, eg, \u0022/\u0022\n\t * In your handler you can use the public APIs\n\t * lws_hdr_total_length() / lws_hdr_copy() to access all of the\n\t * headers using the header enums lws_token_indexes from\n\t * libwebsockets.h to check for and read the supported header\n\t * presence and content before deciding to allow the http\n\t * connection to proceed or to kill the connection. */\n\n\tLWS_CALLBACK_ADD_HEADERS\t\t\t\t\u003d 53,\n\t/**\u003c This gives your user code a chance to add headers to a server\n\t * transaction bound to your protocol. `in` points to a\n\t * `struct lws_process_html_args` describing a buffer and length\n\t * you can add headers into using the normal lws apis.\n\t *\n\t * (see LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER to add headers to\n\t * a client transaction)\n\t *\n\t * Only `args-\u003ep` and `args-\u003elen` are valid, and `args-\u003ep` should\n\t * be moved on by the amount of bytes written, if any. Eg\n\t *\n\t * \tcase LWS_CALLBACK_ADD_HEADERS:\n\t *\n\t * struct lws_process_html_args *args \u003d\n\t * \t\t(struct lws_process_html_args *)in;\n\t *\n\t *\t if (lws_add_http_header_by_name(wsi,\n\t *\t\t\t(unsigned char *)\u0022set-cookie:\u0022,\n\t *\t\t\t(unsigned char *)cookie, cookie_len,\n\t *\t\t\t(unsigned char **)\u0026args-\u003ep,\n\t *\t\t\t(unsigned char *)args-\u003ep + args-\u003emax_len))\n\t *\t\treturn 1;\n\t *\n\t * break;\n\t */\n\n\tLWS_CALLBACK_CHECK_ACCESS_RIGHTS\t\t\t\u003d 51,\n\t/**\u003c This gives the user code a chance to forbid an http access.\n\t * `in` points to a `struct lws_process_html_args`, which\n\t * describes the URL, and a bit mask describing the type of\n\t * authentication required. If the callback returns nonzero,\n\t * the transaction ends with HTTP_STATUS_UNAUTHORIZED. */\n\n\tLWS_CALLBACK_PROCESS_HTML\t\t\t\t\u003d 52,\n\t/**\u003c This gives your user code a chance to mangle outgoing\n\t * HTML. `in` points to a `struct lws_process_html_args`\n\t * which describes the buffer containing outgoing HTML.\n\t * The buffer may grow up to `.max_len` (currently +128\n\t * bytes per buffer).\n\t */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to HTTP Client -----\n\t */\n\n\tLWS_CALLBACK_ESTABLISHED_CLIENT_HTTP\t\t\t\u003d 44,\n\t/**\u003c The HTTP client connection has succeeded, and is now\n\t * connected to the server */\n\n\tLWS_CALLBACK_CLOSED_CLIENT_HTTP\t\t\t\t\u003d 45,\n\t/**\u003c The HTTP client connection is closing */\n\n\tLWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ\t\t\t\u003d 48,\n\t/**\u003c This is generated by lws_http_client_read() used to drain\n\t * incoming data. In the case the incoming data was chunked, it will\n\t * be split into multiple smaller callbacks for each chunk block,\n\t * removing the chunk headers. If not chunked, it will appear all in\n\t * one callback. */\n\n\tLWS_CALLBACK_RECEIVE_CLIENT_HTTP\t\t\t\u003d 46,\n\t/**\u003c This simply indicates data was received on the HTTP client\n\t * connection. It does NOT drain or provide the data.\n\t * This exists to neatly allow a proxying type situation,\n\t * where this incoming data will go out on another connection.\n\t * If the outgoing connection stalls, we should stall processing\n\t * the incoming data. So a handler for this in that case should\n\t * simply set a flag to indicate there is incoming data ready\n\t * and ask for a writeable callback on the outgoing connection.\n\t * In the writable callback he can check the flag and then get\n\t * and drain the waiting incoming data using lws_http_client_read().\n\t * This will use callbacks to LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ\n\t * to get and drain the incoming data, where it should be sent\n\t * back out on the outgoing connection. */\n\tLWS_CALLBACK_COMPLETED_CLIENT_HTTP\t\t\t\u003d 47,\n\t/**\u003c The client transaction completed... at the moment this\n\t * is the same as closing since transaction pipelining on\n\t * client side is not yet supported. */\n\n\tLWS_CALLBACK_CLIENT_HTTP_WRITEABLE\t\t\t\u003d 57,\n\t/**\u003c when doing an HTTP type client connection, you can call\n\t * lws_client_http_body_pending(wsi, 1) from\n\t * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER to get these callbacks\n\t * sending the HTTP headers.\n\t *\n\t * From this callback, when you have sent everything, you should let\n\t * lws know by calling lws_client_http_body_pending(wsi, 0)\n\t */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to Websocket Server -----\n\t */\n\n\tLWS_CALLBACK_ESTABLISHED\t\t\t\t\u003d 0,\n\t/**\u003c (VH) after the server completes a handshake with an incoming\n\t * client. If you built the library with ssl support, in is a\n\t * pointer to the ssl struct associated with the connection or NULL.\n\t *\n\t * b0 of len is set if the connection was made using ws-over-h2\n\t */\n\n\tLWS_CALLBACK_CLOSED\t\t\t\t\t\u003d 4,\n\t/**\u003c when the websocket session ends */\n\n\tLWS_CALLBACK_SERVER_WRITEABLE\t\t\t\t\u003d 11,\n\t/**\u003c See LWS_CALLBACK_CLIENT_WRITEABLE */\n\n\tLWS_CALLBACK_RECEIVE\t\t\t\t\t\u003d 6,\n\t/**\u003c data has appeared for this server endpoint from a\n\t * remote client, it can be found at *in and is\n\t * len bytes long */\n\n\tLWS_CALLBACK_RECEIVE_PONG\t\t\t\t\u003d 7,\n\t/**\u003c servers receive PONG packets with this callback reason */\n\n\tLWS_CALLBACK_WS_PEER_INITIATED_CLOSE\t\t\t\u003d 38,\n\t/**\u003c The peer has sent an unsolicited Close WS packet. in and\n\t * len are the optional close code (first 2 bytes, network\n\t * order) and the optional additional information which is not\n\t * defined in the standard, and may be a string or non human-readable\n\t * data.\n\t * If you return 0 lws will echo the close and then close the\n\t * connection. If you return nonzero lws will just close the\n\t * connection. */\n\n\tLWS_CALLBACK_FILTER_PROTOCOL_CONNECTION\t\t\t\u003d 20,\n\t/**\u003c called when the handshake has\n\t * been received and parsed from the client, but the response is\n\t * not sent yet. Return non-zero to disallow the connection.\n\t * user is a pointer to the connection user space allocation,\n\t * in is the requested protocol name\n\t * In your handler you can use the public APIs\n\t * lws_hdr_total_length() / lws_hdr_copy() to access all of the\n\t * headers using the header enums lws_token_indexes from\n\t * libwebsockets.h to check for and read the supported header\n\t * presence and content before deciding to allow the handshake\n\t * to proceed or to kill the connection. */\n\n\tLWS_CALLBACK_CONFIRM_EXTENSION_OKAY\t\t\t\u003d 25,\n\t/**\u003c When the server handshake code\n\t * sees that it does support a requested extension, before\n\t * accepting the extension by additing to the list sent back to\n\t * the client it gives this callback just to check that it's okay\n\t * to use that extension. It calls back to the requested protocol\n\t * and with in being the extension name, len is 0 and user is\n\t * valid. Note though at this time the ESTABLISHED callback hasn't\n\t * happened yet so if you initialize user content there, user\n\t * content during this callback might not be useful for anything. */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to Websocket Client -----\n\t */\n\n\tLWS_CALLBACK_CLIENT_CONNECTION_ERROR\t\t\t\u003d 1,\n\t/**\u003c the request client connection has been unable to complete a\n\t * handshake with the remote server. If in is non-NULL, you can\n\t * find an error string of length len where it points to\n\t *\n\t * Diagnostic strings that may be returned include\n\t *\n\t * \t\u0022getaddrinfo (ipv6) failed\u0022\n\t * \t\u0022unknown address family\u0022\n\t * \t\u0022getaddrinfo (ipv4) failed\u0022\n\t * \t\u0022set socket opts failed\u0022\n\t * \t\u0022insert wsi failed\u0022\n\t * \t\u0022lws_ssl_client_connect1 failed\u0022\n\t * \t\u0022lws_ssl_client_connect2 failed\u0022\n\t * \t\u0022Peer hung up\u0022\n\t * \t\u0022read failed\u0022\n\t * \t\u0022HS: URI missing\u0022\n\t * \t\u0022HS: Redirect code but no Location\u0022\n\t * \t\u0022HS: URI did not parse\u0022\n\t * \t\u0022HS: Redirect failed\u0022\n\t * \t\u0022HS: Server did not return 200\u0022\n\t * \t\u0022HS: OOM\u0022\n\t * \t\u0022HS: disallowed by client filter\u0022\n\t * \t\u0022HS: disallowed at ESTABLISHED\u0022\n\t * \t\u0022HS: ACCEPT missing\u0022\n\t * \t\u0022HS: ws upgrade response not 101\u0022\n\t * \t\u0022HS: UPGRADE missing\u0022\n\t * \t\u0022HS: Upgrade to something other than websocket\u0022\n\t * \t\u0022HS: CONNECTION missing\u0022\n\t * \t\u0022HS: UPGRADE malformed\u0022\n\t * \t\u0022HS: PROTOCOL malformed\u0022\n\t * \t\u0022HS: Cannot match protocol\u0022\n\t * \t\u0022HS: EXT: list too big\u0022\n\t * \t\u0022HS: EXT: failed setting defaults\u0022\n\t * \t\u0022HS: EXT: failed parsing defaults\u0022\n\t * \t\u0022HS: EXT: failed parsing options\u0022\n\t * \t\u0022HS: EXT: Rejects server options\u0022\n\t * \t\u0022HS: EXT: unknown ext\u0022\n\t * \t\u0022HS: Accept hash wrong\u0022\n\t * \t\u0022HS: Rejected by filter cb\u0022\n\t * \t\u0022HS: OOM\u0022\n\t * \t\u0022HS: SO_SNDBUF failed\u0022\n\t * \t\u0022HS: Rejected at CLIENT_ESTABLISHED\u0022\n\t */\n\n\tLWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH\t\t\u003d 2,\n\t/**\u003c this is the last chance for the client user code to examine the\n\t * http headers and decide to reject the connection. If the\n\t * content in the headers is interesting to the\n\t * client (url, etc) it needs to copy it out at\n\t * this point since it will be destroyed before\n\t * the CLIENT_ESTABLISHED call */\n\n\tLWS_CALLBACK_CLIENT_ESTABLISHED\t\t\t\t\u003d 3,\n\t/**\u003c after your client connection completed the websocket upgrade\n\t * handshake with the remote server */\n\n\tLWS_CALLBACK_CLIENT_CLOSED\t\t\t\t\u003d 75,\n\t/**\u003c when a client websocket session ends */\n\n\tLWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\t\t\u003d 24,\n\t/**\u003c this callback happens\n\t * when a client handshake is being compiled. user is NULL,\n\t * in is a char **, it's pointing to a char * which holds the\n\t * next location in the header buffer where you can add\n\t * headers, and len is the remaining space in the header buffer,\n\t * which is typically some hundreds of bytes. So, to add a canned\n\t * cookie, your handler code might look similar to:\n\t *\n\t *\tchar **p \u003d (char **)in;\n\t *\n\t *\tif (len \u003c 100)\n\t *\t\treturn 1;\n\t *\n\t *\t*p +\u003d sprintf(*p, \u0022Cookie: a\u003db\u005cx0d\u005cx0a\u0022);\n\t *\n\t *\treturn 0;\n\t *\n\t * Notice if you add anything, you just have to take care about\n\t * the CRLF on the line you added. Obviously this callback is\n\t * optional, if you don't handle it everything is fine.\n\t *\n\t * Notice the callback is coming to protocols[0] all the time,\n\t * because there is no specific protocol negotiated yet.\n\t *\n\t * See LWS_CALLBACK_ADD_HEADERS for adding headers to server\n\t * transactions.\n\t */\n\n\tLWS_CALLBACK_CLIENT_RECEIVE\t\t\t\t\u003d 8,\n\t/**\u003c data has appeared from the server for the client connection, it\n\t * can be found at *in and is len bytes long */\n\n\tLWS_CALLBACK_CLIENT_RECEIVE_PONG\t\t\t\u003d 9,\n\t/**\u003c clients receive PONG packets with this callback reason */\n\n\tLWS_CALLBACK_CLIENT_WRITEABLE\t\t\t\t\u003d 10,\n\t/**\u003c If you call lws_callback_on_writable() on a connection, you will\n\t * get one of these callbacks coming when the connection socket\n\t * is able to accept another write packet without blocking.\n\t * If it already was able to take another packet without blocking,\n\t * you'll get this callback at the next call to the service loop\n\t * function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE\n\t * and servers get LWS_CALLBACK_SERVER_WRITEABLE. */\n\n\tLWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED\t\t\u003d 26,\n\t/**\u003c When a ws client\n\t * connection is being prepared to start a handshake to a server,\n\t * each supported extension is checked with protocols[0] callback\n\t * with this reason, giving the user code a chance to suppress the\n\t * claim to support that extension by returning non-zero. If\n\t * unhandled, by default 0 will be returned and the extension\n\t * support included in the header to the server. Notice this\n\t * callback comes to protocols[0]. */\n\n\tLWS_CALLBACK_WS_EXT_DEFAULTS\t\t\t\t\u003d 39,\n\t/**\u003c Gives client connections an opportunity to adjust negotiated\n\t * extension defaults. `user` is the extension name that was\n\t * negotiated (eg, \u0022permessage-deflate\u0022). `in` points to a\n\t * buffer and `len` is the buffer size. The user callback can\n\t * set the buffer to a string describing options the extension\n\t * should parse. Or just ignore for defaults. */\n\n\n\tLWS_CALLBACK_FILTER_NETWORK_CONNECTION\t\t\t\u003d 17,\n\t/**\u003c called when a client connects to\n\t * the server at network level; the connection is accepted but then\n\t * passed to this callback to decide whether to hang up immediately\n\t * or not, based on the client IP. in contains the connection\n\t * socket's descriptor. Since the client connection information is\n\t * not available yet, wsi still pointing to the main server socket.\n\t * Return non-zero to terminate the connection before sending or\n\t * receiving anything. Because this happens immediately after the\n\t * network connection from the client, there's no websocket protocol\n\t * selected yet so this callback is issued only to protocol 0. */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to external poll loop integration -----\n\t */\n\n\tLWS_CALLBACK_GET_THREAD_ID\t\t\t\t\u003d 31,\n\t/**\u003c lws can accept callback when writable requests from other\n\t * threads, if you implement this callback and return an opaque\n\t * current thread ID integer. */\n\n\t/* external poll() management support */\n\tLWS_CALLBACK_ADD_POLL_FD\t\t\t\t\u003d 32,\n\t/**\u003c lws normally deals with its poll() or other event loop\n\t * internally, but in the case you are integrating with another\n\t * server you will need to have lws sockets share a\n\t * polling array with the other server. This and the other\n\t * POLL_FD related callbacks let you put your specialized\n\t * poll array interface code in the callback for protocol 0, the\n\t * first protocol you support, usually the HTTP protocol in the\n\t * serving case.\n\t * This callback happens when a socket needs to be\n\t * added to the polling loop: in points to a struct\n\t * lws_pollargs; the fd member of the struct is the file\n\t * descriptor, and events contains the active events\n\t *\n\t * If you are using the internal lws polling / event loop\n\t * you can just ignore these callbacks. */\n\n\tLWS_CALLBACK_DEL_POLL_FD\t\t\t\t\u003d 33,\n\t/**\u003c This callback happens when a socket descriptor\n\t * needs to be removed from an external polling array. in is\n\t * again the struct lws_pollargs containing the fd member\n\t * to be removed. If you are using the internal polling\n\t * loop, you can just ignore it. */\n\n\tLWS_CALLBACK_CHANGE_MODE_POLL_FD\t\t\t\u003d 34,\n\t/**\u003c This callback happens when lws wants to modify the events for\n\t * a connection.\n\t * in is the struct lws_pollargs with the fd to change.\n\t * The new event mask is in events member and the old mask is in\n\t * the prev_events member.\n\t * If you are using the internal polling loop, you can just ignore\n\t * it. */\n\n\tLWS_CALLBACK_LOCK_POLL\t\t\t\t\t\u003d 35,\n\t/**\u003c These allow the external poll changes driven\n\t * by lws to participate in an external thread locking\n\t * scheme around the changes, so the whole thing is threadsafe.\n\t * These are called around three activities in the library,\n\t *\t- inserting a new wsi in the wsi / fd table (len\u003d1)\n\t *\t- deleting a wsi from the wsi / fd table (len\u003d1)\n\t *\t- changing a wsi's POLLIN/OUT state (len\u003d0)\n\t * Locking and unlocking external synchronization objects when\n\t * len \u003d\u003d 1 allows external threads to be synchronized against\n\t * wsi lifecycle changes if it acquires the same lock for the\n\t * duration of wsi dereference from the other thread context. */\n\n\tLWS_CALLBACK_UNLOCK_POLL\t\t\t\t\u003d 36,\n\t/**\u003c See LWS_CALLBACK_LOCK_POLL, ignore if using lws internal poll */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to CGI serving -----\n\t */\n\n\tLWS_CALLBACK_CGI\t\t\t\t\t\u003d 40,\n\t/**\u003c CGI: CGI IO events on stdin / out / err are sent here on\n\t * protocols[0]. The provided `lws_callback_http_dummy()`\n\t * handles this and the callback should be directed there if\n\t * you use CGI. */\n\n\tLWS_CALLBACK_CGI_TERMINATED\t\t\t\t\u003d 41,\n\t/**\u003c CGI: The related CGI process ended, this is called before\n\t * the wsi is closed. Used to, eg, terminate chunking.\n\t * The provided `lws_callback_http_dummy()`\n\t * handles this and the callback should be directed there if\n\t * you use CGI. The child PID that terminated is in len. */\n\n\tLWS_CALLBACK_CGI_STDIN_DATA\t\t\t\t\u003d 42,\n\t/**\u003c CGI: Data is, to be sent to the CGI process stdin, eg from\n\t * a POST body. The provided `lws_callback_http_dummy()`\n\t * handles this and the callback should be directed there if\n\t * you use CGI. */\n\n\tLWS_CALLBACK_CGI_STDIN_COMPLETED\t\t\t\u003d 43,\n\t/**\u003c CGI: no more stdin is coming. The provided\n\t * `lws_callback_http_dummy()` handles this and the callback\n\t * should be directed there if you use CGI. */\n\n\tLWS_CALLBACK_CGI_PROCESS_ATTACH\t\t\t\t\u003d 70,\n\t/**\u003c CGI: Sent when the CGI process is spawned for the wsi. The\n\t * len parameter is the PID of the child process */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to Generic Sessions -----\n\t */\n\n\tLWS_CALLBACK_SESSION_INFO\t\t\t\t\u003d 54,\n\t/**\u003c This is only generated by user code using generic sessions.\n\t * It's used to get a `struct lws_session_info` filled in by\n\t * generic sessions with information about the logged-in user.\n\t * See the messageboard sample for an example of how to use. */\n\n\tLWS_CALLBACK_GS_EVENT\t\t\t\t\t\u003d 55,\n\t/**\u003c Indicates an event happened to the Generic Sessions session.\n\t * `in` contains a `struct lws_gs_event_args` describing the event. */\n\n\tLWS_CALLBACK_HTTP_PMO\t\t\t\t\t\u003d 56,\n\t/**\u003c per-mount options for this connection, called before\n\t * the normal LWS_CALLBACK_HTTP when the mount has per-mount\n\t * options.\n\t */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to RAW sockets -----\n\t */\n\n\tLWS_CALLBACK_RAW_RX\t\t\t\t\t\u003d 59,\n\t/**\u003c RAW mode connection RX */\n\n\tLWS_CALLBACK_RAW_CLOSE\t\t\t\t\t\u003d 60,\n\t/**\u003c RAW mode connection is closing */\n\n\tLWS_CALLBACK_RAW_WRITEABLE\t\t\t\t\u003d 61,\n\t/**\u003c RAW mode connection may be written */\n\n\tLWS_CALLBACK_RAW_ADOPT\t\t\t\t\t\u003d 62,\n\t/**\u003c RAW mode connection was adopted (equivalent to 'wsi created') */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to RAW file handles -----\n\t */\n\n\tLWS_CALLBACK_RAW_ADOPT_FILE\t\t\t\t\u003d 63,\n\t/**\u003c RAW mode file was adopted (equivalent to 'wsi created') */\n\n\tLWS_CALLBACK_RAW_RX_FILE\t\t\t\t\u003d 64,\n\t/**\u003c This is the indication the RAW mode file has something to read.\n\t * This doesn't actually do the read of the file and len is always\n\t * 0... your code should do the read having been informed there is\n\t * something to read now. */\n\n\tLWS_CALLBACK_RAW_WRITEABLE_FILE\t\t\t\t\u003d 65,\n\t/**\u003c RAW mode file is writeable */\n\n\tLWS_CALLBACK_RAW_CLOSE_FILE\t\t\t\t\u003d 66,\n\t/**\u003c RAW mode wsi that adopted a file is closing */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to generic wsi events -----\n\t */\n\n\tLWS_CALLBACK_TIMER\t\t\t\t\t\u003d 73,\n\t/**\u003c When the time elapsed after a call to\n\t * lws_set_timer_usecs(wsi, usecs) is up, the wsi will get one of\n\t * these callbacks. The deadline can be continuously extended into the\n\t * future by later calls to lws_set_timer_usecs() before the deadline\n\t * expires, or cancelled by lws_set_timer_usecs(wsi, -1);\n\t * See the note on lws_set_timer_usecs() about which event loops are\n\t * supported. */\n\n\tLWS_CALLBACK_EVENT_WAIT_CANCELLED\t\t\t\u003d 71,\n\t/**\u003c This is sent to every protocol of every vhost in response\n\t * to lws_cancel_service() or lws_cancel_service_pt(). This\n\t * callback is serialized in the lws event loop normally, even\n\t * if the lws_cancel_service[_pt]() call was from a different\n\t * thread. */\n\n\tLWS_CALLBACK_CHILD_CLOSING\t\t\t\t\u003d 69,\n\t/**\u003c Sent to parent to notify them a child is closing / being\n\t * destroyed. in is the child wsi.\n\t */\n\n\tLWS_CALLBACK_CHILD_WRITE_VIA_PARENT\t\t\t\u003d 68,\n\t/**\u003c Child has been marked with parent_carries_io attribute, so\n\t * lws_write directs the to this callback at the parent,\n\t * in is a struct lws_write_passthru containing the args\n\t * the lws_write() was called with.\n\t */\n\n\t/* ---------------------------------------------------------------------\n\t * ----- Callbacks related to TLS certificate management -----\n\t */\n\n\tLWS_CALLBACK_VHOST_CERT_AGING\t\t\t\t\u003d 72,\n\t/**\u003c When a vhost TLS cert has its expiry checked, this callback\n\t * is broadcast to every protocol of every vhost in case the\n\t * protocol wants to take some action with this information.\n\t * \u005cp in is a pointer to a struct lws_acme_cert_aging_args,\n\t * and \u005cp len is the number of days left before it expires, as\n\t * a (ssize_t). In the struct lws_acme_cert_aging_args, vh\n\t * points to the vhost the cert aging information applies to,\n\t * and element_overrides[] is an optional way to update information\n\t * from the pvos... NULL in an index means use the information from\n\t * from the pvo for the cert renewal, non-NULL in the array index\n\t * means use that pointer instead for the index. */\n\n\tLWS_CALLBACK_VHOST_CERT_UPDATE\t\t\t\t\u003d 74,\n\t/**\u003c When a vhost TLS cert is being updated, progress is\n\t * reported to the vhost in question here, including completion\n\t * and failure. in points to optional JSON, and len represents the\n\t * connection state using enum lws_cert_update_state */\n\n\n\t/****** add new things just above ---^ ******/\n\n\tLWS_CALLBACK_USER \u003d 1000,\n\t/**\u003c user code can use any including above without fear of clashes */\n};\n\n\n\n/**\n * typedef lws_callback_function() - User server actions\n * \u005cparam wsi:\tOpaque websocket instance pointer\n * \u005cparam reason:\tThe reason for the call\n * \u005cparam user:\tPointer to per-session user data allocated by library\n * \u005cparam in:\t\tPointer used for some callback reasons\n * \u005cparam len:\tLength set for some callback reasons\n *\n *\tThis callback is the way the user controls what is served. All the\n *\tprotocol detail is hidden and handled by the library.\n *\n *\tFor each connection / session there is user data allocated that is\n *\tpointed to by \u0022user\u0022. You set the size of this user data area when\n *\tthe library is initialized with lws_create_server.\n */\ntypedef int\nlws_callback_function(struct lws *wsi, enum lws_callback_reasons reason,\n\t\t void *user, void *in, size_t len);\n\n#define LWS_CB_REASON_AUX_BF__CGI\t\t1\n#define LWS_CB_REASON_AUX_BF__PROXY\t\t2\n#define LWS_CB_REASON_AUX_BF__CGI_CHUNK_END\t4\n#define LWS_CB_REASON_AUX_BF__CGI_HEADERS\t8\n///@}\n\nstruct lws_vhost;\n\n/*! \u005cdefgroup generic hash\n * ## Generic Hash related functions\n *\n * Lws provides generic hash / digest accessors that abstract the ones\n * provided by whatever OpenSSL library you are linking against.\n *\n * It lets you use the same code if you build against mbedtls or OpenSSL\n * for example.\n */\n///@{\n\n#if defined(LWS_WITH_TLS)\n\n#if defined(LWS_WITH_MBEDTLS)\n#include \u003cmbedtls/sha1.h\u003e\n#include \u003cmbedtls/sha256.h\u003e\n#include \u003cmbedtls/sha512.h\u003e\n#endif\n\nenum lws_genhash_types {\n\tLWS_GENHASH_TYPE_SHA1,\n\tLWS_GENHASH_TYPE_SHA256,\n\tLWS_GENHASH_TYPE_SHA384,\n\tLWS_GENHASH_TYPE_SHA512,\n};\n\nenum lws_genhmac_types {\n\tLWS_GENHMAC_TYPE_SHA256,\n\tLWS_GENHMAC_TYPE_SHA384,\n\tLWS_GENHMAC_TYPE_SHA512,\n};\n\n#define LWS_GENHASH_LARGEST 64\n\nstruct lws_genhash_ctx {\n uint8_t type;\n#if defined(LWS_WITH_MBEDTLS)\n union {\n\t\tmbedtls_sha1_context sha1;\n\t\tmbedtls_sha256_context sha256;\n\t\tmbedtls_sha512_context sha512; /* 384 also uses this */\n\t\tconst mbedtls_md_info_t *hmac;\n } u;\n#else\n const EVP_MD *evp_type;\n EVP_MD_CTX *mdctx;\n#endif\n};\n\nstruct lws_genhmac_ctx {\n uint8_t type;\n#if defined(LWS_WITH_MBEDTLS)\n\tconst mbedtls_md_info_t *hmac;\n\tmbedtls_md_context_t ctx;\n#else\n const EVP_MD *evp_type;\n EVP_MD_CTX *ctx;\n#endif\n};\n\n/** lws_genhash_size() - get hash size in bytes\n *\n * \u005cparam type:\tone of LWS_GENHASH_TYPE_...\n *\n * Returns number of bytes in this type of hash\n */\nLWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT\nlws_genhash_size(enum lws_genhash_types type);\n\n/** lws_genhmac_size() - get hash size in bytes\n *\n * \u005cparam type:\tone of LWS_GENHASH_TYPE_...\n *\n * Returns number of bytes in this type of hmac\n */\nLWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT\nlws_genhmac_size(enum lws_genhmac_types type);\n\n/** lws_genhash_init() - prepare your struct lws_genhash_ctx for use\n *\n * \u005cparam ctx: your struct lws_genhash_ctx\n * \u005cparam type:\tone of LWS_GENHASH_TYPE_...\n *\n * Initializes the hash context for the type you requested\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhash_init(struct lws_genhash_ctx *ctx, enum lws_genhash_types type);\n\n/** lws_genhash_update() - digest len bytes of the buffer starting at in\n *\n * \u005cparam ctx: your struct lws_genhash_ctx\n * \u005cparam in: start of the bytes to digest\n * \u005cparam len: count of bytes to digest\n *\n * Updates the state of your hash context to reflect digesting len bytes from in\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhash_update(struct lws_genhash_ctx *ctx, const void *in, size_t len);\n\n/** lws_genhash_destroy() - copy out the result digest and destroy the ctx\n *\n * \u005cparam ctx: your struct lws_genhash_ctx\n * \u005cparam result: NULL, or where to copy the result hash\n *\n * Finalizes the hash and copies out the digest. Destroys any allocations such\n * that ctx can safely go out of scope after calling this.\n *\n * NULL result is supported so that you can destroy the ctx cleanly on error\n * conditions, where there is no valid result.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genhash_destroy(struct lws_genhash_ctx *ctx, void *result);\n\n/** lws_genhmac_init() - prepare your struct lws_genhmac_ctx for use\n *\n * \u005cparam ctx: your struct lws_genhmac_ctx\n * \u005cparam type:\tone of LWS_GENHMAC_TYPE_...\n * \u005cparam key: pointer to the start of the HMAC key\n * \u005cparam key_len: length of the HMAC key\n *\n * Initializes the hash context for the type you requested\n *\n * If the return is nonzero, it failed and there is nothing needing to be\n * destroyed.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhmac_init(struct lws_genhmac_ctx *ctx, enum lws_genhmac_types type,\n\t\tconst uint8_t *key, size_t key_len);\n\n/** lws_genhmac_update() - digest len bytes of the buffer starting at in\n *\n * \u005cparam ctx: your struct lws_genhmac_ctx\n * \u005cparam in: start of the bytes to digest\n * \u005cparam len: count of bytes to digest\n *\n * Updates the state of your hash context to reflect digesting len bytes from in\n *\n * If the return is nonzero, it failed and needs destroying.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhmac_update(struct lws_genhmac_ctx *ctx, const void *in, size_t len);\n\n/** lws_genhmac_destroy() - copy out the result digest and destroy the ctx\n *\n * \u005cparam ctx: your struct lws_genhmac_ctx\n * \u005cparam result: NULL, or where to copy the result hash\n *\n * Finalizes the hash and copies out the digest. Destroys any allocations such\n * that ctx can safely go out of scope after calling this.\n *\n * NULL result is supported so that you can destroy the ctx cleanly on error\n * conditions, where there is no valid result.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genhmac_destroy(struct lws_genhmac_ctx *ctx, void *result);\n///@}\n\n/*! \u005cdefgroup generic RSA\n * ## Generic RSA related functions\n *\n * Lws provides generic RSA functions that abstract the ones\n * provided by whatever OpenSSL library you are linking against.\n *\n * It lets you use the same code if you build against mbedtls or OpenSSL\n * for example.\n */\n///@{\n\nenum enum_jwk_tok {\n\tJWK_KEY_E,\n\tJWK_KEY_N,\n\tJWK_KEY_D,\n\tJWK_KEY_P,\n\tJWK_KEY_Q,\n\tJWK_KEY_DP,\n\tJWK_KEY_DQ,\n\tJWK_KEY_QI,\n\tJWK_KTY, /* also serves as count of real elements */\n\tJWK_KEY,\n};\n\n#define LWS_COUNT_RSA_ELEMENTS JWK_KTY\n\nstruct lws_genrsa_ctx {\n#if defined(LWS_WITH_MBEDTLS)\n\tmbedtls_rsa_context *ctx;\n#else\n\tBIGNUM *bn[LWS_COUNT_RSA_ELEMENTS];\n\tRSA *rsa;\n#endif\n};\n\nstruct lws_genrsa_element {\n\tuint8_t *buf;\n\tuint16_t len;\n};\n\nstruct lws_genrsa_elements {\n\tstruct lws_genrsa_element e[LWS_COUNT_RSA_ELEMENTS];\n};\n\n/** lws_jwk_destroy_genrsa_elements() - Free allocations in genrsa_elements\n *\n * \u005cparam el: your struct lws_genrsa_elements\n *\n * This is a helper for user code making use of struct lws_genrsa_elements\n * where the elements are allocated on the heap, it frees any non-NULL\n * buf element and sets the buf to NULL.\n *\n * NB: lws_genrsa_public_... apis do not need this as they take care of the key\n * creation and destruction themselves.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_jwk_destroy_genrsa_elements(struct lws_genrsa_elements *el);\n\n/** lws_genrsa_public_decrypt_create() - Create RSA public decrypt context\n *\n * \u005cparam ctx: your struct lws_genrsa_ctx\n * \u005cparam el: struct prepared with key element data\n *\n * Creates an RSA context with a public key associated with it, formed from\n * the key elements in \u005cp el.\n *\n * Returns 0 for OK or nonzero for error.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genrsa_create(struct lws_genrsa_ctx *ctx, struct lws_genrsa_elements *el);\n\n/** lws_genrsa_new_keypair() - Create new RSA keypair\n *\n * \u005cparam context: your struct lws_context (may be used for RNG)\n * \u005cparam ctx: your struct lws_genrsa_ctx\n * \u005cparam el: struct to get the new key element data allocated into it\n * \u005cparam bits: key size, eg, 4096\n *\n * Creates a new RSA context and generates a new keypair into it, with \u005cp bits\n * bits.\n *\n * Returns 0 for OK or nonzero for error.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genrsa_new_keypair(struct lws_context *context, struct lws_genrsa_ctx *ctx,\n\t\t struct lws_genrsa_elements *el, int bits);\n\n/** lws_genrsa_public_decrypt() - Perform RSA public decryption\n *\n * \u005cparam ctx: your struct lws_genrsa_ctx\n * \u005cparam in: encrypted input\n * \u005cparam in_len: length of encrypted input\n * \u005cparam out: decrypted output\n * \u005cparam out_max: size of output buffer\n *\n * Performs the decryption.\n *\n * Returns \u003c0 for error, or length of decrypted data.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genrsa_public_decrypt(struct lws_genrsa_ctx *ctx, const uint8_t *in,\n\t\t\t size_t in_len, uint8_t *out, size_t out_max);\n\n/** lws_genrsa_public_verify() - Perform RSA public verification\n *\n * \u005cparam ctx: your struct lws_genrsa_ctx\n * \u005cparam in: unencrypted payload (usually a recomputed hash)\n * \u005cparam hash_type: one of LWS_GENHASH_TYPE_\n * \u005cparam sig: pointer to the signature we received with the payload\n * \u005cparam sig_len: length of the signature we are checking in bytes\n *\n * Returns \u003c0 for error, or 0 if signature matches the payload + key.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genrsa_public_verify(struct lws_genrsa_ctx *ctx, const uint8_t *in,\n\t\t\t enum lws_genhash_types hash_type,\n\t\t\t const uint8_t *sig, size_t sig_len);\n\n/** lws_genrsa_public_sign() - Create RSA signature\n *\n * \u005cparam ctx: your struct lws_genrsa_ctx\n * \u005cparam in: precomputed hash\n * \u005cparam hash_type: one of LWS_GENHASH_TYPE_\n * \u005cparam sig: pointer to buffer to take signature\n * \u005cparam sig_len: length of the buffer (must be \u003e\u003d length of key N)\n *\n * Returns \u003c0 for error, or 0 for success.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genrsa_public_sign(struct lws_genrsa_ctx *ctx, const uint8_t *in,\n\t\t\t enum lws_genhash_types hash_type, uint8_t *sig,\n\t\t\t size_t sig_len);\n\n/** lws_genrsa_public_decrypt_destroy() - Destroy RSA public decrypt context\n *\n * \u005cparam ctx: your struct lws_genrsa_ctx\n *\n * Destroys any allocations related to \u005cp ctx.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_genrsa_destroy(struct lws_genrsa_ctx *ctx);\n\n/** lws_genrsa_render_pkey_asn1() - Exports public or private key to ASN1/DER\n *\n * \u005cparam ctx: your struct lws_genrsa_ctx\n * \u005cparam _private: 0 \u003d public part only, 1 \u003d all parts of the key\n * \u005cparam pkey_asn1: pointer to buffer to take the ASN1\n * \u005cparam pkey_asn1_len: max size of the pkey_asn1_len\n *\n * Returns length of pkey_asn1 written, or -1 for error.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genrsa_render_pkey_asn1(struct lws_genrsa_ctx *ctx, int _private,\n\t\t\t uint8_t *pkey_asn1, size_t pkey_asn1_len);\n///@}\n\n/*! \u005cdefgroup jwk JSON Web Keys\n * ## JSON Web Keys API\n *\n * Lws provides an API to parse JSON Web Keys into a struct lws_genrsa_elements.\n *\n * \u0022oct\u0022 and \u0022RSA\u0022 type keys are supported. For \u0022oct\u0022 keys, they are held in\n * the \u0022e\u0022 member of the struct lws_genrsa_elements.\n *\n * Keys elements are allocated on the heap. You must destroy the allocations\n * in the struct lws_genrsa_elements by calling\n * lws_jwk_destroy_genrsa_elements() when you are finished with it.\n */\n///@{\n\nstruct lws_jwk {\n\tchar keytype[5];\t\t/**\u003c \u0022oct\u0022 or \u0022RSA\u0022 */\n\tstruct lws_genrsa_elements el;\t/**\u003c OCTet key is in el.e */\n};\n\n/** lws_jwk_import() - Create a JSON Web key from the textual representation\n *\n * \u005cparam s: the JWK object to create\n * \u005cparam in: a single JWK JSON stanza in utf-8\n * \u005cparam len: the length of the JWK JSON stanza in bytes\n *\n * Creates an lws_jwk struct filled with data from the JSON representation.\n * \u0022oct\u0022 and \u0022rsa\u0022 key types are supported.\n *\n * For \u0022oct\u0022 type keys, it is loaded into el.e.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_jwk_import(struct lws_jwk *s, const char *in, size_t len);\n\n/** lws_jwk_destroy() - Destroy a JSON Web key\n *\n * \u005cparam s: the JWK object to destroy\n *\n * All allocations in the lws_jwk are destroyed\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_jwk_destroy(struct lws_jwk *s);\n\n/** lws_jwk_export() - Export a JSON Web key to a textual representation\n *\n * \u005cparam s: the JWK object to export\n * \u005cparam _private: 0 \u003d just export public parts, 1 \u003d export everything\n * \u005cparam p: the buffer to write the exported JWK to\n * \u005cparam len: the length of the buffer \u005cp p in bytes\n *\n * Returns length of the used part of the buffer if OK, or -1 for error.\n *\n * Serializes the content of the JWK into a char buffer.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_jwk_export(struct lws_jwk *s, int _private, char *p, size_t len);\n\n/** lws_jwk_load() - Import a JSON Web key from a file\n *\n * \u005cparam s: the JWK object to load into\n * \u005cparam filename: filename to load from\n *\n * Returns 0 for OK or -1 for failure\n */\nLWS_VISIBLE int\nlws_jwk_load(struct lws_jwk *s, const char *filename);\n\n/** lws_jwk_save() - Export a JSON Web key to a file\n *\n * \u005cparam s: the JWK object to save from\n * \u005cparam filename: filename to save to\n *\n * Returns 0 for OK or -1 for failure\n */\nLWS_VISIBLE int\nlws_jwk_save(struct lws_jwk *s, const char *filename);\n\n/** lws_jwk_rfc7638_fingerprint() - jwk to RFC7638 compliant fingerprint\n *\n * \u005cparam s: the JWK object to fingerprint\n * \u005cparam digest32: buffer to take 32-byte digest\n *\n * Returns 0 for OK or -1 for failure\n */\nLWS_VISIBLE int\nlws_jwk_rfc7638_fingerprint(struct lws_jwk *s, char *digest32);\n///@}\n\n\n/*! \u005cdefgroup jws JSON Web Signature\n * ## JSON Web Signature API\n *\n * Lws provides an API to check and create RFC7515 JSON Web Signatures\n *\n * SHA256/384/512 HMAC, and RSA 256/384/512 are supported.\n *\n * The API uses your TLS library crypto, but works exactly the same no matter\n * what you TLS backend is.\n */\n///@{\n\nLWS_VISIBLE LWS_EXTERN int\nlws_jws_confirm_sig(const char *in, size_t len, struct lws_jwk *jwk);\n\n/**\n * lws_jws_sign_from_b64() - add b64 sig to b64 hdr + payload\n *\n * \u005cparam b64_hdr: protected header encoded in b64, may be NULL\n * \u005cparam hdr_len: bytes in b64 coding of protected header\n * \u005cparam b64_pay: payload encoded in b64\n * \u005cparam pay_len: bytes in b64 coding of payload\n * \u005cparam b64_sig: buffer to write the b64 encoded signature into\n * \u005cparam sig_len: max bytes we can write at b64_sig\n * \u005cparam hash_type: one of LWS_GENHASH_TYPE_SHA[256|384|512]\n * \u005cparam jwk: the struct lws_jwk containing the signing key\n *\n * This adds a b64-coded JWS signature of the b64-encoded protected header\n * and b64-encoded payload, at \u005cp b64_sig. The signature will be as large\n * as the N element of the RSA key when the RSA key is used, eg, 512 bytes for\n * a 4096-bit key, and then b64-encoding on top.\n *\n * In some special cases, there is only payload to sign and no header, in that\n * case \u005cp b64_hdr may be NULL, and only the payload will be hashed before\n * signing.\n *\n * Returns the length of the encoded signature written to \u005cp b64_sig, or -1.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_jws_sign_from_b64(const char *b64_hdr, size_t hdr_len, const char *b64_pay,\n\t\t size_t pay_len, char *b64_sig, size_t sig_len,\n\t\t enum lws_genhash_types hash_type, struct lws_jwk *jwk);\n\n/**\n * lws_jws_create_packet() - add b64 sig to b64 hdr + payload\n *\n * \u005cparam jwk: the struct lws_jwk containing the signing key\n * \u005cparam payload: unencoded payload JSON\n * \u005cparam len: length of unencoded payload JSON\n * \u005cparam nonce: Nonse string to include in protected header\n * \u005cparam out: buffer to take signed packet\n * \u005cparam out_len: size of \u005cp out buffer\n *\n * This creates a \u0022flattened\u0022 JWS packet from the jwk and the plaintext\n * payload, and signs it. The packet is written into \u005cp out.\n *\n * This does the whole packet assembly and signing, calling through to\n * lws_jws_sign_from_b64() as part of the process.\n *\n * Returns the length written to \u005cp out, or -1.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_jws_create_packet(struct lws_jwk *jwk, const char *payload, size_t len,\n\t\t const char *nonce, char *out, size_t out_len);\n\n/**\n * lws_jws_base64_enc() - encode input data into b64url data\n *\n * \u005cparam in: the incoming plaintext\n * \u005cparam in_len: the length of the incoming plaintext in bytes\n * \u005cparam out: the buffer to store the b64url encoded data to\n * \u005cparam out_max: the length of \u005cp out in bytes\n *\n * Returns either -1 if problems, or the number of bytes written to \u005cp out.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_jws_base64_enc(const char *in, size_t in_len, char *out, size_t out_max);\n///@}\n#endif\n\n/*! \u005cdefgroup extensions Extension related functions\n * ##Extension releated functions\n *\n * Ws defines optional extensions, lws provides the ability to implement these\n * in user code if so desired.\n *\n * We provide one extensions permessage-deflate.\n */\n///@{\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\nenum lws_extension_callback_reasons {\n\tLWS_EXT_CB_CONSTRUCT\t\t\t\t\u003d 4,\n\tLWS_EXT_CB_CLIENT_CONSTRUCT\t\t\t\u003d 5,\n\tLWS_EXT_CB_DESTROY\t\t\t\t\u003d 8,\n\tLWS_EXT_CB_PACKET_TX_PRESEND\t\t\t\u003d 12,\n\tLWS_EXT_CB_PAYLOAD_TX\t\t\t\t\u003d 21,\n\tLWS_EXT_CB_PAYLOAD_RX\t\t\t\t\u003d 22,\n\tLWS_EXT_CB_OPTION_DEFAULT\t\t\t\u003d 23,\n\tLWS_EXT_CB_OPTION_SET\t\t\t\t\u003d 24,\n\tLWS_EXT_CB_OPTION_CONFIRM\t\t\t\u003d 25,\n\tLWS_EXT_CB_NAMED_OPTION_SET\t\t\t\u003d 26,\n\n\t/****** add new things just above ---^ ******/\n};\n\n/** enum lws_ext_options_types */\nenum lws_ext_options_types {\n\tEXTARG_NONE, /**\u003c does not take an argument */\n\tEXTARG_DEC, /**\u003c requires a decimal argument */\n\tEXTARG_OPT_DEC /**\u003c may have an optional decimal argument */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n};\n\n/** struct lws_ext_options -\tOption arguments to the extension. These are\n *\t\t\t\tused in the negotiation at ws upgrade time.\n *\t\t\t\tThe helper function lws_ext_parse_options()\n *\t\t\t\tuses these to generate callbacks */\nstruct lws_ext_options {\n\tconst char *name; /**\u003c Option name, eg, \u0022server_no_context_takeover\u0022 */\n\tenum lws_ext_options_types type; /**\u003c What kind of args the option can take */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n};\n\n/** struct lws_ext_option_arg */\nstruct lws_ext_option_arg {\n\tconst char *option_name; /**\u003c may be NULL, option_index used then */\n\tint option_index; /**\u003c argument ordinal to use if option_name missing */\n\tconst char *start; /**\u003c value */\n\tint len; /**\u003c length of value */\n};\n\n/**\n * typedef lws_extension_callback_function() - Hooks to allow extensions to operate\n * \u005cparam context:\tWebsockets context\n * \u005cparam ext:\tThis extension\n * \u005cparam wsi:\tOpaque websocket instance pointer\n * \u005cparam reason:\tThe reason for the call\n * \u005cparam user:\tPointer to ptr to per-session user data allocated by library\n * \u005cparam in:\t\tPointer used for some callback reasons\n * \u005cparam len:\tLength set for some callback reasons\n *\n *\tEach extension that is active on a particular connection receives\n *\tcallbacks during the connection lifetime to allow the extension to\n *\toperate on websocket data and manage itself.\n *\n *\tLibwebsockets takes care of allocating and freeing \u0022user\u0022 memory for\n *\teach active extension on each connection. That is what is pointed to\n *\tby the user parameter.\n *\n *\tLWS_EXT_CB_CONSTRUCT: called when the server has decided to\n *\t\tselect this extension from the list provided by the client,\n *\t\tjust before the server will send back the handshake accepting\n *\t\tthe connection with this extension active. This gives the\n *\t\textension a chance to initialize its connection context found\n *\t\tin user.\n *\n *\tLWS_EXT_CB_CLIENT_CONSTRUCT: same as LWS_EXT_CB_CONSTRUCT\n *\t\tbut called when client is instantiating this extension. Some\n *\t\textensions will work the same on client and server side and then\n *\t\tyou can just merge handlers for both CONSTRUCTS.\n *\n *\tLWS_EXT_CB_DESTROY: called when the connection the extension was\n *\t\tbeing used on is about to be closed and deallocated. It's the\n *\t\tlast chance for the extension to deallocate anything it has\n *\t\tallocated in the user data (pointed to by user) before the\n *\t\tuser data is deleted. This same callback is used whether you\n *\t\tare in client or server instantiation context.\n *\n *\tLWS_EXT_CB_PACKET_TX_PRESEND: this works the same way as\n *\t\tLWS_EXT_CB_PACKET_RX_PREPARSE above, except it gives the\n *\t\textension a chance to change websocket data just before it will\n *\t\tbe sent out. Using the same lws_token pointer scheme in in,\n *\t\tthe extension can change the buffer and the length to be\n *\t\ttransmitted how it likes. Again if it wants to grow the\n *\t\tbuffer safely, it should copy the data into its own buffer and\n *\t\tset the lws_tokens token pointer to it.\n *\n *\tLWS_EXT_CB_ARGS_VALIDATE:\n */\ntypedef int\nlws_extension_callback_function(struct lws_context *context,\n\t\t\t const struct lws_extension *ext, struct lws *wsi,\n\t\t\t enum lws_extension_callback_reasons reason,\n\t\t\t void *user, void *in, size_t len);\n\n/** struct lws_extension -\tAn extension we support */\nstruct lws_extension {\n\tconst char *name; /**\u003c Formal extension name, eg, \u0022permessage-deflate\u0022 */\n\tlws_extension_callback_function *callback; /**\u003c Service callback */\n\tconst char *client_offer; /**\u003c String containing exts and options client offers */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n};\n\n/**\n * lws_set_extension_option(): set extension option if possible\n *\n * \u005cparam wsi:\twebsocket connection\n * \u005cparam ext_name:\tname of ext, like \u0022permessage-deflate\u0022\n * \u005cparam opt_name:\tname of option, like \u0022rx_buf_size\u0022\n * \u005cparam opt_val:\tvalue to set option to\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_set_extension_option(struct lws *wsi, const char *ext_name,\n\t\t\t const char *opt_name, const char *opt_val);\n\n/**\n * lws_ext_parse_options() - deal with parsing negotiated extension options\n *\n * \u005cparam ext: related extension struct\n * \u005cparam wsi:\twebsocket connection\n * \u005cparam ext_user: per-connection extension private data\n * \u005cparam opts: list of supported options\n * \u005cparam o: option string to parse\n * \u005cparam len: length\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,\n\t\t void *ext_user, const struct lws_ext_options *opts,\n\t\t const char *o, int len);\n\n/** lws_extension_callback_pm_deflate() - extension for RFC7692\n *\n * \u005cparam context:\tlws context\n * \u005cparam ext:\trelated lws_extension struct\n * \u005cparam wsi:\twebsocket connection\n * \u005cparam reason:\tincoming callback reason\n * \u005cparam user:\tper-connection extension private data\n * \u005cparam in:\tpointer parameter\n * \u005cparam len:\tlength parameter\n *\n * Built-in callback implementing RFC7692 permessage-deflate\n */\nLWS_EXTERN\nint lws_extension_callback_pm_deflate(\n\tstruct lws_context *context, const struct lws_extension *ext,\n\tstruct lws *wsi, enum lws_extension_callback_reasons reason,\n\tvoid *user, void *in, size_t len);\n\n/*\n * The internal exts are part of the public abi\n * If we add more extensions, publish the callback here ------v\n */\n///@}\n\n/*! \u005cdefgroup Protocols-and-Plugins Protocols and Plugins\n * \u005cingroup lwsapi\n *\n * ##Protocol and protocol plugin -related apis\n *\n * Protocols bind ws protocol names to a custom callback specific to that\n * protocol implementaion.\n *\n * A list of protocols can be passed in at context creation time, but it is\n * also legal to leave that NULL and add the protocols and their callback code\n * using plugins.\n *\n * Plugins are much preferable compared to cut and pasting code into an\n * application each time, since they can be used standalone.\n */\n///@{\n/** struct lws_protocols -\tList of protocols and handlers client or server\n *\t\t\t\t\tsupports. */\n\nstruct lws_protocols {\n\tconst char *name;\n\t/**\u003c Protocol name that must match the one given in the client\n\t * Javascript new WebSocket(url, 'protocol') name. */\n\tlws_callback_function *callback;\n\t/**\u003c The service callback used for this protocol. It allows the\n\t * service action for an entire protocol to be encapsulated in\n\t * the protocol-specific callback */\n\tsize_t per_session_data_size;\n\t/**\u003c Each new connection using this protocol gets\n\t * this much memory allocated on connection establishment and\n\t * freed on connection takedown. A pointer to this per-connection\n\t * allocation is passed into the callback in the 'user' parameter */\n\tsize_t rx_buffer_size;\n\t/**\u003c lws allocates this much space for rx data and informs callback\n\t * when something came. Due to rx flow control, the callback may not\n\t * be able to consume it all without having to return to the event\n\t * loop. That is supported in lws.\n\t *\n\t * If .tx_packet_size is 0, this also controls how much may be sent at\n\t * once for backwards compatibility.\n\t */\n\tunsigned int id;\n\t/**\u003c ignored by lws, but useful to contain user information bound\n\t * to the selected protocol. For example if this protocol was\n\t * called \u0022myprotocol-v2\u0022, you might set id to 2, and the user\n\t * code that acts differently according to the version can do so by\n\t * switch (wsi-\u003eprotocol-\u003eid), user code might use some bits as\n\t * capability flags based on selected protocol version, etc. */\n\tvoid *user; /**\u003c ignored by lws, but user code can pass a pointer\n\t\t\there it can later access from the protocol callback */\n\tsize_t tx_packet_size;\n\t/**\u003c 0 indicates restrict send() size to .rx_buffer_size for backwards-\n\t * compatibility.\n\t * If greater than zero, a single send() is restricted to this amount\n\t * and any remainder is buffered by lws and sent afterwards also in\n\t * these size chunks. Since that is expensive, it's preferable\n\t * to restrict one fragment you are trying to send to match this\n\t * size.\n\t */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n};\n\n/**\n * lws_vhost_name_to_protocol() - get vhost's protocol object from its name\n *\n * \u005cparam vh: vhost to search\n * \u005cparam name: protocol name\n *\n * Returns NULL or a pointer to the vhost's protocol of the requested name\n */\nLWS_VISIBLE LWS_EXTERN const struct lws_protocols *\nlws_vhost_name_to_protocol(struct lws_vhost *vh, const char *name);\n\n/**\n * lws_get_protocol() - Returns a protocol pointer from a websocket\n *\t\t\t\t connection.\n * \u005cparam wsi:\tpointer to struct websocket you want to know the protocol of\n *\n *\n *\tSome apis can act on all live connections of a given protocol,\n *\tthis is how you can get a pointer to the active protocol if needed.\n */\nLWS_VISIBLE LWS_EXTERN const struct lws_protocols *\nlws_get_protocol(struct lws *wsi);\n\n/** lws_protocol_get() - deprecated: use lws_get_protocol */\nLWS_VISIBLE LWS_EXTERN const struct lws_protocols *\nlws_protocol_get(struct lws *wsi) LWS_WARN_DEPRECATED;\n\n/**\n * lws_protocol_vh_priv_zalloc() - Allocate and zero down a protocol's per-vhost\n *\t\t\t\t storage\n * \u005cparam vhost:\tvhost the instance is related to\n * \u005cparam prot:\t\tprotocol the instance is related to\n * \u005cparam size:\t\tbytes to allocate\n *\n * Protocols often find it useful to allocate a per-vhost struct, this is a\n * helper to be called in the per-vhost init LWS_CALLBACK_PROTOCOL_INIT\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_protocol_vh_priv_zalloc(struct lws_vhost *vhost, const struct lws_protocols *prot,\n\t\t\t int size);\n\n/**\n * lws_protocol_vh_priv_get() - retreive a protocol's per-vhost storage\n *\n * \u005cparam vhost:\tvhost the instance is related to\n * \u005cparam prot:\t\tprotocol the instance is related to\n *\n * Recover a pointer to the allocated per-vhost storage for the protocol created\n * by lws_protocol_vh_priv_zalloc() earlier\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_protocol_vh_priv_get(struct lws_vhost *vhost, const struct lws_protocols *prot);\n\n/**\n * lws_adjust_protocol_psds - change a vhost protocol's per session data size\n *\n * \u005cparam wsi: a connection with the protocol to change\n * \u005cparam new_size: the new size of the per session data size for the protocol\n *\n * Returns user_space for the wsi, after allocating\n *\n * This should not be used except to initalize a vhost protocol's per session\n * data size one time, before any connections are accepted.\n *\n * Sometimes the protocol wraps another protocol and needs to discover and set\n * its per session data size at runtime.\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_adjust_protocol_psds(struct lws *wsi, size_t new_size);\n\n/**\n * lws_finalize_startup() - drop initial process privileges\n *\n * \u005cparam context:\tlws context\n *\n * This is called after the end of the vhost protocol initializations, but\n * you may choose to call it earlier\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_finalize_startup(struct lws_context *context);\n\n/**\n * lws_pvo_search() - helper to find a named pvo in a linked-list\n *\n * \u005cparam pvo:\tthe first pvo in the linked-list\n * \u005cparam name: the name of the pvo to return if found\n *\n * Returns NULL, or a pointer to the name pvo in the linked-list\n */\nLWS_VISIBLE LWS_EXTERN const struct lws_protocol_vhost_options *\nlws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_protocol_init(struct lws_context *context);\n\n#ifdef LWS_WITH_PLUGINS\n\n/* PLUGINS implies LIBUV */\n\n#define LWS_PLUGIN_API_MAGIC 180\n\n/** struct lws_plugin_capability - how a plugin introduces itself to lws */\nstruct lws_plugin_capability {\n\tunsigned int api_magic;\t/**\u003c caller fills this in, plugin fills rest */\n\tconst struct lws_protocols *protocols; /**\u003c array of supported protocols provided by plugin */\n\tint count_protocols; /**\u003c how many protocols */\n\tconst struct lws_extension *extensions; /**\u003c array of extensions provided by plugin */\n\tint count_extensions; /**\u003c how many extensions */\n};\n\ntypedef int (*lws_plugin_init_func)(struct lws_context *,\n\t\t\t\t struct lws_plugin_capability *);\ntypedef int (*lws_plugin_destroy_func)(struct lws_context *);\n\n/** struct lws_plugin */\nstruct lws_plugin {\n\tstruct lws_plugin *list; /**\u003c linked list */\n#if (UV_VERSION_MAJOR \u003e 0)\n\tuv_lib_t lib; /**\u003c shared library pointer */\n#else\n\tvoid *l; /**\u003c so we can compile on ancient libuv */\n#endif\n\tchar name[64]; /**\u003c name of the plugin */\n\tstruct lws_plugin_capability caps; /**\u003c plugin capabilities */\n};\n\n#endif\n\n///@}\n\n\n/*! \u005cdefgroup generic-sessions plugin: generic-sessions\n * \u005cingroup Protocols-and-Plugins\n *\n * ##Plugin Generic-sessions related\n *\n * generic-sessions plugin provides a reusable, generic session and login /\n * register / forgot password framework including email verification.\n */\n///@{\n\n#define LWSGS_EMAIL_CONTENT_SIZE 16384\n/**\u003c Maximum size of email we might send */\n\n/* SHA-1 binary and hexified versions */\n/** typedef struct lwsgw_hash_bin */\ntypedef struct { unsigned char bin[20]; /**\u003c binary representation of hash */} lwsgw_hash_bin;\n/** typedef struct lwsgw_hash */\ntypedef struct { char id[41]; /**\u003c ascii hex representation of hash */ } lwsgw_hash;\n\n/** enum lwsgs_auth_bits */\nenum lwsgs_auth_bits {\n\tLWSGS_AUTH_LOGGED_IN \u003d 1, /**\u003c user is logged in as somebody */\n\tLWSGS_AUTH_ADMIN \u003d 2,\t/**\u003c logged in as the admin user */\n\tLWSGS_AUTH_VERIFIED \u003d 4, /**\u003c user has verified his email */\n\tLWSGS_AUTH_FORGOT_FLOW \u003d 8,\t/**\u003c he just completed \u0022forgot password\u0022 flow */\n};\n\n/** struct lws_session_info - information about user session status */\nstruct lws_session_info {\n\tchar username[32]; /**\u003c username logged in as, or empty string */\n\tchar email[100]; /**\u003c email address associated with login, or empty string */\n\tchar ip[72]; /**\u003c ip address session was started from */\n\tunsigned int mask; /**\u003c access rights mask associated with session\n\t \t \t * see enum lwsgs_auth_bits */\n\tchar session[42]; /**\u003c session id string, usable as opaque uid when not logged in */\n};\n\n/** enum lws_gs_event */\nenum lws_gs_event {\n\tLWSGSE_CREATED, /**\u003c a new user was created */\n\tLWSGSE_DELETED /**\u003c an existing user was deleted */\n};\n\n/** struct lws_gs_event_args */\nstruct lws_gs_event_args {\n\tenum lws_gs_event event; /**\u003c which event happened */\n\tconst char *username; /**\u003c which username the event happened to */\n\tconst char *email; /**\u003c the email address of that user */\n};\n\n///@}\n\n\n/*! \u005cdefgroup context-and-vhost context and vhost related functions\n * ##Context and Vhost releated functions\n * \u005cingroup lwsapi\n *\n *\n * LWS requires that there is one context, in which you may define multiple\n * vhosts. Each vhost is a virtual host, with either its own listen port\n * or sharing an existing one. Each vhost has its own SSL context that can\n * be set up individually or left disabled.\n *\n * If you don't care about multiple \u0022site\u0022 support, you can ignore it and\n * lws will create a single default vhost at context creation time.\n */\n///@{\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\n\n/** enum lws_context_options - context and vhost options */\nenum lws_context_options {\n\tLWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT\t\u003d (1 \u003c\u003c 1) |\n\t\t\t\t\t\t\t\t (1 \u003c\u003c 12),\n\t/**\u003c (VH) Don't allow the connection unless the client has a\n\t * client cert that we recognize; provides\n\t * LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT */\n\tLWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME\t\t\u003d (1 \u003c\u003c 2),\n\t/**\u003c (CTX) Don't try to get the server's hostname */\n\tLWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT\t\t\u003d (1 \u003c\u003c 3) |\n\t\t\t\t\t\t\t\t (1 \u003c\u003c 12),\n\t/**\u003c (VH) Allow non-SSL (plaintext) connections on the same\n\t * port as SSL is listening... undermines the security of SSL;\n\t * provides LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT */\n\tLWS_SERVER_OPTION_LIBEV\t\t\t\t\t\u003d (1 \u003c\u003c 4),\n\t/**\u003c (CTX) Use libev event loop */\n\tLWS_SERVER_OPTION_DISABLE_IPV6\t\t\t\t\u003d (1 \u003c\u003c 5),\n\t/**\u003c (VH) Disable IPV6 support */\n\tLWS_SERVER_OPTION_DISABLE_OS_CA_CERTS\t\t\t\u003d (1 \u003c\u003c 6),\n\t/**\u003c (VH) Don't load OS CA certs, you will need to load your\n\t * own CA cert(s) */\n\tLWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED\t\t\u003d (1 \u003c\u003c 7),\n\t/**\u003c (VH) Accept connections with no valid Cert (eg, selfsigned) */\n\tLWS_SERVER_OPTION_VALIDATE_UTF8\t\t\t\t\u003d (1 \u003c\u003c 8),\n\t/**\u003c (VH) Check UT-8 correctness */\n\tLWS_SERVER_OPTION_SSL_ECDH\t\t\t\t\u003d (1 \u003c\u003c 9) |\n\t\t\t\t\t\t\t\t (1 \u003c\u003c 12),\n\t/**\u003c (VH) initialize ECDH ciphers */\n\tLWS_SERVER_OPTION_LIBUV\t\t\t\t\t\u003d (1 \u003c\u003c 10),\n\t/**\u003c (CTX) Use libuv event loop */\n\tLWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS\t\t\u003d (1 \u003c\u003c 11) |\n\t\t\t\t\t\t\t\t (1 \u003c\u003c 12),\n\t/**\u003c (VH) Use http redirect to force http to https\n\t * (deprecated: use mount redirection) */\n\tLWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT\t\t\t\u003d (1 \u003c\u003c 12),\n\t/**\u003c (CTX) Initialize the SSL library at all */\n\tLWS_SERVER_OPTION_EXPLICIT_VHOSTS\t\t\t\u003d (1 \u003c\u003c 13),\n\t/**\u003c (CTX) Only create the context when calling context\n\t * create api, implies user code will create its own vhosts */\n\tLWS_SERVER_OPTION_UNIX_SOCK\t\t\t\t\u003d (1 \u003c\u003c 14),\n\t/**\u003c (VH) Use Unix socket */\n\tLWS_SERVER_OPTION_STS\t\t\t\t\t\u003d (1 \u003c\u003c 15),\n\t/**\u003c (VH) Send Strict Transport Security header, making\n\t * clients subsequently go to https even if user asked for http */\n\tLWS_SERVER_OPTION_IPV6_V6ONLY_MODIFY\t\t\t\u003d (1 \u003c\u003c 16),\n\t/**\u003c (VH) Enable LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE to take effect */\n\tLWS_SERVER_OPTION_IPV6_V6ONLY_VALUE\t\t\t\u003d (1 \u003c\u003c 17),\n\t/**\u003c (VH) if set, only ipv6 allowed on the vhost */\n\tLWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN\t\t\u003d (1 \u003c\u003c 18),\n\t/**\u003c (CTX) Libuv only: Do not spin on SIGSEGV / SIGFPE. A segfault\n\t * normally makes the lib spin so you can attach a debugger to it\n\t * even if it happened without a debugger in place. You can disable\n\t * that by giving this option.\n\t */\n\tLWS_SERVER_OPTION_JUST_USE_RAW_ORIGIN\t\t\t\u003d (1 \u003c\u003c 19),\n\t/**\u003c For backwards-compatibility reasons, by default\n\t * lws prepends \u0022http://\u0022 to the origin you give in the client\n\t * connection info struct. If you give this flag when you create\n\t * the context, only the string you give in the client connect\n\t * info for .origin (if any) will be used directly.\n\t */\n\tLWS_SERVER_OPTION_FALLBACK_TO_RAW\t\t\t\u003d (1 \u003c\u003c 20),\n\t/**\u003c (VH) if invalid http is coming in the first line, */\n\tLWS_SERVER_OPTION_LIBEVENT\t\t\t\t\u003d (1 \u003c\u003c 21),\n\t/**\u003c (CTX) Use libevent event loop */\n\tLWS_SERVER_OPTION_ONLY_RAW\t\t\t\t\u003d (1 \u003c\u003c 22),\n\t/**\u003c (VH) All connections to this vhost / port are RAW as soon as\n\t * the connection is accepted, no HTTP is going to be coming.\n\t */\n\tLWS_SERVER_OPTION_ALLOW_LISTEN_SHARE\t\t\t\u003d (1 \u003c\u003c 23),\n\t/**\u003c (VH) Set to allow multiple listen sockets on one interface +\n\t * address + port. The default is to strictly allow only one\n\t * listen socket at a time. This is automatically selected if you\n\t * have multiple service threads.\n\t */\n\tLWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX\t\t\t\u003d (1 \u003c\u003c 24),\n\t/**\u003c (VH) Force setting up the vhost SSL_CTX, even though the user\n\t * code doesn't explicitly provide a cert in the info struct. It\n\t * implies the user code is going to provide a cert at the\n\t * LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS callback, which\n\t * provides the vhost SSL_CTX * in the user parameter.\n\t */\n\tLWS_SERVER_OPTION_SKIP_PROTOCOL_INIT\t\t\t\u003d (1 \u003c\u003c 25),\n\t/**\u003c (VH) You probably don't want this. It forces this vhost to not\n\t * call LWS_CALLBACK_PROTOCOL_INIT on its protocols. It's used in the\n\t * special case of a temporary vhost bound to a single protocol.\n\t */\n\tLWS_SERVER_OPTION_IGNORE_MISSING_CERT\t\t\t\u003d (1 \u003c\u003c 26),\n\t/**\u003c (VH) Don't fail if the vhost TLS cert or key are missing, just\n\t * continue. The vhost won't be able to serve anything, but if for\n\t * example the ACME plugin was configured to fetch a cert, this lets\n\t * you bootstrap your vhost from having no cert to start with.\n\t */\n\n\t/****** add new things just above ---^ ******/\n};\n\n#define lws_check_opt(c, f) (((c) \u0026 (f)) \u003d\u003d (f))\n\nstruct lws_plat_file_ops;\n\n/** struct lws_context_creation_info - parameters to create context and /or vhost with\n *\n * This is also used to create vhosts.... if LWS_SERVER_OPTION_EXPLICIT_VHOSTS\n * is not given, then for backwards compatibility one vhost is created at\n * context-creation time using the info from this struct.\n *\n * If LWS_SERVER_OPTION_EXPLICIT_VHOSTS is given, then no vhosts are created\n * at the same time as the context, they are expected to be created afterwards.\n */\nstruct lws_context_creation_info {\n\tint port;\n\t/**\u003c VHOST: Port to listen on. Use CONTEXT_PORT_NO_LISTEN to suppress\n\t * listening for a client. Use CONTEXT_PORT_NO_LISTEN_SERVER if you are\n\t * writing a server but you are using \u005cref sock-adopt instead of the\n\t * built-in listener.\n\t *\n\t * You can also set port to 0, in which case the kernel will pick\n\t * a random port that is not already in use. You can find out what\n\t * port the vhost is listening on using lws_get_vhost_listen_port() */\n\tconst char *iface;\n\t/**\u003c VHOST: NULL to bind the listen socket to all interfaces, or the\n\t * interface name, eg, \u0022eth2\u0022\n\t * If options specifies LWS_SERVER_OPTION_UNIX_SOCK, this member is\n\t * the pathname of a UNIX domain socket. you can use the UNIX domain\n\t * sockets in abstract namespace, by prepending an at symbol to the\n\t * socket name. */\n\tconst struct lws_protocols *protocols;\n\t/**\u003c VHOST: Array of structures listing supported protocols and a protocol-\n\t * specific callback for each one. The list is ended with an\n\t * entry that has a NULL callback pointer. */\n\tconst struct lws_extension *extensions;\n\t/**\u003c VHOST: NULL or array of lws_extension structs listing the\n\t * extensions this context supports. */\n\tconst struct lws_token_limits *token_limits;\n\t/**\u003c CONTEXT: NULL or struct lws_token_limits pointer which is initialized\n\t * with a token length limit for each possible WSI_TOKEN_ */\n\tconst char *ssl_private_key_password;\n\t/**\u003c VHOST: NULL or the passphrase needed for the private key. (For\n\t * backwards compatibility, this can also be used to pass the client\n\t * cert passphrase when setting up a vhost client SSL context, but it is\n\t * preferred to use .client_ssl_private_key_password for that.) */\n\tconst char *ssl_cert_filepath;\n\t/**\u003c VHOST: If libwebsockets was compiled to use ssl, and you want\n\t * to listen using SSL, set to the filepath to fetch the\n\t * server cert from, otherwise NULL for unencrypted. (For backwards\n\t * compatibility, this can also be used to pass the client certificate\n\t * when setting up a vhost client SSL context, but it is preferred to\n\t * use .client_ssl_cert_filepath for that.) */\n\tconst char *ssl_private_key_filepath;\n\t/**\u003c VHOST: filepath to private key if wanting SSL mode;\n\t * if this is set to NULL but ssl_cert_filepath is set, the\n\t * OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY callback is called\n\t * to allow setting of the private key directly via openSSL\n\t * library calls. (For backwards compatibility, this can also be used\n\t * to pass the client cert private key filepath when setting up a\n\t * vhost client SSL context, but it is preferred to use\n\t * .client_ssl_private_key_filepath for that.) */\n\tconst char *ssl_ca_filepath;\n\t/**\u003c VHOST: CA certificate filepath or NULL. (For backwards\n\t * compatibility, this can also be used to pass the client CA\n\t * filepath when setting up a vhost client SSL context,\n\t * but it is preferred to use .client_ssl_ca_filepath for that.) */\n\tconst char *ssl_cipher_list;\n\t/**\u003c VHOST: List of valid ciphers to use (eg,\n\t * \u0022RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL\u0022\n\t * or you can leave it as NULL to get \u0022DEFAULT\u0022 (For backwards\n\t * compatibility, this can also be used to pass the client cipher\n\t * list when setting up a vhost client SSL context,\n\t * but it is preferred to use .client_ssl_cipher_list for that.)*/\n\tconst char *http_proxy_address;\n\t/**\u003c VHOST: If non-NULL, attempts to proxy via the given address.\n\t * If proxy auth is required, use format \u0022username:password\u005c@server:port\u0022 */\n\tunsigned int http_proxy_port;\n\t/**\u003c VHOST: If http_proxy_address was non-NULL, uses this port */\n\tint gid;\n\t/**\u003c CONTEXT: group id to change to after setting listen socket, or -1. */\n\tint uid;\n\t/**\u003c CONTEXT: user id to change to after setting listen socket, or -1. */\n\tunsigned int options;\n\t/**\u003c VHOST + CONTEXT: 0, or LWS_SERVER_OPTION_... bitfields */\n\tvoid *user;\n\t/**\u003c VHOST + CONTEXT: optional user pointer that will be associated\n\t * with the context when creating the context (and can be retrieved by\n\t * lws_context_user(context), or with the vhost when creating the vhost\n\t * (and can be retrieved by lws_vhost_user(vhost)). You will need to\n\t * use LWS_SERVER_OPTION_EXPLICIT_VHOSTS and create the vhost separately\n\t * if you care about giving the context and vhost different user pointer\n\t * values.\n\t */\n\tint ka_time;\n\t/**\u003c CONTEXT: 0 for no TCP keepalive, otherwise apply this keepalive\n\t * timeout to all libwebsocket sockets, client or server */\n\tint ka_probes;\n\t/**\u003c CONTEXT: if ka_time was nonzero, after the timeout expires how many\n\t * times to try to get a response from the peer before giving up\n\t * and killing the connection */\n\tint ka_interval;\n\t/**\u003c CONTEXT: if ka_time was nonzero, how long to wait before each ka_probes\n\t * attempt */\n#if defined(LWS_WITH_TLS) \u0026\u0026 !defined(LWS_WITH_MBEDTLS)\n\tSSL_CTX *provided_client_ssl_ctx;\n\t/**\u003c CONTEXT: If non-null, swap out libwebsockets ssl\n\t * implementation for the one provided by provided_ssl_ctx.\n\t * Libwebsockets no longer is responsible for freeing the context\n\t * if this option is selected. */\n#else /* maintain structure layout either way */\n\tvoid *provided_client_ssl_ctx; /**\u003c dummy if ssl disabled */\n#endif\n\n\tshort max_http_header_data;\n\t/**\u003c CONTEXT: The max amount of header payload that can be handled\n\t * in an http request (unrecognized header payload is dropped) */\n\tshort max_http_header_pool;\n\t/**\u003c CONTEXT: The max number of connections with http headers that\n\t * can be processed simultaneously (the corresponding memory is\n\t * allocated and deallocated dynamically as needed). If the pool is\n\t * fully busy new incoming connections must wait for accept until one\n\t * becomes free. 0 \u003d allow as many ah as number of availble fds for\n\t * the process */\n\n\tunsigned int count_threads;\n\t/**\u003c CONTEXT: how many contexts to create in an array, 0 \u003d 1 */\n\tunsigned int fd_limit_per_thread;\n\t/**\u003c CONTEXT: nonzero means restrict each service thread to this\n\t * many fds, 0 means the default which is divide the process fd\n\t * limit by the number of threads. */\n\tunsigned int timeout_secs;\n\t/**\u003c VHOST: various processes involving network roundtrips in the\n\t * library are protected from hanging forever by timeouts. If\n\t * nonzero, this member lets you set the timeout used in seconds.\n\t * Otherwise a default timeout is used. */\n\tconst char *ecdh_curve;\n\t/**\u003c VHOST: if NULL, defaults to initializing server with \u0022prime256v1\u0022 */\n\tconst char *vhost_name;\n\t/**\u003c VHOST: name of vhost, must match external DNS name used to\n\t * access the site, like \u0022warmcat.com\u0022 as it's used to match\n\t * Host: header and / or SNI name for SSL. */\n\tconst char * const *plugin_dirs;\n\t/**\u003c CONTEXT: NULL, or NULL-terminated array of directories to\n\t * scan for lws protocol plugins at context creation time */\n\tconst struct lws_protocol_vhost_options *pvo;\n\t/**\u003c VHOST: pointer to optional linked list of per-vhost\n\t * options made accessible to protocols */\n\tint keepalive_timeout;\n\t/**\u003c VHOST: (default \u003d 0 \u003d 5s) seconds to allow remote\n\t * client to hold on to an idle HTTP/1.1 connection */\n\tconst char *log_filepath;\n\t/**\u003c VHOST: filepath to append logs to... this is opened before\n\t *\t\tany dropping of initial privileges */\n\tconst struct lws_http_mount *mounts;\n\t/**\u003c VHOST: optional linked list of mounts for this vhost */\n\tconst char *server_string;\n\t/**\u003c CONTEXT: string used in HTTP headers to identify server\n *\t\tsoftware, if NULL, \u0022libwebsockets\u0022. */\n\tunsigned int pt_serv_buf_size;\n\t/**\u003c CONTEXT: 0 \u003d default of 4096. This buffer is used by\n\t * various service related features including file serving, it\n\t * defines the max chunk of file that can be sent at once.\n\t * At the risk of lws having to buffer failed large sends, it\n\t * can be increased to, eg, 128KiB to improve throughput. */\n\tunsigned int max_http_header_data2;\n\t/**\u003c CONTEXT: if max_http_header_data is 0 and this\n\t * is nonzero, this will be used in place of the default. It's\n\t * like this for compatibility with the original short version,\n\t * this is unsigned int length. */\n\tlong ssl_options_set;\n\t/**\u003c VHOST: Any bits set here will be set as SSL options */\n\tlong ssl_options_clear;\n\t/**\u003c VHOST: Any bits set here will be cleared as SSL options */\n\tunsigned short ws_ping_pong_interval;\n\t/**\u003c CONTEXT: 0 for none, else interval in seconds between sending\n\t * PINGs on idle websocket connections. When the PING is sent,\n\t * the PONG must come within the normal timeout_secs timeout period\n\t * or the connection will be dropped.\n\t * Any RX or TX traffic on the connection restarts the interval timer,\n\t * so a connection which always sends or receives something at intervals\n\t * less than the interval given here will never send PINGs / expect\n\t * PONGs. Conversely as soon as the ws connection is established, an\n\t * idle connection will do the PING / PONG roundtrip as soon as\n\t * ws_ping_pong_interval seconds has passed without traffic\n\t */\n\tconst struct lws_protocol_vhost_options *headers;\n\t\t/**\u003c VHOST: pointer to optional linked list of per-vhost\n\t\t * canned headers that are added to server responses */\n\n\tconst struct lws_protocol_vhost_options *reject_service_keywords;\n\t/**\u003c CONTEXT: Optional list of keywords and rejection codes + text.\n\t *\n\t * The keywords are checked for existing in the user agent string.\n\t *\n\t * Eg, \u0022badrobot\u0022 \u0022404 Not Found\u0022\n\t */\n\tvoid *external_baggage_free_on_destroy;\n\t/**\u003c CONTEXT: NULL, or pointer to something externally malloc'd, that\n\t * should be freed when the context is destroyed. This allows you to\n\t * automatically sync the freeing action to the context destruction\n\t * action, so there is no need for an external free() if the context\n\t * succeeded to create.\n\t */\n\n\tconst char *client_ssl_private_key_password;\n\t/**\u003c VHOST: Client SSL context init: NULL or the passphrase needed\n\t * for the private key */\n\tconst char *client_ssl_cert_filepath;\n\t/**\u003c VHOST: Client SSL context init:T he certificate the client\n\t * should present to the peer on connection */\n\tconst char *client_ssl_private_key_filepath;\n\t/**\u003c VHOST: Client SSL context init: filepath to client private key\n\t * if this is set to NULL but client_ssl_cert_filepath is set, you\n\t * can handle the LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS\n\t * callback of protocols[0] to allow setting of the private key directly\n\t * via openSSL library calls */\n\tconst char *client_ssl_ca_filepath;\n\t/**\u003c VHOST: Client SSL context init: CA certificate filepath or NULL */\n\tconst char *client_ssl_cipher_list;\n\t/**\u003c VHOST: Client SSL context init: List of valid ciphers to use (eg,\n\t* \u0022RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL\u0022\n\t* or you can leave it as NULL to get \u0022DEFAULT\u0022 */\n\n\tconst struct lws_plat_file_ops *fops;\n\t/**\u003c CONTEXT: NULL, or pointer to an array of fops structs, terminated\n\t * by a sentinel with NULL .open.\n\t *\n\t * If NULL, lws provides just the platform file operations struct for\n\t * backwards compatibility.\n\t */\n\tint simultaneous_ssl_restriction;\n\t/**\u003c CONTEXT: 0 (no limit) or limit of simultaneous SSL sessions possible.*/\n\tconst char *socks_proxy_address;\n\t/**\u003c VHOST: If non-NULL, attempts to proxy via the given address.\n\t * If proxy auth is required, use format \u0022username:password\u005c@server:port\u0022 */\n\tunsigned int socks_proxy_port;\n\t/**\u003c VHOST: If socks_proxy_address was non-NULL, uses this port */\n#if defined(LWS_HAVE_SYS_CAPABILITY_H) \u0026\u0026 defined(LWS_HAVE_LIBCAP)\n\tcap_value_t caps[4];\n\t/**\u003c CONTEXT: array holding Linux capabilities you want to\n\t * continue to be available to the server after it transitions\n\t * to a noprivileged user. Usually none are needed but for, eg,\n\t * .bind_iface, CAP_NET_RAW is required. This gives you a way\n\t * to still have the capability but drop root.\n\t */\n\tchar count_caps;\n\t/**\u003c CONTEXT: count of Linux capabilities in .caps[]. 0 means\n\t * no capabilities will be inherited from root (the default) */\n#endif\n\tint bind_iface;\n\t/**\u003c VHOST: nonzero to strictly bind sockets to the interface name in\n\t * .iface (eg, \u0022eth2\u0022), using SO_BIND_TO_DEVICE.\n\t *\n\t * Requires SO_BINDTODEVICE support from your OS and CAP_NET_RAW\n\t * capability.\n\t *\n\t * Notice that common things like access network interface IP from\n\t * your local machine use your lo / loopback interface and will be\n\t * disallowed by this.\n\t */\n\tint ssl_info_event_mask;\n\t/**\u003c VHOST: mask of ssl events to be reported on LWS_CALLBACK_SSL_INFO\n\t * callback for connections on this vhost. The mask values are of\n\t * the form SSL_CB_ALERT, defined in openssl/ssl.h. The default of\n\t * 0 means no info events will be reported.\n\t */\n\tunsigned int timeout_secs_ah_idle;\n\t/**\u003c VHOST: seconds to allow a client to hold an ah without using it.\n\t * 0 defaults to 10s. */\n\tunsigned short ip_limit_ah;\n\t/**\u003c CONTEXT: max number of ah a single IP may use simultaneously\n\t *\t 0 is no limit. This is a soft limit: if the limit is\n\t *\t reached, connections from that IP will wait in the ah\n\t *\t waiting list and not be able to acquire an ah until\n\t *\t a connection belonging to the IP relinquishes one it\n\t *\t already has.\n\t */\n\tunsigned short ip_limit_wsi;\n\t/**\u003c CONTEXT: max number of wsi a single IP may use simultaneously.\n\t *\t 0 is no limit. This is a hard limit, connections from\n\t *\t the same IP will simply be dropped once it acquires the\n\t *\t amount of simultaneous wsi / accepted connections\n\t *\t given here.\n\t */\n\tuint32_t\thttp2_settings[7];\n\t/**\u003c VHOST: if http2_settings[0] is nonzero, the values given in\n\t *\t http2_settings[1]..[6] are used instead of the lws\n\t *\t platform default values.\n\t *\t Just leave all at 0 if you don't care.\n\t */\n\tconst char *error_document_404;\n\t/**\u003c VHOST: If non-NULL, when asked to serve a non-existent file,\n\t * lws attempts to server this url path instead. Eg,\n\t * \u0022/404.html\u0022 */\n\tconst char *alpn;\n\t/**\u003c CONTEXT: If non-NULL, default list of advertised alpn, comma-\n\t *\t separated\n\t *\n\t * VHOST: If non-NULL, per-vhost list of advertised alpn, comma-\n\t *\t separated\n\t */\n\tvoid **foreign_loops;\n\t/**\u003c CONTEXT: This is ignored if the context is not being started with\n\t *\t\tan event loop, ie, .options has a flag like\n\t *\t\tLWS_SERVER_OPTION_LIBUV.\n\t *\n\t *\t\tNULL indicates lws should start its own even loop for\n\t *\t\teach service thread, and deal with closing the loops\n\t *\t\twhen the context is destroyed.\n\t *\n\t *\t\tNon-NULL means it points to an array of external\n\t *\t\t(\u0022foreign\u0022) event loops that are to be used in turn for\n\t *\t\teach service thread. In the default case of 1 service\n\t *\t\tthread, it can just point to one foreign event loop.\n\t */\n\tvoid (*signal_cb)(void *event_lib_handle, int signum);\n\t/**\u003c CONTEXT: NULL: default signal handling. Otherwise this receives\n\t *\t\tthe signal handler callback. event_lib_handle is the\n\t *\t\tnative event library signal handle, eg uv_signal_t *\n\t *\t\tfor libuv.\n\t */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility\n\t *\n\t * The below is to ensure later library versions with new\n\t * members added above will see 0 (default) even if the app\n\t * was not built against the newer headers.\n\t */\n\tstruct lws_context **pcontext;\n\t/**\u003c CONTEXT: if non-NULL, at the end of context destroy processing,\n\t * the pointer pointed to by pcontext is written with NULL. You can\n\t * use this to let foreign event loops know that lws context destruction\n\t * is fully completed.\n\t */\n\n\tvoid *_unused[4]; /**\u003c dummy */\n};\n\n/**\n * lws_create_context() - Create the websocket handler\n * \u005cparam info:\tpointer to struct with parameters\n *\n *\tThis function creates the listening socket (if serving) and takes care\n *\tof all initialization in one step.\n *\n *\tIf option LWS_SERVER_OPTION_EXPLICIT_VHOSTS is given, no vhost is\n *\tcreated; you're expected to create your own vhosts afterwards using\n *\tlws_create_vhost(). Otherwise a vhost named \u0022default\u0022 is also created\n *\tusing the information in the vhost-related members, for compatibility.\n *\n *\tAfter initialization, it returns a struct lws_context * that\n *\trepresents this server. After calling, user code needs to take care\n *\tof calling lws_service() with the context pointer to get the\n *\tserver's sockets serviced. This must be done in the same process\n *\tcontext as the initialization call.\n *\n *\tThe protocol callback functions are called for a handful of events\n *\tincluding http requests coming in, websocket connections becoming\n *\testablished, and data arriving; it's also called periodically to allow\n *\tasync transmission.\n *\n *\tHTTP requests are sent always to the FIRST protocol in protocol, since\n *\tat that time websocket protocol has not been negotiated. Other\n *\tprotocols after the first one never see any HTTP callback activity.\n *\n *\tThe server created is a simple http server by default; part of the\n *\twebsocket standard is upgrading this http connection to a websocket one.\n *\n *\tThis allows the same server to provide files like scripts and favicon /\n *\timages or whatever over http and dynamic data over websockets all in\n *\tone place; they're all handled in the user callback.\n */\nLWS_VISIBLE LWS_EXTERN struct lws_context *\nlws_create_context(const struct lws_context_creation_info *info);\n\n\n/**\n * lws_context_destroy() - Destroy the websocket context\n * \u005cparam context:\tWebsocket context\n *\n *\tThis function closes any active connections and then frees the\n *\tcontext. After calling this, any further use of the context is\n *\tundefined.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_context_destroy(struct lws_context *context);\n\ntypedef int (*lws_reload_func)(void);\n\n/**\n * lws_context_deprecate() - Deprecate the websocket context\n *\n * \u005cparam context:\tWebsocket context\n * \u005cparam cb: Callback notified when old context listen sockets are closed\n *\n *\tThis function is used on an existing context before superceding it\n *\twith a new context.\n *\n *\tIt closes any listen sockets in the context, so new connections are\n *\tnot possible.\n *\n *\tAnd it marks the context to be deleted when the number of active\n *\tconnections into it falls to zero.\n *\n *\tOtherwise if you attach the deprecated context to the replacement\n *\tcontext when it has been created using lws_context_attach_deprecated()\n *\tboth any deprecated and the new context will service their connections.\n *\n *\tThis is aimed at allowing seamless configuration reloads.\n *\n *\tThe callback cb will be called after the listen sockets are actually\n *\tclosed and may be reopened. In the callback the new context should be\n *\tconfigured and created. (With libuv, socket close happens async after\n *\tmore loop events).\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_context_deprecate(struct lws_context *context, lws_reload_func cb);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_context_is_deprecated(struct lws_context *context);\n\n/**\n * lws_set_proxy() - Setups proxy to lws_context.\n * \u005cparam vhost:\tpointer to struct lws_vhost you want set proxy for\n * \u005cparam proxy: pointer to c string containing proxy in format address:port\n *\n * Returns 0 if proxy string was parsed and proxy was setup.\n * Returns -1 if proxy is NULL or has incorrect format.\n *\n * This is only required if your OS does not provide the http_proxy\n * environment variable (eg, OSX)\n *\n * IMPORTANT! You should call this function right after creation of the\n * lws_context and before call to connect. If you call this\n * function after connect behavior is undefined.\n * This function will override proxy settings made on lws_context\n * creation with genenv() call.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_set_proxy(struct lws_vhost *vhost, const char *proxy);\n\n/**\n * lws_set_socks() - Setup socks to lws_context.\n * \u005cparam vhost:\tpointer to struct lws_vhost you want set socks for\n * \u005cparam socks: pointer to c string containing socks in format address:port\n *\n * Returns 0 if socks string was parsed and socks was setup.\n * Returns -1 if socks is NULL or has incorrect format.\n *\n * This is only required if your OS does not provide the socks_proxy\n * environment variable (eg, OSX)\n *\n * IMPORTANT! You should call this function right after creation of the\n * lws_context and before call to connect. If you call this\n * function after connect behavior is undefined.\n * This function will override proxy settings made on lws_context\n * creation with genenv() call.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_set_socks(struct lws_vhost *vhost, const char *socks);\n\nstruct lws_vhost;\n\n/**\n * lws_create_vhost() - Create a vhost (virtual server context)\n * \u005cparam context:\tpointer to result of lws_create_context()\n * \u005cparam info:\t\tpointer to struct with parameters\n *\n * This function creates a virtual server (vhost) using the vhost-related\n * members of the info struct. You can create many vhosts inside one context\n * if you created the context with the option LWS_SERVER_OPTION_EXPLICIT_VHOSTS\n */\nLWS_VISIBLE LWS_EXTERN struct lws_vhost *\nlws_create_vhost(struct lws_context *context,\n\t\t const struct lws_context_creation_info *info);\n\n/**\n * lws_vhost_destroy() - Destroy a vhost (virtual server context)\n *\n * \u005cparam vh:\tpointer to result of lws_create_vhost()\n *\n * This function destroys a vhost. Normally, if you just want to exit,\n * then lws_destroy_context() will take care of everything. If you want\n * to destroy an individual vhost and all connections and allocations, you\n * can do it with this.\n *\n * If the vhost has a listen sockets shared by other vhosts, it will be given\n * to one of the vhosts sharing it rather than closed.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_vhost_destroy(struct lws_vhost *vh);\n\n/**\n * lwsws_get_config_globals() - Parse a JSON server config file\n * \u005cparam info:\t\tpointer to struct with parameters\n * \u005cparam d:\t\tfilepath of the config file\n * \u005cparam config_strings: storage for the config strings extracted from JSON,\n * \t\t\t the pointer is incremented as strings are stored\n * \u005cparam len:\t\tpointer to the remaining length left in config_strings\n *\t\t\t the value is decremented as strings are stored\n *\n * This function prepares a n lws_context_creation_info struct with global\n * settings from a file d.\n *\n * Requires CMake option LWS_WITH_LEJP_CONF to have been enabled\n */\nLWS_VISIBLE LWS_EXTERN int\nlwsws_get_config_globals(struct lws_context_creation_info *info, const char *d,\n\t\t\t char **config_strings, int *len);\n\n/**\n * lwsws_get_config_vhosts() - Create vhosts from a JSON server config file\n * \u005cparam context:\tpointer to result of lws_create_context()\n * \u005cparam info:\t\tpointer to struct with parameters\n * \u005cparam d:\t\tfilepath of the config file\n * \u005cparam config_strings: storage for the config strings extracted from JSON,\n * \t\t\t the pointer is incremented as strings are stored\n * \u005cparam len:\t\tpointer to the remaining length left in config_strings\n *\t\t\t the value is decremented as strings are stored\n *\n * This function creates vhosts into a context according to the settings in\n *JSON files found in directory d.\n *\n * Requires CMake option LWS_WITH_LEJP_CONF to have been enabled\n */\nLWS_VISIBLE LWS_EXTERN int\nlwsws_get_config_vhosts(struct lws_context *context,\n\t\t\tstruct lws_context_creation_info *info, const char *d,\n\t\t\tchar **config_strings, int *len);\n\n/** lws_vhost_get() - \u005cdeprecated deprecated: use lws_get_vhost() */\nLWS_VISIBLE LWS_EXTERN struct lws_vhost *\nlws_vhost_get(struct lws *wsi) LWS_WARN_DEPRECATED;\n\n/**\n * lws_get_vhost() - return the vhost a wsi belongs to\n *\n * \u005cparam wsi: which connection\n */\nLWS_VISIBLE LWS_EXTERN struct lws_vhost *\nlws_get_vhost(struct lws *wsi);\n\n/**\n * lws_get_vhost_name() - returns the name of a vhost\n *\n * \u005cparam vhost: which vhost\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_get_vhost_name(struct lws_vhost *vhost);\n\n/**\n * lws_get_vhost_port() - returns the port a vhost listens on, or -1\n *\n * \u005cparam vhost: which vhost\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_get_vhost_port(struct lws_vhost *vhost);\n\n/**\n * lws_get_vhost_user() - returns the user pointer for the vhost\n *\n * \u005cparam vhost: which vhost\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_get_vhost_user(struct lws_vhost *vhost);\n\n/**\n * lws_get_vhost_iface() - returns the binding for the vhost listen socket\n *\n * \u005cparam vhost: which vhost\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_get_vhost_iface(struct lws_vhost *vhost);\n\n/**\n * lws_json_dump_vhost() - describe vhost state and stats in JSON\n *\n * \u005cparam vh: the vhost\n * \u005cparam buf: buffer to fill with JSON\n * \u005cparam len: max length of buf\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len);\n\n/**\n * lws_json_dump_context() - describe context state and stats in JSON\n *\n * \u005cparam context: the context\n * \u005cparam buf: buffer to fill with JSON\n * \u005cparam len: max length of buf\n * \u005cparam hide_vhosts: nonzero to not provide per-vhost mount etc information\n *\n * Generates a JSON description of vhost state into buf\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_json_dump_context(const struct lws_context *context, char *buf, int len,\n\t\t int hide_vhosts);\n\n/**\n * lws_vhost_user() - get the user data associated with the vhost\n * \u005cparam vhost: Websocket vhost\n *\n * This returns the optional user pointer that can be attached to\n * a vhost when it was created. Lws never dereferences this pointer, it only\n * sets it when the vhost is created, and returns it using this api.\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_vhost_user(struct lws_vhost *vhost);\n\n/**\n * lws_context_user() - get the user data associated with the context\n * \u005cparam context: Websocket context\n *\n * This returns the optional user allocation that can be attached to\n * the context the sockets live in at context_create time. It's a way\n * to let all sockets serviced in the same context share data without\n * using globals statics in the user code.\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_context_user(struct lws_context *context);\n\n/*! \u005cdefgroup vhost-mounts Vhost mounts and options\n * \u005cingroup context-and-vhost-creation\n *\n * ##Vhost mounts and options\n */\n///@{\n/** struct lws_protocol_vhost_options - linked list of per-vhost protocol\n * \t\t\t\t\tname\u003dvalue options\n *\n * This provides a general way to attach a linked-list of name\u003dvalue pairs,\n * which can also have an optional child link-list using the options member.\n */\nstruct lws_protocol_vhost_options {\n\tconst struct lws_protocol_vhost_options *next; /**\u003c linked list */\n\tconst struct lws_protocol_vhost_options *options; /**\u003c child linked-list of more options for this node */\n\tconst char *name; /**\u003c name of name\u003dvalue pair */\n\tconst char *value; /**\u003c value of name\u003dvalue pair */\n};\n\n/** enum lws_mount_protocols\n * This specifies the mount protocol for a mountpoint, whether it is to be\n * served from a filesystem, or it is a cgi etc.\n */\nenum lws_mount_protocols {\n\tLWSMPRO_HTTP\t\t\u003d 0, /**\u003c http reverse proxy */\n\tLWSMPRO_HTTPS\t\t\u003d 1, /**\u003c https reverse proxy */\n\tLWSMPRO_FILE\t\t\u003d 2, /**\u003c serve from filesystem directory */\n\tLWSMPRO_CGI\t\t\u003d 3, /**\u003c pass to CGI to handle */\n\tLWSMPRO_REDIR_HTTP\t\u003d 4, /**\u003c redirect to http:// url */\n\tLWSMPRO_REDIR_HTTPS\t\u003d 5, /**\u003c redirect to https:// url */\n\tLWSMPRO_CALLBACK\t\u003d 6, /**\u003c hand by named protocol's callback */\n};\n\n/** struct lws_http_mount\n *\n * arguments for mounting something in a vhost's url namespace\n */\nstruct lws_http_mount {\n\tconst struct lws_http_mount *mount_next;\n\t/**\u003c pointer to next struct lws_http_mount */\n\tconst char *mountpoint;\n\t/**\u003c mountpoint in http pathspace, eg, \u0022/\u0022 */\n\tconst char *origin;\n\t/**\u003c path to be mounted, eg, \u0022/var/www/warmcat.com\u0022 */\n\tconst char *def;\n\t/**\u003c default target, eg, \u0022index.html\u0022 */\n\tconst char *protocol;\n\t/**\u003c\u0022protocol-name\u0022 to handle mount */\n\n\tconst struct lws_protocol_vhost_options *cgienv;\n\t/**\u003c optional linked-list of cgi options. These are created\n\t * as environment variables for the cgi process\n\t */\n\tconst struct lws_protocol_vhost_options *extra_mimetypes;\n\t/**\u003c optional linked-list of mimetype mappings */\n\tconst struct lws_protocol_vhost_options *interpret;\n\t/**\u003c optional linked-list of files to be interpreted */\n\n\tint cgi_timeout;\n\t/**\u003c seconds cgi is allowed to live, if cgi://mount type */\n\tint cache_max_age;\n\t/**\u003c max-age for reuse of client cache of files, seconds */\n\tunsigned int auth_mask;\n\t/**\u003c bits set here must be set for authorized client session */\n\n\tunsigned int cache_reusable:1; /**\u003c set if client cache may reuse this */\n\tunsigned int cache_revalidate:1; /**\u003c set if client cache should revalidate on use */\n\tunsigned int cache_intermediaries:1; /**\u003c set if intermediaries are allowed to cache */\n\n\tunsigned char origin_protocol; /**\u003c one of enum lws_mount_protocols */\n\tunsigned char mountpoint_len; /**\u003c length of mountpoint string */\n\n\tconst char *basic_auth_login_file;\n\t/**\u003cNULL, or filepath to use to check basic auth logins against */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility\n\t *\n\t * The below is to ensure later library versions with new\n\t * members added above will see 0 (default) even if the app\n\t * was not built against the newer headers.\n\t */\n\n\tvoid *_unused[2]; /**\u003c dummy */\n};\n///@}\n///@}\n\n/*! \u005cdefgroup client Client related functions\n * ##Client releated functions\n * \u005cingroup lwsapi\n *\n * */\n///@{\n\n/** enum lws_client_connect_ssl_connection_flags - flags that may be used\n * with struct lws_client_connect_info ssl_connection member to control if\n * and how SSL checks apply to the client connection being created\n */\n\nenum lws_client_connect_ssl_connection_flags {\n\tLCCSCF_USE_SSL \t\t\t\t\u003d (1 \u003c\u003c 0),\n\tLCCSCF_ALLOW_SELFSIGNED\t\t\t\u003d (1 \u003c\u003c 1),\n\tLCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK\t\u003d (1 \u003c\u003c 2),\n\tLCCSCF_ALLOW_EXPIRED\t\t\t\u003d (1 \u003c\u003c 3),\n\n\tLCCSCF_PIPELINE\t\t\t\t\u003d (1 \u003c\u003c 16),\n\t\t/**\u003c Serialize / pipeline multiple client connections\n\t\t * on a single connection where possible.\n\t\t *\n\t\t * HTTP/1.0: possible if Keep-Alive: yes sent by server\n\t\t * HTTP/1.1: always possible... uses pipelining\n\t\t * HTTP/2: always possible... uses parallel streams\n\t\t * */\n};\n\n/** struct lws_client_connect_info - parameters to connect with when using\n *\t\t\t\t lws_client_connect_via_info() */\n\nstruct lws_client_connect_info {\n\tstruct lws_context *context;\n\t/**\u003c lws context to create connection in */\n\tconst char *address;\n\t/**\u003c remote address to connect to */\n\tint port;\n\t/**\u003c remote port to connect to */\n\tint ssl_connection;\n\t/**\u003c 0, or a combination of LCCSCF_ flags */\n\tconst char *path;\n\t/**\u003c uri path */\n\tconst char *host;\n\t/**\u003c content of host header */\n\tconst char *origin;\n\t/**\u003c content of origin header */\n\tconst char *protocol;\n\t/**\u003c list of ws protocols we could accept */\n\tint ietf_version_or_minus_one;\n\t/**\u003c deprecated: currently leave at 0 or -1 */\n\tvoid *userdata;\n\t/**\u003c if non-NULL, use this as wsi user_data instead of malloc it */\n\tconst void *client_exts;\n\t/**\u003c UNUSED... provide in info.extensions at context creation time */\n\tconst char *method;\n\t/**\u003c if non-NULL, do this http method instead of ws[s] upgrade.\n\t * use \u0022GET\u0022 to be a simple http client connection. \u0022RAW\u0022 gets\n\t * you a connected socket that lws itself will leave alone once\n\t * connected. */\n\tstruct lws *parent_wsi;\n\t/**\u003c if another wsi is responsible for this connection, give it here.\n\t * this is used to make sure if the parent closes so do any\n\t * child connections first. */\n\tconst char *uri_replace_from;\n\t/**\u003c if non-NULL, when this string is found in URIs in\n\t * text/html content-encoding, it's replaced with uri_replace_to */\n\tconst char *uri_replace_to;\n\t/**\u003c see uri_replace_from */\n\tstruct lws_vhost *vhost;\n\t/**\u003c vhost to bind to (used to determine related SSL_CTX) */\n\tstruct lws **pwsi;\n\t/**\u003c if not NULL, store the new wsi here early in the connection\n\t * process. Although we return the new wsi, the call to create the\n\t * client connection does progress the connection somewhat and may\n\t * meet an error that will result in the connection being scrubbed and\n\t * NULL returned. While the wsi exists though, he may process a\n\t * callback like CLIENT_CONNECTION_ERROR with his wsi: this gives the\n\t * user callback a way to identify which wsi it is that faced the error\n\t * even before the new wsi is returned and even if ultimately no wsi\n\t * is returned.\n\t */\n\tconst char *iface;\n\t/**\u003c NULL to allow routing on any interface, or interface name or IP\n\t * to bind the socket to */\n\tconst char *local_protocol_name;\n\t/**\u003c NULL: .protocol is used both to select the local protocol handler\n\t * to bind to and as the list of remote ws protocols we could\n\t * accept.\n\t * non-NULL: this protocol name is used to bind the connection to\n\t * the local protocol handler. .protocol is used for the\n\t * list of remote ws protocols we could accept */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility\n\t *\n\t * The below is to ensure later library versions with new\n\t * members added above will see 0 (default) even if the app\n\t * was not built against the newer headers.\n\t */\n\tconst char *alpn;\n\t/* NULL: allow lws default ALPN list, from vhost if present or from\n\t * list of roles built into lws\n\t * non-NULL: require one from provided comma-separated list of alpn\n\t * tokens\n\t */\n\n\tvoid *_unused[4]; /**\u003c dummy */\n};\n\n/**\n * lws_client_connect_via_info() - Connect to another websocket server\n * \u005cparam ccinfo: pointer to lws_client_connect_info struct\n *\n *\tThis function creates a connection to a remote server using the\n *\tinformation provided in ccinfo.\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_client_connect_via_info(struct lws_client_connect_info * ccinfo);\n\n/**\n * lws_client_connect() - Connect to another websocket server\n * \t\t\u005cdeprecated DEPRECATED use lws_client_connect_via_info\n * \u005cparam clients:\tWebsocket context\n * \u005cparam address:\tRemote server address, eg, \u0022myserver.com\u0022\n * \u005cparam port:\tPort to connect to on the remote server, eg, 80\n * \u005cparam ssl_connection:\t0 \u003d ws://, 1 \u003d wss:// encrypted, 2 \u003d wss:// allow self\n *\t\t\tsigned certs\n * \u005cparam path:\tWebsocket path on server\n * \u005cparam host:\tHostname on server\n * \u005cparam origin:\tSocket origin name\n * \u005cparam protocol:\tComma-separated list of protocols being asked for from\n *\t\tthe server, or just one. The server will pick the one it\n *\t\tlikes best. If you don't want to specify a protocol, which is\n *\t\tlegal, use NULL here.\n * \u005cparam ietf_version_or_minus_one: -1 to ask to connect using the default, latest\n *\t\tprotocol supported, or the specific protocol ordinal\n *\n *\tThis function creates a connection to a remote server\n */\n/* deprecated, use lws_client_connect_via_info() */\nLWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT\nlws_client_connect(struct lws_context *clients, const char *address,\n\t\t int port, int ssl_connection, const char *path,\n\t\t const char *host, const char *origin, const char *protocol,\n\t\t int ietf_version_or_minus_one) LWS_WARN_DEPRECATED;\n/* deprecated, use lws_client_connect_via_info() */\n/**\n * lws_client_connect_extended() - Connect to another websocket server\n * \t\t\t\u005cdeprecated DEPRECATED use lws_client_connect_via_info\n * \u005cparam clients:\tWebsocket context\n * \u005cparam address:\tRemote server address, eg, \u0022myserver.com\u0022\n * \u005cparam port:\tPort to connect to on the remote server, eg, 80\n * \u005cparam ssl_connection:\t0 \u003d ws://, 1 \u003d wss:// encrypted, 2 \u003d wss:// allow self\n *\t\t\tsigned certs\n * \u005cparam path:\tWebsocket path on server\n * \u005cparam host:\tHostname on server\n * \u005cparam origin:\tSocket origin name\n * \u005cparam protocol:\tComma-separated list of protocols being asked for from\n *\t\tthe server, or just one. The server will pick the one it\n *\t\tlikes best.\n * \u005cparam ietf_version_or_minus_one: -1 to ask to connect using the default, latest\n *\t\tprotocol supported, or the specific protocol ordinal\n * \u005cparam userdata: Pre-allocated user data\n *\n *\tThis function creates a connection to a remote server\n */\nLWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT\nlws_client_connect_extended(struct lws_context *clients, const char *address,\n\t\t\t int port, int ssl_connection, const char *path,\n\t\t\t const char *host, const char *origin,\n\t\t\t const char *protocol, int ietf_version_or_minus_one,\n\t\t\t void *userdata) LWS_WARN_DEPRECATED;\n\n/**\n * lws_init_vhost_client_ssl() - also enable client SSL on an existing vhost\n *\n * \u005cparam info: client ssl related info\n * \u005cparam vhost: which vhost to initialize client ssl operations on\n *\n * You only need to call this if you plan on using SSL client connections on\n * the vhost. For non-SSL client connections, it's not necessary to call this.\n *\n * The following members of info are used during the call\n *\n *\t - options must have LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT set,\n *\t otherwise the call does nothing\n *\t - provided_client_ssl_ctx must be NULL to get a generated client\n *\t ssl context, otherwise you can pass a prepared one in by setting it\n *\t - ssl_cipher_list may be NULL or set to the client valid cipher list\n *\t - ssl_ca_filepath may be NULL or client cert filepath\n *\t - ssl_cert_filepath may be NULL or client cert filepath\n *\t - ssl_private_key_filepath may be NULL or client cert private key\n *\n * You must create your vhost explicitly if you want to use this, so you have\n * a pointer to the vhost. Create the context first with the option flag\n * LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with\n * the same info struct.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_init_vhost_client_ssl(const struct lws_context_creation_info *info,\n\t\t\t struct lws_vhost *vhost);\n/**\n * lws_http_client_read() - consume waiting received http client data\n *\n * \u005cparam wsi: client connection\n * \u005cparam buf: pointer to buffer pointer - fill with pointer to your buffer\n * \u005cparam len: pointer to chunk length - fill with max length of buffer\n *\n * This is called when the user code is notified client http data has arrived.\n * The user code may choose to delay calling it to consume the data, for example\n * waiting until an onward connection is writeable.\n *\n * For non-chunked connections, up to len bytes of buf are filled with the\n * received content. len is set to the actual amount filled before return.\n *\n * For chunked connections, the linear buffer content contains the chunking\n * headers and it cannot be passed in one lump. Instead, this function will\n * call back LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ with in pointing to the\n * chunk start and len set to the chunk length. There will be as many calls\n * as there are chunks or partial chunks in the buffer.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_http_client_read(struct lws *wsi, char **buf, int *len);\n\n/**\n * lws_http_client_http_response() - get last HTTP response code\n *\n * \u005cparam wsi: client connection\n *\n * Returns the last server response code, eg, 200 for client http connections.\n *\n * You should capture this during the LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP\n * callback, because after that the memory reserved for storing the related\n * headers is freed and this value is lost.\n */\nLWS_VISIBLE LWS_EXTERN unsigned int\nlws_http_client_http_response(struct lws *wsi);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_client_http_body_pending(struct lws *wsi, int something_left_to_send);\n\n/**\n * lws_client_http_body_pending() - control if client connection neeeds to send body\n *\n * \u005cparam wsi: client connection\n * \u005cparam something_left_to_send: nonzero if need to send more body, 0 (default)\n * \t\t\t\tif nothing more to send\n *\n * If you will send payload data with your HTTP client connection, eg, for POST,\n * when you set the related http headers in\n * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER callback you should also call\n * this API with something_left_to_send nonzero, and call\n * lws_callback_on_writable(wsi);\n *\n * After sending the headers, lws will call your callback with\n * LWS_CALLBACK_CLIENT_HTTP_WRITEABLE reason when writable. You can send the\n * next part of the http body payload, calling lws_callback_on_writable(wsi);\n * if there is more to come, or lws_client_http_body_pending(wsi, 0); to\n * let lws know the last part is sent and the connection can move on.\n */\n\n///@}\n\n/** \u005cdefgroup service Built-in service loop entry\n *\n * ##Built-in service loop entry\n *\n * If you're not using libev / libuv, these apis are needed to enter the poll()\n * wait in lws and service any connections with pending events.\n */\n///@{\n\n/**\n * lws_service() - Service any pending websocket activity\n * \u005cparam context:\tWebsocket context\n * \u005cparam timeout_ms:\tTimeout for poll; 0 means return immediately if nothing needed\n *\t\tservice otherwise block and service immediately, returning\n *\t\tafter the timeout if nothing needed service.\n *\n *\tThis function deals with any pending websocket traffic, for three\n *\tkinds of event. It handles these events on both server and client\n *\ttypes of connection the same.\n *\n *\t1) Accept new connections to our context's server\n *\n *\t2) Call the receive callback for incoming frame data received by\n *\t server or client connections.\n *\n *\tYou need to call this service function periodically to all the above\n *\tfunctions to happen; if your application is single-threaded you can\n *\tjust call it in your main event loop.\n *\n *\tAlternatively you can fork a new process that asynchronously handles\n *\tcalling this service in a loop. In that case you are happy if this\n *\tcall blocks your thread until it needs to take care of something and\n *\twould call it with a large nonzero timeout. Your loop then takes no\n *\tCPU while there is nothing happening.\n *\n *\tIf you are calling it in a single-threaded app, you don't want it to\n *\twait around blocking other things in your loop from happening, so you\n *\twould call it with a timeout_ms of 0, so it returns immediately if\n *\tnothing is pending, or as soon as it services whatever was pending.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_service(struct lws_context *context, int timeout_ms);\n\n/**\n * lws_service_tsi() - Service any pending websocket activity\n *\n * \u005cparam context:\tWebsocket context\n * \u005cparam timeout_ms:\tTimeout for poll; 0 means return immediately if nothing needed\n *\t\tservice otherwise block and service immediately, returning\n *\t\tafter the timeout if nothing needed service.\n * \u005cparam tsi:\t\tThread service index, starting at 0\n *\n * Same as lws_service(), but for a specific thread service index. Only needed\n * if you are spawning multiple service threads.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_service_tsi(struct lws_context *context, int timeout_ms, int tsi);\n\n/**\n * lws_cancel_service_pt() - Cancel servicing of pending socket activity\n *\t\t\t\ton one thread\n * \u005cparam wsi:\tCancel service on the thread this wsi is serviced by\n *\n * Same as lws_cancel_service(), but targets a single service thread, the one\n * the wsi belongs to. You probably want to use lws_cancel_service() instead.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_cancel_service_pt(struct lws *wsi);\n\n/**\n * lws_cancel_service() - Cancel wait for new pending socket activity\n * \u005cparam context:\tWebsocket context\n *\n * This function creates an immediate \u0022synchronous interrupt\u0022 to the lws poll()\n * wait or event loop. As soon as possible in the serialzed service sequencing,\n * a LWS_CALLBACK_EVENT_WAIT_CANCELLED callback is sent to every protocol on\n * every vhost.\n *\n * lws_cancel_service() may be called from another thread while the context\n * exists, and its effect will be immediately serialized.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_cancel_service(struct lws_context *context);\n\n/**\n * lws_service_fd() - Service polled socket with something waiting\n * \u005cparam context:\tWebsocket context\n * \u005cparam pollfd:\tThe pollfd entry describing the socket fd and which events\n *\t\thappened, or NULL to tell lws to do only timeout servicing.\n *\n * This function takes a pollfd that has POLLIN or POLLOUT activity and\n * services it according to the state of the associated\n * struct lws.\n *\n * The one call deals with all \u0022service\u0022 that might happen on a socket\n * including listen accepts, http files as well as websocket protocol.\n *\n * If a pollfd says it has something, you can just pass it to\n * lws_service_fd() whether it is a socket handled by lws or not.\n * If it sees it is a lws socket, the traffic will be handled and\n * pollfd-\u003erevents will be zeroed now.\n *\n * If the socket is foreign to lws, it leaves revents alone. So you can\n * see if you should service yourself by checking the pollfd revents\n * after letting lws try to service it.\n *\n * You should also call this with pollfd \u003d NULL to just allow the\n * once-per-second global timeout checks; if less than a second since the last\n * check it returns immediately then.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd);\n\n/**\n * lws_service_fd_tsi() - Service polled socket in specific service thread\n * \u005cparam context:\tWebsocket context\n * \u005cparam pollfd:\tThe pollfd entry describing the socket fd and which events\n *\t\thappened.\n * \u005cparam tsi: thread service index\n *\n * Same as lws_service_fd() but used with multiple service threads\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,\n\t\t int tsi);\n\n/**\n * lws_service_adjust_timeout() - Check for any connection needing forced service\n * \u005cparam context:\tWebsocket context\n * \u005cparam timeout_ms:\tThe original poll timeout value. You can just set this\n *\t\t\tto 1 if you don't really have a poll timeout.\n * \u005cparam tsi: thread service index\n *\n * Under some conditions connections may need service even though there is no\n * pending network action on them, this is \u0022forced service\u0022. For default\n * poll() and libuv / libev, the library takes care of calling this and\n * dealing with it for you. But for external poll() integration, you need\n * access to the apis.\n *\n * If anybody needs \u0022forced service\u0022, returned timeout is zero. In that case,\n * you can call lws_service_tsi() with a timeout of -1 to only service\n * guys who need forced service.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi);\n\n/* Backwards compatibility */\n#define lws_plat_service_tsi lws_service_tsi\n\nLWS_VISIBLE LWS_EXTERN int\nlws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd);\n\n///@}\n\n/*! \u005cdefgroup http HTTP\n\n Modules related to handling HTTP\n*/\n//@{\n\n/*! \u005cdefgroup httpft HTTP File transfer\n * \u005cingroup http\n\n APIs for sending local files in response to HTTP requests\n*/\n//@{\n\n/**\n * lws_get_mimetype() - Determine mimetype to use from filename\n *\n * \u005cparam file:\t\tfilename\n * \u005cparam m:\t\tNULL, or mount context\n *\n * This uses a canned list of known filetypes first, if no match and m is\n * non-NULL, then tries a list of per-mount file suffix to mimtype mappings.\n *\n * Returns either NULL or a pointer to the mimetype matching the file.\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_get_mimetype(const char *file, const struct lws_http_mount *m);\n\n/**\n * lws_serve_http_file() - Send a file back to the client using http\n * \u005cparam wsi:\t\tWebsocket instance (available from user callback)\n * \u005cparam file:\t\tThe file to issue over http\n * \u005cparam content_type:\tThe http content type, eg, text/html\n * \u005cparam other_headers:\tNULL or pointer to header string\n * \u005cparam other_headers_len:\tlength of the other headers if non-NULL\n *\n *\tThis function is intended to be called from the callback in response\n *\tto http requests from the client. It allows the callback to issue\n *\tlocal files down the http link in a single step.\n *\n *\tReturning \u003c0 indicates error and the wsi should be closed. Returning\n *\t\u003e0 indicates the file was completely sent and\n *\tlws_http_transaction_completed() called on the wsi (and close if !\u003d 0)\n *\t\u003d\u003d0 indicates the file transfer is started and needs more service later,\n *\tthe wsi should be left alone.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,\n\t\t const char *other_headers, int other_headers_len);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_serve_http_file_fragment(struct lws *wsi);\n//@}\n\n\nenum http_status {\n\tHTTP_STATUS_CONTINUE\t\t\t\t\t\u003d 100,\n\n\tHTTP_STATUS_OK\t\t\t\t\t\t\u003d 200,\n\tHTTP_STATUS_NO_CONTENT\t\t\t\t\t\u003d 204,\n\tHTTP_STATUS_PARTIAL_CONTENT\t\t\t\t\u003d 206,\n\n\tHTTP_STATUS_MOVED_PERMANENTLY\t\t\t\t\u003d 301,\n\tHTTP_STATUS_FOUND\t\t\t\t\t\u003d 302,\n\tHTTP_STATUS_SEE_OTHER\t\t\t\t\t\u003d 303,\n\tHTTP_STATUS_NOT_MODIFIED\t\t\t\t\u003d 304,\n\n\tHTTP_STATUS_BAD_REQUEST\t\t\t\t\t\u003d 400,\n\tHTTP_STATUS_UNAUTHORIZED,\n\tHTTP_STATUS_PAYMENT_REQUIRED,\n\tHTTP_STATUS_FORBIDDEN,\n\tHTTP_STATUS_NOT_FOUND,\n\tHTTP_STATUS_METHOD_NOT_ALLOWED,\n\tHTTP_STATUS_NOT_ACCEPTABLE,\n\tHTTP_STATUS_PROXY_AUTH_REQUIRED,\n\tHTTP_STATUS_REQUEST_TIMEOUT,\n\tHTTP_STATUS_CONFLICT,\n\tHTTP_STATUS_GONE,\n\tHTTP_STATUS_LENGTH_REQUIRED,\n\tHTTP_STATUS_PRECONDITION_FAILED,\n\tHTTP_STATUS_REQ_ENTITY_TOO_LARGE,\n\tHTTP_STATUS_REQ_URI_TOO_LONG,\n\tHTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,\n\tHTTP_STATUS_REQ_RANGE_NOT_SATISFIABLE,\n\tHTTP_STATUS_EXPECTATION_FAILED,\n\n\tHTTP_STATUS_INTERNAL_SERVER_ERROR\t\t\t\u003d 500,\n\tHTTP_STATUS_NOT_IMPLEMENTED,\n\tHTTP_STATUS_BAD_GATEWAY,\n\tHTTP_STATUS_SERVICE_UNAVAILABLE,\n\tHTTP_STATUS_GATEWAY_TIMEOUT,\n\tHTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED,\n};\n/*! \u005cdefgroup html-chunked-substitution HTML Chunked Substitution\n * \u005cingroup http\n *\n * ##HTML chunked Substitution\n *\n * APIs for receiving chunks of text, replacing a set of variable names via\n * a callback, and then prepending and appending HTML chunked encoding\n * headers.\n */\n//@{\n\nstruct lws_process_html_args {\n\tchar *p; /**\u003c pointer to the buffer containing the data */\n\tint len; /**\u003c length of the original data at p */\n\tint max_len; /**\u003c maximum length we can grow the data to */\n\tint final; /**\u003c set if this is the last chunk of the file */\n\tint chunked; /**\u003c 0 \u003d\u003d unchunked, 1 \u003d\u003d produce chunk headers (incompatible with HTTP/2) */\n};\n\ntypedef const char *(*lws_process_html_state_cb)(void *data, int index);\n\nstruct lws_process_html_state {\n\tchar *start; /**\u003c pointer to start of match */\n\tchar swallow[16]; /**\u003c matched character buffer */\n\tint pos; /**\u003c position in match */\n\tvoid *data; /**\u003c opaque pointer */\n\tconst char * const *vars; /**\u003c list of variable names */\n\tint count_vars; /**\u003c count of variable names */\n\n\tlws_process_html_state_cb replace; /**\u003c called on match to perform substitution */\n};\n\n/*! lws_chunked_html_process() - generic chunked substitution\n * \u005cparam args: buffer to process using chunked encoding\n * \u005cparam s: current processing state\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_chunked_html_process(struct lws_process_html_args *args,\n\t\t\t struct lws_process_html_state *s);\n//@}\n\n/** \u005cdefgroup HTTP-headers-read HTTP headers: read\n * \u005cingroup http\n *\n * ##HTTP header releated functions\n *\n * In lws the client http headers are temporarily stored in a pool, only for the\n * duration of the http part of the handshake. It's because in most cases,\n * the header content is ignored for the whole rest of the connection lifetime\n * and would then just be taking up space needlessly.\n *\n * During LWS_CALLBACK_HTTP when the URI path is delivered is the last time\n * the http headers are still allocated, you can use these apis then to\n * look at and copy out interesting header content (cookies, etc)\n *\n * Notice that the header total length reported does not include a terminating\n * '\u005c0', however you must allocate for it when using the _copy apis. So the\n * length reported for a header containing \u0022123\u0022 is 3, but you must provide\n * a buffer of length 4 so that \u0022123\u005c0\u0022 may be copied into it, or the copy\n * will fail with a nonzero return code.\n *\n * In the special case of URL arguments, like ?x\u003d1\u0026y\u003d2, the arguments are\n * stored in a token named for the method, eg, WSI_TOKEN_GET_URI if it\n * was a GET or WSI_TOKEN_POST_URI if POST. You can check the total\n * length to confirm the method.\n *\n * For URL arguments, each argument is stored urldecoded in a \u0022fragment\u0022, so\n * you can use the fragment-aware api lws_hdr_copy_fragment() to access each\n * argument in turn: the fragments contain urldecoded strings like x\u003d1 or y\u003d2.\n *\n * As a convenience, lws has an api that will find the fragment with a\n * given name\u003d part, lws_get_urlarg_by_name().\n */\n///@{\n\n/** struct lws_tokens\n * you need these to look at headers that have been parsed if using the\n * LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum\n * list below is absent, .token \u003d NULL and len \u003d 0. Otherwise .token\n * points to .len chars containing that header content.\n */\nstruct lws_tokens {\n\tchar *token; /**\u003c pointer to start of the token */\n\tint len; /**\u003c length of the token's value */\n};\n\n/* enum lws_token_indexes\n * these have to be kept in sync with lextable.h / minilex.c\n *\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\nenum lws_token_indexes {\n\tWSI_TOKEN_GET_URI\t\t\t\t\t\u003d 0,\n\tWSI_TOKEN_POST_URI\t\t\t\t\t\u003d 1,\n\tWSI_TOKEN_OPTIONS_URI\t\t\t\t\t\u003d 2,\n\tWSI_TOKEN_HOST\t\t\t\t\t\t\u003d 3,\n\tWSI_TOKEN_CONNECTION\t\t\t\t\t\u003d 4,\n\tWSI_TOKEN_UPGRADE\t\t\t\t\t\u003d 5,\n\tWSI_TOKEN_ORIGIN\t\t\t\t\t\u003d 6,\n\tWSI_TOKEN_DRAFT\t\t\t\t\t\t\u003d 7,\n\tWSI_TOKEN_CHALLENGE\t\t\t\t\t\u003d 8,\n\tWSI_TOKEN_EXTENSIONS\t\t\t\t\t\u003d 9,\n\tWSI_TOKEN_KEY1\t\t\t\t\t\t\u003d 10,\n\tWSI_TOKEN_KEY2\t\t\t\t\t\t\u003d 11,\n\tWSI_TOKEN_PROTOCOL\t\t\t\t\t\u003d 12,\n\tWSI_TOKEN_ACCEPT\t\t\t\t\t\u003d 13,\n\tWSI_TOKEN_NONCE\t\t\t\t\t\t\u003d 14,\n\tWSI_TOKEN_HTTP\t\t\t\t\t\t\u003d 15,\n\tWSI_TOKEN_HTTP2_SETTINGS\t\t\t\t\u003d 16,\n\tWSI_TOKEN_HTTP_ACCEPT\t\t\t\t\t\u003d 17,\n\tWSI_TOKEN_HTTP_AC_REQUEST_HEADERS\t\t\t\u003d 18,\n\tWSI_TOKEN_HTTP_IF_MODIFIED_SINCE\t\t\t\u003d 19,\n\tWSI_TOKEN_HTTP_IF_NONE_MATCH\t\t\t\t\u003d 20,\n\tWSI_TOKEN_HTTP_ACCEPT_ENCODING\t\t\t\t\u003d 21,\n\tWSI_TOKEN_HTTP_ACCEPT_LANGUAGE\t\t\t\t\u003d 22,\n\tWSI_TOKEN_HTTP_PRAGMA\t\t\t\t\t\u003d 23,\n\tWSI_TOKEN_HTTP_CACHE_CONTROL\t\t\t\t\u003d 24,\n\tWSI_TOKEN_HTTP_AUTHORIZATION\t\t\t\t\u003d 25,\n\tWSI_TOKEN_HTTP_COOKIE\t\t\t\t\t\u003d 26,\n\tWSI_TOKEN_HTTP_CONTENT_LENGTH\t\t\t\t\u003d 27,\n\tWSI_TOKEN_HTTP_CONTENT_TYPE\t\t\t\t\u003d 28,\n\tWSI_TOKEN_HTTP_DATE\t\t\t\t\t\u003d 29,\n\tWSI_TOKEN_HTTP_RANGE\t\t\t\t\t\u003d 30,\n\tWSI_TOKEN_HTTP_REFERER\t\t\t\t\t\u003d 31,\n\tWSI_TOKEN_KEY\t\t\t\t\t\t\u003d 32,\n\tWSI_TOKEN_VERSION\t\t\t\t\t\u003d 33,\n\tWSI_TOKEN_SWORIGIN\t\t\t\t\t\u003d 34,\n\n\tWSI_TOKEN_HTTP_COLON_AUTHORITY\t\t\t\t\u003d 35,\n\tWSI_TOKEN_HTTP_COLON_METHOD\t\t\t\t\u003d 36,\n\tWSI_TOKEN_HTTP_COLON_PATH\t\t\t\t\u003d 37,\n\tWSI_TOKEN_HTTP_COLON_SCHEME\t\t\t\t\u003d 38,\n\tWSI_TOKEN_HTTP_COLON_STATUS\t\t\t\t\u003d 39,\n\n\tWSI_TOKEN_HTTP_ACCEPT_CHARSET\t\t\t\t\u003d 40,\n\tWSI_TOKEN_HTTP_ACCEPT_RANGES\t\t\t\t\u003d 41,\n\tWSI_TOKEN_HTTP_ACCESS_CONTROL_ALLOW_ORIGIN\t\t\u003d 42,\n\tWSI_TOKEN_HTTP_AGE\t\t\t\t\t\u003d 43,\n\tWSI_TOKEN_HTTP_ALLOW\t\t\t\t\t\u003d 44,\n\tWSI_TOKEN_HTTP_CONTENT_DISPOSITION\t\t\t\u003d 45,\n\tWSI_TOKEN_HTTP_CONTENT_ENCODING\t\t\t\t\u003d 46,\n\tWSI_TOKEN_HTTP_CONTENT_LANGUAGE\t\t\t\t\u003d 47,\n\tWSI_TOKEN_HTTP_CONTENT_LOCATION\t\t\t\t\u003d 48,\n\tWSI_TOKEN_HTTP_CONTENT_RANGE\t\t\t\t\u003d 49,\n\tWSI_TOKEN_HTTP_ETAG\t\t\t\t\t\u003d 50,\n\tWSI_TOKEN_HTTP_EXPECT\t\t\t\t\t\u003d 51,\n\tWSI_TOKEN_HTTP_EXPIRES\t\t\t\t\t\u003d 52,\n\tWSI_TOKEN_HTTP_FROM\t\t\t\t\t\u003d 53,\n\tWSI_TOKEN_HTTP_IF_MATCH\t\t\t\t\t\u003d 54,\n\tWSI_TOKEN_HTTP_IF_RANGE\t\t\t\t\t\u003d 55,\n\tWSI_TOKEN_HTTP_IF_UNMODIFIED_SINCE\t\t\t\u003d 56,\n\tWSI_TOKEN_HTTP_LAST_MODIFIED\t\t\t\t\u003d 57,\n\tWSI_TOKEN_HTTP_LINK\t\t\t\t\t\u003d 58,\n\tWSI_TOKEN_HTTP_LOCATION\t\t\t\t\t\u003d 59,\n\tWSI_TOKEN_HTTP_MAX_FORWARDS\t\t\t\t\u003d 60,\n\tWSI_TOKEN_HTTP_PROXY_AUTHENTICATE\t\t\t\u003d 61,\n\tWSI_TOKEN_HTTP_PROXY_AUTHORIZATION\t\t\t\u003d 62,\n\tWSI_TOKEN_HTTP_REFRESH\t\t\t\t\t\u003d 63,\n\tWSI_TOKEN_HTTP_RETRY_AFTER\t\t\t\t\u003d 64,\n\tWSI_TOKEN_HTTP_SERVER\t\t\t\t\t\u003d 65,\n\tWSI_TOKEN_HTTP_SET_COOKIE\t\t\t\t\u003d 66,\n\tWSI_TOKEN_HTTP_STRICT_TRANSPORT_SECURITY\t\t\u003d 67,\n\tWSI_TOKEN_HTTP_TRANSFER_ENCODING\t\t\t\u003d 68,\n\tWSI_TOKEN_HTTP_USER_AGENT\t\t\t\t\u003d 69,\n\tWSI_TOKEN_HTTP_VARY\t\t\t\t\t\u003d 70,\n\tWSI_TOKEN_HTTP_VIA\t\t\t\t\t\u003d 71,\n\tWSI_TOKEN_HTTP_WWW_AUTHENTICATE\t\t\t\t\u003d 72,\n\n\tWSI_TOKEN_PATCH_URI\t\t\t\t\t\u003d 73,\n\tWSI_TOKEN_PUT_URI\t\t\t\t\t\u003d 74,\n\tWSI_TOKEN_DELETE_URI\t\t\t\t\t\u003d 75,\n\n\tWSI_TOKEN_HTTP_URI_ARGS\t\t\t\t\t\u003d 76,\n\tWSI_TOKEN_PROXY\t\t\t\t\t\t\u003d 77,\n\tWSI_TOKEN_HTTP_X_REAL_IP\t\t\t\t\u003d 78,\n\tWSI_TOKEN_HTTP1_0\t\t\t\t\t\u003d 79,\n\tWSI_TOKEN_X_FORWARDED_FOR\t\t\t\t\u003d 80,\n\tWSI_TOKEN_CONNECT\t\t\t\t\t\u003d 81,\n\tWSI_TOKEN_HEAD_URI\t\t\t\t\t\u003d 82,\n\tWSI_TOKEN_TE\t\t\t\t\t\t\u003d 83,\n\tWSI_TOKEN_REPLAY_NONCE\t\t\t\t\t\u003d 84,\n\tWSI_TOKEN_COLON_PROTOCOL\t\t\t\t\u003d 85,\n\tWSI_TOKEN_X_AUTH_TOKEN\t\t\t\t\t\u003d 86,\n\n\t/****** add new things just above ---^ ******/\n\n\t/* use token storage to stash these internally, not for\n\t * user use */\n\n\t_WSI_TOKEN_CLIENT_SENT_PROTOCOLS,\n\t_WSI_TOKEN_CLIENT_PEER_ADDRESS,\n\t_WSI_TOKEN_CLIENT_URI,\n\t_WSI_TOKEN_CLIENT_HOST,\n\t_WSI_TOKEN_CLIENT_ORIGIN,\n\t_WSI_TOKEN_CLIENT_METHOD,\n\t_WSI_TOKEN_CLIENT_IFACE,\n\t_WSI_TOKEN_CLIENT_ALPN,\n\n\t/* always last real token index*/\n\tWSI_TOKEN_COUNT,\n\n\t/* parser state additions, no storage associated */\n\tWSI_TOKEN_NAME_PART,\n\tWSI_TOKEN_SKIPPING,\n\tWSI_TOKEN_SKIPPING_SAW_CR,\n\tWSI_PARSING_COMPLETE,\n\tWSI_INIT_TOKEN_MUXURL,\n};\n\nstruct lws_token_limits {\n\tunsigned short token_limit[WSI_TOKEN_COUNT]; /**\u003c max chars for this token */\n};\n\n/**\n * lws_token_to_string() - returns a textual representation of a hdr token index\n *\n * \u005cparam token: token index\n */\nLWS_VISIBLE LWS_EXTERN const unsigned char *\nlws_token_to_string(enum lws_token_indexes token);\n\n/**\n * lws_hdr_total_length: report length of all fragments of a header totalled up\n *\t\tThe returned length does not include the space for a\n *\t\tterminating '\u005c0'\n *\n * \u005cparam wsi: websocket connection\n * \u005cparam h: which header index we are interested in\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);\n\n/**\n * lws_hdr_fragment_length: report length of a single fragment of a header\n *\t\tThe returned length does not include the space for a\n *\t\tterminating '\u005c0'\n *\n * \u005cparam wsi: websocket connection\n * \u005cparam h: which header index we are interested in\n * \u005cparam frag_idx: which fragment of h we want to get the length of\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx);\n\n/**\n * lws_hdr_copy() - copy a single fragment of the given header to a buffer\n *\t\tThe buffer length len must include space for an additional\n *\t\tterminating '\u005c0', or it will fail returning -1.\n *\n * \u005cparam wsi: websocket connection\n * \u005cparam dest: destination buffer\n * \u005cparam len: length of destination buffer\n * \u005cparam h: which header index we are interested in\n *\n * copies the whole, aggregated header, even if it was delivered in\n * several actual headers piece by piece\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_hdr_copy(struct lws *wsi, char *dest, int len, enum lws_token_indexes h);\n\n/**\n * lws_hdr_copy_fragment() - copy a single fragment of the given header to a buffer\n *\t\tThe buffer length len must include space for an additional\n *\t\tterminating '\u005c0', or it will fail returning -1.\n *\t\tIf the requested fragment index is not present, it fails\n *\t\treturning -1.\n *\n * \u005cparam wsi: websocket connection\n * \u005cparam dest: destination buffer\n * \u005cparam len: length of destination buffer\n * \u005cparam h: which header index we are interested in\n * \u005cparam frag_idx: which fragment of h we want to copy\n *\n * Normally this is only useful\n * to parse URI arguments like ?x\u003d1\u0026y\u003d2, token index WSI_TOKEN_HTTP_URI_ARGS\n * fragment 0 will contain \u0022x\u003d1\u0022 and fragment 1 \u0022y\u003d2\u0022\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_hdr_copy_fragment(struct lws *wsi, char *dest, int len,\n\t\t enum lws_token_indexes h, int frag_idx);\n\n/**\n * lws_get_urlarg_by_name() - return pointer to arg value if present\n * \u005cparam wsi: the connection to check\n * \u005cparam name: the arg name, like \u0022token\u003d\u0022\n * \u005cparam buf: the buffer to receive the urlarg (including the name\u003d part)\n * \u005cparam len: the length of the buffer to receive the urlarg\n *\n * Returns NULL if not found or a pointer inside buf to just after the\n * name\u003d part.\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_get_urlarg_by_name(struct lws *wsi, const char *name, char *buf, int len);\n///@}\n\n/*! \u005cdefgroup HTTP-headers-create HTTP headers: create\n *\n * ## HTTP headers: Create\n *\n * These apis allow you to create HTTP response headers in a way compatible with\n * both HTTP/1.x and HTTP/2.\n *\n * They each append to a buffer taking care about the buffer end, which is\n * passed in as a pointer. When data is written to the buffer, the current\n * position p is updated accordingly.\n *\n * All of these apis are LWS_WARN_UNUSED_RESULT as they can run out of space\n * and fail with nonzero return.\n */\n///@{\n\n#define LWSAHH_CODE_MASK\t\t\t((1 \u003c\u003c 16) - 1)\n#define LWSAHH_FLAG_NO_SERVER_NAME\t\t(1 \u003c\u003c 30)\n\n/**\n * lws_add_http_header_status() - add the HTTP response status code\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam code: an HTTP code like 200, 404 etc (see enum http_status)\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Adds the initial response code, so should be called first.\n *\n * Code may additionally take OR'd flags:\n *\n * LWSAHH_FLAG_NO_SERVER_NAME: don't apply server name header this time\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_add_http_header_status(struct lws *wsi,\n\t\t\t unsigned int code, unsigned char **p,\n\t\t\t unsigned char *end);\n/**\n * lws_add_http_header_by_name() - append named header and value\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam name: the hdr name, like \u0022my-header\u0022\n * \u005cparam value: the value after the \u003d for this header\n * \u005cparam length: the length of the value\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Appends name: value to the headers\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_add_http_header_by_name(struct lws *wsi, const unsigned char *name,\n\t\t\t const unsigned char *value, int length,\n\t\t\t unsigned char **p, unsigned char *end);\n/**\n * lws_add_http_header_by_token() - append given header and value\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam token: the token index for the hdr\n * \u005cparam value: the value after the \u003d for this header\n * \u005cparam length: the length of the value\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Appends name\u003dvalue to the headers, but is able to take advantage of better\n * HTTP/2 coding mechanisms where possible.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_add_http_header_by_token(struct lws *wsi, enum lws_token_indexes token,\n\t\t\t const unsigned char *value, int length,\n\t\t\t unsigned char **p, unsigned char *end);\n/**\n * lws_add_http_header_content_length() - append content-length helper\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam content_length: the content length to use\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Appends content-length: content_length to the headers\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_add_http_header_content_length(struct lws *wsi,\n\t\t\t\t lws_filepos_t content_length,\n\t\t\t\t unsigned char **p, unsigned char *end);\n/**\n * lws_finalize_http_header() - terminate header block\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Indicates no more headers will be added\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_finalize_http_header(struct lws *wsi, unsigned char **p,\n\t\t\t unsigned char *end);\n\n/**\n * lws_finalize_write_http_header() - Helper finializing and writing http headers\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam start: pointer to the start of headers in the buffer, eg \u0026buf[LWS_PRE]\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Terminates the headers correctly accoring to the protocol in use (h1 / h2)\n * and writes the headers. Returns nonzero for error.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_finalize_write_http_header(struct lws *wsi, unsigned char *start,\n\t\t\t unsigned char **p, unsigned char *end);\n\n#define LWS_ILLEGAL_HTTP_CONTENT_LEN ((lws_filepos_t)-1ll)\n\n/**\n * lws_add_http_common_headers() - Helper preparing common http headers\n *\n * \u005cparam wsi: the connection to check\n * \u005cparam code: an HTTP code like 200, 404 etc (see enum http_status)\n * \u005cparam content_type: the content type, like \u0022text/html\u0022\n * \u005cparam content_len: the content length, in bytes\n * \u005cparam p: pointer to current position in buffer pointer\n * \u005cparam end: pointer to end of buffer\n *\n * Adds the initial response code, so should be called first.\n *\n * Code may additionally take OR'd flags:\n *\n * LWSAHH_FLAG_NO_SERVER_NAME: don't apply server name header this time\n *\n * This helper just calls public apis to simplify adding headers that are\n * commonly needed. If it doesn't fit your case, or you want to add additional\n * headers just call the public apis directly yourself for what you want.\n *\n * You can miss out the content length header by providing the constant\n * LWS_ILLEGAL_HTTP_CONTENT_LEN for the content_len.\n *\n * It does not call lws_finalize_http_header(), to allow you to add further\n * headers after calling this. You will need to call that yourself at the end.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_add_http_common_headers(struct lws *wsi, unsigned int code,\n\t\t\t const char *content_type, lws_filepos_t content_len,\n\t\t\t unsigned char **p, unsigned char *end);\n///@}\n\n/** \u005cdefgroup form-parsing Form Parsing\n * \u005cingroup http\n * ##POSTed form parsing functions\n *\n * These lws_spa (stateful post arguments) apis let you parse and urldecode\n * POSTed form arguments, both using simple urlencoded and multipart transfer\n * encoding.\n *\n * It's capable of handling file uploads as well a named input parsing,\n * and the apis are the same for both form upload styles.\n *\n * You feed it a list of parameter names and it creates pointers to the\n * urldecoded arguments: file upload parameters pass the file data in chunks to\n * a user-supplied callback as they come.\n *\n * Since it's stateful, it handles the incoming data needing more than one\n * POST_BODY callback and has no limit on uploaded file size.\n */\n///@{\n\n/** enum lws_spa_fileupload_states */\nenum lws_spa_fileupload_states {\n\tLWS_UFS_CONTENT,\n\t/**\u003c a chunk of file content has arrived */\n\tLWS_UFS_FINAL_CONTENT,\n\t/**\u003c the last chunk (possibly zero length) of file content has arrived */\n\tLWS_UFS_OPEN\n\t/**\u003c a new file is starting to arrive */\n};\n\n/**\n * lws_spa_fileupload_cb() - callback to receive file upload data\n *\n * \u005cparam data: opt_data pointer set in lws_spa_create\n * \u005cparam name: name of the form field being uploaded\n * \u005cparam filename: original filename from client\n * \u005cparam buf: start of data to receive\n * \u005cparam len: length of data to receive\n * \u005cparam state: information about how this call relates to file\n *\n * Notice name and filename shouldn't be trusted, as they are passed from\n * HTTP provided by the client.\n */\ntypedef int (*lws_spa_fileupload_cb)(void *data, const char *name,\n\t\t\tconst char *filename, char *buf, int len,\n\t\t\tenum lws_spa_fileupload_states state);\n\n/** struct lws_spa - opaque urldecode parser capable of handling multipart\n *\t\t\tand file uploads */\nstruct lws_spa;\n\n/**\n * lws_spa_create() - create urldecode parser\n *\n * \u005cparam wsi: lws connection (used to find Content Type)\n * \u005cparam param_names: array of form parameter names, like \u0022username\u0022\n * \u005cparam count_params: count of param_names\n * \u005cparam max_storage: total amount of form parameter values we can store\n * \u005cparam opt_cb: NULL, or callback to receive file upload data.\n * \u005cparam opt_data: NULL, or user pointer provided to opt_cb.\n *\n * Creates a urldecode parser and initializes it.\n *\n * opt_cb can be NULL if you just want normal name\u003dvalue parsing, however\n * if one or more entries in your form are bulk data (file transfer), you\n * can provide this callback and filter on the name callback parameter to\n * treat that urldecoded data separately. The callback should return -1\n * in case of fatal error, and 0 if OK.\n */\nLWS_VISIBLE LWS_EXTERN struct lws_spa *\nlws_spa_create(struct lws *wsi, const char * const *param_names,\n\t int count_params, int max_storage, lws_spa_fileupload_cb opt_cb,\n\t void *opt_data);\n\n/**\n * lws_spa_process() - parses a chunk of input data\n *\n * \u005cparam spa: the parser object previously created\n * \u005cparam in: incoming, urlencoded data\n * \u005cparam len: count of bytes valid at \u005cparam in\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_spa_process(struct lws_spa *spa, const char *in, int len);\n\n/**\n * lws_spa_finalize() - indicate incoming data completed\n *\n * \u005cparam spa: the parser object previously created\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_spa_finalize(struct lws_spa *spa);\n\n/**\n * lws_spa_get_length() - return length of parameter value\n *\n * \u005cparam spa: the parser object previously created\n * \u005cparam n: parameter ordinal to return length of value for\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_spa_get_length(struct lws_spa *spa, int n);\n\n/**\n * lws_spa_get_string() - return pointer to parameter value\n * \u005cparam spa: the parser object previously created\n * \u005cparam n: parameter ordinal to return pointer to value for\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_spa_get_string(struct lws_spa *spa, int n);\n\n/**\n * lws_spa_destroy() - destroy parser object\n *\n * \u005cparam spa: the parser object previously created\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_spa_destroy(struct lws_spa *spa);\n///@}\n\n/*! \u005cdefgroup urlendec Urlencode and Urldecode\n * \u005cingroup http\n *\n * ##HTML chunked Substitution\n *\n * APIs for receiving chunks of text, replacing a set of variable names via\n * a callback, and then prepending and appending HTML chunked encoding\n * headers.\n */\n//@{\n\n/**\n * lws_urlencode() - like strncpy but with urlencoding\n *\n * \u005cparam escaped: output buffer\n * \u005cparam string: input buffer ('/0' terminated)\n * \u005cparam len: output buffer max length\n *\n * Because urlencoding expands the output string, it's not\n * possible to do it in-place, ie, with escaped \u003d\u003d string\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_urlencode(char *escaped, const char *string, int len);\n\n/*\n * URLDECODE 1 / 2\n *\n * This simple urldecode only operates until the first '\u005c0' and requires the\n * data to exist all at once\n */\n/**\n * lws_urldecode() - like strncpy but with urldecoding\n *\n * \u005cparam string: output buffer\n * \u005cparam escaped: input buffer ('\u005c0' terminated)\n * \u005cparam len: output buffer max length\n *\n * This is only useful for '\u005c0' terminated strings\n *\n * Since urldecoding only shrinks the output string, it is possible to\n * do it in-place, ie, string \u003d\u003d escaped\n *\n * Returns 0 if completed OK or nonzero for urldecode violation (non-hex chars\n * where hex required, etc)\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_urldecode(char *string, const char *escaped, int len);\n///@}\n/**\n * lws_return_http_status() - Return simple http status\n * \u005cparam wsi:\t\tWebsocket instance (available from user callback)\n * \u005cparam code:\t\tStatus index, eg, 404\n * \u005cparam html_body:\t\tUser-readable HTML description \u003c 1KB, or NULL\n *\n *\tHelper to report HTTP errors back to the client cleanly and\n *\tconsistently\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_return_http_status(struct lws *wsi, unsigned int code,\n\t\t const char *html_body);\n\n/**\n * lws_http_redirect() - write http redirect out on wsi\n *\n * \u005cparam wsi:\twebsocket connection\n * \u005cparam code:\tHTTP response code (eg, 301)\n * \u005cparam loc:\twhere to redirect to\n * \u005cparam len:\tlength of loc\n * \u005cparam p:\tpointer current position in buffer (updated as we write)\n * \u005cparam end:\tpointer to end of buffer\n *\n * Returns amount written, or \u003c 0 indicating fatal write failure.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_http_redirect(struct lws *wsi, int code, const unsigned char *loc, int len,\n\t\t unsigned char **p, unsigned char *end);\n\n/**\n * lws_http_transaction_completed() - wait for new http transaction or close\n * \u005cparam wsi:\twebsocket connection\n *\n *\tReturns 1 if the HTTP connection must close now\n *\tReturns 0 and resets connection to wait for new HTTP header /\n *\t transaction if possible\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_http_transaction_completed(struct lws *wsi);\n///@}\n\n/*! \u005cdefgroup pur Sanitize / purify SQL and JSON helpers\n *\n * ##Sanitize / purify SQL and JSON helpers\n *\n * APIs for escaping untrusted JSON and SQL safely before use\n */\n//@{\n\n/**\n * lws_sql_purify() - like strncpy but with escaping for sql quotes\n *\n * \u005cparam escaped: output buffer\n * \u005cparam string: input buffer ('/0' terminated)\n * \u005cparam len: output buffer max length\n *\n * Because escaping expands the output string, it's not\n * possible to do it in-place, ie, with escaped \u003d\u003d string\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_sql_purify(char *escaped, const char *string, int len);\n\n/**\n * lws_json_purify() - like strncpy but with escaping for json chars\n *\n * \u005cparam escaped: output buffer\n * \u005cparam string: input buffer ('/0' terminated)\n * \u005cparam len: output buffer max length\n *\n * Because escaping expands the output string, it's not\n * possible to do it in-place, ie, with escaped \u003d\u003d string\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_json_purify(char *escaped, const char *string, int len);\n\n/**\n * lws_filename_purify_inplace() - replace scary filename chars with underscore\n *\n * \u005cparam filename: filename to be purified\n *\n * Replace scary characters in the filename (it should not be a path)\n * with underscore, so it's safe to use.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_filename_purify_inplace(char *filename);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_plat_write_cert(struct lws_vhost *vhost, int is_key, int fd, void *buf,\n\t\t\tint len);\nLWS_VISIBLE LWS_EXTERN int\nlws_plat_write_file(const char *filename, void *buf, int len);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_plat_read_file(const char *filename, void *buf, int len);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_plat_recommended_rsa_bits(void);\n///@}\n\n/*! \u005cdefgroup uv libuv helpers\n *\n * ##libuv helpers\n *\n * APIs specific to libuv event loop itegration\n */\n///@{\n#ifdef LWS_WITH_LIBUV\n/*\n * Any direct libuv allocations in lws protocol handlers must participate in the\n * lws reference counting scheme. Two apis are provided:\n *\n * - lws_libuv_static_refcount_add(handle, context) to mark the handle with\n * a pointer to the context and increment the global uv object counter\n *\n * - lws_libuv_static_refcount_del() which should be used as the close callback\n * for your own libuv objects declared in the protocol scope.\n *\n * Using the apis allows lws to detach itself from a libuv loop completely\n * cleanly and at the moment all of its libuv objects have completed close.\n */\n\nLWS_VISIBLE LWS_EXTERN uv_loop_t *\nlws_uv_getloop(struct lws_context *context, int tsi);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_libuv_static_refcount_add(uv_handle_t *, struct lws_context *context);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_libuv_static_refcount_del(uv_handle_t *);\n\n#endif /* LWS_WITH_LIBUV */\n\n#if defined(LWS_WITH_ESP32)\n#define lws_libuv_static_refcount_add(_a, _b)\n#define lws_libuv_static_refcount_del NULL\n#endif\n///@}\n\n\n/*! \u005cdefgroup timeout Connection timeouts\n\n APIs related to setting connection timeouts\n*/\n//@{\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\nenum pending_timeout {\n\tNO_PENDING_TIMEOUT\t\t\t\t\t\u003d 0,\n\tPENDING_TIMEOUT_AWAITING_PROXY_RESPONSE\t\t\t\u003d 1,\n\tPENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE\t\t\u003d 2,\n\tPENDING_TIMEOUT_ESTABLISH_WITH_SERVER\t\t\t\u003d 3,\n\tPENDING_TIMEOUT_AWAITING_SERVER_RESPONSE\t\t\u003d 4,\n\tPENDING_TIMEOUT_AWAITING_PING\t\t\t\t\u003d 5,\n\tPENDING_TIMEOUT_CLOSE_ACK\t\t\t\t\u003d 6,\n\tPENDING_TIMEOUT_UNUSED1\t\t\t\t\t\u003d 7,\n\tPENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE\t\t\t\u003d 8,\n\tPENDING_TIMEOUT_SSL_ACCEPT\t\t\t\t\u003d 9,\n\tPENDING_TIMEOUT_HTTP_CONTENT\t\t\t\t\u003d 10,\n\tPENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND\t\t\t\u003d 11,\n\tPENDING_FLUSH_STORED_SEND_BEFORE_CLOSE\t\t\t\u003d 12,\n\tPENDING_TIMEOUT_SHUTDOWN_FLUSH\t\t\t\t\u003d 13,\n\tPENDING_TIMEOUT_CGI\t\t\t\t\t\u003d 14,\n\tPENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE\t\t\t\u003d 15,\n\tPENDING_TIMEOUT_WS_PONG_CHECK_SEND_PING\t\t\t\u003d 16,\n\tPENDING_TIMEOUT_WS_PONG_CHECK_GET_PONG\t\t\t\u003d 17,\n\tPENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD\t\t\t\u003d 18,\n\tPENDING_TIMEOUT_AWAITING_SOCKS_GREETING_REPLY\t \u003d 19,\n\tPENDING_TIMEOUT_AWAITING_SOCKS_CONNECT_REPLY\t\t\u003d 20,\n\tPENDING_TIMEOUT_AWAITING_SOCKS_AUTH_REPLY\t\t\u003d 21,\n\tPENDING_TIMEOUT_KILLED_BY_SSL_INFO\t\t\t\u003d 22,\n\tPENDING_TIMEOUT_KILLED_BY_PARENT\t\t\t\u003d 23,\n\tPENDING_TIMEOUT_CLOSE_SEND\t\t\t\t\u003d 24,\n\tPENDING_TIMEOUT_HOLDING_AH\t\t\t\t\u003d 25,\n\tPENDING_TIMEOUT_UDP_IDLE\t\t\t\t\u003d 26,\n\tPENDING_TIMEOUT_CLIENT_CONN_IDLE\t\t\t\u003d 27,\n\tPENDING_TIMEOUT_LAGGING\t\t\t\t\t\u003d 28,\n\n\t/****** add new things just above ---^ ******/\n\n\tPENDING_TIMEOUT_USER_REASON_BASE\t\t\t\u003d 1000\n};\n\n#define LWS_TO_KILL_ASYNC -1\n/**\u003c If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout()\n * call, then the connection is marked to be killed at the next timeout\n * check. This is how you should force-close the wsi being serviced if\n * you are doing it outside the callback (where you should close by nonzero\n * return).\n */\n#define LWS_TO_KILL_SYNC -2\n/**\u003c If LWS_TO_KILL_SYNC is given as the timeout sec in a lws_set_timeout()\n * call, then the connection is closed before returning (which may delete\n * the wsi). This should only be used where the wsi being closed is not the\n * wsi currently being serviced.\n */\n/**\n * lws_set_timeout() - marks the wsi as subject to a timeout\n *\n * You will not need this unless you are doing something special\n *\n * \u005cparam wsi:\tWebsocket connection instance\n * \u005cparam reason:\ttimeout reason\n * \u005cparam secs:\thow many seconds. You may set to LWS_TO_KILL_ASYNC to\n *\t\tforce the connection to timeout at the next opportunity, or\n *\t\tLWS_TO_KILL_SYNC to close it synchronously if you know the\n *\t\twsi is not the one currently being serviced.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs);\n\n#define LWS_SET_TIMER_USEC_CANCEL ((lws_usec_t)-1ll)\n#define LWS_USEC_PER_SEC (1000000ll)\n\n/**\n * lws_set_timer_usecs() - schedules a callback on the wsi in the future\n *\n * \u005cparam wsi:\tWebsocket connection instance\n * \u005cparam usecs: LWS_SET_TIMER_USEC_CANCEL removes any existing scheduled\n *\t\t callback, otherwise number of microseconds in the future\n *\t\t the callback will occur at.\n *\n * NOTE: event loop support for this:\n *\n * default poll() loop: yes\n * libuv event loop: yes\n * libev: not implemented (patch welcome)\n * libevent: not implemented (patch welcome)\n *\n * After the deadline expires, the wsi will get a callback of type\n * LWS_CALLBACK_TIMER and the timer is exhausted. The deadline may be\n * continuously deferred by further calls to lws_set_timer_usecs() with a later\n * deadline, or cancelled by lws_set_timer_usecs(wsi, -1).\n *\n * If the timer should repeat, lws_set_timer_usecs() must be called again from\n * LWS_CALLBACK_TIMER.\n *\n * Accuracy depends on the platform and the load on the event loop or system...\n * all that's guaranteed is the callback will come after the requested wait\n * period.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_timer_usecs(struct lws *wsi, lws_usec_t usecs);\n\n/*\n * lws_timed_callback_vh_protocol() - calls back a protocol on a vhost after\n * \t\t\t\t\tthe specified delay\n *\n * \u005cparam vh:\t the vhost to call back\n * \u005cparam protocol: the protocol to call back\n * \u005cparam reason: callback reason\n * \u005cparam secs:\thow many seconds in the future to do the callback. Set to\n *\t\t-1 to cancel the timer callback.\n *\n * Callback the specified protocol with a fake wsi pointing to the specified\n * vhost and protocol, with the specified reason, at the specified time in the\n * future.\n *\n * Returns 0 if OK.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_timed_callback_vh_protocol(struct lws_vhost *vh,\n\t\t\t const struct lws_protocols *prot,\n\t\t\t int reason, int secs);\n///@}\n\n/*! \u005cdefgroup sending-data Sending data\n\n APIs related to writing data on a connection\n*/\n//@{\n#if !defined(LWS_SIZEOFPTR)\n#define LWS_SIZEOFPTR ((int)sizeof (void *))\n#endif\n\n#if defined(__x86_64__)\n#define _LWS_PAD_SIZE 16\t/* Intel recommended for best performance */\n#else\n#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target arch */\n#endif\n#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \u005c\n\t\t((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n))\n/* last 2 is for lws-meta */\n#define LWS_PRE _LWS_PAD(4 + 10 + 2)\n/* used prior to 1.7 and retained for backward compatibility */\n#define LWS_SEND_BUFFER_PRE_PADDING LWS_PRE\n#define LWS_SEND_BUFFER_POST_PADDING 0\n\n#define LWS_WRITE_RAW LWS_WRITE_HTTP\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\nenum lws_write_protocol {\n\tLWS_WRITE_TEXT\t\t\t\t\t\t\u003d 0,\n\t/**\u003c Send a ws TEXT message,the pointer must have LWS_PRE valid\n\t * memory behind it. The receiver expects only valid utf-8 in the\n\t * payload */\n\tLWS_WRITE_BINARY\t\t\t\t\t\u003d 1,\n\t/**\u003c Send a ws BINARY message, the pointer must have LWS_PRE valid\n\t * memory behind it. Any sequence of bytes is valid */\n\tLWS_WRITE_CONTINUATION\t\t\t\t\t\u003d 2,\n\t/**\u003c Continue a previous ws message, the pointer must have LWS_PRE valid\n\t * memory behind it */\n\tLWS_WRITE_HTTP\t\t\t\t\t\t\u003d 3,\n\t/**\u003c Send HTTP content */\n\n\t/* LWS_WRITE_CLOSE is handled by lws_close_reason() */\n\tLWS_WRITE_PING\t\t\t\t\t\t\u003d 5,\n\tLWS_WRITE_PONG\t\t\t\t\t\t\u003d 6,\n\n\t/* Same as write_http but we know this write ends the transaction */\n\tLWS_WRITE_HTTP_FINAL\t\t\t\t\t\u003d 7,\n\n\t/* HTTP2 */\n\n\tLWS_WRITE_HTTP_HEADERS\t\t\t\t\t\u003d 8,\n\t/**\u003c Send http headers (http2 encodes this payload and LWS_WRITE_HTTP\n\t * payload differently, http 1.x links also handle this correctly. so\n\t * to be compatible with both in the future,header response part should\n\t * be sent using this regardless of http version expected)\n\t */\n\tLWS_WRITE_HTTP_HEADERS_CONTINUATION\t\t\t\u003d 9,\n\t/**\u003c Continuation of http/2 headers\n\t */\n\n\t/****** add new things just above ---^ ******/\n\n\t/* flags */\n\n\tLWS_WRITE_NO_FIN \u003d 0x40,\n\t/**\u003c This part of the message is not the end of the message */\n\n\tLWS_WRITE_H2_STREAM_END \u003d 0x80,\n\t/**\u003c Flag indicates this packet should go out with STREAM_END if h2\n\t * STREAM_END is allowed on DATA or HEADERS.\n\t */\n\n\tLWS_WRITE_CLIENT_IGNORE_XOR_MASK \u003d 0x80\n\t/**\u003c client packet payload goes out on wire unmunged\n\t * only useful for security tests since normal servers cannot\n\t * decode the content if used */\n};\n\n/* used with LWS_CALLBACK_CHILD_WRITE_VIA_PARENT */\n\nstruct lws_write_passthru {\n\tstruct lws *wsi;\n\tunsigned char *buf;\n\tsize_t len;\n\tenum lws_write_protocol wp;\n};\n\n\n/**\n * lws_write() - Apply protocol then write data to client\n * \u005cparam wsi:\tWebsocket instance (available from user callback)\n * \u005cparam buf:\tThe data to send. For data being sent on a websocket\n *\t\tconnection (ie, not default http), this buffer MUST have\n *\t\tLWS_PRE bytes valid BEFORE the pointer.\n *\t\tThis is so the protocol header data can be added in-situ.\n * \u005cparam len:\tCount of the data bytes in the payload starting from buf\n * \u005cparam protocol:\tUse LWS_WRITE_HTTP to reply to an http connection, and one\n *\t\tof LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate\n *\t\tdata on a websockets connection. Remember to allow the extra\n *\t\tbytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT\n *\t\tare used.\n *\n *\tThis function provides the way to issue data back to the client\n *\tfor both http and websocket protocols.\n *\n * IMPORTANT NOTICE!\n *\n * When sending with websocket protocol\n *\n * LWS_WRITE_TEXT,\n * LWS_WRITE_BINARY,\n * LWS_WRITE_CONTINUATION,\n * LWS_WRITE_PING,\n * LWS_WRITE_PONG\n *\n * the send buffer has to have LWS_PRE bytes valid BEFORE\n * the buffer pointer you pass to lws_write().\n *\n * This allows us to add protocol info before and after the data, and send as\n * one packet on the network without payload copying, for maximum efficiency.\n *\n * So for example you need this kind of code to use lws_write with a\n * 128-byte payload\n *\n * char buf[LWS_PRE + 128];\n *\n * // fill your part of the buffer... for example here it's all zeros\n * memset(\u0026buf[LWS_PRE], 0, 128);\n *\n * lws_write(wsi, \u0026buf[LWS_PRE], 128, LWS_WRITE_TEXT);\n *\n * When sending HTTP, with\n *\n * LWS_WRITE_HTTP,\n * LWS_WRITE_HTTP_HEADERS\n * LWS_WRITE_HTTP_FINAL\n *\n * there is no protocol data prepended, and don't need to take care about the\n * LWS_PRE bytes valid before the buffer pointer.\n *\n * LWS_PRE is at least the frame nonce + 2 header + 8 length\n * LWS_SEND_BUFFER_POST_PADDING is deprecated, it's now 0 and can be left off.\n * The example apps no longer use it.\n *\n * Pad LWS_PRE to the CPU word size, so that word references\n * to the address immediately after the padding won't cause an unaligned access\n * error. Sometimes for performance reasons the recommended padding is even\n * larger than sizeof(void *).\n *\n *\tIn the case of sending using websocket protocol, be sure to allocate\n *\tvalid storage before and after buf as explained above. This scheme\n *\tallows maximum efficiency of sending data and protocol in a single\n *\tpacket while not burdening the user code with any protocol knowledge.\n *\n *\tReturn may be -1 for a fatal error needing connection close, or the\n *\tnumber of bytes sent.\n *\n * Truncated Writes\n * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n *\n * The OS may not accept everything you asked to write on the connection.\n *\n * Posix defines POLLOUT indication from poll() to show that the connection\n * will accept more write data, but it doesn't specifiy how much. It may just\n * accept one byte of whatever you wanted to send.\n *\n * LWS will buffer the remainder automatically, and send it out autonomously.\n *\n * During that time, WRITABLE callbacks will be suppressed.\n *\n * This is to handle corner cases where unexpectedly the OS refuses what we\n * usually expect it to accept. You should try to send in chunks that are\n * almost always accepted in order to avoid the inefficiency of the buffering.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_write(struct lws *wsi, unsigned char *buf, size_t len,\n\t enum lws_write_protocol protocol);\n\n/* helper for case where buffer may be const */\n#define lws_write_http(wsi, buf, len) \u005c\n\tlws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP)\n\n/* helper for multi-frame ws message flags */\nstatic LWS_INLINE int\nlws_write_ws_flags(int initial, int is_start, int is_end)\n{\n\tint r;\n\n\tif (is_start)\n\t\tr \u003d initial;\n\telse\n\t\tr \u003d LWS_WRITE_CONTINUATION;\n\n\tif (!is_end)\n\t\tr |\u003d LWS_WRITE_NO_FIN;\n\n\treturn r;\n}\n///@}\n\n/** \u005cdefgroup callback-when-writeable Callback when writeable\n *\n * ##Callback When Writeable\n *\n * lws can only write data on a connection when it is able to accept more\n * data without blocking.\n *\n * So a basic requirement is we should only use the lws_write() apis when the\n * connection we want to write on says that he can accept more data.\n *\n * When lws cannot complete your send at the time, it will buffer the data\n * and send it in the background, suppressing any further WRITEABLE callbacks\n * on that connection until it completes. So it is important to write new\n * things in a new writeable callback.\n *\n * These apis reflect the various ways we can indicate we would like to be\n * called back when one or more connections is writeable.\n */\n///@{\n\n/**\n * lws_callback_on_writable() - Request a callback when this socket\n *\t\t\t\t\t becomes able to be written to without\n *\t\t\t\t\t blocking\n *\n * \u005cparam wsi:\tWebsocket connection instance to get callback for\n *\n * - Which: only this wsi\n * - When: when the individual connection becomes writeable\n * - What: LWS_CALLBACK_*_WRITEABLE\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_on_writable(struct lws *wsi);\n\n/**\n * lws_callback_on_writable_all_protocol() - Request a callback for all\n *\t\t\tconnections using the given protocol when it\n *\t\t\tbecomes possible to write to each socket without\n *\t\t\tblocking in turn.\n *\n * \u005cparam context:\tlws_context\n * \u005cparam protocol:\tProtocol whose connections will get callbacks\n *\n * - Which: connections using this protocol on ANY VHOST\n * - When: when the individual connection becomes writeable\n * - What: LWS_CALLBACK_*_WRITEABLE\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_on_writable_all_protocol(const struct lws_context *context,\n\t\t\t\t const struct lws_protocols *protocol);\n\n/**\n * lws_callback_on_writable_all_protocol_vhost() - Request a callback for\n *\t\t\tall connections on same vhost using the given protocol\n *\t\t\twhen it becomes possible to write to each socket without\n *\t\t\tblocking in turn.\n *\n * \u005cparam vhost:\tOnly consider connections on this lws_vhost\n * \u005cparam protocol:\tProtocol whose connections will get callbacks\n *\n * - Which: connections using this protocol on GIVEN VHOST ONLY\n * - When: when the individual connection becomes writeable\n * - What: LWS_CALLBACK_*_WRITEABLE\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_on_writable_all_protocol_vhost(const struct lws_vhost *vhost,\n\t\t\t\t const struct lws_protocols *protocol);\n\n/**\n * lws_callback_all_protocol() - Callback all connections using\n *\t\t\t\tthe given protocol with the given reason\n *\n * \u005cparam context:\tlws_context\n * \u005cparam protocol:\tProtocol whose connections will get callbacks\n * \u005cparam reason:\tCallback reason index\n *\n * - Which: connections using this protocol on ALL VHOSTS\n * - When: before returning\n * - What: reason\n *\n * This isn't normally what you want... normally any update of connection-\n * specific information can wait until a network-related callback like rx,\n * writable, or close.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_all_protocol(struct lws_context *context,\n\t\t\t const struct lws_protocols *protocol, int reason);\n\n/**\n * lws_callback_all_protocol_vhost() - Callback all connections using\n *\t\t\tthe given protocol with the given reason. This is\n *\t\t\tdeprecated since v2.4: use lws_callback_all_protocol_vhost_args\n *\n * \u005cparam vh:\t\tVhost whose connections will get callbacks\n * \u005cparam protocol:\tWhich protocol to match. NULL means all.\n * \u005cparam reason:\tCallback reason index\n *\n * - Which: connections using this protocol on GIVEN VHOST ONLY\n * - When: now\n * - What: reason\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_all_protocol_vhost(struct lws_vhost *vh,\n\t\t\t const struct lws_protocols *protocol, int reason)\nLWS_WARN_DEPRECATED;\n\n/**\n * lws_callback_all_protocol_vhost_args() - Callback all connections using\n *\t\t\tthe given protocol with the given reason and args\n *\n * \u005cparam vh:\t\tVhost whose connections will get callbacks\n * \u005cparam protocol:\tWhich protocol to match. NULL means all.\n * \u005cparam reason:\tCallback reason index\n * \u005cparam argp:\t\tCallback \u0022in\u0022 parameter\n * \u005cparam len:\t\tCallback \u0022len\u0022 parameter\n *\n * - Which: connections using this protocol on GIVEN VHOST ONLY\n * - When: now\n * - What: reason\n */\nLWS_VISIBLE int\nlws_callback_all_protocol_vhost_args(struct lws_vhost *vh,\n\t\t\t const struct lws_protocols *protocol, int reason,\n\t\t\t void *argp, size_t len);\n\n/**\n * lws_callback_vhost_protocols() - Callback all protocols enabled on a vhost\n *\t\t\t\t\twith the given reason\n *\n * \u005cparam wsi:\twsi whose vhost will get callbacks\n * \u005cparam reason:\tCallback reason index\n * \u005cparam in:\t\tin argument to callback\n * \u005cparam len:\tlen argument to callback\n *\n * - Which: connections using this protocol on same VHOST as wsi ONLY\n * - When: now\n * - What: reason\n *\n * This is deprecated since v2.5, use lws_callback_vhost_protocols_vhost()\n * which takes the pointer to the vhost directly without using or needing the\n * wsi.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len)\nLWS_WARN_DEPRECATED;\n\n/**\n * lws_callback_vhost_protocols_vhost() - Callback all protocols enabled on a vhost\n *\t\t\t\t\twith the given reason\n *\n * \u005cparam vh:\t\tvhost that will get callbacks\n * \u005cparam reason:\tCallback reason index\n * \u005cparam in:\t\tin argument to callback\n * \u005cparam len:\t\tlen argument to callback\n *\n * - Which: connections using this protocol on same VHOST as wsi ONLY\n * - When: now\n * - What: reason\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_vhost_protocols_vhost(struct lws_vhost *vh, int reason, void *in,\n\t\t\t\t size_t len);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason,\n\t\t void *user, void *in, size_t len);\n\n/**\n * lws_get_socket_fd() - returns the socket file descriptor\n *\n * This is needed to use sendto() on UDP raw sockets\n *\n * \u005cparam wsi:\tWebsocket connection instance\n */\nLWS_VISIBLE LWS_EXTERN lws_sockfd_type\nlws_get_socket_fd(struct lws *wsi);\n\n/**\n * lws_get_peer_write_allowance() - get the amount of data writeable to peer\n * \t\t\t\t\tif known\n *\n * \u005cparam wsi:\tWebsocket connection instance\n *\n * if the protocol does not have any guidance, returns -1. Currently only\n * http2 connections get send window information from this API. But your code\n * should use it so it can work properly with any protocol.\n *\n * If nonzero return is the amount of payload data the peer or intermediary has\n * reported it has buffer space for. That has NO relationship with the amount\n * of buffer space your OS can accept on this connection for a write action.\n *\n * This number represents the maximum you could send to the peer or intermediary\n * on this connection right now without the protocol complaining.\n *\n * lws manages accounting for send window updates and payload writes\n * automatically, so this number reflects the situation at the peer or\n * intermediary dynamically.\n */\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\nlws_get_peer_write_allowance(struct lws *wsi);\n///@}\n\nenum {\n\t/*\n\t * Flags for enable and disable rxflow with reason bitmap and with\n\t * backwards-compatible single bool\n\t */\n\tLWS_RXFLOW_REASON_USER_BOOL\t\t\u003d (1 \u003c\u003c 0),\n\tLWS_RXFLOW_REASON_HTTP_RXBUFFER\t\t\u003d (1 \u003c\u003c 6),\n\tLWS_RXFLOW_REASON_H2_PPS_PENDING\t\u003d (1 \u003c\u003c 7),\n\n\tLWS_RXFLOW_REASON_APPLIES\t\t\u003d (1 \u003c\u003c 14),\n\tLWS_RXFLOW_REASON_APPLIES_ENABLE_BIT\t\u003d (1 \u003c\u003c 13),\n\tLWS_RXFLOW_REASON_APPLIES_ENABLE\t\u003d LWS_RXFLOW_REASON_APPLIES |\n\t\t\t\t\t\t LWS_RXFLOW_REASON_APPLIES_ENABLE_BIT,\n\tLWS_RXFLOW_REASON_APPLIES_DISABLE\t\u003d LWS_RXFLOW_REASON_APPLIES,\n\tLWS_RXFLOW_REASON_FLAG_PROCESS_NOW\t\u003d (1 \u003c\u003c 12),\n\n};\n\n/**\n * lws_rx_flow_control() - Enable and disable socket servicing for\n *\t\t\t\treceived packets.\n *\n * If the output side of a server process becomes choked, this allows flow\n * control for the input side.\n *\n * \u005cparam wsi:\tWebsocket connection instance to get callback for\n * \u005cparam enable:\t0 \u003d disable read servicing for this connection, 1 \u003d enable\n *\n * If you need more than one additive reason for rxflow control, you can give\n * iLWS_RXFLOW_REASON_APPLIES_ENABLE or _DISABLE together with one or more of\n * b5..b0 set to idicate which bits to enable or disable. If any bits are\n * enabled, rx on the connection is suppressed.\n *\n * LWS_RXFLOW_REASON_FLAG_PROCESS_NOW flag may also be given to force any change\n * in rxflowbstatus to benapplied immediately, this should be used when you are\n * changing a wsi flow control state from outside a callback on that wsi.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_rx_flow_control(struct lws *wsi, int enable);\n\n/**\n * lws_rx_flow_allow_all_protocol() - Allow all connections with this protocol to receive\n *\n * When the user server code realizes it can accept more input, it can\n * call this to have the RX flow restriction removed from all connections using\n * the given protocol.\n * \u005cparam context:\tlws_context\n * \u005cparam protocol:\tall connections using this protocol will be allowed to receive\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_rx_flow_allow_all_protocol(const struct lws_context *context,\n\t\t\t const struct lws_protocols *protocol);\n\n/**\n * lws_remaining_packet_payload() - Bytes to come before \u0022overall\u0022\n *\t\t\t\t\t rx fragment is complete\n * \u005cparam wsi:\t\tWebsocket instance (available from user callback)\n *\n * This tracks how many bytes are left in the current ws fragment, according\n * to the ws length given in the fragment header.\n *\n * If the message was in a single fragment, and there is no compression, this\n * is the same as \u0022how much data is left to read for this message\u0022.\n *\n * However, if the message is being sent in multiple fragments, this will\n * reflect the unread amount of the current **fragment**, not the message. With\n * ws, it is legal to not know the length of the message before it completes.\n *\n * Additionally if the message is sent via the negotiated permessage-deflate\n * extension, this number only tells the amount of **compressed** data left to\n * be read, since that is the only information available at the ws layer.\n */\nLWS_VISIBLE LWS_EXTERN size_t\nlws_remaining_packet_payload(struct lws *wsi);\n\n\n/** \u005cdefgroup sock-adopt Socket adoption helpers\n * ##Socket adoption helpers\n *\n * When integrating with an external app with its own event loop, these can\n * be used to accept connections from someone else's listening socket.\n *\n * When using lws own event loop, these are not needed.\n */\n///@{\n\n/**\n * lws_adopt_socket() - adopt foreign socket as if listen socket accepted it\n * for the default vhost of context.\n *\n * \u005cparam context: lws context\n * \u005cparam accept_fd: fd of already-accepted socket to adopt\n *\n * Either returns new wsi bound to accept_fd, or closes accept_fd and\n * returns NULL, having cleaned up any new wsi pieces.\n *\n * LWS adopts the socket in http serving mode, it's ready to accept an upgrade\n * to ws or just serve http.\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd);\n/**\n * lws_adopt_socket_vhost() - adopt foreign socket as if listen socket accepted it\n * for vhost\n *\n * \u005cparam vh: lws vhost\n * \u005cparam accept_fd: fd of already-accepted socket to adopt\n *\n * Either returns new wsi bound to accept_fd, or closes accept_fd and\n * returns NULL, having cleaned up any new wsi pieces.\n *\n * LWS adopts the socket in http serving mode, it's ready to accept an upgrade\n * to ws or just serve http.\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd);\n\ntypedef enum {\n\tLWS_ADOPT_RAW_FILE_DESC \u003d 0,\t/* convenience constant */\n\tLWS_ADOPT_HTTP \u003d 1,\t\t/* flag: absent implies RAW */\n\tLWS_ADOPT_SOCKET \u003d 2,\t\t/* flag: absent implies file descr */\n\tLWS_ADOPT_ALLOW_SSL \u003d 4,\t/* flag: if set requires LWS_ADOPT_SOCKET */\n\tLWS_ADOPT_WS_PARENTIO \u003d 8,\t/* flag: ws mode parent handles IO\n\t\t\t\t\t * if given must be only flag\n\t\t\t\t\t * wsi put directly into ws mode */\n\tLWS_ADOPT_FLAG_UDP \u003d 16,\t/* flag: socket is UDP */\n\n\tLWS_ADOPT_RAW_SOCKET_UDP \u003d LWS_ADOPT_SOCKET | LWS_ADOPT_FLAG_UDP,\n} lws_adoption_type;\n\ntypedef union {\n\tlws_sockfd_type sockfd;\n\tlws_filefd_type filefd;\n} lws_sock_file_fd_type;\n\n#if !defined(LWS_WITH_ESP32)\nstruct lws_udp {\n\tstruct sockaddr sa;\n\tsocklen_t salen;\n\n\tstruct sockaddr sa_pending;\n\tsocklen_t salen_pending;\n};\n#endif\n\n/*\n* lws_adopt_descriptor_vhost() - adopt foreign socket or file descriptor\n* if socket descriptor, should already have been accepted from listen socket\n*\n* \u005cparam vhost: lws vhost\n* \u005cparam type: OR-ed combinations of lws_adoption_type flags\n* \u005cparam fd: union with either .sockfd or .filefd set\n* \u005cparam vh_prot_name: NULL or vh protocol name to bind raw connection to\n* \u005cparam parent: NULL or struct lws to attach new_wsi to as a child\n*\n* Either returns new wsi bound to accept_fd, or closes accept_fd and\n* returns NULL, having cleaned up any new wsi pieces.\n*\n* If LWS_ADOPT_SOCKET is set, LWS adopts the socket in http serving mode, it's\n* ready to accept an upgrade to ws or just serve http.\n*\n* parent may be NULL, if given it should be an existing wsi that will become the\n* parent of the new wsi created by this call.\n*/\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,\n\t\t\t lws_sock_file_fd_type fd, const char *vh_prot_name,\n\t\t\t struct lws *parent);\n\n/**\n * lws_adopt_socket_readbuf() - adopt foreign socket and first rx as if listen socket accepted it\n * for the default vhost of context.\n * \u005cparam context:\tlws context\n * \u005cparam accept_fd:\tfd of already-accepted socket to adopt\n * \u005cparam readbuf:\tNULL or pointer to data that must be drained before reading from\n *\t\taccept_fd\n * \u005cparam len:\tThe length of the data held at \u005cparam readbuf\n *\n * Either returns new wsi bound to accept_fd, or closes accept_fd and\n * returns NULL, having cleaned up any new wsi pieces.\n *\n * LWS adopts the socket in http serving mode, it's ready to accept an upgrade\n * to ws or just serve http.\n *\n * If your external code did not already read from the socket, you can use\n * lws_adopt_socket() instead.\n *\n * This api is guaranteed to use the data at \u005cparam readbuf first, before reading from\n * the socket.\n *\n * readbuf is limited to the size of the ah rx buf, currently 2048 bytes.\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,\n const char *readbuf, size_t len);\n/**\n * lws_adopt_socket_vhost_readbuf() - adopt foreign socket and first rx as if listen socket\n * accepted it for vhost.\n * \u005cparam vhost:\tlws vhost\n * \u005cparam accept_fd:\tfd of already-accepted socket to adopt\n * \u005cparam readbuf:\tNULL or pointer to data that must be drained before reading from\n *\t\t\taccept_fd\n * \u005cparam len:\t\tThe length of the data held at \u005cparam readbuf\n *\n * Either returns new wsi bound to accept_fd, or closes accept_fd and\n * returns NULL, having cleaned up any new wsi pieces.\n *\n * LWS adopts the socket in http serving mode, it's ready to accept an upgrade\n * to ws or just serve http.\n *\n * If your external code did not already read from the socket, you can use\n * lws_adopt_socket() instead.\n *\n * This api is guaranteed to use the data at \u005cparam readbuf first, before reading from\n * the socket.\n *\n * readbuf is limited to the size of the ah rx buf, currently 2048 bytes.\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_adopt_socket_vhost_readbuf(struct lws_vhost *vhost, lws_sockfd_type accept_fd,\n const char *readbuf, size_t len);\n\n#define LWS_CAUDP_BIND 1\n\n/**\n * lws_create_adopt_udp() - create, bind and adopt a UDP socket\n *\n * \u005cparam vhost:\t lws vhost\n * \u005cparam port:\t\t UDP port to bind to, -1 means unbound\n * \u005cparam flags:\t 0 or LWS_CAUDP_NO_BIND\n * \u005cparam protocol_name: Name of protocol on vhost to bind wsi to\n * \u005cparam parent_wsi:\t NULL or parent wsi new wsi will be a child of\n *\n * Either returns new wsi bound to accept_fd, or closes accept_fd and\n * returns NULL, having cleaned up any new wsi pieces.\n * */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_create_adopt_udp(struct lws_vhost *vhost, int port, int flags,\n\t\t const char *protocol_name, struct lws *parent_wsi);\n///@}\n\n/** \u005cdefgroup net Network related helper APIs\n * ##Network related helper APIs\n *\n * These wrap miscellaneous useful network-related functions\n */\n///@{\n\n/**\n * lws_canonical_hostname() - returns this host's hostname\n *\n * This is typically used by client code to fill in the host parameter\n * when making a client connection. You can only call it after the context\n * has been created.\n *\n * \u005cparam context:\tWebsocket context\n */\nLWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT\nlws_canonical_hostname(struct lws_context *context);\n\n/**\n * lws_get_peer_addresses() - Get client address information\n * \u005cparam wsi:\tLocal struct lws associated with\n * \u005cparam fd:\t\tConnection socket descriptor\n * \u005cparam name:\tBuffer to take client address name\n * \u005cparam name_len:\tLength of client address name buffer\n * \u005cparam rip:\tBuffer to take client address IP dotted quad\n * \u005cparam rip_len:\tLength of client address IP buffer\n *\n *\tThis function fills in name and rip with the name and IP of\n *\tthe client connected with socket descriptor fd. Names may be\n *\ttruncated if there is not enough room. If either cannot be\n *\tdetermined, they will be returned as valid zero-length strings.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_get_peer_addresses(struct lws *wsi, lws_sockfd_type fd, char *name,\n\t\t int name_len, char *rip, int rip_len);\n\n/**\n * lws_get_peer_simple() - Get client address information without RDNS\n *\n * \u005cparam wsi:\tLocal struct lws associated with\n * \u005cparam name:\tBuffer to take client address name\n * \u005cparam namelen:\tLength of client address name buffer\n *\n * This provides a 123.123.123.123 type IP address in name from the\n * peer that has connected to wsi\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_get_peer_simple(struct lws *wsi, char *name, int namelen);\n\n\n#define LWS_ITOSA_NOT_EXIST -1\n#define LWS_ITOSA_NOT_USABLE -2\n#define LWS_ITOSA_USABLE 0\n#if !defined(LWS_WITH_ESP32)\n/**\n * lws_interface_to_sa() - Convert interface name or IP to sockaddr struct\n *\n * \u005cparam ipv6:\t\tAllow IPV6 addresses\n * \u005cparam ifname:\tInterface name or IP\n * \u005cparam addr:\t\tstruct sockaddr_in * to be written\n * \u005cparam addrlen:\tLength of addr\n *\n * This converts a textual network interface name to a sockaddr usable by\n * other network functions.\n *\n * If the network interface doesn't exist, it will return LWS_ITOSA_NOT_EXIST.\n *\n * If the network interface is not usable, eg ethernet cable is removed, it\n * may logically exist but not have any IP address. As such it will return\n * LWS_ITOSA_NOT_USABLE.\n *\n * If the network interface exists and is usable, it will return\n * LWS_ITOSA_USABLE.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,\n\t\t size_t addrlen);\n///@}\n#endif\n\n/** \u005cdefgroup misc Miscellaneous APIs\n* ##Miscellaneous APIs\n*\n* Various APIs outside of other categories\n*/\n///@{\n\n/**\n * lws_start_foreach_ll(): linkedlist iterator helper start\n *\n * \u005cparam type: type of iteration, eg, struct xyz *\n * \u005cparam it: iterator var name to create\n * \u005cparam start: start of list\n *\n * This helper creates an iterator and starts a while (it) {\n * loop. The iterator runs through the linked list starting at start and\n * ends when it gets a NULL.\n * The while loop should be terminated using lws_start_foreach_ll().\n */\n#define lws_start_foreach_ll(type, it, start)\u005c\n{ \u005c\n\ttype it \u003d start; \u005c\n\twhile (it) {\n\n/**\n * lws_end_foreach_ll(): linkedlist iterator helper end\n *\n * \u005cparam it: same iterator var name given when starting\n * \u005cparam nxt: member name in the iterator pointing to next list element\n *\n * This helper is the partner for lws_start_foreach_ll() that ends the\n * while loop.\n */\n\n#define lws_end_foreach_ll(it, nxt) \u005c\n\t\tit \u003d it-\u003enxt; \u005c\n\t} \u005c\n}\n\n/**\n * lws_start_foreach_llp(): linkedlist pointer iterator helper start\n *\n * \u005cparam type: type of iteration, eg, struct xyz **\n * \u005cparam it: iterator var name to create\n * \u005cparam start: start of list\n *\n * This helper creates an iterator and starts a while (it) {\n * loop. The iterator runs through the linked list starting at the\n * address of start and ends when it gets a NULL.\n * The while loop should be terminated using lws_start_foreach_llp().\n *\n * This helper variant iterates using a pointer to the previous linked-list\n * element. That allows you to easily delete list members by rewriting the\n * previous pointer to the element's next pointer.\n */\n#define lws_start_foreach_llp(type, it, start)\u005c\n{ \u005c\n\ttype it \u003d \u0026(start); \u005c\n\twhile (*(it)) {\n\n#define lws_start_foreach_llp_safe(type, it, start, nxt)\u005c\n{ \u005c\n\ttype it \u003d \u0026(start); \u005c\n\ttype next; \u005c\n\twhile (*(it)) { \u005c\n\t\tnext \u003d \u0026((*(it))-\u003enxt); \u005c\n\n/**\n * lws_end_foreach_llp(): linkedlist pointer iterator helper end\n *\n * \u005cparam it: same iterator var name given when starting\n * \u005cparam nxt: member name in the iterator pointing to next list element\n *\n * This helper is the partner for lws_start_foreach_llp() that ends the\n * while loop.\n */\n\n#define lws_end_foreach_llp(it, nxt) \u005c\n\t\tit \u003d \u0026(*(it))-\u003enxt; \u005c\n\t} \u005c\n}\n\n#define lws_end_foreach_llp_safe(it) \u005c\n\t\tit \u003d next; \u005c\n\t} \u005c\n}\n\n#define lws_ll_fwd_insert(\u005c\n\t___new_object,\t/* pointer to new object */ \u005c\n\t___m_list,\t/* member for next list object ptr */ \u005c\n\t___list_head\t/* list head */ \u005c\n\t\t) {\u005c\n\t\t___new_object-\u003e___m_list \u003d ___list_head; \u005c\n\t\t___list_head \u003d ___new_object; \u005c\n\t}\n\n#define lws_ll_fwd_remove(\u005c\n\t___type,\t/* type of listed object */ \u005c\n\t___m_list,\t/* member for next list object ptr */ \u005c\n\t___target,\t/* object to remove from list */ \u005c\n\t___list_head\t/* list head */ \u005c\n\t) { \u005c\n lws_start_foreach_llp(___type **, ___ppss, ___list_head) { \u005c\n if (*___ppss \u003d\u003d ___target) { \u005c\n *___ppss \u003d ___target-\u003e___m_list; \u005c\n break; \u005c\n } \u005c\n } lws_end_foreach_llp(___ppss, ___m_list); \u005c\n\t}\n\n/*\n * doubly linked-list\n */\n\nstruct lws_dll { /* abstract */\n\tstruct lws_dll *prev;\n\tstruct lws_dll *next;\n};\n\n/*\n * these all point to the composed list objects... you have to use the\n * lws_container_of() helper to recover the start of the containing struct\n */\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll_add_front(struct lws_dll *d, struct lws_dll *phead);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll_remove(struct lws_dll *d);\n\nstruct lws_dll_lws { /* typed as struct lws * */\n\tstruct lws_dll_lws *prev;\n\tstruct lws_dll_lws *next;\n};\n\n#define lws_dll_is_null(___dll) (!(___dll)-\u003eprev \u0026\u0026 !(___dll)-\u003enext)\n\nstatic LWS_INLINE void\nlws_dll_lws_add_front(struct lws_dll_lws *_a, struct lws_dll_lws *_head)\n{\n\tlws_dll_add_front((struct lws_dll *)_a, (struct lws_dll *)_head);\n}\n\nstatic LWS_INLINE void\nlws_dll_lws_remove(struct lws_dll_lws *_a)\n{\n\tlws_dll_remove((struct lws_dll *)_a);\n}\n\n/*\n * these are safe against the current container object getting deleted,\n * since the hold his next in a temp and go to that next. ___tmp is\n * the temp.\n */\n\n#define lws_start_foreach_dll_safe(___type, ___it, ___tmp, ___start) \u005c\n{ \u005c\n\t___type ___it \u003d ___start; \u005c\n\twhile (___it) { \u005c\n\t\t___type ___tmp \u003d (___it)-\u003enext;\n\n#define lws_end_foreach_dll_safe(___it, ___tmp) \u005c\n\t\t___it \u003d ___tmp; \u005c\n\t} \u005c\n}\n\n#define lws_start_foreach_dll(___type, ___it, ___start) \u005c\n{ \u005c\n\t___type ___it \u003d ___start; \u005c\n\twhile (___it) {\n\n#define lws_end_foreach_dll(___it) \u005c\n\t\t___it \u003d (___it)-\u003enext; \u005c\n\t} \u005c\n}\n\nstruct lws_buflist;\n\n/**\n * lws_buflist_append_segment(): add buffer to buflist at head\n *\n * \u005cparam head: list head\n * \u005cparam buf: buffer to stash\n * \u005cparam len: length of buffer to stash\n *\n * Returns -1 on OOM, 1 if this was the first segment on the list, and 0 if\n * it was a subsequent segment.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_buflist_append_segment(struct lws_buflist **head, const uint8_t *buf,\n\t\t\t size_t len);\n/**\n * lws_buflist_next_segment_len(): number of bytes left in current segment\n *\n * \u005cparam head: list head\n * \u005cparam buf: if non-NULL, *buf is written with the address of the start of\n *\t\tthe remaining data in the segment\n *\n * Returns the number of bytes left in the current segment. 0 indicates\n * that the buflist is empty (there are no segments on the buflist).\n */\nLWS_VISIBLE LWS_EXTERN size_t\nlws_buflist_next_segment_len(struct lws_buflist **head, uint8_t **buf);\n/**\n * lws_buflist_use_segment(): remove len bytes from the current segment\n *\n * \u005cparam head: list head\n * \u005cparam len: number of bytes to mark as used\n *\n * If len is less than the remaining length of the current segment, the position\n * in the current segment is simply advanced and it returns.\n *\n * If len uses up the remaining length of the current segment, then the segment\n * is deleted and the list head moves to the next segment if any.\n *\n * Returns the number of bytes left in the current segment. 0 indicates\n * that the buflist is empty (there are no segments on the buflist).\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_buflist_use_segment(struct lws_buflist **head, size_t len);\n/**\n * lws_buflist_destroy_all_segments(): free all segments on the list\n *\n * \u005cparam head: list head\n *\n * This frees everything on the list unconditionally. *head is always\n * NULL after this.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_buflist_destroy_all_segments(struct lws_buflist **head);\n\nvoid\nlws_buflist_describe(struct lws_buflist **head, void *id);\n\n/**\n * lws_ptr_diff(): helper to report distance between pointers as an int\n *\n * \u005cparam head: the pointer with the larger address\n * \u005cparam tail: the pointer with the smaller address\n *\n * This helper gives you an int representing the number of bytes further\n * forward the first pointer is compared to the second pointer.\n */\n#define lws_ptr_diff(head, tail) \u005c\n\t\t\t((int)((char *)(head) - (char *)(tail)))\n\n/**\n * lws_snprintf(): snprintf that truncates the returned length too\n *\n * \u005cparam str: destination buffer\n * \u005cparam size: bytes left in destination buffer\n * \u005cparam format: format string\n * \u005cparam ...: args for format\n *\n * This lets you correctly truncate buffers by concatenating lengths, if you\n * reach the limit the reported length doesn't exceed the limit.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3);\n\n/**\n * lws_strncpy(): strncpy that guarantees NUL on truncated copy\n *\n * \u005cparam dest: destination buffer\n * \u005cparam src: source buffer\n * \u005cparam size: bytes left in destination buffer\n *\n * This lets you correctly truncate buffers by concatenating lengths, if you\n * reach the limit the reported length doesn't exceed the limit.\n */\nLWS_VISIBLE LWS_EXTERN char *\nlws_strncpy(char *dest, const char *src, size_t size);\n\n/**\n * lws_get_random(): fill a buffer with platform random data\n *\n * \u005cparam context: the lws context\n * \u005cparam buf: buffer to fill\n * \u005cparam len: how much to fill\n *\n * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if\n * it's interested to see if the frame it's dealing with was sent in binary\n * mode.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_get_random(struct lws_context *context, void *buf, int len);\n/**\n * lws_daemonize(): make current process run in the background\n *\n * \u005cparam _lock_path: the filepath to write the lock file\n *\n * Spawn lws as a background process, taking care of various things\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_daemonize(const char *_lock_path);\n/**\n * lws_get_library_version(): return string describing the version of lws\n *\n * On unix, also includes the git describe\n */\nLWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT\nlws_get_library_version(void);\n\n/**\n * lws_wsi_user() - get the user data associated with the connection\n * \u005cparam wsi: lws connection\n *\n * Not normally needed since it's passed into the callback\n */\nLWS_VISIBLE LWS_EXTERN void *\nlws_wsi_user(struct lws *wsi);\n\n/**\n * lws_wsi_set_user() - set the user data associated with the client connection\n * \u005cparam wsi: lws connection\n * \u005cparam user: user data\n *\n * By default lws allocates this and it's not legal to externally set it\n * yourself. However client connections may have it set externally when the\n * connection is created... if so, this api can be used to modify it at\n * runtime additionally.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_wsi_user(struct lws *wsi, void *user);\n\n/**\n * lws_parse_uri:\tcut up prot:/ads:port/path into pieces\n *\t\t\tNotice it does so by dropping '\u005c0' into input string\n *\t\t\tand the leading / on the path is consequently lost\n *\n * \u005cparam p:\t\t\tincoming uri string.. will get written to\n * \u005cparam prot:\t\tresult pointer for protocol part (https://)\n * \u005cparam ads:\t\tresult pointer for address part\n * \u005cparam port:\t\tresult pointer for port part\n * \u005cparam path:\t\tresult pointer for path part\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_parse_uri(char *p, const char **prot, const char **ads, int *port,\n\t const char **path);\n/**\n * lws_cmdline_option():\tsimple commandline parser\n *\n * \u005cparam argc:\t\tcount of argument strings\n * \u005cparam argv:\t\targument strings\n * \u005cparam val:\t\tstring to find\n *\n * Returns NULL if the string \u005cp val is not found in the arguments.\n *\n * If it is found, then it returns a pointer to the next character after \u005cp val.\n * So if \u005cp val is \u0022-d\u0022, then for the commandlines \u0022myapp -d15\u0022 and\n * \u0022myapp -d 15\u0022, in both cases the return will point to the \u002215\u0022.\n *\n * In the case there is no argument, like \u0022myapp -d\u0022, the return will\n * either point to the '\u005c\u005c0' at the end of -d, or to the start of the\n * next argument, ie, will be non-NULL.\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_cmdline_option(int argc, const char **argv, const char *val);\n\n/**\n * lws_now_secs(): return seconds since 1970-1-1\n */\nLWS_VISIBLE LWS_EXTERN unsigned long\nlws_now_secs(void);\n\n/**\n * lws_compare_time_t(): return relationship between two time_t\n *\n * \u005cparam context: struct lws_context\n * \u005cparam t1: time_t 1\n * \u005cparam t2: time_t 2\n *\n * returns \u003c0 if t2 \u003e t1; \u003e0 if t1 \u003e t2; or \u003d\u003d 0 if t1 \u003d\u003d t2.\n *\n * This is aware of clock discontiguities that may have affected either t1 or\n * t2 and adapts the comparison for them.\n *\n * For the discontiguity detection to work, you must avoid any arithmetic on\n * the times being compared. For example to have a timeout that triggers\n * 15s from when it was set, store the time it was set and compare like\n * `if (lws_compare_time_t(context, now, set_time) \u003e 15)`\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_compare_time_t(struct lws_context *context, time_t t1, time_t t2);\n\n/**\n * lws_get_context - Allow getting lws_context from a Websocket connection\n * instance\n *\n * With this function, users can access context in the callback function.\n * Otherwise users may have to declare context as a global variable.\n *\n * \u005cparam wsi:\tWebsocket connection instance\n */\nLWS_VISIBLE LWS_EXTERN struct lws_context * LWS_WARN_UNUSED_RESULT\nlws_get_context(const struct lws *wsi);\n\n/**\n * lws_get_vhost_listen_port - Find out the port number a vhost is listening on\n *\n * In the case you passed 0 for the port number at context creation time, you\n * can discover the port number that was actually chosen for the vhost using\n * this api.\n *\n * \u005cparam vhost:\tVhost to get listen port from\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_get_vhost_listen_port(struct lws_vhost *vhost);\n\n/**\n * lws_get_count_threads(): how many service threads the context uses\n *\n * \u005cparam context: the lws context\n *\n * By default this is always 1, if you asked for more than lws can handle it\n * will clip the number of threads. So you can use this to find out how many\n * threads are actually in use.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_get_count_threads(struct lws_context *context);\n\n/**\n * lws_get_parent() - get parent wsi or NULL\n * \u005cparam wsi: lws connection\n *\n * Specialized wsi like cgi stdin/out/err are associated to a parent wsi,\n * this allows you to get their parent.\n */\nLWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT\nlws_get_parent(const struct lws *wsi);\n\n/**\n * lws_get_child() - get child wsi or NULL\n * \u005cparam wsi: lws connection\n *\n * Allows you to find a related wsi from the parent wsi.\n */\nLWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT\nlws_get_child(const struct lws *wsi);\n\n/**\n * lws_get_udp() - get wsi's udp struct\n *\n * \u005cparam wsi: lws connection\n *\n * Returns NULL or pointer to the wsi's UDP-specific information\n */\nLWS_VISIBLE LWS_EXTERN const struct lws_udp * LWS_WARN_UNUSED_RESULT\nlws_get_udp(const struct lws *wsi);\n\n/**\n * lws_parent_carries_io() - mark wsi as needing to send messages via parent\n *\n * \u005cparam wsi: child lws connection\n */\n\nLWS_VISIBLE LWS_EXTERN void\nlws_set_parent_carries_io(struct lws *wsi);\n\nLWS_VISIBLE LWS_EXTERN void *\nlws_get_opaque_parent_data(const struct lws *wsi);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_set_opaque_parent_data(struct lws *wsi, void *data);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_get_child_pending_on_writable(const struct lws *wsi);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_clear_child_pending_on_writable(struct lws *wsi);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_get_close_length(struct lws *wsi);\n\nLWS_VISIBLE LWS_EXTERN unsigned char *\nlws_get_close_payload(struct lws *wsi);\n\n/**\n * lws_get_network_wsi() - Returns wsi that has the tcp connection for this wsi\n *\n * \u005cparam wsi: wsi you have\n *\n * Returns wsi that has the tcp connection (which may be the incoming wsi)\n *\n * HTTP/1 connections will always return the incoming wsi\n * HTTP/2 connections may return a different wsi that has the tcp connection\n */\nLWS_VISIBLE LWS_EXTERN\nstruct lws *lws_get_network_wsi(struct lws *wsi);\n\n/**\n * lws_set_allocator() - custom allocator support\n *\n * \u005cparam realloc\n *\n * Allows you to replace the allocator (and deallocator) used by lws\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_allocator(void *(*realloc)(void *ptr, size_t size, const char *reason));\n///@}\n\n/** \u005cdefgroup wsstatus Websocket status APIs\n * ##Websocket connection status APIs\n *\n * These provide information about ws connection or message status\n */\n///@{\n/**\n * lws_send_pipe_choked() - tests if socket is writable or not\n * \u005cparam wsi: lws connection\n *\n * Allows you to check if you can write more on the socket\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_send_pipe_choked(struct lws *wsi);\n\n/**\n * lws_is_final_fragment() - tests if last part of ws message\n *\n * \u005cparam wsi: lws connection\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_is_final_fragment(struct lws *wsi);\n\n/**\n * lws_is_first_fragment() - tests if first part of ws message\n *\n * \u005cparam wsi: lws connection\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_is_first_fragment(struct lws *wsi);\n\n/**\n * lws_get_reserved_bits() - access reserved bits of ws frame\n * \u005cparam wsi: lws connection\n */\nLWS_VISIBLE LWS_EXTERN unsigned char\nlws_get_reserved_bits(struct lws *wsi);\n\n/**\n * lws_partial_buffered() - find out if lws buffered the last write\n * \u005cparam wsi:\twebsocket connection to check\n *\n * Returns 1 if you cannot use lws_write because the last\n * write on this connection is still buffered, and can't be cleared without\n * returning to the service loop and waiting for the connection to be\n * writeable again.\n *\n * If you will try to do \u003e1 lws_write call inside a single\n * WRITEABLE callback, you must check this after every write and bail if\n * set, ask for a new writeable callback and continue writing from there.\n *\n * This is never set at the start of a writeable callback, but any write\n * may set it.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_partial_buffered(struct lws *wsi);\n\n/**\n * lws_frame_is_binary(): true if the current frame was sent in binary mode\n *\n * \u005cparam wsi: the connection we are inquiring about\n *\n * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if\n * it's interested to see if the frame it's dealing with was sent in binary\n * mode.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_frame_is_binary(struct lws *wsi);\n\n/**\n * lws_is_ssl() - Find out if connection is using SSL\n * \u005cparam wsi:\twebsocket connection to check\n *\n *\tReturns 0 if the connection is not using SSL, 1 if using SSL and\n *\tusing verified cert, and 2 if using SSL but the cert was not\n *\tchecked (appears for client wsi told to skip check on connection)\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_is_ssl(struct lws *wsi);\n/**\n * lws_is_cgi() - find out if this wsi is running a cgi process\n * \u005cparam wsi: lws connection\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_is_cgi(struct lws *wsi);\n\n\nstruct lws_wifi_scan { /* generic wlan scan item */\n\tstruct lws_wifi_scan *next;\n\tchar ssid[32];\n\tint32_t rssi; /* divide by .count to get db */\n\tuint8_t bssid[6];\n\tuint8_t count;\n\tuint8_t channel;\n\tuint8_t authmode;\n};\n\n#if defined(LWS_WITH_TLS) \u0026\u0026 !defined(LWS_WITH_MBEDTLS)\n/**\n * lws_get_ssl() - Return wsi's SSL context structure\n * \u005cparam wsi:\twebsocket connection\n *\n * Returns pointer to the SSL library's context structure\n */\nLWS_VISIBLE LWS_EXTERN SSL*\nlws_get_ssl(struct lws *wsi);\n#endif\n\nenum lws_tls_cert_info {\n\tLWS_TLS_CERT_INFO_VALIDITY_FROM,\n\t/**\u003c fills .time with the time_t the cert validity started from */\n\tLWS_TLS_CERT_INFO_VALIDITY_TO,\n\t/**\u003c fills .time with the time_t the cert validity ends at */\n\tLWS_TLS_CERT_INFO_COMMON_NAME,\n\t/**\u003c fills up to len bytes of .ns.name with the cert common name */\n\tLWS_TLS_CERT_INFO_ISSUER_NAME,\n\t/**\u003c fills up to len bytes of .ns.name with the cert issuer name */\n\tLWS_TLS_CERT_INFO_USAGE,\n\t/**\u003c fills verified with a bitfield asserting the valid uses */\n\tLWS_TLS_CERT_INFO_VERIFIED,\n\t/**\u003c fills .verified with a bool representing peer cert validity,\n\t * call returns -1 if no cert */\n\tLWS_TLS_CERT_INFO_OPAQUE_PUBLIC_KEY,\n\t/**\u003c the certificate's public key, as an opaque bytestream. These\n\t * opaque bytestreams can only be compared with each other using the\n\t * same tls backend, ie, OpenSSL or mbedTLS. The different backends\n\t * produce different, incompatible representations for the same cert.\n\t */\n};\n\nunion lws_tls_cert_info_results {\n\tunsigned int verified;\n\ttime_t time;\n\tunsigned int usage;\n\tstruct {\n\t\tint len;\n\t\t/* KEEP LAST... notice the [64] is only there because\n\t\t * name[] is not allowed in a union. The actual length of\n\t\t * name[] is arbitrary and is passed into the api using the\n\t\t * len parameter. Eg\n\t\t *\n\t\t * char big[1024];\n\t\t * union lws_tls_cert_info_results *buf \u003d\n\t\t * \t(union lws_tls_cert_info_results *)big;\n\t\t *\n\t\t * lws_tls_peer_cert_info(wsi, type, buf, sizeof(big) -\n\t\t *\t\t\t sizeof(*buf) + sizeof(buf-\u003ens.name));\n\t\t */\n\t\tchar name[64];\n\t} ns;\n};\n\n/**\n * lws_tls_peer_cert_info() - get information from the peer's TLS cert\n *\n * \u005cparam wsi: the connection to query\n * \u005cparam type: one of LWS_TLS_CERT_INFO_\n * \u005cparam buf: pointer to union to take result\n * \u005cparam len: when result is a string, the true length of buf-\u003ens.name[]\n *\n * lws_tls_peer_cert_info() lets you get hold of information from the peer\n * certificate.\n *\n * Return 0 if there is a result in \u005cp buf, or -1 indicating there was no cert\n * or another problem.\n *\n * This function works the same no matter if the TLS backend is OpenSSL or\n * mbedTLS.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_tls_peer_cert_info(struct lws *wsi, enum lws_tls_cert_info type,\n\t\t union lws_tls_cert_info_results *buf, size_t len);\n\n/**\n * lws_tls_vhost_cert_info() - get information from the vhost's own TLS cert\n *\n * \u005cparam vhost: the vhost to query\n * \u005cparam type: one of LWS_TLS_CERT_INFO_\n * \u005cparam buf: pointer to union to take result\n * \u005cparam len: when result is a string, the true length of buf-\u003ens.name[]\n *\n * lws_tls_vhost_cert_info() lets you get hold of information from the vhost\n * certificate.\n *\n * Return 0 if there is a result in \u005cp buf, or -1 indicating there was no cert\n * or another problem.\n *\n * This function works the same no matter if the TLS backend is OpenSSL or\n * mbedTLS.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_tls_vhost_cert_info(struct lws_vhost *vhost, enum lws_tls_cert_info type,\n\t\t union lws_tls_cert_info_results *buf, size_t len);\n\n/**\n * lws_tls_acme_sni_cert_create() - creates a temp selfsigned cert\n *\t\t\t\t and attaches to a vhost\n *\n * \u005cparam vhost: the vhost to acquire the selfsigned cert\n * \u005cparam san_a: SAN written into the certificate\n * \u005cparam san_b: second SAN written into the certificate\n *\n *\n * Returns 0 if created and attached to the vhost. Returns -1 if problems and\n * frees all allocations before returning.\n *\n * On success, any allocations are destroyed at vhost destruction automatically.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_tls_acme_sni_cert_create(struct lws_vhost *vhost, const char *san_a,\n\t\t\t const char *san_b);\n\n/**\n * lws_tls_acme_sni_csr_create() - creates a CSR and related private key PEM\n *\n * \u005cparam context: lws_context used for random\n * \u005cparam elements: array of LWS_TLS_REQ_ELEMENT_COUNT const char *\n * \u005cparam csr: buffer that will get the b64URL(ASN-1 CSR)\n * \u005cparam csr_len: max length of the csr buffer\n * \u005cparam privkey_pem: pointer to pointer allocated to hold the privkey_pem\n * \u005cparam privkey_len: pointer to size_t set to the length of the privkey_pem\n *\n * Creates a CSR according to the information in \u005cp elements, and a private\n * RSA key used to sign the CSR.\n *\n * The outputs are the b64URL(ASN-1 CSR) into csr, and the PEM private key into\n * privkey_pem.\n *\n * Notice that \u005cp elements points to an array of const char *s pointing to the\n * information listed in the enum above. If an entry is NULL or an empty\n * string, the element is set to \u0022none\u0022 in the CSR.\n *\n * Returns 0 on success or nonzero for failure.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_tls_acme_sni_csr_create(struct lws_context *context, const char *elements[],\n\t\t\t uint8_t *csr, size_t csr_len, char **privkey_pem,\n\t\t\t size_t *privkey_len);\n\n/**\n * lws_tls_cert_updated() - update every vhost using the given cert path\n *\n * \u005cparam context: our lws_context\n * \u005cparam certpath: the filepath to the certificate\n * \u005cparam keypath: the filepath to the private key of the certificate\n * \u005cparam mem_cert: copy of the cert in memory\n * \u005cparam len_mem_cert: length of the copy of the cert in memory\n * \u005cparam mem_privkey: copy of the private key in memory\n * \u005cparam len_mem_privkey: length of the copy of the private key in memory\n *\n * Checks every vhost to see if it is the using certificate described by the\n * the given filepaths. If so, it attempts to update the vhost ssl_ctx to use\n * the new certificate.\n *\n * Returns 0 on success or nonzero for failure.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_tls_cert_updated(struct lws_context *context, const char *certpath,\n\t\t const char *keypath,\n\t\t const char *mem_cert, size_t len_mem_cert,\n\t\t const char *mem_privkey, size_t len_mem_privkey);\n///@}\n\n/** \u005cdefgroup lws_ring LWS Ringbuffer APIs\n * ##lws_ring: generic ringbuffer struct\n *\n * Provides an abstract ringbuffer api supporting one head and one or an\n * unlimited number of tails.\n *\n * All of the members are opaque and manipulated by lws_ring_...() apis.\n *\n * The lws_ring and its buffer is allocated at runtime on the heap, using\n *\n * - lws_ring_create()\n * - lws_ring_destroy()\n *\n * It may contain any type, the size of the \u0022element\u0022 stored in the ring\n * buffer and the number of elements is given at creation time.\n *\n * When you create the ringbuffer, you can optionally provide an element\n * destroy callback that frees any allocations inside the element. This is then\n * automatically called for elements with no tail behind them, ie, elements\n * which don't have any pending consumer are auto-freed.\n *\n * Whole elements may be inserted into the ringbuffer and removed from it, using\n *\n * - lws_ring_insert()\n * - lws_ring_consume()\n *\n * You can find out how many whole elements are free or waiting using\n *\n * - lws_ring_get_count_free_elements()\n * - lws_ring_get_count_waiting_elements()\n *\n * In addition there are special purpose optional byte-centric apis\n *\n * - lws_ring_next_linear_insert_range()\n * - lws_ring_bump_head()\n *\n * which let you, eg, read() directly into the ringbuffer without needing\n * an intermediate bounce buffer.\n *\n * The accessors understand that the ring wraps, and optimizes insertion and\n * consumption into one or two memcpy()s depending on if the head or tail\n * wraps.\n *\n * lws_ring only supports a single head, but optionally multiple tails with\n * an API to inform it when the \u0022oldest\u0022 tail has moved on. You can give\n * NULL where-ever an api asks for a tail pointer, and it will use an internal\n * single tail pointer for convenience.\n *\n * The \u0022oldest tail\u0022, which is the only tail if you give it NULL instead of\n * some other tail, is used to track which elements in the ringbuffer are\n * still unread by anyone.\n *\n * - lws_ring_update_oldest_tail()\n */\n///@{\nstruct lws_ring;\n\n/**\n * lws_ring_create(): create a new ringbuffer\n *\n * \u005cparam element_len: the size in bytes of one element in the ringbuffer\n * \u005cparam count: the number of elements the ringbuffer can contain\n * \u005cparam destroy_element: NULL, or callback to be called for each element\n *\t\t\t that is removed from the ringbuffer due to the\n *\t\t\t oldest tail moving beyond it\n *\n * Creates the ringbuffer and allocates the storage. Returns the new\n * lws_ring *, or NULL if the allocation failed.\n *\n * If non-NULL, destroy_element will get called back for every element that is\n * retired from the ringbuffer after the oldest tail has gone past it, and for\n * any element still left in the ringbuffer when it is destroyed. It replaces\n * all other element destruction code in your user code.\n */\nLWS_VISIBLE LWS_EXTERN struct lws_ring *\nlws_ring_create(size_t element_len, size_t count,\n\t\tvoid (*destroy_element)(void *element));\n\n/**\n * lws_ring_destroy(): destroy a previously created ringbuffer\n *\n * \u005cparam ring: the struct lws_ring to destroy\n *\n * Destroys the ringbuffer allocation and the struct lws_ring itself.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_ring_destroy(struct lws_ring *ring);\n\n/**\n * lws_ring_get_count_free_elements(): return how many elements can fit\n *\t\t\t\t in the free space\n *\n * \u005cparam ring: the struct lws_ring to report on\n *\n * Returns how much room is left in the ringbuffer for whole element insertion.\n */\nLWS_VISIBLE LWS_EXTERN size_t\nlws_ring_get_count_free_elements(struct lws_ring *ring);\n\n/**\n * lws_ring_get_count_waiting_elements(): return how many elements can be consumed\n *\n * \u005cparam ring: the struct lws_ring to report on\n * \u005cparam tail: a pointer to the tail struct to use, or NULL for single tail\n *\n * Returns how many elements are waiting to be consumed from the perspective\n * of the tail pointer given.\n */\nLWS_VISIBLE LWS_EXTERN size_t\nlws_ring_get_count_waiting_elements(struct lws_ring *ring, uint32_t *tail);\n\n/**\n * lws_ring_insert(): attempt to insert up to max_count elements from src\n *\n * \u005cparam ring: the struct lws_ring to report on\n * \u005cparam src: the array of elements to be inserted\n * \u005cparam max_count: the number of available elements at src\n *\n * Attempts to insert as many of the elements at src as possible, up to the\n * maximum max_count. Returns the number of elements actually inserted.\n */\nLWS_VISIBLE LWS_EXTERN size_t\nlws_ring_insert(struct lws_ring *ring, const void *src, size_t max_count);\n\n/**\n * lws_ring_consume(): attempt to copy out and remove up to max_count elements\n *\t\t to src\n *\n * \u005cparam ring: the struct lws_ring to report on\n * \u005cparam tail: a pointer to the tail struct to use, or NULL for single tail\n * \u005cparam dest: the array of elements to be inserted. or NULL for no copy\n * \u005cparam max_count: the number of available elements at src\n *\n * Attempts to copy out as many waiting elements as possible into dest, from\n * the perspective of the given tail, up to max_count. If dest is NULL, the\n * copying out is not done but the elements are logically consumed as usual.\n * NULL dest is useful in combination with lws_ring_get_element(), where you\n * can use the element direct from the ringbuffer and then call this with NULL\n * dest to logically consume it.\n *\n * Increments the tail position according to how many elements could be\n * consumed.\n *\n * Returns the number of elements consumed.\n */\nLWS_VISIBLE LWS_EXTERN size_t\nlws_ring_consume(struct lws_ring *ring, uint32_t *tail, void *dest,\n\t\t size_t max_count);\n\n/**\n * lws_ring_get_element(): get a pointer to the next waiting element for tail\n *\n * \u005cparam ring: the struct lws_ring to report on\n * \u005cparam tail: a pointer to the tail struct to use, or NULL for single tail\n *\n * Points to the next element that tail would consume, directly in the\n * ringbuffer. This lets you write() or otherwise use the element without\n * having to copy it out somewhere first.\n *\n * After calling this, you must call lws_ring_consume(ring, \u0026tail, NULL, 1)\n * which will logically consume the element you used up and increment your\n * tail (tail may also be NULL there if you use a single tail).\n *\n * Returns NULL if no waiting element, or a const void * pointing to it.\n */\nLWS_VISIBLE LWS_EXTERN const void *\nlws_ring_get_element(struct lws_ring *ring, uint32_t *tail);\n\n/**\n * lws_ring_update_oldest_tail(): free up elements older than tail for reuse\n *\n * \u005cparam ring: the struct lws_ring to report on\n * \u005cparam tail: a pointer to the tail struct to use, or NULL for single tail\n *\n * If you are using multiple tails, you must use this API to inform the\n * lws_ring when none of the tails still need elements in the fifo any more,\n * by updating it when the \u0022oldest\u0022 tail has moved on.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_ring_update_oldest_tail(struct lws_ring *ring, uint32_t tail);\n\n/**\n * lws_ring_get_oldest_tail(): get current oldest available data index\n *\n * \u005cparam ring: the struct lws_ring to report on\n *\n * If you are initializing a new ringbuffer consumer, you can set its tail to\n * this to start it from the oldest ringbuffer entry still available.\n */\nLWS_VISIBLE LWS_EXTERN uint32_t\nlws_ring_get_oldest_tail(struct lws_ring *ring);\n\n/**\n * lws_ring_next_linear_insert_range(): used to write directly into the ring\n *\n * \u005cparam ring: the struct lws_ring to report on\n * \u005cparam start: pointer to a void * set to the start of the next ringbuffer area\n * \u005cparam bytes: pointer to a size_t set to the max length you may use from *start\n *\n * This provides a low-level, bytewise access directly into the ringbuffer\n * allowing direct insertion of data without having to use a bounce buffer.\n *\n * The api reports the position and length of the next linear range that can\n * be written in the ringbuffer, ie, up to the point it would wrap, and sets\n * *start and *bytes accordingly. You can then, eg, directly read() into\n * *start for up to *bytes, and use lws_ring_bump_head() to update the lws_ring\n * with what you have done.\n *\n * Returns nonzero if no insertion is currently possible.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_ring_next_linear_insert_range(struct lws_ring *ring, void **start,\n\t\t\t\t size_t *bytes);\n\n/**\n * lws_ring_bump_head(): used to write directly into the ring\n *\n * \u005cparam ring: the struct lws_ring to operate on\n * \u005cparam bytes: the number of bytes you inserted at the current head\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_ring_bump_head(struct lws_ring *ring, size_t bytes);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_ring_dump(struct lws_ring *ring, uint32_t *tail);\n\n/*\n * This is a helper that combines the common pattern of needing to consume\n * some ringbuffer elements, move the consumer tail on, and check if that\n * has moved any ringbuffer elements out of scope, because it was the last\n * consumer that had not already consumed them.\n *\n * Elements that go out of scope because the oldest tail is now after them\n * get garbage-collected by calling the destroy_element callback on them\n * defined when the ringbuffer was created.\n */\n\n#define lws_ring_consume_and_update_oldest_tail(\u005c\n\t\t___ring, /* the lws_ring object */ \u005c\n\t\t___type, /* type of objects with tails */ \u005c\n\t\t___ptail, /* ptr to tail of obj with tail doing consuming */ \u005c\n\t\t___count, /* count of payload objects being consumed */ \u005c\n\t\t___list_head,\t/* head of list of objects with tails */ \u005c\n\t\t___mtail, /* member name of tail in ___type */ \u005c\n\t\t___mlist /* member name of next list member ptr in ___type */ \u005c\n\t) { \u005c\n\t\tint ___n, ___m; \u005c\n\t\u005c\n\t___n \u003d lws_ring_get_oldest_tail(___ring) \u003d\u003d *(___ptail); \u005c\n\tlws_ring_consume(___ring, ___ptail, NULL, ___count); \u005c\n\tif (___n) { \u005c\n\t\tuint32_t ___oldest; \u005c\n\t\t___n \u003d 0; \u005c\n\t\t___oldest \u003d *(___ptail); \u005c\n\t\tlws_start_foreach_llp(___type **, ___ppss, ___list_head) { \u005c\n\t\t\t___m \u003d lws_ring_get_count_waiting_elements( \u005c\n\t\t\t\t\t___ring, \u0026(*___ppss)-\u003etail); \u005c\n\t\t\tif (___m \u003e\u003d ___n) { \u005c\n\t\t\t\t___n \u003d ___m; \u005c\n\t\t\t\t___oldest \u003d (*___ppss)-\u003etail; \u005c\n\t\t\t} \u005c\n\t\t} lws_end_foreach_llp(___ppss, ___mlist); \u005c\n\t\u005c\n\t\tlws_ring_update_oldest_tail(___ring, ___oldest); \u005c\n\t} \u005c\n}\n\n/*\n * This does the same as the lws_ring_consume_and_update_oldest_tail()\n * helper, but for the simpler case there is only one consumer, so one\n * tail, and that tail is always the oldest tail.\n */\n\n#define lws_ring_consume_single_tail(\u005c\n\t\t___ring, /* the lws_ring object */ \u005c\n\t\t___ptail, /* ptr to tail of obj with tail doing consuming */ \u005c\n\t\t___count /* count of payload objects being consumed */ \u005c\n\t) { \u005c\n\tlws_ring_consume(___ring, ___ptail, NULL, ___count); \u005c\n\tlws_ring_update_oldest_tail(___ring, *(___ptail)); \u005c\n}\n///@}\n\n/** \u005cdefgroup sha SHA and B64 helpers\n * ##SHA and B64 helpers\n *\n * These provide SHA-1 and B64 helper apis\n */\n///@{\n#ifdef LWS_SHA1_USE_OPENSSL_NAME\n#define lws_SHA1 SHA1\n#else\n/**\n * lws_SHA1(): make a SHA-1 digest of a buffer\n *\n * \u005cparam d: incoming buffer\n * \u005cparam n: length of incoming buffer\n * \u005cparam md: buffer for message digest (must be \u003e\u003d 20 bytes)\n *\n * Reduces any size buffer into a 20-byte SHA-1 hash.\n */\nLWS_VISIBLE LWS_EXTERN unsigned char *\nlws_SHA1(const unsigned char *d, size_t n, unsigned char *md);\n#endif\n/**\n * lws_b64_encode_string(): encode a string into base 64\n *\n * \u005cparam in: incoming buffer\n * \u005cparam in_len: length of incoming buffer\n * \u005cparam out: result buffer\n * \u005cparam out_size: length of result buffer\n *\n * Encodes a string using b64\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_b64_encode_string(const char *in, int in_len, char *out, int out_size);\n/**\n * lws_b64_encode_string_url(): encode a string into base 64\n *\n * \u005cparam in: incoming buffer\n * \u005cparam in_len: length of incoming buffer\n * \u005cparam out: result buffer\n * \u005cparam out_size: length of result buffer\n *\n * Encodes a string using b64 with the \u0022URL\u0022 variant (+ -\u003e -, and / -\u003e _)\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_b64_encode_string_url(const char *in, int in_len, char *out, int out_size);\n/**\n * lws_b64_decode_string(): decode a string from base 64\n *\n * \u005cparam in: incoming buffer\n * \u005cparam out: result buffer\n * \u005cparam out_size: length of result buffer\n *\n * Decodes a NUL-terminated string using b64\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_b64_decode_string(const char *in, char *out, int out_size);\n/**\n * lws_b64_decode_string_len(): decode a string from base 64\n *\n * \u005cparam in: incoming buffer\n * \u005cparam in_len: length of incoming buffer\n * \u005cparam out: result buffer\n * \u005cparam out_size: length of result buffer\n *\n * Decodes a range of chars using b64\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_b64_decode_string_len(const char *in, int in_len, char *out, int out_size);\n///@}\n\n\n/*! \u005cdefgroup cgi cgi handling\n *\n * ##CGI handling\n *\n * These functions allow low-level control over stdin/out/err of the cgi.\n *\n * However for most cases, binding the cgi to http in and out, the default\n * lws implementation already does the right thing.\n */\n\nenum lws_enum_stdinouterr {\n\tLWS_STDIN \u003d 0,\n\tLWS_STDOUT \u003d 1,\n\tLWS_STDERR \u003d 2,\n};\n\nenum lws_cgi_hdr_state {\n\tLCHS_HEADER,\n\tLCHS_CR1,\n\tLCHS_LF1,\n\tLCHS_CR2,\n\tLCHS_LF2,\n\tLHCS_RESPONSE,\n\tLHCS_DUMP_HEADERS,\n\tLHCS_PAYLOAD,\n\tLCHS_SINGLE_0A,\n};\n\nstruct lws_cgi_args {\n\tstruct lws **stdwsi; /**\u003c get fd with lws_get_socket_fd() */\n\tenum lws_enum_stdinouterr ch; /**\u003c channel index */\n\tunsigned char *data; /**\u003c for messages with payload */\n\tenum lws_cgi_hdr_state hdr_state; /**\u003c track where we are in cgi headers */\n\tint len; /**\u003c length */\n};\n\n#ifdef LWS_WITH_CGI\n/**\n * lws_cgi: spawn network-connected cgi process\n *\n * \u005cparam wsi: connection to own the process\n * \u005cparam exec_array: array of \u0022exec-name\u0022 \u0022arg1\u0022 ... \u0022argn\u0022 NULL\n * \u005cparam script_uri_path_len: how many chars on the left of the uri are the\n * path to the cgi, or -1 to spawn without URL-related env vars\n * \u005cparam timeout_secs: seconds script should be allowed to run\n * \u005cparam mp_cgienv: pvo list with per-vhost cgi options to put in env\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_cgi(struct lws *wsi, const char * const *exec_array,\n\tint script_uri_path_len, int timeout_secs,\n\tconst struct lws_protocol_vhost_options *mp_cgienv);\n\n/**\n * lws_cgi_write_split_stdout_headers: write cgi output accounting for header part\n *\n * \u005cparam wsi: connection to own the process\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_cgi_write_split_stdout_headers(struct lws *wsi);\n\n/**\n * lws_cgi_kill: terminate cgi process associated with wsi\n *\n * \u005cparam wsi: connection to own the process\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_cgi_kill(struct lws *wsi);\n\n/**\n * lws_cgi_get_stdwsi: get wsi for stdin, stdout, or stderr\n *\n * \u005cparam wsi: parent wsi that has cgi\n * \u005cparam ch: which of LWS_STDIN, LWS_STDOUT or LWS_STDERR\n */\nLWS_VISIBLE LWS_EXTERN struct lws *\nlws_cgi_get_stdwsi(struct lws *wsi, enum lws_enum_stdinouterr ch);\n\n#endif\n///@}\n\n\n/*! \u005cdefgroup fops file operation wrapping\n *\n * ##File operation wrapping\n *\n * Use these helper functions if you want to access a file from the perspective\n * of a specific wsi, which is usually the case. If you just want contextless\n * file access, use the fops callbacks directly with NULL wsi instead of these\n * helpers.\n *\n * If so, then it calls the platform handler or user overrides where present\n * (as defined in info-\u003efops)\n *\n * The advantage from all this is user code can be portable for file operations\n * without having to deal with differences between platforms.\n */\n//@{\n\n/** struct lws_plat_file_ops - Platform-specific file operations\n *\n * These provide platform-agnostic ways to deal with filesystem access in the\n * library and in the user code.\n */\n\n#if defined(LWS_WITH_ESP32)\n/* sdk preprocessor defs? compiler issue? gets confused with member names */\n#define LWS_FOP_OPEN\t\t_open\n#define LWS_FOP_CLOSE\t\t_close\n#define LWS_FOP_SEEK_CUR\t_seek_cur\n#define LWS_FOP_READ\t\t_read\n#define LWS_FOP_WRITE\t\t_write\n#else\n#define LWS_FOP_OPEN\t\topen\n#define LWS_FOP_CLOSE\t\tclose\n#define LWS_FOP_SEEK_CUR\tseek_cur\n#define LWS_FOP_READ\t\tread\n#define LWS_FOP_WRITE\t\twrite\n#endif\n\n#define LWS_FOP_FLAGS_MASK\t\t ((1 \u003c\u003c 23) - 1)\n#define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP (1 \u003c\u003c 24)\n#define LWS_FOP_FLAG_COMPR_IS_GZIP\t (1 \u003c\u003c 25)\n#define LWS_FOP_FLAG_MOD_TIME_VALID\t (1 \u003c\u003c 26)\n#define LWS_FOP_FLAG_VIRTUAL\t\t (1 \u003c\u003c 27)\n\nstruct lws_plat_file_ops;\n\nstruct lws_fop_fd {\n\tlws_filefd_type\t\t\tfd;\n\t/**\u003c real file descriptor related to the file... */\n\tconst struct lws_plat_file_ops\t*fops;\n\t/**\u003c fops that apply to this fop_fd */\n\tvoid\t\t\t\t*filesystem_priv;\n\t/**\u003c ignored by lws; owned by the fops handlers */\n\tlws_filepos_t\t\t\tpos;\n\t/**\u003c generic \u0022position in file\u0022 */\n\tlws_filepos_t\t\t\tlen;\n\t/**\u003c generic \u0022length of file\u0022 */\n\tlws_fop_flags_t\t\t\tflags;\n\t/**\u003c copy of the returned flags */\n\tuint32_t\t\t\tmod_time;\n\t/**\u003c optional \u0022modification time of file\u0022, only valid if .open()\n\t * set the LWS_FOP_FLAG_MOD_TIME_VALID flag */\n};\ntypedef struct lws_fop_fd *lws_fop_fd_t;\n\nstruct lws_fops_index {\n\tconst char *sig;\t/* NULL or vfs signature, eg, \u0022.zip/\u0022 */\n\tuint8_t len;\t\t/* length of above string */\n};\n\nstruct lws_plat_file_ops {\n\tlws_fop_fd_t (*LWS_FOP_OPEN)(const struct lws_plat_file_ops *fops,\n\t\t\t\t const char *filename, const char *vpath,\n\t\t\t\t lws_fop_flags_t *flags);\n\t/**\u003c Open file (always binary access if plat supports it)\n\t * vpath may be NULL, or if the fops understands it, the point at which\n\t * the filename's virtual part starts.\n\t * *flags \u0026 LWS_FOP_FLAGS_MASK should be set to O_RDONLY or O_RDWR.\n\t * If the file may be gzip-compressed,\n\t * LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP is set. If it actually is\n\t * gzip-compressed, then the open handler should OR\n\t * LWS_FOP_FLAG_COMPR_IS_GZIP on to *flags before returning.\n\t */\n\tint (*LWS_FOP_CLOSE)(lws_fop_fd_t *fop_fd);\n\t/**\u003c close file AND set the pointer to NULL */\n\tlws_fileofs_t (*LWS_FOP_SEEK_CUR)(lws_fop_fd_t fop_fd,\n\t\t\t\t\t lws_fileofs_t offset_from_cur_pos);\n\t/**\u003c seek from current position */\n\tint (*LWS_FOP_READ)(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t\t uint8_t *buf, lws_filepos_t len);\n\t/**\u003c Read from file, on exit *amount is set to amount actually read */\n\tint (*LWS_FOP_WRITE)(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t\t uint8_t *buf, lws_filepos_t len);\n\t/**\u003c Write to file, on exit *amount is set to amount actually written */\n\n\tstruct lws_fops_index fi[3];\n\t/**\u003c vfs path signatures implying use of this fops */\n\n\tconst struct lws_plat_file_ops *next;\n\t/**\u003c NULL or next fops in list */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n};\n\n/**\n * lws_get_fops() - get current file ops\n *\n * \u005cparam context: context\n */\nLWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops * LWS_WARN_UNUSED_RESULT\nlws_get_fops(struct lws_context *context);\nLWS_VISIBLE LWS_EXTERN void\nlws_set_fops(struct lws_context *context, const struct lws_plat_file_ops *fops);\n/**\n * lws_vfs_tell() - get current file position\n *\n * \u005cparam fop_fd: fop_fd we are asking about\n */\nLWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT\nlws_vfs_tell(lws_fop_fd_t fop_fd);\n/**\n * lws_vfs_get_length() - get current file total length in bytes\n *\n * \u005cparam fop_fd: fop_fd we are asking about\n */\nLWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT\nlws_vfs_get_length(lws_fop_fd_t fop_fd);\n/**\n * lws_vfs_get_mod_time() - get time file last modified\n *\n * \u005cparam fop_fd: fop_fd we are asking about\n */\nLWS_VISIBLE LWS_EXTERN uint32_t LWS_WARN_UNUSED_RESULT\nlws_vfs_get_mod_time(lws_fop_fd_t fop_fd);\n/**\n * lws_vfs_file_seek_set() - seek relative to start of file\n *\n * \u005cparam fop_fd: fop_fd we are seeking in\n * \u005cparam offset: offset from start of file\n */\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\nlws_vfs_file_seek_set(lws_fop_fd_t fop_fd, lws_fileofs_t offset);\n/**\n * lws_vfs_file_seek_end() - seek relative to end of file\n *\n * \u005cparam fop_fd: fop_fd we are seeking in\n * \u005cparam offset: offset from start of file\n */\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\nlws_vfs_file_seek_end(lws_fop_fd_t fop_fd, lws_fileofs_t offset);\n\nextern struct lws_plat_file_ops fops_zip;\n\n/**\n * lws_plat_file_open() - open vfs filepath\n *\n * \u005cparam fops: file ops struct that applies to this descriptor\n * \u005cparam vfs_path: filename to open\n * \u005cparam flags: pointer to open flags\n *\n * The vfs_path is scanned for known fops signatures, and the open directed\n * to any matching fops open.\n *\n * User code should use this api to perform vfs opens.\n *\n * returns semi-opaque handle\n */\nLWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT\nlws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_path,\n\t\t lws_fop_flags_t *flags);\n\n/**\n * lws_plat_file_close() - close file\n *\n * \u005cparam fop_fd: file handle to close\n */\nstatic LWS_INLINE int\nlws_vfs_file_close(lws_fop_fd_t *fop_fd)\n{\n\treturn (*fop_fd)-\u003efops-\u003eLWS_FOP_CLOSE(fop_fd);\n}\n\n/**\n * lws_plat_file_seek_cur() - close file\n *\n *\n * \u005cparam fop_fd: file handle\n * \u005cparam offset: position to seek to\n */\nstatic LWS_INLINE lws_fileofs_t\nlws_vfs_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset)\n{\n\treturn fop_fd-\u003efops-\u003eLWS_FOP_SEEK_CUR(fop_fd, offset);\n}\n/**\n * lws_plat_file_read() - read from file\n *\n * \u005cparam fop_fd: file handle\n * \u005cparam amount: how much to read (rewritten by call)\n * \u005cparam buf: buffer to write to\n * \u005cparam len: max length\n */\nstatic LWS_INLINE int LWS_WARN_UNUSED_RESULT\nlws_vfs_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len)\n{\n\treturn fop_fd-\u003efops-\u003eLWS_FOP_READ(fop_fd, amount, buf, len);\n}\n/**\n * lws_plat_file_write() - write from file\n *\n * \u005cparam fop_fd: file handle\n * \u005cparam amount: how much to write (rewritten by call)\n * \u005cparam buf: buffer to read from\n * \u005cparam len: max length\n */\nstatic LWS_INLINE int LWS_WARN_UNUSED_RESULT\nlws_vfs_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len)\n{\n\treturn fop_fd-\u003efops-\u003eLWS_FOP_WRITE(fop_fd, amount, buf, len);\n}\n\n/* these are the platform file operations implementations... they can\n * be called directly and used in fops arrays\n */\n\nLWS_VISIBLE LWS_EXTERN lws_fop_fd_t\n_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,\n\t\t const char *vpath, lws_fop_flags_t *flags);\nLWS_VISIBLE LWS_EXTERN int\n_lws_plat_file_close(lws_fop_fd_t *fop_fd);\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\n_lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset);\nLWS_VISIBLE LWS_EXTERN int\n_lws_plat_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len);\nLWS_VISIBLE LWS_EXTERN int\n_lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_alloc_vfs_file(struct lws_context *context, const char *filename,\n\t\t uint8_t **buf, lws_filepos_t *amount);\n//@}\n\n/** \u005cdefgroup smtp SMTP related functions\n * ##SMTP related functions\n * \u005cingroup lwsapi\n *\n * These apis let you communicate with a local SMTP server to send email from\n * lws. It handles all the SMTP sequencing and protocol actions.\n *\n * Your system should have postfix, sendmail or another MTA listening on port\n * 25 and able to send email using the \u0022mail\u0022 commandline app. Usually distro\n * MTAs are configured for this by default.\n *\n * It runs via its own libuv events if initialized (which requires giving it\n * a libuv loop to attach to).\n *\n * It operates using three callbacks, on_next() queries if there is a new email\n * to send, on_get_body() asks for the body of the email, and on_sent() is\n * called after the email is successfully sent.\n *\n * To use it\n *\n * - create an lws_email struct\n *\n * - initialize data, loop, the email_* strings, max_content_size and\n * the callbacks\n *\n * - call lws_email_init()\n *\n * When you have at least one email to send, call lws_email_check() to\n * schedule starting to send it.\n */\n//@{\n#ifdef LWS_WITH_SMTP\n\n/** enum lwsgs_smtp_states - where we are in SMTP protocol sequence */\nenum lwsgs_smtp_states {\n\tLGSSMTP_IDLE, /**\u003c awaiting new email */\n\tLGSSMTP_CONNECTING, /**\u003c opening tcp connection to MTA */\n\tLGSSMTP_CONNECTED, /**\u003c tcp connection to MTA is connected */\n\tLGSSMTP_SENT_HELO, /**\u003c sent the HELO */\n\tLGSSMTP_SENT_FROM, /**\u003c sent FROM */\n\tLGSSMTP_SENT_TO, /**\u003c sent TO */\n\tLGSSMTP_SENT_DATA, /**\u003c sent DATA request */\n\tLGSSMTP_SENT_BODY, /**\u003c sent the email body */\n\tLGSSMTP_SENT_QUIT, /**\u003c sent the session quit */\n};\n\n/** struct lws_email - abstract context for performing SMTP operations */\nstruct lws_email {\n\tvoid *data;\n\t/**\u003c opaque pointer set by user code and available to the callbacks */\n\tuv_loop_t *loop;\n\t/**\u003c the libuv loop we will work on */\n\n\tchar email_smtp_ip[32]; /**\u003c Fill before init, eg, \u0022127.0.0.1\u0022 */\n\tchar email_helo[32];\t/**\u003c Fill before init, eg, \u0022myserver.com\u0022 */\n\tchar email_from[100];\t/**\u003c Fill before init or on_next */\n\tchar email_to[100];\t/**\u003c Fill before init or on_next */\n\n\tunsigned int max_content_size;\n\t/**\u003c largest possible email body size */\n\n\t/* Fill all the callbacks before init */\n\n\tint (*on_next)(struct lws_email *email);\n\t/**\u003c (Fill in before calling lws_email_init)\n\t * called when idle, 0 \u003d another email to send, nonzero is idle.\n\t * If you return 0, all of the email_* char arrays must be set\n\t * to something useful. */\n\tint (*on_sent)(struct lws_email *email);\n\t/**\u003c (Fill in before calling lws_email_init)\n\t * called when transfer of the email to the SMTP server was\n\t * successful, your callback would remove the current email\n\t * from its queue */\n\tint (*on_get_body)(struct lws_email *email, char *buf, int len);\n\t/**\u003c (Fill in before calling lws_email_init)\n\t * called when the body part of the queued email is about to be\n\t * sent to the SMTP server. */\n\n\n\t/* private things */\n\tuv_timer_t timeout_email; /**\u003c private */\n\tenum lwsgs_smtp_states estate; /**\u003c private */\n\tuv_connect_t email_connect_req; /**\u003c private */\n\tuv_tcp_t email_client; /**\u003c private */\n\ttime_t email_connect_started; /**\u003c private */\n\tchar email_buf[256]; /**\u003c private */\n\tchar *content; /**\u003c private */\n};\n\n/**\n * lws_email_init() - Initialize a struct lws_email\n *\n * \u005cparam email: struct lws_email to init\n * \u005cparam loop: libuv loop to use\n * \u005cparam max_content: max email content size\n *\n * Prepares a struct lws_email for use ending SMTP\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_email_init(struct lws_email *email, uv_loop_t *loop, int max_content);\n\n/**\n * lws_email_check() - Request check for new email\n *\n * \u005cparam email: struct lws_email context to check\n *\n * Schedules a check for new emails in 1s... call this when you have queued an\n * email for send.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_email_check(struct lws_email *email);\n/**\n * lws_email_destroy() - stop using the struct lws_email\n *\n * \u005cparam email: the struct lws_email context\n *\n * Stop sending email using email and free allocations\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_email_destroy(struct lws_email *email);\n\n#endif\n//@}\n\n\n/** \u005cdefgroup lejp JSON parser\n * ##JSON parsing related functions\n * \u005cingroup lwsapi\n *\n * LEJP is an extremely lightweight JSON stream parser included in lws.\n */\n//@{\nstruct lejp_ctx;\n\n#define LWS_ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0]))\n#define LEJP_FLAG_WS_KEEP 64\n#define LEJP_FLAG_WS_COMMENTLINE 32\n\nenum lejp_states {\n\tLEJP_IDLE \u003d 0,\n\tLEJP_MEMBERS \u003d 1,\n\tLEJP_M_P \u003d 2,\n\tLEJP_MP_STRING \u003d LEJP_FLAG_WS_KEEP | 3,\n\tLEJP_MP_STRING_ESC \u003d LEJP_FLAG_WS_KEEP | 4,\n\tLEJP_MP_STRING_ESC_U1 \u003d LEJP_FLAG_WS_KEEP | 5,\n\tLEJP_MP_STRING_ESC_U2 \u003d LEJP_FLAG_WS_KEEP | 6,\n\tLEJP_MP_STRING_ESC_U3 \u003d LEJP_FLAG_WS_KEEP | 7,\n\tLEJP_MP_STRING_ESC_U4 \u003d LEJP_FLAG_WS_KEEP | 8,\n\tLEJP_MP_DELIM \u003d 9,\n\tLEJP_MP_VALUE \u003d 10,\n\tLEJP_MP_VALUE_NUM_INT \u003d LEJP_FLAG_WS_KEEP | 11,\n\tLEJP_MP_VALUE_NUM_EXP \u003d LEJP_FLAG_WS_KEEP | 12,\n\tLEJP_MP_VALUE_TOK \u003d LEJP_FLAG_WS_KEEP | 13,\n\tLEJP_MP_COMMA_OR_END \u003d 14,\n\tLEJP_MP_ARRAY_END \u003d 15,\n};\n\nenum lejp_reasons {\n\tLEJP_CONTINUE \u003d -1,\n\tLEJP_REJECT_IDLE_NO_BRACE \u003d -2,\n\tLEJP_REJECT_MEMBERS_NO_CLOSE \u003d -3,\n\tLEJP_REJECT_MP_NO_OPEN_QUOTE \u003d -4,\n\tLEJP_REJECT_MP_STRING_UNDERRUN \u003d -5,\n\tLEJP_REJECT_MP_ILLEGAL_CTRL \u003d -6,\n\tLEJP_REJECT_MP_STRING_ESC_ILLEGAL_ESC \u003d -7,\n\tLEJP_REJECT_ILLEGAL_HEX \u003d -8,\n\tLEJP_REJECT_MP_DELIM_MISSING_COLON \u003d -9,\n\tLEJP_REJECT_MP_DELIM_BAD_VALUE_START \u003d -10,\n\tLEJP_REJECT_MP_VAL_NUM_INT_NO_FRAC \u003d -11,\n\tLEJP_REJECT_MP_VAL_NUM_FORMAT \u003d -12,\n\tLEJP_REJECT_MP_VAL_NUM_EXP_BAD_EXP \u003d -13,\n\tLEJP_REJECT_MP_VAL_TOK_UNKNOWN \u003d -14,\n\tLEJP_REJECT_MP_C_OR_E_UNDERF \u003d -15,\n\tLEJP_REJECT_MP_C_OR_E_NOTARRAY \u003d -16,\n\tLEJP_REJECT_MP_ARRAY_END_MISSING \u003d -17,\n\tLEJP_REJECT_STACK_OVERFLOW \u003d -18,\n\tLEJP_REJECT_MP_DELIM_ISTACK \u003d -19,\n\tLEJP_REJECT_NUM_TOO_LONG \u003d -20,\n\tLEJP_REJECT_MP_C_OR_E_NEITHER \u003d -21,\n\tLEJP_REJECT_UNKNOWN \u003d -22,\n\tLEJP_REJECT_CALLBACK \u003d -23\n};\n\n#define LEJP_FLAG_CB_IS_VALUE 64\n\nenum lejp_callbacks {\n\tLEJPCB_CONSTRUCTED\t\u003d 0,\n\tLEJPCB_DESTRUCTED\t\u003d 1,\n\n\tLEJPCB_START\t\t\u003d 2,\n\tLEJPCB_COMPLETE\t\t\u003d 3,\n\tLEJPCB_FAILED\t\t\u003d 4,\n\n\tLEJPCB_PAIR_NAME\t\u003d 5,\n\n\tLEJPCB_VAL_TRUE\t\t\u003d LEJP_FLAG_CB_IS_VALUE | 6,\n\tLEJPCB_VAL_FALSE\t\u003d LEJP_FLAG_CB_IS_VALUE | 7,\n\tLEJPCB_VAL_NULL\t\t\u003d LEJP_FLAG_CB_IS_VALUE | 8,\n\tLEJPCB_VAL_NUM_INT\t\u003d LEJP_FLAG_CB_IS_VALUE | 9,\n\tLEJPCB_VAL_NUM_FLOAT\t\u003d LEJP_FLAG_CB_IS_VALUE | 10,\n\tLEJPCB_VAL_STR_START\t\u003d 11, /* notice handle separately */\n\tLEJPCB_VAL_STR_CHUNK\t\u003d LEJP_FLAG_CB_IS_VALUE | 12,\n\tLEJPCB_VAL_STR_END\t\u003d LEJP_FLAG_CB_IS_VALUE | 13,\n\n\tLEJPCB_ARRAY_START\t\u003d 14,\n\tLEJPCB_ARRAY_END\t\u003d 15,\n\n\tLEJPCB_OBJECT_START\t\u003d 16,\n\tLEJPCB_OBJECT_END\t\u003d 17\n};\n\n/**\n * _lejp_callback() - User parser actions\n * \u005cparam ctx:\tLEJP context\n * \u005cparam reason:\tCallback reason\n *\n *\tYour user callback is associated with the context at construction time,\n *\tand receives calls as the parsing progresses.\n *\n *\tAll of the callbacks may be ignored and just return 0.\n *\n *\tThe reasons it might get called, found in @reason, are:\n *\n * LEJPCB_CONSTRUCTED: The context was just constructed... you might want to\n *\t\tperform one-time allocation for the life of the context.\n *\n * LEJPCB_DESTRUCTED:\tThe context is being destructed... if you made any\n *\t\tallocations at construction-time, you can free them now\n *\n * LEJPCB_START:\tParsing is beginning at the first byte of input\n *\n * LEJPCB_COMPLETE:\tParsing has completed successfully. You'll get a 0 or\n *\t\t\tpositive return code from lejp_parse indicating the\n *\t\t\tamount of unused bytes left in the input buffer\n *\n * LEJPCB_FAILED:\tParsing failed. You'll get a negative error code\n * \t\t\treturned from lejp_parse\n *\n * LEJPCB_PAIR_NAME:\tWhen a \u0022name\u0022:\u0022value\u0022 pair has had the name parsed,\n *\t\t\tthis callback occurs. You can find the new name at\n *\t\t\tthe end of ctx-\u003epath[]\n *\n * LEJPCB_VAL_TRUE:\tThe \u0022true\u0022 value appeared\n *\n * LEJPCB_VAL_FALSE:\tThe \u0022false\u0022 value appeared\n *\n * LEJPCB_VAL_NULL:\tThe \u0022null\u0022 value appeared\n *\n * LEJPCB_VAL_NUM_INT:\tA string representing an integer is in ctx-\u003ebuf\n *\n * LEJPCB_VAL_NUM_FLOAT: A string representing a float is in ctx-\u003ebuf\n *\n * LEJPCB_VAL_STR_START: We are starting to parse a string, no data yet\n *\n * LEJPCB_VAL_STR_CHUNK: We parsed LEJP_STRING_CHUNK -1 bytes of string data in\n *\t\t\tctx-\u003ebuf, which is as much as we can buffer, so we are\n *\t\t\tspilling it. If all your strings are less than\n *\t\t\tLEJP_STRING_CHUNK - 1 bytes, you will never see this\n *\t\t\tcallback.\n *\n * LEJPCB_VAL_STR_END:\tString parsing has completed, the last chunk of the\n *\t\t\tstring is in ctx-\u003ebuf.\n *\n * LEJPCB_ARRAY_START:\tAn array started\n *\n * LEJPCB_ARRAY_END:\tAn array ended\n *\n * LEJPCB_OBJECT_START: An object started\n *\n * LEJPCB_OBJECT_END:\tAn object ended\n */\nLWS_EXTERN signed char _lejp_callback(struct lejp_ctx *ctx, char reason);\n\ntypedef signed char (*lejp_callback)(struct lejp_ctx *ctx, char reason);\n\n#ifndef LEJP_MAX_DEPTH\n#define LEJP_MAX_DEPTH 12\n#endif\n#ifndef LEJP_MAX_INDEX_DEPTH\n#define LEJP_MAX_INDEX_DEPTH 5\n#endif\n#ifndef LEJP_MAX_PATH\n#define LEJP_MAX_PATH 128\n#endif\n#ifndef LEJP_STRING_CHUNK\n/* must be \u003e\u003d 30 to assemble floats */\n#define LEJP_STRING_CHUNK 254\n#endif\n\nenum num_flags {\n\tLEJP_SEEN_MINUS \u003d (1 \u003c\u003c 0),\n\tLEJP_SEEN_POINT \u003d (1 \u003c\u003c 1),\n\tLEJP_SEEN_POST_POINT \u003d (1 \u003c\u003c 2),\n\tLEJP_SEEN_EXP \u003d (1 \u003c\u003c 3)\n};\n\nstruct _lejp_stack {\n\tchar s; /* lejp_state stack*/\n\tchar p;\t/* path length */\n\tchar i; /* index array length */\n\tchar b; /* user bitfield */\n};\n\nstruct lejp_ctx {\n\n\t/* sorted by type for most compact alignment\n\t *\n\t * pointers\n\t */\n\n\tsigned char (*callback)(struct lejp_ctx *ctx, char reason);\n\tvoid *user;\n\tconst char * const *paths;\n\n\t/* arrays */\n\n\tstruct _lejp_stack st[LEJP_MAX_DEPTH];\n\tuint16_t i[LEJP_MAX_INDEX_DEPTH]; /* index array */\n\tuint16_t wild[LEJP_MAX_INDEX_DEPTH]; /* index array */\n\tchar path[LEJP_MAX_PATH];\n\tchar buf[LEJP_STRING_CHUNK + 1];\n\n\t/* int */\n\n\tuint32_t line;\n\n\t/* short */\n\n\tuint16_t uni;\n\n\t/* char */\n\n\tuint8_t npos;\n\tuint8_t dcount;\n\tuint8_t f;\n\tuint8_t sp; /* stack head */\n\tuint8_t ipos; /* index stack depth */\n\tuint8_t ppos;\n\tuint8_t count_paths;\n\tuint8_t path_match;\n\tuint8_t path_match_len;\n\tuint8_t wildcount;\n};\n\nLWS_VISIBLE LWS_EXTERN void\nlejp_construct(struct lejp_ctx *ctx,\n\t signed char (*callback)(struct lejp_ctx *ctx, char reason),\n\t void *user, const char * const *paths, unsigned char paths_count);\n\nLWS_VISIBLE LWS_EXTERN void\nlejp_destruct(struct lejp_ctx *ctx);\n\nLWS_VISIBLE LWS_EXTERN int\nlejp_parse(struct lejp_ctx *ctx, const unsigned char *json, int len);\n\nLWS_VISIBLE LWS_EXTERN void\nlejp_change_callback(struct lejp_ctx *ctx,\n\t\t signed char (*callback)(struct lejp_ctx *ctx, char reason));\n\nLWS_VISIBLE LWS_EXTERN int\nlejp_get_wildcard(struct lejp_ctx *ctx, int wildcard, char *dest, int len);\n//@}\n\n/*\n * Stats are all uint64_t numbers that start at 0.\n * Index names here have the convention\n *\n * _C_ counter\n * _B_ byte count\n * _MS_ millisecond count\n */\n\nenum {\n\tLWSSTATS_C_CONNECTIONS, /**\u003c count incoming connections */\n\tLWSSTATS_C_API_CLOSE, /**\u003c count calls to close api */\n\tLWSSTATS_C_API_READ, /**\u003c count calls to read from socket api */\n\tLWSSTATS_C_API_LWS_WRITE, /**\u003c count calls to lws_write API */\n\tLWSSTATS_C_API_WRITE, /**\u003c count calls to write API */\n\tLWSSTATS_C_WRITE_PARTIALS, /**\u003c count of partial writes */\n\tLWSSTATS_C_WRITEABLE_CB_REQ, /**\u003c count of writable callback requests */\n\tLWSSTATS_C_WRITEABLE_CB_EFF_REQ, /**\u003c count of effective writable callback requests */\n\tLWSSTATS_C_WRITEABLE_CB, /**\u003c count of writable callbacks */\n\tLWSSTATS_C_SSL_CONNECTIONS_FAILED, /**\u003c count of failed SSL connections */\n\tLWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, /**\u003c count of accepted SSL connections */\n\tLWSSTATS_C_SSL_CONNECTIONS_ACCEPT_SPIN, /**\u003c count of SSL_accept() attempts */\n\tLWSSTATS_C_SSL_CONNS_HAD_RX, /**\u003c count of accepted SSL conns that have had some RX */\n\tLWSSTATS_C_TIMEOUTS, /**\u003c count of timed-out connections */\n\tLWSSTATS_C_SERVICE_ENTRY, /**\u003c count of entries to lws service loop */\n\tLWSSTATS_B_READ, /**\u003c aggregate bytes read */\n\tLWSSTATS_B_WRITE, /**\u003c aggregate bytes written */\n\tLWSSTATS_B_PARTIALS_ACCEPTED_PARTS, /**\u003c aggreate of size of accepted write data from new partials */\n\tLWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY, /**\u003c aggregate delay in accepting connection */\n\tLWSSTATS_MS_WRITABLE_DELAY, /**\u003c aggregate delay between asking for writable and getting cb */\n\tLWSSTATS_MS_WORST_WRITABLE_DELAY, /**\u003c single worst delay between asking for writable and getting cb */\n\tLWSSTATS_MS_SSL_RX_DELAY, /**\u003c aggregate delay between ssl accept complete and first RX */\n\tLWSSTATS_C_PEER_LIMIT_AH_DENIED, /**\u003c number of times we would have given an ah but for the peer limit */\n\tLWSSTATS_C_PEER_LIMIT_WSI_DENIED, /**\u003c number of times we would have given a wsi but for the peer limit */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n\tLWSSTATS_SIZE\n};\n\n#if defined(LWS_WITH_STATS)\n\nLWS_VISIBLE LWS_EXTERN uint64_t\nlws_stats_get(struct lws_context *context, int index);\nLWS_VISIBLE LWS_EXTERN void\nlws_stats_log_dump(struct lws_context *context);\n#else\nstatic LWS_INLINE uint64_t\nlws_stats_get(struct lws_context *context, int index) { (void)context; (void)index; return 0; }\nstatic LWS_INLINE void\nlws_stats_log_dump(struct lws_context *context) { (void)context; }\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n","s":{"c":1571481737,"u": 5840}} ],"g": 258305,"chitpc": 0,"ehitpc": 0, "indexed":0 }