mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
add toString function for lws reasons (for debugging and logging purposes)
This commit is contained in:
parent
77810168e0
commit
8841ac40f8
@ -8,6 +8,7 @@ add_library(webfuse-core STATIC
|
||||
lib/webfuse/core/string.c
|
||||
lib/webfuse/core/base64.c
|
||||
lib/webfuse/core/lws_log.c
|
||||
lib/webfuse/core/lws_utils.c
|
||||
)
|
||||
|
||||
set_target_properties(webfuse-core PROPERTIES OUTPUT_NAME webfuse-core)
|
||||
|
210
lib/webfuse/core/lws_utils.c
Normal file
210
lib/webfuse/core/lws_utils.c
Normal file
@ -0,0 +1,210 @@
|
||||
#include "webfuse/core/lws_utils.h"
|
||||
|
||||
extern char const *
|
||||
wf_lws_reason_tostring(
|
||||
enum lws_callback_reasons reason)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case LWS_CALLBACK_PROTOCOL_INIT:
|
||||
return "protocol_init";
|
||||
case LWS_CALLBACK_PROTOCOL_DESTROY:
|
||||
return "protcol_destory";
|
||||
case LWS_CALLBACK_WSI_CREATE:
|
||||
return "wsi_create";
|
||||
case LWS_CALLBACK_WSI_DESTROY:
|
||||
return "wsi_destroy";
|
||||
case LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS:
|
||||
return "openssl_load_extra_client_verify_certs";
|
||||
case LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS:
|
||||
return "openssl_load_extra_server_verify_certs";
|
||||
case LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION:
|
||||
return "openssl_perform_client_cert_verification";
|
||||
case LWS_CALLBACK_OPENSSL_PERFORM_SERVER_CERT_VERIFICATION:
|
||||
return "openssl_perform_server_cert_verification";
|
||||
case LWS_CALLBACK_OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY:
|
||||
return "openssl_context_required_private_key";
|
||||
case LWS_CALLBACK_SSL_INFO:
|
||||
return "ssl_info";
|
||||
case LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED:
|
||||
return "server_new_client_instantiated";
|
||||
case LWS_CALLBACK_HTTP:
|
||||
return "http";
|
||||
case LWS_CALLBACK_HTTP_BODY:
|
||||
return "http_body";
|
||||
case LWS_CALLBACK_HTTP_BODY_COMPLETION:
|
||||
return "http_body_completion";
|
||||
case LWS_CALLBACK_HTTP_FILE_COMPLETION:
|
||||
return "http_file_completion";
|
||||
case LWS_CALLBACK_HTTP_WRITEABLE:
|
||||
return "http_writeable";
|
||||
case LWS_CALLBACK_CLOSED_HTTP:
|
||||
return "closed_http";
|
||||
case LWS_CALLBACK_FILTER_HTTP_CONNECTION:
|
||||
return "filter_http_connection";
|
||||
case LWS_CALLBACK_ADD_HEADERS:
|
||||
return "add_headers";
|
||||
case LWS_CALLBACK_CHECK_ACCESS_RIGHTS:
|
||||
return "check_access_rights";
|
||||
case LWS_CALLBACK_PROCESS_HTML:
|
||||
return "process_html";
|
||||
case LWS_CALLBACK_HTTP_BIND_PROTOCOL:
|
||||
return "http_bind_protocol";
|
||||
case LWS_CALLBACK_HTTP_DROP_PROTOCOL:
|
||||
return "http_drop_protocol";
|
||||
case LWS_CALLBACK_HTTP_CONFIRM_UPGRADE:
|
||||
return "http_confirm_upgrade";
|
||||
case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP:
|
||||
return "established_client_http";
|
||||
case LWS_CALLBACK_CLOSED_CLIENT_HTTP:
|
||||
return "closed_http_client";
|
||||
case LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ:
|
||||
return "receive_client_http_read";
|
||||
case LWS_CALLBACK_COMPLETED_CLIENT_HTTP:
|
||||
return "completed_client_http";
|
||||
case LWS_CALLBACK_CLIENT_HTTP_WRITEABLE:
|
||||
return "client_http_writeable";
|
||||
case LWS_CALLBACK_CLIENT_HTTP_BIND_PROTOCOL:
|
||||
return "client_http_bind_protocol";
|
||||
case LWS_CALLBACK_CLIENT_HTTP_DROP_PROTOCOL:
|
||||
return "client_http_drop_protocol";
|
||||
case LWS_CALLBACK_ESTABLISHED:
|
||||
return "established";
|
||||
case LWS_CALLBACK_CLOSED:
|
||||
return "closed";
|
||||
case LWS_CALLBACK_SERVER_WRITEABLE:
|
||||
return "server_writeable";
|
||||
case LWS_CALLBACK_RECEIVE:
|
||||
return "receive";
|
||||
case LWS_CALLBACK_RECEIVE_PONG:
|
||||
return "receive_pong";
|
||||
case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
|
||||
return "ws_peer_initiated_close";
|
||||
case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
|
||||
return "filter_protocol_connection";
|
||||
case LWS_CALLBACK_CONFIRM_EXTENSION_OKAY:
|
||||
return "confirm_extension_okay";
|
||||
case LWS_CALLBACK_WS_SERVER_BIND_PROTOCOL:
|
||||
return "ws_server_bind_protocol";
|
||||
case LWS_CALLBACK_WS_SERVER_DROP_PROTOCOL:
|
||||
return "ws_server_drop_protocol";
|
||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
||||
return "client_connection_error";
|
||||
case LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH:
|
||||
return "client_filter_pre_establish";
|
||||
case LWS_CALLBACK_CLIENT_ESTABLISHED:
|
||||
return "client_established";
|
||||
case LWS_CALLBACK_CLIENT_CLOSED:
|
||||
return "client_closed";
|
||||
case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
|
||||
return "client_append_handshake_header";
|
||||
case LWS_CALLBACK_CLIENT_RECEIVE:
|
||||
return "client_receive";
|
||||
case LWS_CALLBACK_CLIENT_RECEIVE_PONG:
|
||||
return "client_receive_pong";
|
||||
case LWS_CALLBACK_CLIENT_WRITEABLE:
|
||||
return "client_writeable";
|
||||
case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
|
||||
return "client_confirm_extension_supported";
|
||||
case LWS_CALLBACK_WS_EXT_DEFAULTS:
|
||||
return "ws_ext_defaults";
|
||||
case LWS_CALLBACK_FILTER_NETWORK_CONNECTION:
|
||||
return "filter_network_connection";
|
||||
case LWS_CALLBACK_WS_CLIENT_BIND_PROTOCOL:
|
||||
return "ws_client_bind_protocol";
|
||||
case LWS_CALLBACK_WS_CLIENT_DROP_PROTOCOL:
|
||||
return "ws_client_drop_protocol";
|
||||
case LWS_CALLBACK_GET_THREAD_ID:
|
||||
return "get_thread_id";
|
||||
case LWS_CALLBACK_ADD_POLL_FD:
|
||||
return "add_poll_fd";
|
||||
case LWS_CALLBACK_DEL_POLL_FD:
|
||||
return "del_poll_fd";
|
||||
case LWS_CALLBACK_CHANGE_MODE_POLL_FD:
|
||||
return "change_mode_poll_fd";
|
||||
case LWS_CALLBACK_LOCK_POLL:
|
||||
return "lock_poll";
|
||||
case LWS_CALLBACK_UNLOCK_POLL:
|
||||
return "unlock_poll";
|
||||
case LWS_CALLBACK_CGI:
|
||||
return "cgi";
|
||||
case LWS_CALLBACK_CGI_TERMINATED:
|
||||
return "cgi_terminated";
|
||||
case LWS_CALLBACK_CGI_STDIN_DATA:
|
||||
return "cgi_stdin_data";
|
||||
case LWS_CALLBACK_CGI_STDIN_COMPLETED:
|
||||
return "cgi_stdin_completed";
|
||||
case LWS_CALLBACK_CGI_PROCESS_ATTACH:
|
||||
return "cgi_process_attach";
|
||||
case LWS_CALLBACK_SESSION_INFO:
|
||||
return "session_info";
|
||||
case LWS_CALLBACK_GS_EVENT:
|
||||
return "gs_event";
|
||||
case LWS_CALLBACK_HTTP_PMO:
|
||||
return "http_pmo";
|
||||
case LWS_CALLBACK_RAW_PROXY_CLI_RX:
|
||||
return "raw_proxy_cli_rx";
|
||||
case LWS_CALLBACK_RAW_PROXY_SRV_RX:
|
||||
return "raw_proxy_srv_rx";
|
||||
case LWS_CALLBACK_RAW_PROXY_CLI_CLOSE:
|
||||
return "raw_proxy_cli_close";
|
||||
case LWS_CALLBACK_RAW_PROXY_SRV_CLOSE:
|
||||
return "raw_proxy_srv_close";
|
||||
case LWS_CALLBACK_RAW_PROXY_CLI_WRITEABLE:
|
||||
return "raw_proxy_cli_writeable";
|
||||
case LWS_CALLBACK_RAW_PROXY_SRV_WRITEABLE:
|
||||
return "raw_prxy_srv_wrtieable";
|
||||
case LWS_CALLBACK_RAW_PROXY_CLI_ADOPT:
|
||||
return "raw_proxy_cli_adopt";
|
||||
case LWS_CALLBACK_RAW_PROXY_SRV_ADOPT:
|
||||
return "raw_proxy_srv_adopt";
|
||||
case LWS_CALLBACK_RAW_PROXY_CLI_BIND_PROTOCOL:
|
||||
return "raw_proxy_cli_bind_protocol";
|
||||
case LWS_CALLBACK_RAW_PROXY_SRV_BIND_PROTOCOL:
|
||||
return "raw_proxy_srv_bind_protocol";
|
||||
case LWS_CALLBACK_RAW_PROXY_CLI_DROP_PROTOCOL:
|
||||
return "raw_proxy_cli_drop_protocol";
|
||||
case LWS_CALLBACK_RAW_PROXY_SRV_DROP_PROTOCOL:
|
||||
return "raw_proxy_srv_drop_protocol";
|
||||
case LWS_CALLBACK_RAW_RX:
|
||||
return "raw_rx";
|
||||
case LWS_CALLBACK_RAW_CLOSE:
|
||||
return "raw_close";
|
||||
case LWS_CALLBACK_RAW_WRITEABLE:
|
||||
return "raw_writeable";
|
||||
case LWS_CALLBACK_RAW_ADOPT:
|
||||
return "raw_adopt";
|
||||
case LWS_CALLBACK_RAW_CONNECTED:
|
||||
return "raw_connected";
|
||||
case LWS_CALLBACK_RAW_SKT_BIND_PROTOCOL:
|
||||
return "raw_skt_bind_protocol";
|
||||
case LWS_CALLBACK_RAW_SKT_DROP_PROTOCOL:
|
||||
return "raw_skt_drop_protocol";
|
||||
case LWS_CALLBACK_RAW_ADOPT_FILE:
|
||||
return "raw_adopt_file";
|
||||
case LWS_CALLBACK_RAW_RX_FILE:
|
||||
return "raw_rx_file";
|
||||
case LWS_CALLBACK_RAW_WRITEABLE_FILE:
|
||||
return "raw_writeable_file";
|
||||
case LWS_CALLBACK_RAW_CLOSE_FILE:
|
||||
return "raw_close_file";
|
||||
case LWS_CALLBACK_RAW_FILE_BIND_PROTOCOL:
|
||||
return "raw_file_bind_protocol";
|
||||
case LWS_CALLBACK_RAW_FILE_DROP_PROTOCOL:
|
||||
return "raw_file_drop_protocol";
|
||||
case LWS_CALLBACK_TIMER:
|
||||
return "timer";
|
||||
case LWS_CALLBACK_EVENT_WAIT_CANCELLED:
|
||||
return "event_wait_cancelled";
|
||||
case LWS_CALLBACK_CHILD_CLOSING:
|
||||
return "child_closing";
|
||||
case LWS_CALLBACK_VHOST_CERT_AGING:
|
||||
return "vhost_cert_aging";
|
||||
case LWS_CALLBACK_VHOST_CERT_UPDATE:
|
||||
return "vhost_cert_update";
|
||||
case LWS_CALLBACK_USER:
|
||||
return "user";
|
||||
default:
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
19
lib/webfuse/core/lws_utils.h
Normal file
19
lib/webfuse/core/lws_utils.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef WF_LWS_UTILS_H
|
||||
#define WF_LWS_UTILS_H
|
||||
|
||||
#include <libwebsockets.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern char const *
|
||||
wf_lws_reason_tostring(
|
||||
enum lws_callback_reasons reason);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user