diff --git a/include/libhttp.h b/include/libhttp.h index 374c28e6..024a586d 100644 --- a/include/libhttp.h +++ b/include/libhttp.h @@ -145,7 +145,7 @@ struct pollfd { #endif /* _WIN32 && ! POLLIN */ -struct httplib_context; /* Handle for the HTTP service itself */ +struct lh_ctx_t; /* Handle for the HTTP service itself */ struct httplib_connection; /* Handle for the individual connection */ @@ -192,18 +192,18 @@ struct client_cert { */ struct httplib_callbacks { - int (*begin_request)( const struct httplib_context *ctx, struct httplib_connection *conn ); - void (*end_request)( const struct httplib_context *ctx, const struct httplib_connection *conn, int reply_status_code ); - int (*log_message)( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *message ); - int (*log_access)( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *message ); - int (*init_ssl)( const struct httplib_context *ctx, void *ssl_context, void *user_data ); - void (*connection_close)( const struct httplib_context *ctx, const struct httplib_connection *conn ); - const char * (*open_file)( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, size_t *data_len ); - void (*init_lua)( const struct httplib_context *ctx, const struct httplib_connection *conn, void *lua_context ); - int (*http_error)( const struct httplib_context *ctx, struct httplib_connection *, int status); - void (*init_context)( const struct httplib_context *ctx ); - void (*init_thread)( const struct httplib_context *ctx, int thread_type ); - void (*exit_context)( const struct httplib_context *ctx ); + int (*begin_request)( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); + void (*end_request)( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, int reply_status_code ); + int (*log_message)( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *message ); + int (*log_access)( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *message ); + int (*init_ssl)( const struct lh_ctx_t *ctx, void *ssl_context, void *user_data ); + void (*connection_close)( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ); + const char * (*open_file)( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, size_t *data_len ); + void (*init_lua)( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, void *lua_context ); + int (*http_error)( const struct lh_ctx_t *ctx, struct httplib_connection *, int status); + void (*init_context)( const struct lh_ctx_t *ctx ); + void (*init_thread)( const struct lh_ctx_t *ctx, int thread_type ); + void (*exit_context)( const struct lh_ctx_t *ctx ); }; /************************************************************************************************/ @@ -214,8 +214,8 @@ struct httplib_option_t { /* */ /************************************************************************************************/ -typedef int (*httplib_request_handler)( const struct httplib_context *ctx, struct httplib_connection *conn, void *cbdata ); -typedef int (*httplib_authorization_handler)( const struct httplib_context *ctx, struct httplib_connection *conn, void *cbdata ); +typedef int (*httplib_request_handler)( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *cbdata ); +typedef int (*httplib_authorization_handler)( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *cbdata ); /* Callback types for websocket handlers in C/C++. @@ -243,10 +243,10 @@ typedef int (*httplib_authorization_handler)( const struct httplib_context *ctx, httplib_connection_close_handler Is called, when the connection is closed.*/ -typedef int (*httplib_websocket_connect_handler)( const struct httplib_context *ctx, struct httplib_connection *conn, void *); -typedef void (*httplib_websocket_ready_handler)( const struct httplib_context *ctx, struct httplib_connection *conn, void *); -typedef int (*httplib_websocket_data_handler)( const struct httplib_context *ctx, struct httplib_connection *conn, int, char *, size_t, void *); -typedef void (*httplib_websocket_close_handler)( const struct httplib_context *ctx, struct httplib_connection *conn, void *); +typedef int (*httplib_websocket_connect_handler)( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *); +typedef void (*httplib_websocket_ready_handler)( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *); +typedef int (*httplib_websocket_data_handler)( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int, char *, size_t, void *); +typedef void (*httplib_websocket_close_handler)( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *); /* httplib_set_auth_handler @@ -265,7 +265,7 @@ typedef void (*httplib_websocket_close_handler)( const struct httplib_context /* Get user data passed to httplib_start from context. */ -LIBHTTP_API void *httplib_get_user_data(const struct httplib_context *ctx); +LIBHTTP_API void *httplib_get_user_data(const struct lh_ctx_t *ctx); struct httplib_server_ports { @@ -281,7 +281,7 @@ struct httplib_server_ports { The caller is responsibility to allocate the required memory. This function returns the number of struct httplib_server_ports elements filled in, or <0 in case of an error. */ -LIBHTTP_API int httplib_get_server_ports(const struct httplib_context *ctx, int size, struct httplib_server_ports *ports); +LIBHTTP_API int httplib_get_server_ports(const struct lh_ctx_t *ctx, int size, struct httplib_server_ports *ports); /* Add, edit or delete the entry in the passwords file. @@ -615,38 +615,38 @@ LIBHTTP_API int httplib_atomic_dec( volatile int *addr ); LIBHTTP_API int httplib_atomic_inc( volatile int *addr ); LIBHTTP_API int httplib_base64_encode( const unsigned char *src, int src_len, char *dst, int dst_len ); LIBHTTP_API unsigned httplib_check_feature( unsigned feature ); -LIBHTTP_API void httplib_close_connection( struct httplib_context *ctx, struct httplib_connection *conn ); +LIBHTTP_API void httplib_close_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ); LIBHTTP_API int httplib_closedir( DIR *dir ); -LIBHTTP_API struct httplib_connection * httplib_connect_client( struct httplib_context *ctx, const char *host, int port, int use_ssl ); -LIBHTTP_API struct httplib_connection * httplib_connect_client_secure( struct httplib_context *ctx, const struct httplib_client_options *client_options ); -LIBHTTP_API struct httplib_connection * httplib_connect_websocket_client( struct httplib_context *ctx, const char *host, int port, int use_ssl, const char *path, const char *origin, httplib_websocket_data_handler data_func, httplib_websocket_close_handler close_func, void *user_data ); -LIBHTTP_API struct httplib_context * httplib_create_client_context( const struct httplib_callbacks *callbacks, const struct httplib_option_t *options ); -LIBHTTP_API void httplib_cry( enum debug_level_t debug_level, const struct httplib_context *ctx, const struct httplib_connection *conn, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(4, 5); -LIBHTTP_API void httplib_destroy_client_context( struct httplib_context *ctx ); -LIBHTTP_API struct httplib_connection * httplib_download( struct httplib_context *ctx, const char *host, int port, int use_ssl, PRINTF_FORMAT_STRING(const char *request_fmt), ...) PRINTF_ARGS(5, 6); +LIBHTTP_API struct httplib_connection * httplib_connect_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl ); +LIBHTTP_API struct httplib_connection * httplib_connect_client_secure( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options ); +LIBHTTP_API struct httplib_connection * httplib_connect_websocket_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, const char *path, const char *origin, httplib_websocket_data_handler data_func, httplib_websocket_close_handler close_func, void *user_data ); +LIBHTTP_API struct lh_ctx_t * httplib_create_client_context( const struct httplib_callbacks *callbacks, const struct httplib_option_t *options ); +LIBHTTP_API void httplib_cry( enum debug_level_t debug_level, const struct lh_ctx_t *ctx, const struct httplib_connection *conn, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(4, 5); +LIBHTTP_API void httplib_destroy_client_context( struct lh_ctx_t *ctx ); +LIBHTTP_API struct httplib_connection * httplib_download( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, PRINTF_FORMAT_STRING(const char *request_fmt), ...) PRINTF_ARGS(5, 6); LIBHTTP_API char * httplib_error_string( int error_code, char *buf, size_t buf_len ); LIBHTTP_API const char * httplib_get_builtin_mime_type( const char *file_name ); LIBHTTP_API int httplib_get_cookie( const char *cookie, const char *var_name, char *buf, size_t buf_len ); -LIBHTTP_API enum debug_level_t httplib_get_debug_level( struct httplib_context *ctx ); +LIBHTTP_API enum debug_level_t httplib_get_debug_level( struct lh_ctx_t *ctx ); LIBHTTP_API const char * httplib_get_header( const struct httplib_connection *conn, const char *name ); -LIBHTTP_API const char * httplib_get_option( const struct httplib_context *ctx, const char *name, char *buffer, size_t buflen ); +LIBHTTP_API const char * httplib_get_option( const struct lh_ctx_t *ctx, const char *name, char *buffer, size_t buflen ); LIBHTTP_API uint64_t httplib_get_random( void ); -LIBHTTP_API int httplib_get_response( const struct httplib_context *ctx, struct httplib_connection *conn, int timeout ); -LIBHTTP_API const char * httplib_get_response_code_text( const struct httplib_context *ctx, struct httplib_connection *conn, int response_code ); +LIBHTTP_API int httplib_get_response( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int timeout ); +LIBHTTP_API const char * httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int response_code ); LIBHTTP_API void * httplib_get_user_connection_data( const struct httplib_connection *conn ); LIBHTTP_API int httplib_get_var( const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len ); LIBHTTP_API int httplib_get_var2( const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len, size_t occurrence ); LIBHTTP_API struct tm * httplib_gmtime_r( const time_t *clock, struct tm *result ); -LIBHTTP_API int httplib_handle_form_request( const struct httplib_context *ctx, struct httplib_connection *conn, struct httplib_form_data_handler *fdh ); +LIBHTTP_API int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct httplib_form_data_handler *fdh ); LIBHTTP_API int httplib_kill( pid_t pid, int sig_num ); LIBHTTP_API struct tm * httplib_localtime_r( const time_t *clock, struct tm *result ); LIBHTTP_API void httplib_lock_connection( struct httplib_connection *conn ); -LIBHTTP_API void httplib_lock_context( struct httplib_context *ctx ); +LIBHTTP_API void httplib_lock_context( struct lh_ctx_t *ctx ); LIBHTTP_API char * httplib_md5( char buf[33], ... ); LIBHTTP_API int httplib_mkdir( const char *path, int mode ); LIBHTTP_API DIR * httplib_opendir( const char *name ); LIBHTTP_API int httplib_poll( struct pollfd *pfd, unsigned int nfds, int timeout ); -LIBHTTP_API int httplib_printf( const struct httplib_context *ctx, struct httplib_connection *, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(3, 4); +LIBHTTP_API int httplib_printf( const struct lh_ctx_t *ctx, struct httplib_connection *, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(3, 4); LIBHTTP_API int httplib_pthread_cond_broadcast( pthread_cond_t *cv ); LIBHTTP_API int httplib_pthread_cond_destroy( pthread_cond_t *cv ); LIBHTTP_API int httplib_pthread_cond_init( pthread_cond_t *cv, const pthread_condattr_t *attr ); @@ -664,19 +664,19 @@ LIBHTTP_API int httplib_pthread_mutex_trylock( pthread_mutex_t *mutex ); LIBHTTP_API int httplib_pthread_mutex_unlock( pthread_mutex_t *mutex ); LIBHTTP_API pthread_t httplib_pthread_self( void ); LIBHTTP_API int httplib_pthread_setspecific( pthread_key_t key, void *value ); -LIBHTTP_API int httplib_read( const struct httplib_context *ctx, struct httplib_connection *, void *buf, size_t len ); +LIBHTTP_API int httplib_read( const struct lh_ctx_t *ctx, struct httplib_connection *, void *buf, size_t len ); LIBHTTP_API struct dirent * httplib_readdir( DIR *dir ); LIBHTTP_API int httplib_remove( const char *path ); -LIBHTTP_API void httplib_send_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, const char *mime_type, const char *additional_headers ); +LIBHTTP_API void httplib_send_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, const char *mime_type, const char *additional_headers ); LIBHTTP_API void httplib_set_alloc_callback_func( httplib_alloc_callback_func log_func ); -LIBHTTP_API void httplib_set_auth_handler( struct httplib_context *ctx, const char *uri, httplib_authorization_handler handler, void *cbdata ); -LIBHTTP_API enum debug_level_t httplib_set_debug_level( struct httplib_context *ctx, enum debug_level_t new_level ); -LIBHTTP_API void httplib_set_request_handler( struct httplib_context *ctx, const char *uri, httplib_request_handler handler, void *cbdata ); +LIBHTTP_API void httplib_set_auth_handler( struct lh_ctx_t *ctx, const char *uri, httplib_authorization_handler handler, void *cbdata ); +LIBHTTP_API enum debug_level_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum debug_level_t new_level ); +LIBHTTP_API void httplib_set_request_handler( struct lh_ctx_t *ctx, const char *uri, httplib_request_handler handler, void *cbdata ); LIBHTTP_API void httplib_set_user_connection_data( struct httplib_connection *conn, void *data ); -LIBHTTP_API void httplib_set_websocket_handler( struct httplib_context *ctx, const char *uri, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, void *cbdata ); -LIBHTTP_API struct httplib_context * httplib_start(const struct httplib_callbacks *callbacks, void *user_data, const struct httplib_option_t *options ); -LIBHTTP_API void httplib_stop( struct httplib_context *ctx ); -LIBHTTP_API int64_t httplib_store_body( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); +LIBHTTP_API void httplib_set_websocket_handler( struct lh_ctx_t *ctx, const char *uri, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, void *cbdata ); +LIBHTTP_API struct lh_ctx_t * httplib_start(const struct httplib_callbacks *callbacks, void *user_data, const struct httplib_option_t *options ); +LIBHTTP_API void httplib_stop( struct lh_ctx_t *ctx ); +LIBHTTP_API int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); LIBHTTP_API int httplib_strcasecmp( const char *s1, const char *s2 ); LIBHTTP_API const char * httplib_strcasestr( const char *big_str, const char *small_str ); LIBHTTP_API char * httplib_strdup( const char *str ); @@ -686,13 +686,13 @@ LIBHTTP_API char * httplib_strndup( const char *str, size_t len ); LIBHTTP_API int httplib_system_exit( void ); LIBHTTP_API int httplib_system_init( void ); LIBHTTP_API void httplib_unlock_connection( struct httplib_connection *conn ); -LIBHTTP_API void httplib_unlock_context( struct httplib_context *ctx ); +LIBHTTP_API void httplib_unlock_context( struct lh_ctx_t *ctx ); LIBHTTP_API int httplib_url_decode( const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded ); LIBHTTP_API int httplib_url_encode( const char *src, char *dst, size_t dst_len ); LIBHTTP_API const char * httplib_version( void ); -LIBHTTP_API int httplib_websocket_client_write( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len ); -LIBHTTP_API int httplib_websocket_write( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len ); -LIBHTTP_API int httplib_write( const struct httplib_context *ctx, struct httplib_connection * conn, const void *buf, size_t len ); +LIBHTTP_API int httplib_websocket_client_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len ); +LIBHTTP_API int httplib_websocket_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len ); +LIBHTTP_API int httplib_write( const struct lh_ctx_t *ctx, struct httplib_connection * conn, const void *buf, size_t len ); #ifdef __cplusplus } diff --git a/src/httplib_abort_start.c b/src/httplib_abort_start.c index e3ec8547..7278c692 100644 --- a/src/httplib_abort_start.c +++ b/src/httplib_abort_start.c @@ -23,14 +23,14 @@ #include "httplib_main.h" /* - * struct httplib_context *XX_httplib_abort_start( struct httplib_context *ctx, const char *fmt, ... ); + * struct lh_ctx_t *XX_httplib_abort_start( struct lh_ctx_t *ctx, const char *fmt, ... ); * * The function XX_httplib_abort_start() is called to do some cleanup work when * an error occured initializing a context. The function returns NULL which is * then further returned to the calling party. */ -struct httplib_context *XX_httplib_abort_start( struct httplib_context *ctx, const char *fmt, ... ) { +struct lh_ctx_t *XX_httplib_abort_start( struct lh_ctx_t *ctx, const char *fmt, ... ) { va_list ap; char buf[MG_BUF_LEN]; diff --git a/src/httplib_accept_new_connection.c b/src/httplib_accept_new_connection.c index 1a349ba1..d6cb654f 100644 --- a/src/httplib_accept_new_connection.c +++ b/src/httplib_accept_new_connection.c @@ -29,13 +29,13 @@ #include "httplib_ssl.h" /* - * void XX_httplib_accept_new_connection( const struct socket *lostener, struct httplib_context *ctx ); + * void XX_httplib_accept_new_connection( const struct socket *lostener, struct lh_ctx_t *ctx ); * * The function XX_httplib_accept_new_connection() is used to process new * incoming connections to the server. */ -void XX_httplib_accept_new_connection( const struct socket *listener, struct httplib_context *ctx ) { +void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_ctx_t *ctx ) { struct socket so; char src_addr[IP_ADDR_STR_LEN]; diff --git a/src/httplib_addenv.c b/src/httplib_addenv.c index 087d65c0..dc5d8767 100644 --- a/src/httplib_addenv.c +++ b/src/httplib_addenv.c @@ -30,7 +30,7 @@ #include "httplib_utils.h" /* - * void XX_httplib_addenv( const struct httplib_context *ctx, struct cgi_environment *env, const char *fmt, ... ); + * void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... ); * * The function XX_httplib_addenv() adds one item to the environment before * a CGI script is called. The environment variable has the form @@ -44,7 +44,7 @@ #if !defined(NO_CGI) -void XX_httplib_addenv( const struct httplib_context *ctx, struct cgi_environment *env, const char *fmt, ... ) { +void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... ) { size_t n; size_t space; diff --git a/src/httplib_authorize.c b/src/httplib_authorize.c index 61b9b1f8..abd0775b 100644 --- a/src/httplib_authorize.c +++ b/src/httplib_authorize.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * bool XX_httplib_authorize( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep ); + * bool XX_httplib_authorize( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep ); * * The function XX_httplib_authorize() authorizes agains the open passwords * file. It returns 1 if authorized. */ -bool XX_httplib_authorize( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep ) { +bool XX_httplib_authorize( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep ) { struct read_auth_file_struct workdata; char buf[MG_BUF_LEN]; diff --git a/src/httplib_check_acl.c b/src/httplib_check_acl.c index f0c9bbdb..3d723099 100644 --- a/src/httplib_check_acl.c +++ b/src/httplib_check_acl.c @@ -28,7 +28,7 @@ #include "httplib_main.h" /* - * int XX_httplib_check_acl( struct httplib_context *ctx, uint32_t remote_ip ); + * int XX_httplib_check_acl( struct lh_ctx_t *ctx, uint32_t remote_ip ); * * The function XX_httplib_check_acl() is used to check of the socket address * of a connection is allowed according to the access control list. The @@ -36,7 +36,7 @@ * allowed and 1 if the address is allowed. */ -int XX_httplib_check_acl( struct httplib_context *ctx, uint32_t remote_ip ) { +int XX_httplib_check_acl( struct lh_ctx_t *ctx, uint32_t remote_ip ) { int allowed; int flag; diff --git a/src/httplib_check_authorization.c b/src/httplib_check_authorization.c index 6e8869df..d805d5e9 100644 --- a/src/httplib_check_authorization.c +++ b/src/httplib_check_authorization.c @@ -29,7 +29,7 @@ #include "httplib_string.h" /* Return 1 if request is authorised, 0 otherwise. */ -bool XX_httplib_check_authorization( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ) { +bool XX_httplib_check_authorization( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ) { char fname[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_close_all_listening_sockets.c b/src/httplib_close_all_listening_sockets.c index e137e70c..898d1d0b 100644 --- a/src/httplib_close_all_listening_sockets.c +++ b/src/httplib_close_all_listening_sockets.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void XX_httplib_close_all_listening_sockets( struct httplib_context *ctx ); + * void XX_httplib_close_all_listening_sockets( struct lh_ctx_t *ctx ); * * The function XX_httplib_close_all_listening_sockets() closes all listening * sockets of a given context. */ -void XX_httplib_close_all_listening_sockets( struct httplib_context *ctx ) { +void XX_httplib_close_all_listening_sockets( struct lh_ctx_t *ctx ) { unsigned int i; diff --git a/src/httplib_close_connection.c b/src/httplib_close_connection.c index 4fedb2df..e0e04843 100644 --- a/src/httplib_close_connection.c +++ b/src/httplib_close_connection.c @@ -30,13 +30,13 @@ #include "httplib_ssl.h" /* - * void XX_httplib_close_connection( struct httplib_context *ctx, struct httplib_connection *conn ); + * void XX_httplib_close_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_close_connection() is the internal function which * does the heavy lifting to close a connection. */ -void XX_httplib_close_connection( struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_close_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ) { if ( ctx == NULL || conn == NULL ) return; @@ -82,16 +82,16 @@ void XX_httplib_close_connection( struct httplib_context *ctx, struct httplib_co /* - * void httplib_close_connection( const struct httplib_context *ctx, struct httplib_connection *conn ); + * void httplib_close_connection( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function httplib_close_connection() closes the connection passed as a * parameter to this function. The function does not return a success or * failure value. */ -void httplib_close_connection( struct httplib_context *ctx, struct httplib_connection *conn ) { +void httplib_close_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ) { - struct httplib_context *client_ctx; + struct lh_ctx_t *client_ctx; int i; if ( ctx == NULL || conn == NULL ) return; diff --git a/src/httplib_close_socket_gracefully.c b/src/httplib_close_socket_gracefully.c index 8518e3c0..f95a4490 100644 --- a/src/httplib_close_socket_gracefully.c +++ b/src/httplib_close_socket_gracefully.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void XX_httplib_close_socket_gracefully( const struct httplib_context *ctx, struct httplib_connection *conn ); + * void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_close_socket_gracefully() closes a socket in a * graceful way. */ -void XX_httplib_close_socket_gracefully( const struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { #if defined(_WIN32) char buf[MG_BUF_LEN]; diff --git a/src/httplib_connect_client.c b/src/httplib_connect_client.c index fe5b2fea..f7305bda 100644 --- a/src/httplib_connect_client.c +++ b/src/httplib_connect_client.c @@ -30,30 +30,30 @@ #include "httplib_ssl.h" #include "httplib_string.h" -static struct httplib_connection * httplib_connect_client_impl( struct httplib_context *ctx, const struct httplib_client_options *client_options, int use_ssl ); +static struct httplib_connection * httplib_connect_client_impl( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options, int use_ssl ); /* - * struct httplib_connection *httplib_connect_client_secure( struct httplib_context_*ctx, const struct httplib_client_options *client options, char *error buffer, size_t error_buffer_size ); + * struct httplib_connection *httplib_connect_client_secure( struct lh_ctx_t *ctx, const struct httplib_client_options *client options ); * * The function httplib_connect_client_secure() creates a secure connection as a * client to a remote server and returns a pointer to the connection * information, or NULL if an error occured. */ -LIBHTTP_API struct httplib_connection *httplib_connect_client_secure( struct httplib_context *ctx, const struct httplib_client_options *client_options ) { +LIBHTTP_API struct httplib_connection *httplib_connect_client_secure( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options ) { return httplib_connect_client_impl( ctx, client_options, true ); } /* httplib_connect_client_secure */ /* - * struct httplib_connection *httplib_connect_client( struct httplib_context *ctx, const char *host, int port, int use_ssl ); + * struct httplib_connection *httplib_connect_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl ); * * The function httplib_connect_client() connects to a remote server as a client * with the options of the connection provided as parameters. */ -struct httplib_connection *httplib_connect_client( struct httplib_context *ctx, const char *host, int port, int use_ssl ) { +struct httplib_connection *httplib_connect_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl ) { struct httplib_client_options opts; @@ -68,13 +68,13 @@ struct httplib_connection *httplib_connect_client( struct httplib_context *ctx, /* - * static struct httplib_connection *httplib_connect_client_impl( struct httplib_context *ctx, const struct httplib_client_options *client_options, int use_ssl ); + * static struct httplib_connection *httplib_connect_client_impl( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options, int use_ssl ); * * The function httplib_connect_client_impl() is the background function doing the * heavy lifting to make connections as a client to remote servers. */ -static struct httplib_connection *httplib_connect_client_impl( struct httplib_context *ctx, const struct httplib_client_options *client_options, int use_ssl ) { +static struct httplib_connection *httplib_connect_client_impl( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options, int use_ssl ) { struct httplib_connection *conn; SOCKET sock; diff --git a/src/httplib_connect_socket.c b/src/httplib_connect_socket.c index be985af1..278193b1 100644 --- a/src/httplib_connect_socket.c +++ b/src/httplib_connect_socket.c @@ -41,7 +41,7 @@ * has been established. */ -bool XX_httplib_connect_socket( struct httplib_context *ctx, const char *host, int port, int use_ssl, SOCKET *sock, union usa *sa ) { +bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, SOCKET *sock, union usa *sa ) { int ip_ver; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_connect_websocket_client.c b/src/httplib_connect_websocket_client.c index bd6d6125..7fdc38dc 100644 --- a/src/httplib_connect_websocket_client.c +++ b/src/httplib_connect_websocket_client.c @@ -36,7 +36,7 @@ * returned, otherwise NULL. */ -struct httplib_connection *httplib_connect_websocket_client( struct httplib_context *ctx, const char *host, int port, int use_ssl, const char *path, const char *origin, httplib_websocket_data_handler data_func, httplib_websocket_close_handler close_func, void *user_data ) { +struct httplib_connection *httplib_connect_websocket_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, const char *path, const char *origin, httplib_websocket_data_handler data_func, httplib_websocket_close_handler close_func, void *user_data ) { struct httplib_connection *conn; struct websocket_client_thread_data *thread_data; diff --git a/src/httplib_construct_etag.c b/src/httplib_construct_etag.c index cbc14cd2..1d93d48c 100644 --- a/src/httplib_construct_etag.c +++ b/src/httplib_construct_etag.c @@ -29,13 +29,13 @@ #include "httplib_string.h" /* - * void XX_httplib_construct_etag( const struct httplib_context *ctx, char *buf, size_t buf_len, const struct file *filep ); + * void XX_httplib_construct_etag( const struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ); * * The function XX_httplib_construct_etag() is used to construct an etag which * can be used to identify a file on a specific moment. */ -void XX_httplib_construct_etag( const struct httplib_context *ctx, char *buf, size_t buf_len, const struct file *filep ) { +void XX_httplib_construct_etag( const struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ) { if ( filep != NULL && buf != NULL && buf_len > 0 ) { diff --git a/src/httplib_consume_socket.c b/src/httplib_consume_socket.c index cfe3a883..102a4252 100644 --- a/src/httplib_consume_socket.c +++ b/src/httplib_consume_socket.c @@ -31,7 +31,7 @@ #define QUEUE_SIZE(ctx) ((int)(ARRAY_SIZE(ctx->queue))) /* - * int XX_httplib_consume_socket( struct httplib_context *ctx, struct socket *sp, int thread_index ); + * int XX_httplib_consume_socket( struct lh_ctx_t *ctx, struct socket *sp, int thread_index ); * * The function XX_httplib_consume_socket() takes an accepted socket from the * queue for further processing. @@ -39,7 +39,7 @@ #if defined(ALTERNATIVE_QUEUE) -int XX_httplib_consume_socket( struct httplib_context *ctx, struct socket *sp, int thread_index ) { +int XX_httplib_consume_socket( struct lh_ctx_t *ctx, struct socket *sp, int thread_index ) { ctx->client_socks[thread_index].in_use = 0; event_wait( ctx->client_wait_events[thread_index] ); @@ -52,7 +52,7 @@ int XX_httplib_consume_socket( struct httplib_context *ctx, struct socket *sp, i #else /* ALTERNATIVE_QUEUE */ /* Worker threads take accepted socket from the queue */ -int XX_httplib_consume_socket( struct httplib_context *ctx, struct socket *sp, int thread_index ) { +int XX_httplib_consume_socket( struct lh_ctx_t *ctx, struct socket *sp, int thread_index ) { UNUSED_PARAMETER(thread_index); diff --git a/src/httplib_create_client_context.c b/src/httplib_create_client_context.c index a91d54c3..fee1ebbf 100644 --- a/src/httplib_create_client_context.c +++ b/src/httplib_create_client_context.c @@ -23,7 +23,7 @@ #include "httplib_main.h" /* - * struct httplib_context *httplib_create_client_context( const struct httplib_callbacks *callbacks, const struct httplib_option_t *options ); + * struct lh_ctx_t *httplib_create_client_context( const struct httplib_callbacks *callbacks, const struct httplib_option_t *options ); * * The function httplib_create_client_context() creates a context to be used * for one simultaneous client connection. It is not possible to use one client @@ -31,13 +31,13 @@ * contains SSL context information which is specific for one connection. */ -struct httplib_context *httplib_create_client_context( const struct httplib_callbacks *callbacks, const struct httplib_option_t *options ) { +struct lh_ctx_t *httplib_create_client_context( const struct httplib_callbacks *callbacks, const struct httplib_option_t *options ) { - struct httplib_context *ctx; - void (*exit_callback)(const struct httplib_context *ctx); + struct lh_ctx_t *ctx; + void (*exit_callback)(const struct lh_ctx_t *ctx); exit_callback = NULL; - ctx = httplib_calloc( 1, sizeof(struct httplib_context) ); + ctx = httplib_calloc( 1, sizeof(struct lh_ctx_t) ); if ( ctx == NULL ) return NULL; if ( callbacks != NULL ) { diff --git a/src/httplib_cry.c b/src/httplib_cry.c index 2a6c0da2..2cf3c5df 100644 --- a/src/httplib_cry.c +++ b/src/httplib_cry.c @@ -26,14 +26,14 @@ #include "httplib_ssl.h" /* - * void httplib_cry( enum debug_level_t debug_level, const struct httplib_context *ctx, const struct httplib_connection *conn, const char *fmt, ... ); + * void httplib_cry( enum debug_level_t debug_level, const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *fmt, ... ); * * The function httplib_cry() prints a formatted error message to the opened * error log stream. It first tries to use a user supplied error handler. If * that doesn't work, the alternative is to write to an error log file. */ -void httplib_cry( enum debug_level_t debug_level, const struct httplib_context *ctx, const struct httplib_connection *conn, const char *fmt, ... ) { +void httplib_cry( enum debug_level_t debug_level, const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *fmt, ... ) { char buf[MG_BUF_LEN]; char src_addr[IP_ADDR_STR_LEN]; diff --git a/src/httplib_delete_file.c b/src/httplib_delete_file.c index 6d572b66..beb1a0f7 100644 --- a/src/httplib_delete_file.c +++ b/src/httplib_delete_file.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void XX_httplib_delete_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); + * void XX_httplib_delete_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); * * The function XX_httplib_delete_file() deletes a file after a request over a * connection. */ -void XX_httplib_delete_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ) { +void XX_httplib_delete_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ) { struct de de; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_destroy_client_context.c b/src/httplib_destroy_client_context.c index f16edd81..0636c338 100644 --- a/src/httplib_destroy_client_context.c +++ b/src/httplib_destroy_client_context.c @@ -23,14 +23,14 @@ #include "httplib_main.h" /* - * void httplib_destroy_client_context( struct httplib_context *ctx ); + * void httplib_destroy_client_context( struct lh_ctx_t *ctx ); * * The function httplib_destroy_client_context() destroys the context for a * client connection. This function should not be called for server contexts. * Use httplib_stop() for server contexts instead. */ -void httplib_destroy_client_context( struct httplib_context *ctx ) { +void httplib_destroy_client_context( struct lh_ctx_t *ctx ) { if ( ctx == NULL ) return; diff --git a/src/httplib_dir_scan_callback.c b/src/httplib_dir_scan_callback.c index 8b56605c..ebe3781b 100644 --- a/src/httplib_dir_scan_callback.c +++ b/src/httplib_dir_scan_callback.c @@ -28,7 +28,7 @@ #include "httplib_main.h" #include "httplib_string.h" -void XX_httplib_dir_scan_callback( const struct httplib_context *ctx, struct de *de, void *data ) { +void XX_httplib_dir_scan_callback( const struct lh_ctx_t *ctx, struct de *de, void *data ) { struct dir_scan_data *dsd; struct de* old_entries; diff --git a/src/httplib_discard_unread_request_data.c b/src/httplib_discard_unread_request_data.c index 7d91267f..4bd13128 100644 --- a/src/httplib_discard_unread_request_data.c +++ b/src/httplib_discard_unread_request_data.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * void XX_httplib_discard_unread_request_data( const struct httplib_context *ctx, struct httplib_connection *conn ); + * void XX_httplib_discard_unread_request_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_discard_unread_request_data() discards any request * data on a connection which is not further needed but has alread been * received. */ -void XX_httplib_discard_unread_request_data( const struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_discard_unread_request_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { char buf[MG_BUF_LEN]; size_t to_read; diff --git a/src/httplib_download.c b/src/httplib_download.c index ce36c5d1..f69b4fc7 100644 --- a/src/httplib_download.c +++ b/src/httplib_download.c @@ -35,7 +35,7 @@ * and returns a pointer to the connection on success, or NULL on error. */ -struct httplib_connection * httplib_download( struct httplib_context *ctx, const char *host, int port, int use_ssl, const char *fmt, ... ) { +struct httplib_connection * httplib_download( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, const char *fmt, ... ) { struct httplib_connection *conn; va_list ap; diff --git a/src/httplib_fclose_on_exec.c b/src/httplib_fclose_on_exec.c index 760254d2..568f6cc0 100644 --- a/src/httplib_fclose_on_exec.c +++ b/src/httplib_fclose_on_exec.c @@ -27,7 +27,7 @@ #include "httplib_main.h" -void XX_httplib_fclose_on_exec( const struct httplib_context *ctx, struct file *filep, struct httplib_connection *conn ) { +void XX_httplib_fclose_on_exec( const struct lh_ctx_t *ctx, struct file *filep, struct httplib_connection *conn ) { if ( ctx == NULL || filep == NULL || filep->fp == NULL ) return; diff --git a/src/httplib_fopen.c b/src/httplib_fopen.c index 5d82c8fc..510e1a1b 100644 --- a/src/httplib_fopen.c +++ b/src/httplib_fopen.c @@ -28,7 +28,7 @@ #include "httplib_main.h" /* - * bool XX_httplib_fopen( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, const char *mode, struct file *filep ); + * bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, const char *mode, struct file *filep ); * * The function XX_httplib_fopen() can be used to open a file which is either * in memory or on the disk. The path is in UTF-8 and therefore needs @@ -44,7 +44,7 @@ * of the same structure (bad cohesion). */ -bool XX_httplib_fopen( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, const char *mode, struct file *filep ) { +bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, const char *mode, struct file *filep ) { struct stat st; diff --git a/src/httplib_forward_body_data.c b/src/httplib_forward_body_data.c index e1f49dce..2b501c35 100644 --- a/src/httplib_forward_body_data.c +++ b/src/httplib_forward_body_data.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * bool XX_httplib_forward_body_data( const struct httplib_context *ctx, struct httplib_connection *conn, FILE *fp, SOCKET sock, SSL *ssl ); + * bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn, FILE *fp, SOCKET sock, SSL *ssl ); * * The function XX_httplib_forward_body_data() forwards body data to the * client. The function returns true if successful, and false otherwise. */ -bool XX_httplib_forward_body_data( const struct httplib_context *ctx, struct httplib_connection *conn, FILE *fp, SOCKET sock, SSL *ssl ) { +bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn, FILE *fp, SOCKET sock, SSL *ssl ) { const char *expect; const char *body; diff --git a/src/httplib_free_config_options.c b/src/httplib_free_config_options.c index 37d6245e..3dfc7b79 100644 --- a/src/httplib_free_config_options.c +++ b/src/httplib_free_config_options.c @@ -23,13 +23,13 @@ #include "httplib_main.h" /* - * void XX_httplib_free_config_options( struct htptlib_context *ctx ); + * void XX_httplib_free_config_options( struct lh_ctx_t *ctx ); * * The function XX_httplib_free_config_options() returns all the from the heap * allocated space to store config options back to the heap. */ -void XX_httplib_free_config_options( struct httplib_context *ctx ) { +void XX_httplib_free_config_options( struct lh_ctx_t *ctx ) { if ( ctx == NULL ) return; diff --git a/src/httplib_free_context.c b/src/httplib_free_context.c index 6ed8c04a..51276cad 100644 --- a/src/httplib_free_context.c +++ b/src/httplib_free_context.c @@ -31,13 +31,13 @@ #include "httplib_utils.h" /* - * void XX_httplib_free_context( struct httplib_context *ctx ); + * void XX_httplib_free_context( struct lh_ctx_t *ctx ); * * The function XX_httplib_free_context() is used to free the resources * associated with a context. */ -void XX_httplib_free_context( struct httplib_context *ctx ) { +void XX_httplib_free_context( struct lh_ctx_t *ctx ) { struct httplib_handler_info *tmp_rh; diff --git a/src/httplib_get_debug_level.c b/src/httplib_get_debug_level.c index 9629b6a9..dd6483c8 100644 --- a/src/httplib_get_debug_level.c +++ b/src/httplib_get_debug_level.c @@ -23,13 +23,13 @@ #include "httplib_main.h" /* - * enum debug_level_t httplib_get_debug_level( struct httplib_context *ctx ); + * enum debug_level_t httplib_get_debug_level( struct lh_ctx_t *ctx ); * * The function httplib_get_debug_level() returns the debug level for a * context. */ -enum debug_level_t httplib_get_debug_level( struct httplib_context *ctx ) { +enum debug_level_t httplib_get_debug_level( struct lh_ctx_t *ctx ) { if ( ctx == NULL ) return DEBUG_LEVEL_NONE; return ctx->debug_level; diff --git a/src/httplib_get_first_ssl_listener_index.c b/src/httplib_get_first_ssl_listener_index.c index bd6a742b..011d872f 100644 --- a/src/httplib_get_first_ssl_listener_index.c +++ b/src/httplib_get_first_ssl_listener_index.c @@ -29,13 +29,13 @@ #include "httplib_ssl.h" /* - * int XX_httplib_get_first_ssl_listener_index( const struct httplib_context *ctx ); + * int XX_httplib_get_first_ssl_listener_index( const struct lh_ctx_t *ctx ); * * The function XX_httplib_get_first_ssl_listener_index() returns the first * index of a listening socket where SSL encryption is active. */ -int XX_httplib_get_first_ssl_listener_index( const struct httplib_context *ctx ) { +int XX_httplib_get_first_ssl_listener_index( const struct lh_ctx_t *ctx ) { unsigned int i; int idx; diff --git a/src/httplib_get_mime_type.c b/src/httplib_get_mime_type.c index 77940774..a5fc4da4 100644 --- a/src/httplib_get_mime_type.c +++ b/src/httplib_get_mime_type.c @@ -30,7 +30,7 @@ /* Look at the "path" extension and figure what mime type it has. * Store mime type in the vector. */ -void XX_httplib_get_mime_type( const struct httplib_context *ctx, const char *path, struct vec *vec ) { +void XX_httplib_get_mime_type( const struct lh_ctx_t *ctx, const char *path, struct vec *vec ) { struct vec ext_vec; struct vec mime_vec; diff --git a/src/httplib_get_option.c b/src/httplib_get_option.c index 6ae6b7e1..55816ad4 100644 --- a/src/httplib_get_option.c +++ b/src/httplib_get_option.c @@ -27,7 +27,7 @@ static const char * store_int( char *buffer, size_t buflen, int value ) static const char * store_str( char *buffer, size_t buflen, const char *value ); /* - * const char *httplib_get_option( const struct httplib_context *ctx, const char *name, char *buffer, size_t buflen ); + * const char *httplib_get_option( const struct lh_ctx_t *ctx, const char *name, char *buffer, size_t buflen ); * * The function httplib_get_option() returns the content of an option for a * given context. If an error occurs, NULL is returned. If the option is valid @@ -35,7 +35,7 @@ static const char * store_str( char *buffer, size_t buflen, const char *value ) * string. */ -const char *httplib_get_option( const struct httplib_context *ctx, const char *name, char *buffer, size_t buflen ) { +const char *httplib_get_option( const struct lh_ctx_t *ctx, const char *name, char *buffer, size_t buflen ) { if ( name == NULL || buffer == NULL || buflen < 1 ) return NULL; diff --git a/src/httplib_get_rel_url_at_current_server.c b/src/httplib_get_rel_url_at_current_server.c index 7531fba2..e143e245 100644 --- a/src/httplib_get_rel_url_at_current_server.c +++ b/src/httplib_get_rel_url_at_current_server.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * const char *XX_httplib_get_rel_url_at_current_server( const struct httplib_context *ctx, const char *uri, const struct httplib_connection *conn ); + * const char *XX_httplib_get_rel_url_at_current_server( const struct lh_ctx_t *ctx, const char *uri, const struct httplib_connection *conn ); * * The function XX_httplib_get_rel_url_at_current_server() returns the relative * uri at the current server. */ -const char *XX_httplib_get_rel_url_at_current_server( const struct httplib_context *ctx, const char *uri, const struct httplib_connection *conn ) { +const char *XX_httplib_get_rel_url_at_current_server( const struct lh_ctx_t *ctx, const char *uri, const struct httplib_connection *conn ) { const char *server_domain; size_t server_domain_len; diff --git a/src/httplib_get_request_handler.c b/src/httplib_get_request_handler.c index 6f5bf046..41ba76f0 100644 --- a/src/httplib_get_request_handler.c +++ b/src/httplib_get_request_handler.c @@ -35,7 +35,7 @@ * and 0 otherwise. */ -int XX_httplib_get_request_handler( struct httplib_context *ctx, struct httplib_connection *conn, int handler_type, httplib_request_handler *handler, httplib_websocket_connect_handler *connect_handler, httplib_websocket_ready_handler *ready_handler, httplib_websocket_data_handler *data_handler, httplib_websocket_close_handler *close_handler, httplib_authorization_handler *auth_handler, void **cbdata ) { +int XX_httplib_get_request_handler( struct lh_ctx_t *ctx, struct httplib_connection *conn, int handler_type, httplib_request_handler *handler, httplib_websocket_connect_handler *connect_handler, httplib_websocket_ready_handler *ready_handler, httplib_websocket_data_handler *data_handler, httplib_websocket_close_handler *close_handler, httplib_authorization_handler *auth_handler, void **cbdata ) { const struct httplib_request_info *request_info; const char *uri; diff --git a/src/httplib_get_response.c b/src/httplib_get_response.c index d39f6058..2603a4c5 100644 --- a/src/httplib_get_response.c +++ b/src/httplib_get_response.c @@ -29,7 +29,7 @@ #include "httplib_string.h" /* - * int httplib_get_response( const struct httplib_context *ctx, struct httplib_connection *conn, int timeout ); + * int httplib_get_response( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int timeout ); * * The function httplib_get_response() tries to get a response from a remote * peer. This function does some dirty action by temporarily replacing the @@ -40,11 +40,11 @@ * place. */ -int httplib_get_response( const struct httplib_context *ctx, struct httplib_connection *conn, int timeout ) { +int httplib_get_response( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int timeout ) { int err; int ret; - struct httplib_context rctx; + struct lh_ctx_t rctx; if ( ctx == NULL || conn == NULL ) return -1; diff --git a/src/httplib_get_response_code_text.c b/src/httplib_get_response_code_text.c index 2948af74..b4fc254c 100644 --- a/src/httplib_get_response_code_text.c +++ b/src/httplib_get_response_code_text.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * const char *httplib_get_response_code_text( const struct httplib_context *ctx, struct httplib_connection *conn, int response_code ); + * const char *httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int response_code ); * * The function httplib_get_response_code_text() returns a text associated with an * HTTP response code. */ -const char *httplib_get_response_code_text( const struct httplib_context *ctx, struct httplib_connection *conn, int response_code ) { +const char *httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int response_code ) { /* * See IANA HTTP status code assignment: diff --git a/src/httplib_get_server_ports.c b/src/httplib_get_server_ports.c index 8c58f8f4..5443588d 100644 --- a/src/httplib_get_server_ports.c +++ b/src/httplib_get_server_ports.c @@ -27,7 +27,7 @@ #include "httplib_main.h" -int httplib_get_server_ports( const struct httplib_context *ctx, int size, struct httplib_server_ports *ports ) { +int httplib_get_server_ports( const struct lh_ctx_t *ctx, int size, struct httplib_server_ports *ports ) { int i; int cnt; diff --git a/src/httplib_get_user_data.c b/src/httplib_get_user_data.c index 780cee97..4a48f5f6 100644 --- a/src/httplib_get_user_data.c +++ b/src/httplib_get_user_data.c @@ -28,7 +28,7 @@ #include "httplib_main.h" /* - * void *httplib_get_user_data( const struct httplib_context *ctx ); + * void *httplib_get_user_data( const struct lh_ctx_t *ctx ); * * The function httplib_get_user_data() returns a pointer to user data which is * associated with the context, or NULL if no user data has been registered. @@ -36,7 +36,7 @@ * httplib_start() function. */ -void *httplib_get_user_data( const struct httplib_context *ctx ) { +void *httplib_get_user_data( const struct lh_ctx_t *ctx ) { if ( ctx == NULL ) return NULL; diff --git a/src/httplib_getreq.c b/src/httplib_getreq.c index fbcae0d9..8c94ab1e 100644 --- a/src/httplib_getreq.c +++ b/src/httplib_getreq.c @@ -29,12 +29,12 @@ #include "httplib_string.h" /* - * bool XX_httplib_getreq( const struct httplib_context *ctx, struct httplib_connection *conn, int *err ); + * bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int *err ); * * The function XX_httplib_getreq() processes a request from a remote client. */ -bool XX_httplib_getreq( const struct httplib_context *ctx, struct httplib_connection *conn, int *err ) { +bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int *err ) { const char *cl; diff --git a/src/httplib_handle_cgi_request.c b/src/httplib_handle_cgi_request.c index 245d70e8..35759776 100644 --- a/src/httplib_handle_cgi_request.c +++ b/src/httplib_handle_cgi_request.c @@ -29,7 +29,7 @@ #include "httplib_string.h" /* - * void XX_httplib_handle_cgi_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog ); + * void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog ); * * The function XX_httplib_handle_cgi_request() handles a request for a CGI * resource. @@ -37,7 +37,7 @@ #if !defined(NO_CGI) -void XX_httplib_handle_cgi_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog ) { +void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog ) { char *buf; size_t buflen; diff --git a/src/httplib_handle_directory_request.c b/src/httplib_handle_directory_request.c index ae26548d..b309991e 100644 --- a/src/httplib_handle_directory_request.c +++ b/src/httplib_handle_directory_request.c @@ -28,7 +28,7 @@ #include "httplib_main.h" #include "httplib_utils.h" -void XX_httplib_handle_directory_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir ) { +void XX_httplib_handle_directory_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir ) { unsigned int i; int sort_direction; diff --git a/src/httplib_handle_file_based_request.c b/src/httplib_handle_file_based_request.c index bc0ebb59..7cd743dc 100644 --- a/src/httplib_handle_file_based_request.c +++ b/src/httplib_handle_file_based_request.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * void XX_httplib_handle_file_based_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *file ); + * void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *file ); * * The function XX_httplib_handle_file_based_request() handles a request which * involves a file. This can either be a CGI request, an SSI request of a * request for a static file. */ -void XX_httplib_handle_file_based_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *file ) { +void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *file ) { #if !defined(NO_CGI) const char *cgi_ext; diff --git a/src/httplib_handle_form_request.c b/src/httplib_handle_form_request.c index 430904fe..14aa3c3d 100644 --- a/src/httplib_handle_form_request.c +++ b/src/httplib_handle_form_request.c @@ -26,7 +26,7 @@ #include "httplib_main.h" -static int url_encoded_field_found( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *key, size_t key_len, const char *filename, size_t filename_len, char *path, size_t path_len, struct httplib_form_data_handler *fdh ) { +static int url_encoded_field_found( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *key, size_t key_len, const char *filename, size_t filename_len, char *path, size_t path_len, struct httplib_form_data_handler *fdh ) { char key_dec[1024]; char filename_dec[1024]; @@ -77,7 +77,7 @@ static int url_encoded_field_found( const struct httplib_context *ctx, const str } -static int url_encoded_field_get( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *key, size_t key_len, const char *value, size_t value_len, struct httplib_form_data_handler *fdh ) { +static int url_encoded_field_get( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *key, size_t key_len, const char *value, size_t value_len, struct httplib_form_data_handler *fdh ) { char key_dec[1024]; @@ -155,7 +155,7 @@ static const char * search_boundary(const char *buf, size_t buf_len, const char } -int httplib_handle_form_request( const struct httplib_context *ctx, struct httplib_connection *conn, struct httplib_form_data_handler *fdh ) { +int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct httplib_form_data_handler *fdh ) { const char *content_type; char path[512]; diff --git a/src/httplib_handle_not_modified_static_file_request.c b/src/httplib_handle_not_modified_static_file_request.c index d38d7758..2da16a10 100644 --- a/src/httplib_handle_not_modified_static_file_request.c +++ b/src/httplib_handle_not_modified_static_file_request.c @@ -29,14 +29,14 @@ #include "httplib_utils.h" /* - * void XX_httplib_handle_not_modified_static_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep ); + * void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep ); * * The function XX_httplib_handle_not_modified_static_file_request() is used to * send a 304 response to a client to indicate that the requested resource has * not been changed. */ -void XX_httplib_handle_not_modified_static_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep ) { +void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep ) { char date[64]; char lm[64]; diff --git a/src/httplib_handle_propfind.c b/src/httplib_handle_propfind.c index 5c7ae8a9..b50e4985 100644 --- a/src/httplib_handle_propfind.c +++ b/src/httplib_handle_propfind.c @@ -30,13 +30,13 @@ #include "httplib_utils.h" /* - * static void print_props( const struct httplib_context *ctx, struct httplib_connection *conn, const char *uri, struct file *filep ); + * static void print_props( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *uri, struct file *filep ); * * The function print_props() writes the PROPFIND properties for a collection * event. */ -static void print_props( const struct httplib_context *ctx, struct httplib_connection *conn, const char *uri, struct file *filep ) { +static void print_props( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *uri, struct file *filep ) { char mtime[64]; @@ -63,13 +63,13 @@ static void print_props( const struct httplib_context *ctx, struct httplib_conne } /* print_props */ /* - * static void print_dav_dir_entry( const struct httplib_context *ctx, struct de *de, void *data ); + * static void print_dav_dir_entry( const struct lh_ctx_t *ctx, struct de *de, void *data ); * * The function print_dav_dir_entry() is used to send the properties of a * webdav directory to the remote client. */ -static void print_dav_dir_entry( const struct httplib_context *ctx, struct de *de, void *data ) { +static void print_dav_dir_entry( const struct lh_ctx_t *ctx, struct de *de, void *data ) { char href[PATH_MAX]; char href_encoded[PATH_MAX * 3 /* worst case */]; @@ -91,12 +91,12 @@ static void print_dav_dir_entry( const struct httplib_context *ctx, struct de *d } /* print_dav_dir_entry */ /* - * void XX_httplib_handle_propfind( const stuct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); + * void XX_httplib_handle_propfind( const stuct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); * * The function XX_httlib_handle_propfind() handles a propfind request. */ -void XX_httplib_handle_propfind( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { +void XX_httplib_handle_propfind( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { const char *depth; char date[64]; diff --git a/src/httplib_handle_request.c b/src/httplib_handle_request.c index b2f6684e..fe39554e 100644 --- a/src/httplib_handle_request.c +++ b/src/httplib_handle_request.c @@ -30,7 +30,7 @@ #include "httplib_utils.h" /* - * void XX_httplib_handle_request( const struct httplib_context *ctx, struct httplib_connection *conn ); + * void XX_httplib_handle_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_handle_request() handles an incoming request. This * is the heart of the LibHTTP's logic. This function is called when the @@ -38,7 +38,7 @@ * to take: serve a file, or a directory, or call embedded function, etcetera. */ -void XX_httplib_handle_request( struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_handle_request( struct lh_ctx_t *ctx, struct httplib_connection *conn ) { struct httplib_request_info *ri; char path[PATH_MAX]; diff --git a/src/httplib_handle_static_file_request.c b/src/httplib_handle_static_file_request.c index 1a7a05e0..799e6789 100644 --- a/src/httplib_handle_static_file_request.c +++ b/src/httplib_handle_static_file_request.c @@ -36,7 +36,7 @@ * request for a static file. */ -void XX_httplib_handle_static_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ) { +void XX_httplib_handle_static_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ) { char date[64]; char lm[64]; diff --git a/src/httplib_handle_websocket_request.c b/src/httplib_handle_websocket_request.c index daea58b7..190c28e9 100644 --- a/src/httplib_handle_websocket_request.c +++ b/src/httplib_handle_websocket_request.c @@ -34,7 +34,7 @@ * request on a connection. */ -void XX_httplib_handle_websocket_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData ) { +void XX_httplib_handle_websocket_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData ) { const char *websock_key; const char *version; diff --git a/src/httplib_init_options.c b/src/httplib_init_options.c index f895c988..00624050 100644 --- a/src/httplib_init_options.c +++ b/src/httplib_init_options.c @@ -23,7 +23,7 @@ #include "httplib_main.h" /* - * bool XX_httplib_init_options( struct httplib_context *ctx ); + * bool XX_httplib_init_options( struct lh_ctx_t *ctx ); * * The function XX_httplib_init_options() sets the options of a newly created * context to reasonablei default values. When succesful, the function returns @@ -31,7 +31,7 @@ * cleanup. */ -bool XX_httplib_init_options( struct httplib_context *ctx ) { +bool XX_httplib_init_options( struct lh_ctx_t *ctx ) { if ( ctx == NULL ) return true; diff --git a/src/httplib_initialize_ssl.c b/src/httplib_initialize_ssl.c index 57f7df49..df367843 100644 --- a/src/httplib_initialize_ssl.c +++ b/src/httplib_initialize_ssl.c @@ -45,13 +45,13 @@ static void *cryptolib_dll_handle; /* Store the crypto library handle. */ /* - * int XX_httplib_initialize_ssl( struct httplib_context *ctx ); + * int XX_httplib_initialize_ssl( struct lh_ctx_t *ctx ); * * The function XX_httplib_initialize_ssl() initializes the use of SSL * encrypted communication on the given context. */ -int XX_httplib_initialize_ssl( struct httplib_context *ctx ) { +int XX_httplib_initialize_ssl( struct lh_ctx_t *ctx ) { int i; size_t size; diff --git a/src/httplib_interpret_uri.c b/src/httplib_interpret_uri.c index 97a60e49..7e775527 100644 --- a/src/httplib_interpret_uri.c +++ b/src/httplib_interpret_uri.c @@ -44,7 +44,7 @@ * is_put_or_delete_request: out: put/delete file? */ -void XX_httplib_interpret_uri( const struct httplib_context *ctx, struct httplib_connection *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request ) { +void XX_httplib_interpret_uri( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request ) { /* TODO (high): Restructure this function */ diff --git a/src/httplib_is_authorized_for_put.c b/src/httplib_is_authorized_for_put.c index 1856643a..f5c81f2e 100644 --- a/src/httplib_is_authorized_for_put.c +++ b/src/httplib_is_authorized_for_put.c @@ -25,14 +25,14 @@ #include "httplib_main.h" /* - * bool XX_httplib_is_authorized_for_put( const struct httplib_context *ctx, struct httplib_connection *conn ); + * bool XX_httplib_is_authorized_for_put( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_is_authorized_for_put() returns true, if the client * on the connection has authorization to use put and equivalent methods to * write information to the server. */ -bool XX_httplib_is_authorized_for_put( const struct httplib_context *ctx, struct httplib_connection *conn ) { +bool XX_httplib_is_authorized_for_put( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { struct file file = STRUCT_FILE_INITIALIZER; const char *passfile; diff --git a/src/httplib_is_file_in_memory.c b/src/httplib_is_file_in_memory.c index fa9c58b1..6857bde7 100644 --- a/src/httplib_is_file_in_memory.c +++ b/src/httplib_is_file_in_memory.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * bool XX_httplib_is_file_in_memory( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, struct file *filep ); + * bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, struct file *filep ); * * The function XX_httplib_is_file_in_memory() returns true, if a file defined * by a specific path is located in memory. */ -bool XX_httplib_is_file_in_memory( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, struct file *filep ) { +bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, struct file *filep ) { size_t size; diff --git a/src/httplib_is_not_modified.c b/src/httplib_is_not_modified.c index 98e04c34..627414f2 100644 --- a/src/httplib_is_not_modified.c +++ b/src/httplib_is_not_modified.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * bool XX_httplib_is_not_modified( const struct httplib_context *ctx, const struct httplib_connection *conn, const struct file *filep ); + * bool XX_httplib_is_not_modified( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const struct file *filep ); * * The function XX_httplib_is_not_modified() returns true, if a resource has * not been modified sinze a given datetime and a 304 response should therefore * be sufficient. */ -bool XX_httplib_is_not_modified( const struct httplib_context *ctx, const struct httplib_connection *conn, const struct file *filep ) { +bool XX_httplib_is_not_modified( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const struct file *filep ) { char etag[64]; const char *ims = httplib_get_header( conn, "If-Modified-Since" ); diff --git a/src/httplib_load_dll.c b/src/httplib_load_dll.c index d14d2506..dcb40694 100644 --- a/src/httplib_load_dll.c +++ b/src/httplib_load_dll.c @@ -60,7 +60,7 @@ static int dlclose( void *handle ) { #endif /* _WIN32 */ /* - * XX_httplib_load_dll( struct httplib_context *ctx, const char *dll_name, struct ssl_func *sw ); + * XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ssl_func *sw ); * * The function XX_httplib_load_dll() is used to load the SSL library in a * dynamic way. The function returns either a handle to the dll, or NULL if an @@ -69,7 +69,7 @@ static int dlclose( void *handle ) { #if !defined(NO_SSL) && !defined(NO_SSL_DL) -void *XX_httplib_load_dll( struct httplib_context *ctx, const char *dll_name, struct ssl_func *sw ) { +void *XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ssl_func *sw ) { union { void *p; diff --git a/src/httplib_lock_unlock_context.c b/src/httplib_lock_unlock_context.c index f9476d8c..747ee853 100644 --- a/src/httplib_lock_unlock_context.c +++ b/src/httplib_lock_unlock_context.c @@ -29,12 +29,12 @@ #include "httplib_pthread.h" /* - * void httplib_lock_context( struct httplib_context *ctx ); + * void httplib_lock_context( struct lh_ctx_t *ctx ); * * The function httplib_lock_context() puts a lock on the context. */ -void httplib_lock_context( struct httplib_context *ctx ) { +void httplib_lock_context( struct lh_ctx_t *ctx ) { if ( ctx != NULL ) httplib_pthread_mutex_lock( & ctx->nonce_mutex ); @@ -43,12 +43,12 @@ void httplib_lock_context( struct httplib_context *ctx ) { /* - * void httplib_unlock_context( struct httplib_context *ctx ); + * void httplib_unlock_context( struct lh_ctx_t *ctx ); * * The function httplib_unlock_context() removes the current lock from the context. */ -void httplib_unlock_context( struct httplib_context *ctx ) { +void httplib_unlock_context( struct lh_ctx_t *ctx ) { if ( ctx != NULL ) httplib_pthread_mutex_unlock( & ctx->nonce_mutex ); diff --git a/src/httplib_log_access.c b/src/httplib_log_access.c index 51ef1b88..14ad22e3 100644 --- a/src/httplib_log_access.c +++ b/src/httplib_log_access.c @@ -32,12 +32,12 @@ static const char *header_val( const struct httplib_connection *conn, const char *header ); /* - * void XX_httplib_log_access( const struct httplib_context *ctx, const struct httplib_connection *conn ); + * void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ); * * The function XX_httplib_log_access() logs an access of a client. */ -void XX_httplib_log_access( const struct httplib_context *ctx, const struct httplib_connection *conn ) { +void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ) { const struct httplib_request_info *ri; struct file fi; diff --git a/src/httplib_main.h b/src/httplib_main.h index c0fc85ef..ae55f4db 100644 --- a/src/httplib_main.h +++ b/src/httplib_main.h @@ -518,10 +518,10 @@ struct httplib_handler_info { }; /* - * struct httplib_context; + * struct lh_ctx_t; */ -struct httplib_context { +struct lh_ctx_t { volatile enum ctx_status_t status; /* Should we stop event loop */ SSL_CTX *ssl_ctx; /* SSL context */ @@ -644,17 +644,17 @@ struct httplib_connection { /* */ /****************************************************************************************/ struct worker_thread_args { - struct httplib_context *ctx; - int index; + struct lh_ctx_t * ctx; + int index; }; struct websocket_client_thread_data { - struct httplib_context *ctx; - struct httplib_connection *conn; - httplib_websocket_data_handler data_handler; - httplib_websocket_close_handler close_handler; - void *callback_data; + struct lh_ctx_t * ctx; + struct httplib_connection * conn; + httplib_websocket_data_handler data_handler; + httplib_websocket_close_handler close_handler; + void * callback_data; }; struct uriprot_tp { @@ -786,127 +786,127 @@ void SHA1Final( unsigned char digest[20], SHA1_CTX *context ); void SHA1Init( SHA1_CTX *context ); void SHA1Update( SHA1_CTX *context, const unsigned char *data, uint32_t len ); -struct httplib_context *XX_httplib_abort_start( struct httplib_context *ctx, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3); -void XX_httplib_accept_new_connection( const struct socket *listener, struct httplib_context *ctx ); -bool XX_httplib_authorize( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep ); +struct lh_ctx_t * XX_httplib_abort_start( struct lh_ctx_t *ctx, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3); +void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_ctx_t *ctx ); +bool XX_httplib_authorize( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep ); const char * XX_httplib_builtin_mime_ext( int index ); const char * XX_httplib_builtin_mime_type( int index ); -int XX_httplib_check_acl( struct httplib_context *ctx, uint32_t remote_ip ); -bool XX_httplib_check_authorization( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); +int XX_httplib_check_acl( struct lh_ctx_t *ctx, uint32_t remote_ip ); +bool XX_httplib_check_authorization( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); bool XX_httplib_check_password( const char *method, const char *ha1, const char *uri, const char *nonce, const char *nc, const char *cnonce, const char *qop, const char *response ); -void XX_httplib_close_all_listening_sockets( struct httplib_context *ctx ); -void XX_httplib_close_connection( struct httplib_context *ctx, struct httplib_connection *conn ); -void XX_httplib_close_socket_gracefully( const struct httplib_context *ctx, struct httplib_connection *conn ); +void XX_httplib_close_all_listening_sockets( struct lh_ctx_t *ctx ); +void XX_httplib_close_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ); +void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); int WINCDECL XX_httplib_compare_dir_entries( const void *p1, const void *p2 ); -bool XX_httplib_connect_socket( struct httplib_context *ctx, const char *host, int port, int use_ssl, SOCKET *sock, union usa *sa ); -void XX_httplib_construct_etag( const struct httplib_context *ctx, char *buf, size_t buf_len, const struct file *filep ); -int XX_httplib_consume_socket( struct httplib_context *ctx, struct socket *sp, int thread_index ); -void XX_httplib_delete_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); -void XX_httplib_dir_scan_callback( const struct httplib_context *ctx, struct de *de, void *data ); -void XX_httplib_discard_unread_request_data( const struct httplib_context *ctx, struct httplib_connection *conn ); +bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, SOCKET *sock, union usa *sa ); +void XX_httplib_construct_etag( const struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ); +int XX_httplib_consume_socket( struct lh_ctx_t *ctx, struct socket *sp, int thread_index ); +void XX_httplib_delete_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); +void XX_httplib_dir_scan_callback( const struct lh_ctx_t *ctx, struct de *de, void *data ); +void XX_httplib_discard_unread_request_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); int XX_httplib_fclose( struct file *filep ); -void XX_httplib_fclose_on_exec( const struct httplib_context *ctx, struct file *filep, struct httplib_connection *conn ); +void XX_httplib_fclose_on_exec( const struct lh_ctx_t *ctx, struct file *filep, struct httplib_connection *conn ); const char * XX_httplib_fgets( char *buf, size_t size, struct file *filep, char **p ); -bool XX_httplib_fopen( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, const char *mode, struct file *filep ); -bool XX_httplib_forward_body_data( const struct httplib_context *ctx, struct httplib_connection *conn, FILE *fp, SOCKET sock, SSL *ssl ); -void XX_httplib_free_config_options( struct httplib_context *ctx ); -void XX_httplib_free_context( struct httplib_context *ctx ); +bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, const char *mode, struct file *filep ); +bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn, FILE *fp, SOCKET sock, SSL *ssl ); +void XX_httplib_free_config_options( struct lh_ctx_t *ctx ); +void XX_httplib_free_context( struct lh_ctx_t *ctx ); const char * XX_httplib_get_header( const struct httplib_request_info *ri, const char *name ); -void XX_httplib_get_mime_type( const struct httplib_context *ctx, const char *path, struct vec *vec ); -const char * XX_httplib_get_rel_url_at_current_server( const struct httplib_context *ctx, const char *uri, const struct httplib_connection *conn ); +void XX_httplib_get_mime_type( const struct lh_ctx_t *ctx, const char *path, struct vec *vec ); +const char * XX_httplib_get_rel_url_at_current_server( const struct lh_ctx_t *ctx, const char *uri, const struct httplib_connection *conn ); uint32_t XX_httplib_get_remote_ip( const struct httplib_connection *conn ); -int XX_httplib_get_request_handler( struct httplib_context *ctx, struct httplib_connection *conn, int handler_type, httplib_request_handler *handler, httplib_websocket_connect_handler *connect_handler, httplib_websocket_ready_handler *ready_handler, httplib_websocket_data_handler *data_handler, httplib_websocket_close_handler *close_handler, httplib_authorization_handler *auth_handler, void **cbdata ); +int XX_httplib_get_request_handler( struct lh_ctx_t *ctx, struct httplib_connection *conn, int handler_type, httplib_request_handler *handler, httplib_websocket_connect_handler *connect_handler, httplib_websocket_ready_handler *ready_handler, httplib_websocket_data_handler *data_handler, httplib_websocket_close_handler *close_handler, httplib_authorization_handler *auth_handler, void **cbdata ); int XX_httplib_get_request_len( const char *buf, int buflen ); void XX_httplib_get_system_name( char **sysName ); enum uri_type_t XX_httplib_get_uri_type( const char *uri ); -bool XX_httplib_getreq( const struct httplib_context *ctx, struct httplib_connection *conn, int *err ); -void XX_httplib_handle_cgi_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog ); -void XX_httplib_handle_directory_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir ); -void XX_httplib_handle_file_based_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); -void XX_httplib_handle_not_modified_static_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep ); -void XX_httplib_handle_propfind( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); -void XX_httplib_handle_request( struct httplib_context *ctx, struct httplib_connection *conn ); -void XX_httplib_handle_ssi_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); -void XX_httplib_handle_static_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ); -void XX_httplib_handle_websocket_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData ); +bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int *err ); +void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog ); +void XX_httplib_handle_directory_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir ); +void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); +void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep ); +void XX_httplib_handle_propfind( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); +void XX_httplib_handle_request( struct lh_ctx_t *ctx, struct httplib_connection *conn ); +void XX_httplib_handle_ssi_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); +void XX_httplib_handle_static_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ); +void XX_httplib_handle_websocket_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData ); bool XX_httplib_header_has_option( const char *header, const char *option ); -bool XX_httplib_init_options( struct httplib_context *ctx ); -void XX_httplib_interpret_uri( const struct httplib_context *ctx, struct httplib_connection *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request ); -bool XX_httplib_is_authorized_for_put( const struct httplib_context *ctx, struct httplib_connection *conn ); -bool XX_httplib_is_file_in_memory( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path, struct file *filep ); +bool XX_httplib_init_options( struct lh_ctx_t *ctx ); +void XX_httplib_interpret_uri( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request ); +bool XX_httplib_is_authorized_for_put( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); +bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path, struct file *filep ); bool XX_httplib_is_file_opened( const struct file *filep ); -bool XX_httplib_is_not_modified( const struct httplib_context *ctx, const struct httplib_connection *conn, const struct file *filep ); +bool XX_httplib_is_not_modified( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const struct file *filep ); bool XX_httplib_is_put_or_delete_method( const struct httplib_connection *conn ); bool XX_httplib_is_valid_http_method( const char *method ); int XX_httplib_is_valid_port( unsigned long port ); bool XX_httplib_is_websocket_protocol( const struct httplib_connection *conn ); -void * XX_httplib_load_dll( struct httplib_context *ctx, const char *dll_name, struct ssl_func *sw ); -void XX_httplib_log_access( const struct httplib_context *ctx, const struct httplib_connection *conn ); +void * XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ssl_func *sw ); +void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ); LIBHTTP_THREAD XX_httplib_master_thread( void *thread_func_param ); int XX_httplib_match_prefix(const char *pattern, size_t pattern_len, const char *str); -void XX_httplib_mkcol( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); -bool XX_httplib_must_hide_file( const struct httplib_context *ctx, const char *path ); +void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); +bool XX_httplib_must_hide_file( const struct lh_ctx_t *ctx, const char *path ); const char * XX_httplib_next_option( const char *list, struct vec *val, struct vec *eq_val ); -void XX_httplib_open_auth_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); +void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); bool XX_httplib_option_value_to_bool( const char *value, bool *config ); bool XX_httplib_option_value_to_int( const char *value, int *config ); -int XX_httplib_parse_auth_header( const struct httplib_context *ctx, struct httplib_connection *conn, char *buf, size_t buf_size, struct ah *ah ); +int XX_httplib_parse_auth_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *buf, size_t buf_size, struct ah *ah ); time_t XX_httplib_parse_date_string( const char *datetime ); int XX_httplib_parse_http_headers( char **buf, struct httplib_request_info *ri ); int XX_httplib_parse_http_message( char *buf, int len, struct httplib_request_info *ri ); int XX_httplib_parse_net( const char *spec, uint32_t *net, uint32_t *mask ); int XX_httplib_parse_range_header( const char *header, int64_t *a, int64_t *b ); void XX_httplib_path_to_unicode( const char *path, wchar_t *wbuf, size_t wbuf_len ); -void XX_httplib_prepare_cgi_environment( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog, struct cgi_environment *env ); -void XX_httplib_print_dir_entry( const struct httplib_context *ctx, struct de *de ); -void XX_httplib_process_new_connection( struct httplib_context *ctx, struct httplib_connection *conn ); -bool XX_httplib_process_options( struct httplib_context *ctx, const struct httplib_option_t *options ); -void XX_httplib_produce_socket( struct httplib_context *ctx, const struct socket *sp ); -int XX_httplib_pull( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len, double timeout ); -int XX_httplib_pull_all( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len ); -int64_t XX_httplib_push_all( const struct httplib_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len ); -int XX_httplib_put_dir( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); -void XX_httplib_put_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); -bool XX_httplib_read_auth_file( const struct httplib_context *ctx, struct file *filep, struct read_auth_file_struct *workdata ); -int XX_httplib_read_request( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int bufsiz, int *nread ); -void XX_httplib_read_websocket( const struct httplib_context *ctx, struct httplib_connection *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ); -void XX_httplib_redirect_to_https_port( const struct httplib_context *ctx, struct httplib_connection *conn, int ssl_index ); -int XX_httplib_refresh_trust( const struct httplib_context *ctx, struct httplib_connection *conn ); -void XX_httplib_remove_bad_file( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path ); -int XX_httplib_remove_directory( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir ); +void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog, struct cgi_environment *env ); +void XX_httplib_print_dir_entry( const struct lh_ctx_t *ctx, struct de *de ); +void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ); +bool XX_httplib_process_options( struct lh_ctx_t *ctx, const struct httplib_option_t *options ); +void XX_httplib_produce_socket( struct lh_ctx_t *ctx, const struct socket *sp ); +int XX_httplib_pull( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len, double timeout ); +int XX_httplib_pull_all( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len ); +int64_t XX_httplib_push_all( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len ); +int XX_httplib_put_dir( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); +void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); +bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ); +int XX_httplib_read_request( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int bufsiz, int *nread ); +void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct httplib_connection *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ); +void XX_httplib_redirect_to_https_port( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int ssl_index ); +int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); +void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path ); +int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir ); void XX_httplib_remove_double_dots_and_double_slashes( char *s ); void XX_httplib_reset_per_request_attributes( struct httplib_connection *conn ); -int XX_httplib_scan_directory( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir, void *data, void (*cb)(const struct httplib_context *ctx, struct de *, void *) ); -void XX_httplib_send_authorization_request( struct httplib_context *ctx, struct httplib_connection *conn ); -void XX_httplib_send_file_data( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep, int64_t offset, int64_t len ); -void XX_httplib_send_http_error( const struct httplib_context *ctx, struct httplib_connection *, int, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(4, 5); -int XX_httplib_send_no_cache_header( const struct httplib_context *ctx, struct httplib_connection *conn ); -void XX_httplib_send_options( const struct httplib_context *ctx, struct httplib_connection *conn ); -int XX_httplib_send_static_cache_header( const struct httplib_context *ctx, struct httplib_connection *conn ); -int XX_httplib_send_websocket_handshake( const struct httplib_context *ctx, struct httplib_connection *conn, const char *websock_key ); -int XX_httplib_set_acl_option( struct httplib_context *ctx ); +int XX_httplib_scan_directory( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir, void *data, void (*cb)(const struct lh_ctx_t *ctx, struct de *, void *) ); +void XX_httplib_send_authorization_request( struct lh_ctx_t *ctx, struct httplib_connection *conn ); +void XX_httplib_send_file_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep, int64_t offset, int64_t len ); +void XX_httplib_send_http_error( const struct lh_ctx_t *ctx, struct httplib_connection *, int, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(4, 5); +int XX_httplib_send_no_cache_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); +void XX_httplib_send_options( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); +int XX_httplib_send_static_cache_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); +int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *websock_key ); +int XX_httplib_set_acl_option( struct lh_ctx_t *ctx ); void XX_httplib_set_close_on_exec( SOCKET sock ); -bool XX_httplib_set_gpass_option( struct httplib_context *ctx ); -void XX_httplib_set_handler_type( struct httplib_context *ctx, const char *uri, int handler_type, int is_delete_request, httplib_request_handler handler, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, httplib_authorization_handler auth_handler, void *cbdata ); +bool XX_httplib_set_gpass_option( struct lh_ctx_t *ctx ); +void XX_httplib_set_handler_type( struct lh_ctx_t *ctx, const char *uri, int handler_type, int is_delete_request, httplib_request_handler handler, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, httplib_authorization_handler auth_handler, void *cbdata ); int XX_httplib_set_non_blocking_mode( SOCKET sock ); -int XX_httplib_set_ports_option( struct httplib_context *ctx ); +int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ); int XX_httplib_set_sock_timeout( SOCKET sock, int milliseconds ); int XX_httplib_set_tcp_nodelay( SOCKET sock, bool nodelay_on ); -void XX_httplib_set_thread_name( const struct httplib_context *ctx, const char *name ); +void XX_httplib_set_thread_name( const struct lh_ctx_t *ctx, const char *name ); int XX_httplib_set_throttle( const char *spec, uint32_t remote_ip, const char *uri ); -bool XX_httplib_set_uid_option( struct httplib_context *ctx ); -bool XX_httplib_should_decode_url( const struct httplib_context *ctx ); -bool XX_httplib_should_keep_alive( const struct httplib_context *ctx, const struct httplib_connection *conn ); +bool XX_httplib_set_uid_option( struct lh_ctx_t *ctx ); +bool XX_httplib_should_decode_url( const struct lh_ctx_t *ctx ); +bool XX_httplib_should_keep_alive( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ); char * XX_httplib_skip( char **buf, const char *delimiters ); char * XX_httplib_skip_quoted( char **buf, const char *delimiters, const char *whitespace, char quotechar ); void XX_httplib_sockaddr_to_string(char *buf, size_t len, const union usa *usa ); -pid_t XX_httplib_spawn_process( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ); +pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ); int XX_httplib_start_thread_with_id( httplib_thread_func_t func, void *param, pthread_t *threadidptr ); -int XX_httplib_stat( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); -int XX_httplib_substitute_index_file( const struct httplib_context *ctx, struct httplib_connection *conn, char *path, size_t path_len, struct file *filep ); -const char * XX_httplib_suggest_connection_header( const struct httplib_context *ctx, const struct httplib_connection *conn ); +int XX_httplib_stat( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ); +int XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *path, size_t path_len, struct file *filep ); +const char * XX_httplib_suggest_connection_header( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ); LIBHTTP_THREAD XX_httplib_websocket_client_thread( void *data ); -int XX_httplib_websocket_write_exec( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen, uint32_t masking_key ); +int XX_httplib_websocket_write_exec( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen, uint32_t masking_key ); LIBHTTP_THREAD XX_httplib_worker_thread( void *thread_func_param ); diff --git a/src/httplib_master_thread.c b/src/httplib_master_thread.c index 75e3979c..42fb1c3f 100644 --- a/src/httplib_master_thread.c +++ b/src/httplib_master_thread.c @@ -58,7 +58,7 @@ LIBHTTP_THREAD XX_httplib_master_thread( void *thread_func_param ) { static void master_thread_run(void *thread_func_param) { - struct httplib_context *ctx = (struct httplib_context *)thread_func_param; + struct lh_ctx_t *ctx = (struct lh_ctx_t *)thread_func_param; struct httplib_workerTLS tls; struct pollfd *pfd; int i; diff --git a/src/httplib_mkcol.c b/src/httplib_mkcol.c index dee163c1..d81d734a 100644 --- a/src/httplib_mkcol.c +++ b/src/httplib_mkcol.c @@ -29,14 +29,14 @@ #include "httplib_utils.h" /* - * void XX_httplib_mkcol( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); + * void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); * * The function XX_httplib_mkcol() handles a MKCOL command from a remote * client. The MKCOL method is used to create a new collection resource at the * location specificied by the request URI. */ -void XX_httplib_mkcol( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ) { +void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ) { int rc; int body_len; diff --git a/src/httplib_must_hide_file.c b/src/httplib_must_hide_file.c index 681a4711..381750ad 100644 --- a/src/httplib_must_hide_file.c +++ b/src/httplib_must_hide_file.c @@ -28,7 +28,7 @@ #include "httplib_main.h" /* - * bool XX_httplib_must_hide_file( const struct httplib_context *ctx, const char *path ); + * bool XX_httplib_must_hide_file( const struct lh_ctx_t *ctx, const char *path ); * * The function XX_httplib_must_hide_file() returns true, if a file must be * hidden from browsing by the remote client. A used provided list of file @@ -36,7 +36,7 @@ * the patterns defined by the user. */ -bool XX_httplib_must_hide_file( const struct httplib_context *ctx, const char *path ) { +bool XX_httplib_must_hide_file( const struct lh_ctx_t *ctx, const char *path ) { const char *pw_pattern; const char *pattern; diff --git a/src/httplib_open_auth_file.c b/src/httplib_open_auth_file.c index 7c43f0a2..a61ff0fe 100644 --- a/src/httplib_open_auth_file.c +++ b/src/httplib_open_auth_file.c @@ -33,7 +33,7 @@ * or search for .htpasswd in the requested directory. */ -void XX_httplib_open_auth_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { +void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { char name[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_parse_auth_header.c b/src/httplib_parse_auth_header.c index e6eae983..0092fe25 100644 --- a/src/httplib_parse_auth_header.c +++ b/src/httplib_parse_auth_header.c @@ -32,7 +32,7 @@ * Return 1 on success. Always initializes the ah structure. */ -int XX_httplib_parse_auth_header( const struct httplib_context *ctx, struct httplib_connection *conn, char *buf, size_t buf_size, struct ah *ah ) { +int XX_httplib_parse_auth_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *buf, size_t buf_size, struct ah *ah ) { char *name; char *value; diff --git a/src/httplib_prepare_cgi_environment.c b/src/httplib_prepare_cgi_environment.c index 57d13cab..2b5adc9b 100644 --- a/src/httplib_prepare_cgi_environment.c +++ b/src/httplib_prepare_cgi_environment.c @@ -31,7 +31,7 @@ #include "httplib_utils.h" /* - * void XX_httplib_prepare_cgi_environment( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog, struct cgi_environment *env ); + * void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog, struct cgi_environment *env ); * * The function XX_httplib_prepare_cgi_environment() is used to prepare all * environment variables before a CGI script is called. @@ -39,7 +39,7 @@ #if !defined(NO_CGI) -void XX_httplib_prepare_cgi_environment( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog, struct cgi_environment *env ) { +void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog, struct cgi_environment *env ) { const char *s; struct vec var_vec; diff --git a/src/httplib_print_dir_entry.c b/src/httplib_print_dir_entry.c index 2af6e190..184ecc0d 100644 --- a/src/httplib_print_dir_entry.c +++ b/src/httplib_print_dir_entry.c @@ -28,7 +28,7 @@ #include "httplib_main.h" #include "httplib_string.h" -void XX_httplib_print_dir_entry( const struct httplib_context *ctx, struct de *de ) { +void XX_httplib_print_dir_entry( const struct lh_ctx_t *ctx, struct de *de ) { char size[64]; char mod[64]; diff --git a/src/httplib_printf.c b/src/httplib_printf.c index 658e02c3..cdbea059 100644 --- a/src/httplib_printf.c +++ b/src/httplib_printf.c @@ -28,7 +28,7 @@ #include "httplib_main.h" #include "httplib_string.h" -int httplib_printf( const struct httplib_context *ctx, struct httplib_connection *conn, const char *fmt, ... ) { +int httplib_printf( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *fmt, ... ) { va_list ap; int result; diff --git a/src/httplib_process_new_connection.c b/src/httplib_process_new_connection.c index a2b98d25..5283a520 100644 --- a/src/httplib_process_new_connection.c +++ b/src/httplib_process_new_connection.c @@ -29,13 +29,13 @@ #include "httplib_string.h" /* - * void XX_httplib_process_new_connection( struct httplib_context *ctx, struct httplib_connection *conn ); + * void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_process_new_connection() is used to process a new * incoming connection on a socket. */ -void XX_httplib_process_new_connection( struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct httplib_connection *conn ) { struct httplib_request_info *ri; int keep_alive; diff --git a/src/httplib_process_options.c b/src/httplib_process_options.c index 90b33dce..c9e2f7c6 100644 --- a/src/httplib_process_options.c +++ b/src/httplib_process_options.c @@ -22,16 +22,16 @@ #include "httplib_main.h" -static bool check_bool( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, bool *config ); -static bool check_dbg( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, enum debug_level_t *config ); -static bool check_dir( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); -static bool check_file( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); -static bool check_int( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, int *config, int minval, int maxval ); -static bool check_patt( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); -static bool check_str( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); +static bool check_bool( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, bool *config ); +static bool check_dbg( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, enum debug_level_t *config ); +static bool check_dir( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); +static bool check_file( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); +static bool check_int( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, int *config, int minval, int maxval ); +static bool check_patt( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); +static bool check_str( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); /* - * bool XX_httplib_process_options( struct httplib_context *ctx, const struct httplib_option_t *options ); + * bool XX_httplib_process_options( struct lh_ctx_t *ctx, const struct httplib_option_t *options ); * * The function process_options() processes the user supplied options and adds * them to the central option list of the context. If en error occurs, the @@ -40,7 +40,7 @@ static bool check_str( struct httplib_context *ctx, const struct httplib_opti * generated. */ -bool XX_httplib_process_options( struct httplib_context *ctx, const struct httplib_option_t *options ) { +bool XX_httplib_process_options( struct lh_ctx_t *ctx, const struct httplib_option_t *options ) { if ( ctx == NULL ) return true; @@ -101,7 +101,7 @@ bool XX_httplib_process_options( struct httplib_context *ctx, const struct httpl } /* XX_httplib_process_options */ /* - * static bool check_bool( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, bool *config ); + * static bool check_bool( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, bool *config ); * * The function check_bool() checks if an option is equal to a boolean config * parameter and stores the value if that is the case. If the value cannot be @@ -111,7 +111,7 @@ bool XX_httplib_process_options( struct httplib_context *ctx, const struct httpl * false is returned. */ -static bool check_bool( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, bool *config ) { +static bool check_bool( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, bool *config ) { if ( ctx == NULL || option == NULL || option->name == NULL || name == NULL || config == NULL ) { @@ -128,7 +128,7 @@ static bool check_bool( struct httplib_context *ctx, const struct httplib_option } /* check_bool */ /* - * static bool check_dir( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); + * static bool check_dir( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); * * The function check_dir() checks if an option is equal to a directory config * parameter and stores the value if that is the case. If the value cannot be @@ -138,7 +138,7 @@ static bool check_bool( struct httplib_context *ctx, const struct httplib_option * false is returned. */ -static bool check_dir( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ) { +static bool check_dir( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ) { if ( ctx == NULL || option == NULL || option->name == NULL || name == NULL || config == NULL ) { @@ -161,7 +161,7 @@ static bool check_dir( struct httplib_context *ctx, const struct httplib_option_ } /* check_dir */ /* - * static bool check_patt( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); + * static bool check_patt( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); * * The function check_patt() checks if an option is equal to a pattern config * parameter and stores the value if that is the case. If the value cannot be @@ -171,7 +171,7 @@ static bool check_dir( struct httplib_context *ctx, const struct httplib_option_ * false is returned. */ -static bool check_patt( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ) { +static bool check_patt( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ) { if ( ctx == NULL || option == NULL || option->name == NULL || name == NULL || config == NULL ) { @@ -194,7 +194,7 @@ static bool check_patt( struct httplib_context *ctx, const struct httplib_option } /* check_patt */ /* - * static bool check_file( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); + * static bool check_file( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); * * The function check_file() checks if an option is equal to a filename config * parameter and stores the value if that is the case. If the value cannot be @@ -204,7 +204,7 @@ static bool check_patt( struct httplib_context *ctx, const struct httplib_option * false is returned. */ -static bool check_file( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ) { +static bool check_file( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ) { if ( ctx == NULL || option == NULL || option->name == NULL || name == NULL || config == NULL ) { @@ -227,7 +227,7 @@ static bool check_file( struct httplib_context *ctx, const struct httplib_option } /* check_file */ /* - * static bool check_str( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ); + * static bool check_str( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ); * * The function check_str() checks if an option is equal to a string config * parameter and stores the value if that is the case. If the value cannot be @@ -237,7 +237,7 @@ static bool check_file( struct httplib_context *ctx, const struct httplib_option * false is returned. */ -static bool check_str( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, char **config ) { +static bool check_str( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, char **config ) { if ( ctx == NULL || option == NULL || option->name == NULL || name == NULL || config == NULL ) { @@ -260,7 +260,7 @@ static bool check_str( struct httplib_context *ctx, const struct httplib_option_ } /* check_str */ /* - * static bool check_int( struct httplib_context *ctx, const struct httplib_opion_t *option, const char *name, int *config, int minval, int maxval ); + * static bool check_int( struct lh_ctx_t *ctx, const struct httplib_opion_t *option, const char *name, int *config, int minval, int maxval ); * * The function check_int() checks in an option is equal to an integer config * parameter and stores the value if that is the case. If the value cannot be @@ -270,7 +270,7 @@ static bool check_str( struct httplib_context *ctx, const struct httplib_option_ * valud, also false is returned. */ -static bool check_int( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, int *config, int minval, int maxval ) { +static bool check_int( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, int *config, int minval, int maxval ) { int val; @@ -297,7 +297,7 @@ static bool check_int( struct httplib_context *ctx, const struct httplib_option_ } /* check_int */ /* - * static bool check_dbg( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name ); + * static bool check_dbg( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name ); * * The function check_dbg() checks if an option is equal to a debug level * config parameter and stores the value if that is the case. If the value @@ -307,7 +307,7 @@ static bool check_int( struct httplib_context *ctx, const struct httplib_option_ * valid, also false is returned. */ -static bool check_dbg( struct httplib_context *ctx, const struct httplib_option_t *option, const char *name, enum debug_level_t *config ) { +static bool check_dbg( struct lh_ctx_t *ctx, const struct httplib_option_t *option, const char *name, enum debug_level_t *config ) { int val; diff --git a/src/httplib_produce_socket.c b/src/httplib_produce_socket.c index bdf3490c..b2b703c4 100644 --- a/src/httplib_produce_socket.c +++ b/src/httplib_produce_socket.c @@ -29,14 +29,14 @@ #include "httplib_pthread.h" /* - * void XX_httplib_produce_socket( struct httplib_context *ctx, const struct socket *sp ); + * void XX_httplib_produce_socket( struct lh_ctx_t *ctx, const struct socket *sp ); * * The function XX_httplib_produce_socket() is used to produce a socket. */ #if defined(ALTERNATIVE_QUEUE) -void XX_httplib_produce_socket( struct httplib_context *ctx, const struct socket *sp ) { +void XX_httplib_produce_socket( struct lh_ctx_t *ctx, const struct socket *sp ) { unsigned int i; @@ -74,7 +74,7 @@ void XX_httplib_produce_socket( struct httplib_context *ctx, const struct socket * Master thread adds accepted socket to a queue */ -void XX_httplib_produce_socket( struct httplib_context *ctx, const struct socket *sp ) { +void XX_httplib_produce_socket( struct lh_ctx_t *ctx, const struct socket *sp ) { #define QUEUE_SIZE(ctx) ((int)(ARRAY_SIZE(ctx->queue))) diff --git a/src/httplib_pull.c b/src/httplib_pull.c index 4b020523..37da5112 100644 --- a/src/httplib_pull.c +++ b/src/httplib_pull.c @@ -34,7 +34,7 @@ * Return negative value on error, or number of bytes read on success. */ -int XX_httplib_pull( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len, double timeout ) { +int XX_httplib_pull( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len, double timeout ) { int nread; int err; diff --git a/src/httplib_pull_all.c b/src/httplib_pull_all.c index 7de4ded3..8b78ec6c 100644 --- a/src/httplib_pull_all.c +++ b/src/httplib_pull_all.c @@ -27,7 +27,7 @@ #include "httplib_main.h" -int XX_httplib_pull_all( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len ) { +int XX_httplib_pull_all( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int len ) { int n; int nread; diff --git a/src/httplib_push_all.c b/src/httplib_push_all.c index d407884c..a95929f2 100644 --- a/src/httplib_push_all.c +++ b/src/httplib_push_all.c @@ -36,7 +36,7 @@ #endif /* - * static int64_t push( const struct httplib_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len, double timeout ); + * static int64_t push( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len, double timeout ); * * The function push() writes data to the I/O channel, opened file descriptor, * socket or SSL descriptor. The function returns the number of bytes which @@ -50,7 +50,7 @@ * been written. */ -static int64_t push( const struct httplib_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len, double timeout ) { +static int64_t push( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len, double timeout ) { struct timespec start; struct timespec now; @@ -146,13 +146,13 @@ static int64_t push( const struct httplib_context *ctx, FILE *fp, SOCKET sock, S /* - * int64_t XX_httplib_push_all( const struct httplib_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len ); + * int64_t XX_httplib_push_all( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len ); * * The function XX_httplib_push_all() pushes all data in a buffer to a socket. * The number of bytes written is returned. */ -int64_t XX_httplib_push_all( const struct httplib_context *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len ) { +int64_t XX_httplib_push_all( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len ) { double timeout; int64_t n; diff --git a/src/httplib_put_dir.c b/src/httplib_put_dir.c index e76183d8..bc8cc17e 100644 --- a/src/httplib_put_dir.c +++ b/src/httplib_put_dir.c @@ -28,7 +28,7 @@ #include "httplib_main.h" /* - * int XX_httplib_put_dir( struct httplib_connection *conn, const char *path ); + * int XX_httplib_put_dir( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); * * The function XX_httplib_put_dir() creates a directory mentioned in a PUT * request including all intermediate subdirectories. The following values can @@ -39,7 +39,7 @@ * Return -2 if path can not be created. */ -int XX_httplib_put_dir( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ) { +int XX_httplib_put_dir( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ) { char buf[PATH_MAX]; const char *s; diff --git a/src/httplib_put_file.c b/src/httplib_put_file.c index 665bbd35..ab46528c 100644 --- a/src/httplib_put_file.c +++ b/src/httplib_put_file.c @@ -29,13 +29,13 @@ #include "httplib_utils.h" /* - * void XX_httplib_put_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ); + * void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ); * * The function XX_httplib_put_file() processes a file PUT request coming from * a remote client. */ -void XX_httplib_put_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ) { +void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ) { struct file file = STRUCT_FILE_INITIALIZER; const char *range; diff --git a/src/httplib_read.c b/src/httplib_read.c index e3caf298..e0ea0112 100644 --- a/src/httplib_read.c +++ b/src/httplib_read.c @@ -27,7 +27,7 @@ #include "httplib_main.h" -static int httplib_read_inner( const struct httplib_context *ctx, struct httplib_connection *conn, void *buffie, size_t len ) { +static int httplib_read_inner( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *buffie, size_t len ) { int64_t n; int64_t buffered_len; @@ -101,7 +101,7 @@ static int httplib_read_inner( const struct httplib_context *ctx, struct httplib } /* httplib_read_inner */ -static char httplib_getc( const struct httplib_context *ctx, struct httplib_connection *conn ) { +static char httplib_getc( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { char c; @@ -115,7 +115,7 @@ static char httplib_getc( const struct httplib_context *ctx, struct httplib_conn } /* httplib_getc */ -int httplib_read( const struct httplib_context *ctx, struct httplib_connection *conn, void *buf, size_t len ) { +int httplib_read( const struct lh_ctx_t *ctx, struct httplib_connection *conn, void *buf, size_t len ) { if ( len > INT_MAX ) len = INT_MAX; diff --git a/src/httplib_read_auth_file.c b/src/httplib_read_auth_file.c index 24aef83b..47405a96 100644 --- a/src/httplib_read_auth_file.c +++ b/src/httplib_read_auth_file.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * bool XX_httplib_read_auth_file( const struct httplib_context *ctx, struct file *filep, struct read_auth_file_struct *workdata ); + * bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ); * * The function XX_httpib_read_auth_file() loops over the password file to * read its contents. Include statements are honored which lets the routine * also open and scan child files. */ -bool XX_httplib_read_auth_file( const struct httplib_context *ctx, struct file *filep, struct read_auth_file_struct *workdata ) { +bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ) { int is_authorized; struct file fp; diff --git a/src/httplib_read_request.c b/src/httplib_read_request.c index dcab62af..c6175ddf 100644 --- a/src/httplib_read_request.c +++ b/src/httplib_read_request.c @@ -29,7 +29,7 @@ #include "httplib_utils.h" /* - * int XX_httplib_read_request( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int bufsiz, int *nread ); + * int XX_httplib_read_request( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int bufsiz, int *nread ); * * The function XX_httplib_read_request() keeps reading the input (which can * either be an opened file descriptor, a socket sock or an SSL descriptor ssl) @@ -39,7 +39,7 @@ * is incremented by the number of bytes read. */ -int XX_httplib_read_request( const struct httplib_context *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int bufsiz, int *nread ) { +int XX_httplib_read_request( const struct lh_ctx_t *ctx, FILE *fp, struct httplib_connection *conn, char *buf, int bufsiz, int *nread ) { int request_len; int n; diff --git a/src/httplib_read_websocket.c b/src/httplib_read_websocket.c index 3d42d8b8..862ae558 100644 --- a/src/httplib_read_websocket.c +++ b/src/httplib_read_websocket.c @@ -28,12 +28,12 @@ #include "httplib_main.h" /* - * void XX_httplib_read_websocket( const struct httplib_context *ctx, struct httplib_connection *conn, httplib_websocket_data_handler ws_data_handler, void *calback_data ); + * void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct httplib_connection *conn, httplib_websocket_data_handler ws_data_handler, void *calback_data ); * * The function XX_httplib_read_websocket() reads from a websocket connection. */ -void XX_httplib_read_websocket( const struct httplib_context *ctx, struct httplib_connection *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ) { +void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct httplib_connection *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ) { /* Pointer to the beginning of the portion of the incoming websocket * message queue. diff --git a/src/httplib_redirect_to_https_port.c b/src/httplib_redirect_to_https_port.c index f9b1ae6a..60e9bd81 100644 --- a/src/httplib_redirect_to_https_port.c +++ b/src/httplib_redirect_to_https_port.c @@ -29,13 +29,13 @@ #include "httplib_string.h" /* - * void XX_httplib_redirect_to_https_port( const struct httplib_context *ctx, struct httplib_connection *conn, int ssl_index ); + * void XX_httplib_redirect_to_https_port( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int ssl_index ); * * The function XX_httplib_redirect_to_https_port() redirects a request to an * encrypted connection over HTTPS. */ -void XX_httplib_redirect_to_https_port( const struct httplib_context *ctx, struct httplib_connection *conn, int ssl_index ) { +void XX_httplib_redirect_to_https_port( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int ssl_index ) { char host[1024+1]; const char *host_header; diff --git a/src/httplib_refresh_trust.c b/src/httplib_refresh_trust.c index ae795bb6..4326faa3 100644 --- a/src/httplib_refresh_trust.c +++ b/src/httplib_refresh_trust.c @@ -41,7 +41,7 @@ static long int data_check = 0; #if !defined(NO_SSL) -int XX_httplib_refresh_trust( const struct httplib_context *ctx, struct httplib_connection *conn ) { +int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { volatile int *p_reload_lock; struct stat cert_buf; diff --git a/src/httplib_remove_bad_file.c b/src/httplib_remove_bad_file.c index 47f6d7d0..c2febcd7 100644 --- a/src/httplib_remove_bad_file.c +++ b/src/httplib_remove_bad_file.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void XX_httplib_remove_bad_file( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path ); + * void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path ); * * The function XX_httplib_remove_bad_file() removes an invalid file and throws * an error message if this does not succeed. */ -void XX_httplib_remove_bad_file( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *path ) { +void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *path ) { int r = httplib_remove( path ); diff --git a/src/httplib_remove_directory.c b/src/httplib_remove_directory.c index c330e119..d7ffb061 100644 --- a/src/httplib_remove_directory.c +++ b/src/httplib_remove_directory.c @@ -29,13 +29,13 @@ #include "httplib_string.h" /* - * int XX_httplib_remove_directory( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir ); + * int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir ); * * The function XX_httplib_remove_directory() removes recursively a directory * tree. */ -int XX_httplib_remove_directory( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir ) { +int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir ) { char path[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_scan_directory.c b/src/httplib_scan_directory.c index 53dc45cd..998b15d3 100644 --- a/src/httplib_scan_directory.c +++ b/src/httplib_scan_directory.c @@ -28,7 +28,7 @@ #include "httplib_main.h" #include "httplib_string.h" -int XX_httplib_scan_directory( const struct httplib_context *ctx, struct httplib_connection *conn, const char *dir, void *data, void (*cb)(const struct httplib_context *ctx, struct de *, void *) ) { +int XX_httplib_scan_directory( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *dir, void *data, void (*cb)(const struct lh_ctx_t *ctx, struct de *, void *) ) { char path[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_send_authorization_request.c b/src/httplib_send_authorization_request.c index bbdc3677..de54ac7c 100644 --- a/src/httplib_send_authorization_request.c +++ b/src/httplib_send_authorization_request.c @@ -29,7 +29,7 @@ #include "httplib_pthread.h" #include "httplib_utils.h" -void XX_httplib_send_authorization_request( struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_send_authorization_request( struct lh_ctx_t *ctx, struct httplib_connection *conn ) { char date[64]; time_t curtime; diff --git a/src/httplib_send_file.c b/src/httplib_send_file.c index 198d0d30..429afd07 100644 --- a/src/httplib_send_file.c +++ b/src/httplib_send_file.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void httplib_send_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, const char *mime_type, const char *additional_headers ); + * void httplib_send_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, const char *mime_type, const char *additional_headers ); * * The function httplib_send_file() sends a file to the other peer. Optionally * the MIME type and additional headers can be specified. */ -void httplib_send_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, const char *mime_type, const char *additional_headers ) { +void httplib_send_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, const char *mime_type, const char *additional_headers ) { struct file file = STRUCT_FILE_INITIALIZER; diff --git a/src/httplib_send_file_data.c b/src/httplib_send_file_data.c index 7a6ff51d..5cd23e5f 100644 --- a/src/httplib_send_file_data.c +++ b/src/httplib_send_file_data.c @@ -34,7 +34,7 @@ * Send len bytes from the opened file to the client. */ -void XX_httplib_send_file_data( const struct httplib_context *ctx, struct httplib_connection *conn, struct file *filep, int64_t offset, int64_t len ) { +void XX_httplib_send_file_data( const struct lh_ctx_t *ctx, struct httplib_connection *conn, struct file *filep, int64_t offset, int64_t len ) { char buf[MG_BUF_LEN]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_send_http_error.c b/src/httplib_send_http_error.c index 9acc2dca..3b5fd098 100644 --- a/src/httplib_send_http_error.c +++ b/src/httplib_send_http_error.c @@ -29,7 +29,7 @@ #include "httplib_string.h" #include "httplib_utils.h" -void XX_httplib_send_http_error( const struct httplib_context *ctx, struct httplib_connection *conn, int status, const char *fmt, ... ) { +void XX_httplib_send_http_error( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int status, const char *fmt, ... ) { char buf[MG_BUF_LEN]; va_list ap; diff --git a/src/httplib_send_no_cache_header.c b/src/httplib_send_no_cache_header.c index be6016ae..55c76156 100644 --- a/src/httplib_send_no_cache_header.c +++ b/src/httplib_send_no_cache_header.c @@ -27,7 +27,7 @@ #include "httplib_main.h" -int XX_httplib_send_no_cache_header( const struct httplib_context *ctx, struct httplib_connection *conn ) { +int XX_httplib_send_no_cache_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { /* * Send all current and obsolete cache opt-out directives. diff --git a/src/httplib_send_options.c b/src/httplib_send_options.c index f82f2b7d..a6f10a76 100644 --- a/src/httplib_send_options.c +++ b/src/httplib_send_options.c @@ -29,13 +29,13 @@ #include "httplib_utils.h" /* - * void XX_httplib_send_options( const struct httplib_context *ctx, struct httplib_connection *conn ); + * void XX_httplib_send_options( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_send_options() sends a list of allowed options a * client can use to connect to the server. */ -void XX_httplib_send_options( const struct httplib_context *ctx, struct httplib_connection *conn ) { +void XX_httplib_send_options( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { char date[64]; time_t curtime; diff --git a/src/httplib_send_static_cache_header.c b/src/httplib_send_static_cache_header.c index 90aa3faa..553b2202 100644 --- a/src/httplib_send_static_cache_header.c +++ b/src/httplib_send_static_cache_header.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * int XX_httlib_send_static_cache_header( const struct httplib_context *ctx, struct httplib_connection *conn ); + * int XX_httlib_send_static_cache_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn ); * * The function XX_httplib_send_static_cache_header() sends cache headers * depending on the cache setting of the current context. */ -int XX_httplib_send_static_cache_header( const struct httplib_context *ctx, struct httplib_connection *conn ) { +int XX_httplib_send_static_cache_header( const struct lh_ctx_t *ctx, struct httplib_connection *conn ) { if ( ctx == NULL || conn == NULL ) return 0; diff --git a/src/httplib_send_websocket_handshake.c b/src/httplib_send_websocket_handshake.c index e3646a89..690c8a0c 100644 --- a/src/httplib_send_websocket_handshake.c +++ b/src/httplib_send_websocket_handshake.c @@ -32,13 +32,13 @@ #define B64_SHA_LEN (sizeof(sha)*2) /* - * int XX_httplib_send_websocket_handshake( const struct httplib_context *ctx, struct httplib_connection *conn, const char *websock_key ); + * int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *websock_key ); * * The function XX_httplib_send_websocket_handshake() sends a handshake over * a websocket connection. */ -int XX_httplib_send_websocket_handshake( const struct httplib_context *ctx, struct httplib_connection *conn, const char *websock_key ) { +int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *websock_key ) { static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; const char *protocol; diff --git a/src/httplib_set_acl_option.c b/src/httplib_set_acl_option.c index 8c8a6026..69a0804c 100644 --- a/src/httplib_set_acl_option.c +++ b/src/httplib_set_acl_option.c @@ -28,12 +28,12 @@ #include "httplib_main.h" /* - * int XX_httplib_set_acl_option( struct httplib_context *ctx ); + * int XX_httplib_set_acl_option( struct lh_ctx_t *ctx ); * * The function XX_httplib_set_acl_option() sets the ACL option for a context. */ -int XX_httplib_set_acl_option( struct httplib_context *ctx ) { +int XX_httplib_set_acl_option( struct lh_ctx_t *ctx ) { return XX_httplib_check_acl( ctx, (uint32_t)0x7f000001UL ) != -1; diff --git a/src/httplib_set_auth_handler.c b/src/httplib_set_auth_handler.c index 74231008..2f69a49b 100644 --- a/src/httplib_set_auth_handler.c +++ b/src/httplib_set_auth_handler.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void httplib_set_auth_handler( struct httplib_context *ctx, const char *uri, httplib_request_handler handler, void *cbdata ); + * void httplib_set_auth_handler( struct lh_ctx_t *ctx, const char *uri, httplib_request_handler handler, void *cbdata ); * * The function httplib_set_auth_handler() sets the callback function which handles * authorization requests. */ -LIBHTTP_API void httplib_set_auth_handler( struct httplib_context *ctx, const char *uri, httplib_request_handler handler, void *cbdata ) { +LIBHTTP_API void httplib_set_auth_handler( struct lh_ctx_t *ctx, const char *uri, httplib_request_handler handler, void *cbdata ) { XX_httplib_set_handler_type( ctx, uri, AUTH_HANDLER, (handler == NULL), NULL, NULL, NULL, NULL, NULL, handler, cbdata ); diff --git a/src/httplib_set_debug_level.c b/src/httplib_set_debug_level.c index e527a8ac..5480e8c7 100644 --- a/src/httplib_set_debug_level.c +++ b/src/httplib_set_debug_level.c @@ -23,13 +23,13 @@ #include "httplib_main.h" /* - * enum debug_level_t httplib_set_debug_level( struct httplib_context *ctx, enum debug_level_t new_level ); + * enum debug_level_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum debug_level_t new_level ); * * The function httplib_get_debug_level() sets the debug level for a context * and returns the previous debug level. */ -enum debug_level_t httplib_set_debug_level( struct httplib_context *ctx, enum debug_level_t new_level ) { +enum debug_level_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum debug_level_t new_level ) { enum debug_level_t prev_level; diff --git a/src/httplib_set_gpass_option.c b/src/httplib_set_gpass_option.c index 20394aaa..c181c55c 100644 --- a/src/httplib_set_gpass_option.c +++ b/src/httplib_set_gpass_option.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * bool XX_httplib_set_gpass_option( struct httplib_context *ctx ); + * bool XX_httplib_set_gpass_option( struct lh_ctx_t *ctx ); * * The function XX_httplib_set_gpass_option() sets the global password file * option for a context. The function returns false when an error occurs and * true when successful. */ -bool XX_httplib_set_gpass_option( struct httplib_context *ctx ) { +bool XX_httplib_set_gpass_option( struct lh_ctx_t *ctx ) { struct file file = STRUCT_FILE_INITIALIZER; const char *path; diff --git a/src/httplib_set_handler_type.c b/src/httplib_set_handler_type.c index 0029042e..c1cdffaf 100644 --- a/src/httplib_set_handler_type.c +++ b/src/httplib_set_handler_type.c @@ -35,7 +35,7 @@ * sets callback handlers to uri's. */ -void XX_httplib_set_handler_type( struct httplib_context *ctx, const char *uri, int handler_type, int is_delete_request, httplib_request_handler handler, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, httplib_authorization_handler auth_handler, void *cbdata ) { +void XX_httplib_set_handler_type( struct lh_ctx_t *ctx, const char *uri, int handler_type, int is_delete_request, httplib_request_handler handler, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, httplib_authorization_handler auth_handler, void *cbdata ) { struct httplib_handler_info *tmp_rh; struct httplib_handler_info **lastref; diff --git a/src/httplib_set_ports_option.c b/src/httplib_set_ports_option.c index d7a9b772..73ba0105 100644 --- a/src/httplib_set_ports_option.c +++ b/src/httplib_set_ports_option.c @@ -31,14 +31,14 @@ static bool parse_port_string( const struct vec *vec, struct socket *so, int *ip_version ); /* - * int XX_httplib_set_ports_option( struct httplib_context *ctx ); + * int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ); * * The function XX_httplib_set_ports_option() set the port options for a * context. The function returns the total number of ports opened, or 0 if no * ports have been opened. */ -int XX_httplib_set_ports_option( struct httplib_context *ctx ) { +int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) { const char *list; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_set_request_handler.c b/src/httplib_set_request_handler.c index 9fcfd051..e8a7d7be 100644 --- a/src/httplib_set_request_handler.c +++ b/src/httplib_set_request_handler.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void httplib_set_request_handler( httplib_context *ctx, const char *uri, httplib_request_handler handler, void *cbdata ); + * void httplib_set_request_handler( struct lh_ctx_t *ctx, const char *uri, httplib_request_handler handler, void *cbdata ); * * The function httplib_set_request_handler() sets a request handler for a specific * uri in a server context. */ -LIBHTTP_API void httplib_set_request_handler( struct httplib_context *ctx, const char *uri, httplib_request_handler handler, void *cbdata ) { +LIBHTTP_API void httplib_set_request_handler( struct lh_ctx_t *ctx, const char *uri, httplib_request_handler handler, void *cbdata ) { XX_httplib_set_handler_type( ctx, uri, REQUEST_HANDLER, (handler == NULL), handler, NULL, NULL, NULL, NULL, NULL, cbdata ); diff --git a/src/httplib_set_ssl_option.c b/src/httplib_set_ssl_option.c index 01b7c221..32519104 100644 --- a/src/httplib_set_ssl_option.c +++ b/src/httplib_set_ssl_option.c @@ -31,14 +31,14 @@ static void *ssllib_dll_handle; /* Store the ssl library handle. */ /* - * bool XX_httplib_set_ssl_option( struct httplib_context *ctx ); + * bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ); * * The function XX_httplib_set_ssl_option() loads the SSL library in a dynamic * way. The function returns false if an error occured, otherwise true. */ #if !defined(NO_SSL) -bool XX_httplib_set_ssl_option( struct httplib_context *ctx ) { +bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ) { const char *pem; int callback_ret; diff --git a/src/httplib_set_thread_name.c b/src/httplib_set_thread_name.c index 72dc15ff..d0c44f94 100644 --- a/src/httplib_set_thread_name.c +++ b/src/httplib_set_thread_name.c @@ -54,7 +54,7 @@ typedef struct tagTHREADNAME_INFO { #endif /* __linux__ */ -void XX_httplib_set_thread_name( const struct httplib_context *ctx, const char *name ) { +void XX_httplib_set_thread_name( const struct lh_ctx_t *ctx, const char *name ) { char thread_name[16+1]; /* 16 = Max. thread length in Linux/OSX/.. */ diff --git a/src/httplib_set_uid_option.c b/src/httplib_set_uid_option.c index 70145d94..dd846274 100644 --- a/src/httplib_set_uid_option.c +++ b/src/httplib_set_uid_option.c @@ -28,7 +28,7 @@ #include "httplib_main.h" /* - * bool XX_httplib_set_uid_option( struct httplib_contect *ctx ); + * bool XX_httplib_set_uid_option( struct lh_ctx_t *ctx ); * * The function XX_httplib_set_uid_option() runs on systems which support it * the context in the security environment of a specific user. The function can @@ -38,7 +38,7 @@ * False is returned in case a problem is detected, true otherwise. */ -bool XX_httplib_set_uid_option( struct httplib_context *ctx ) { +bool XX_httplib_set_uid_option( struct lh_ctx_t *ctx ) { #if defined(_WIN32) diff --git a/src/httplib_set_websocket_handler.c b/src/httplib_set_websocket_handler.c index 83051e1d..e1bd6cca 100644 --- a/src/httplib_set_websocket_handler.c +++ b/src/httplib_set_websocket_handler.c @@ -34,7 +34,7 @@ * processing of events from a websocket. */ -void httplib_set_websocket_handler( struct httplib_context *ctx, const char *uri, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, void *cbdata ) { +void httplib_set_websocket_handler( struct lh_ctx_t *ctx, const char *uri, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, void *cbdata ) { int is_delete_request; diff --git a/src/httplib_should_decode_url.c b/src/httplib_should_decode_url.c index 56db98b9..d05e399b 100644 --- a/src/httplib_should_decode_url.c +++ b/src/httplib_should_decode_url.c @@ -24,7 +24,7 @@ #include "httplib_main.h" -bool XX_httplib_should_decode_url( const struct httplib_context *ctx ) { +bool XX_httplib_should_decode_url( const struct lh_ctx_t *ctx ) { return ( ctx != NULL && ctx->decode_url ); diff --git a/src/httplib_should_keep_alive.c b/src/httplib_should_keep_alive.c index 930a21c8..1bb223ee 100644 --- a/src/httplib_should_keep_alive.c +++ b/src/httplib_should_keep_alive.c @@ -25,7 +25,7 @@ #include "httplib_main.h" /* - * bool XX_httplib_should_keep_alive( const struct httplib_context *ctx, const struct httplib_connection *conn ); + * bool XX_httplib_should_keep_alive( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ); * * The function XX_httplib_should_keep_alive() returns true if the connection * should be kept alive and false if it should be closed. @@ -35,7 +35,7 @@ * request parsing failed. */ -bool XX_httplib_should_keep_alive( const struct httplib_context *ctx, const struct httplib_connection *conn ) { +bool XX_httplib_should_keep_alive( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ) { const char *http_version; const char *header; diff --git a/src/httplib_snprintf.c b/src/httplib_snprintf.c index 1533b805..5742d50e 100644 --- a/src/httplib_snprintf.c +++ b/src/httplib_snprintf.c @@ -29,14 +29,14 @@ #include "httplib_string.h" /* - * void XX_httplib_snprintf( const struct httplib_context *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ); + * void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ); * * The function XX_httplib_snprintf() is an internal function to send a string * to a connection. The string can be formated with a format string and * parameters in the same way as the snprintf function works. */ -void XX_httplib_snprintf( const struct httplib_context *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ) { +void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ) { va_list ap; diff --git a/src/httplib_spawn_process.c b/src/httplib_spawn_process.c index eb315b9f..ec220c26 100644 --- a/src/httplib_spawn_process.c +++ b/src/httplib_spawn_process.c @@ -40,7 +40,7 @@ static void trim_trailing_whitespaces( char *s ) { } /* trim_trailing_whitespaces */ -pid_t XX_httplib_spawn_process( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) { +pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) { HANDLE me; char *p; @@ -157,7 +157,7 @@ spawn_cleanup: #else /* _WIN32 */ #ifndef NO_CGI -pid_t XX_httplib_spawn_process( const struct httplib_context *ctx, struct httplib_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) { +pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) { pid_t pid; const char *interp; diff --git a/src/httplib_ssi.c b/src/httplib_ssi.c index 315ed9fe..6368520a 100644 --- a/src/httplib_ssi.c +++ b/src/httplib_ssi.c @@ -29,10 +29,10 @@ #include "httplib_string.h" #include "httplib_utils.h" -static void send_ssi_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *, struct file *, int ); +static void send_ssi_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *, struct file *, int ); -static void do_ssi_include( const struct httplib_context *ctx, struct httplib_connection *conn, const char *ssi, char *tag, int include_level ) { +static void do_ssi_include( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *ssi, char *tag, int include_level ) { char file_name[MG_BUF_LEN]; char path[512]; @@ -127,7 +127,7 @@ static void do_ssi_include( const struct httplib_context *ctx, struct httplib_co #if !defined(NO_POPEN) -static void do_ssi_exec( const struct httplib_context *ctx, struct httplib_connection *conn, char *tag ) { +static void do_ssi_exec( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *tag ) { char cmd[1024] = ""; char error_string[ERROR_STRING_LEN]; @@ -165,7 +165,7 @@ static int httplib_fgetc( struct file *filep, int offset ) { } /* httplib_fgetc */ -static void send_ssi_file( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep, int include_level ) { +static void send_ssi_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep, int include_level ) { char buf[MG_BUF_LEN]; int ch; @@ -269,7 +269,7 @@ static void send_ssi_file( const struct httplib_context *ctx, struct httplib_con } /* send_ssi_file */ -void XX_httplib_handle_ssi_file_request( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { +void XX_httplib_handle_ssi_file_request( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { char date[64]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_ssl.h b/src/httplib_ssl.h index 818b9206..fd0b841b 100644 --- a/src/httplib_ssl.h +++ b/src/httplib_ssl.h @@ -132,18 +132,18 @@ struct ssl_func { -int XX_httplib_get_first_ssl_listener_index( const struct httplib_context *ctx ); -int XX_httplib_initialize_ssl( struct httplib_context *ctx ); -bool XX_httplib_set_ssl_option( struct httplib_context *ctx ); +int XX_httplib_get_first_ssl_listener_index( const struct lh_ctx_t *ctx ); +int XX_httplib_initialize_ssl( struct lh_ctx_t *ctx ); +bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ); const char * XX_httplib_ssl_error( void ); void XX_httplib_ssl_get_client_cert_info( struct httplib_connection *conn ); long XX_httplib_ssl_get_protocol( int version_id ); unsigned long XX_httplib_ssl_id_callback( void ); void XX_httplib_ssl_locking_callback( int mode, int mutex_num, const char *file, int line ); -int XX_httplib_ssl_use_pem_file( const struct httplib_context *ctx, const char *pem ); -int XX_httplib_sslize( const struct httplib_context *ctx, struct httplib_connection *conn, SSL_CTX *s, int (*func)(SSL *) ); +int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem ); +int XX_httplib_sslize( const struct lh_ctx_t *ctx, struct httplib_connection *conn, SSL_CTX *s, int (*func)(SSL *) ); void XX_httplib_tls_dtor( void *key ); -void XX_httplib_uninitialize_ssl( struct httplib_context *ctx ); +void XX_httplib_uninitialize_ssl( struct lh_ctx_t *ctx ); diff --git a/src/httplib_ssl_use_pem_file.c b/src/httplib_ssl_use_pem_file.c index 7608b50d..d0c36d5e 100644 --- a/src/httplib_ssl_use_pem_file.c +++ b/src/httplib_ssl_use_pem_file.c @@ -29,7 +29,7 @@ #include "httplib_ssl.h" /* - * int XX_httplib_ssl_use_pem_file( const struct httplib_context *ctx, const char *pem ); + * int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem ); * * The function XX_httplib_ssl_use_pem_file() tries to use a certificate which * is passed as a parameter with the filename of the certificate. @@ -37,7 +37,7 @@ #if ! defined(NO_SSL) -int XX_httplib_ssl_use_pem_file( const struct httplib_context *ctx, const char *pem ) { +int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem ) { if ( ctx == NULL || pem == NULL ) return 0; diff --git a/src/httplib_sslize.c b/src/httplib_sslize.c index 3e0ff392..837cede4 100644 --- a/src/httplib_sslize.c +++ b/src/httplib_sslize.c @@ -36,7 +36,7 @@ #if !defined(NO_SSL) -int XX_httplib_sslize( const struct httplib_context *ctx, struct httplib_connection *conn, SSL_CTX *s, int (*func)(SSL *) ) { +int XX_httplib_sslize( const struct lh_ctx_t *ctx, struct httplib_connection *conn, SSL_CTX *s, int (*func)(SSL *) ) { int ret; int err; diff --git a/src/httplib_start.c b/src/httplib_start.c index 85e8e4af..a5bbc6da 100644 --- a/src/httplib_start.c +++ b/src/httplib_start.c @@ -32,18 +32,18 @@ #include "httplib_utils.h" /* - * struct httplib_context *httplib_start( const struct httplib_callbacks *callbacks, void *user_data, const struct httplib_t *options ); + * struct lh_ctx_t *httplib_start( const struct httplib_callbacks *callbacks, void *user_data, const struct httplib_t *options ); * * The function httplib_start() functions as the main entry point for the LibHTTP * server. The function starts all threads and when finished returns the * context to the running server for future reference. */ -struct httplib_context *httplib_start( const struct httplib_callbacks *callbacks, void *user_data, const struct httplib_option_t *options ) { +struct lh_ctx_t *httplib_start( const struct httplib_callbacks *callbacks, void *user_data, const struct httplib_option_t *options ) { - struct httplib_context *ctx; + struct lh_ctx_t *ctx; int i; - void (*exit_callback)(const struct httplib_context *ctx); + void (*exit_callback)(const struct lh_ctx_t *ctx); struct httplib_workerTLS tls; /* @@ -55,7 +55,7 @@ struct httplib_context *httplib_start( const struct httplib_callbacks *callbacks */ exit_callback = NULL; - ctx = httplib_calloc( 1, sizeof(struct httplib_context) ); + ctx = httplib_calloc( 1, sizeof(struct lh_ctx_t) ); if ( ctx == NULL ) return NULL; diff --git a/src/httplib_stat.c b/src/httplib_stat.c index 51a2b8a9..5f6e92a2 100644 --- a/src/httplib_stat.c +++ b/src/httplib_stat.c @@ -48,7 +48,7 @@ static bool path_cannot_disclose_cgi( const char *path ) { } -int XX_httplib_stat( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { +int XX_httplib_stat( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { wchar_t wbuf[PATH_MAX]; WIN32_FILE_ATTRIBUTE_DATA info; @@ -121,7 +121,7 @@ int XX_httplib_stat( const struct httplib_context *ctx, struct httplib_connectio #else -int XX_httplib_stat( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { +int XX_httplib_stat( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path, struct file *filep ) { struct stat st; diff --git a/src/httplib_stop.c b/src/httplib_stop.c index 7600fd2f..17f9f6e1 100644 --- a/src/httplib_stop.c +++ b/src/httplib_stop.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * void httplib_stop( struct httplib_context *ctx ); + * void httplib_stop( struct lh_ctx_t *ctx ); * * The function httplib_stop() is used to stop an instance of a LibHTTP server * completely and return all its resources. */ -void httplib_stop( struct httplib_context *ctx ) { +void httplib_stop( struct lh_ctx_t *ctx ) { pthread_t mt; diff --git a/src/httplib_store_body.c b/src/httplib_store_body.c index a9fa6382..eccebb80 100644 --- a/src/httplib_store_body.c +++ b/src/httplib_store_body.c @@ -35,7 +35,7 @@ * negative number to indicate a failure. */ -int64_t httplib_store_body( const struct httplib_context *ctx, struct httplib_connection *conn, const char *path ) { +int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *path ) { char buf[MG_BUF_LEN]; int64_t len; diff --git a/src/httplib_string.h b/src/httplib_string.h index 6d91f809..df73123a 100644 --- a/src/httplib_string.h +++ b/src/httplib_string.h @@ -22,6 +22,6 @@ -void XX_httplib_snprintf( const struct httplib_context *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(6, 7); -int XX_httplib_vprintf( const struct httplib_context *ctx, struct httplib_connection *conn, const char *fmt, va_list ap ); -void XX_httplib_vsnprintf( const struct httplib_context *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ); +void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(6, 7); +int XX_httplib_vprintf( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *fmt, va_list ap ); +void XX_httplib_vsnprintf( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ); diff --git a/src/httplib_substitute_index_file.c b/src/httplib_substitute_index_file.c index e8d7a784..71c85c8e 100644 --- a/src/httplib_substitute_index_file.c +++ b/src/httplib_substitute_index_file.c @@ -29,7 +29,7 @@ #include "httplib_string.h" /* - * bool XX_httplib_substitute_index_file( const struct httplib_context *ctx, struct httplib_connection *conn, char *path, size_t path_len, struct file *filep ); + * bool XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *path, size_t path_len, struct file *filep ); * * The function XX_httplib_substiture_index_file() tries to find an index file * matching a given directory path. The function returns true of an index file @@ -37,7 +37,7 @@ * located, it's stats are returnd in stp. */ -int XX_httplib_substitute_index_file( const struct httplib_context *ctx, struct httplib_connection *conn, char *path, size_t path_len, struct file *filep ) { +int XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct httplib_connection *conn, char *path, size_t path_len, struct file *filep ) { const char *list; struct file file = STRUCT_FILE_INITIALIZER; diff --git a/src/httplib_suggest_connection_header.c b/src/httplib_suggest_connection_header.c index 01d9452c..9683620b 100644 --- a/src/httplib_suggest_connection_header.c +++ b/src/httplib_suggest_connection_header.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * const char *XX_httplib_suggest_connection_header( const struct httplib_context *ctx, const struct httlib_connection *conn ); + * const char *XX_httplib_suggest_connection_header( const struct lh_ctx_t *ctx, const struct httlib_connection *conn ); * * Based on the connection type, the function XX_httplib_connection_header() * returns a string to be used in the header which suggests the connection to * be either closed, or kept alive for further requests. */ -const char *XX_httplib_suggest_connection_header( const struct httplib_context *ctx, const struct httplib_connection *conn ) { +const char *XX_httplib_suggest_connection_header( const struct lh_ctx_t *ctx, const struct httplib_connection *conn ) { return XX_httplib_should_keep_alive( ctx, conn ) ? "keep-alive" : "close"; diff --git a/src/httplib_timer.c b/src/httplib_timer.c index 1e55cb97..7f667f8c 100644 --- a/src/httplib_timer.c +++ b/src/httplib_timer.c @@ -49,7 +49,7 @@ struct ttimers { unsigned timer_count; /* Current size of timer list */ }; -static int timer_add( struct httplib_context *ctx, double next_time, double period, int is_relative, taction action, void *arg ) { +static int timer_add( struct lh_ctx_t *ctx, double next_time, double period, int is_relative, taction action, void *arg ) { unsigned u; unsigned v; @@ -113,7 +113,7 @@ static int timer_add( struct httplib_context *ctx, double next_time, double peri static void timer_thread_run( void *thread_func_param ) { - struct httplib_context *ctx = (struct httplib_context *)thread_func_param; + struct lh_ctx_t *ctx = (struct lh_ctx_t *)thread_func_param; struct timespec now; double d; unsigned u; @@ -178,7 +178,7 @@ static void * timer_thread( void *thread_func_param ) { #endif /* _WIN32 */ -static int timers_init( struct httplib_context *ctx ) { +static int timers_init( struct lh_ctx_t *ctx ) { ctx->timers = httplib_calloc( sizeof(struct ttimers), 1 ); httplib_pthread_mutex_init( & ctx->timers->mutex, NULL ); @@ -193,7 +193,7 @@ static int timers_init( struct httplib_context *ctx ) { } /* timers_init */ -static void timers_exit( struct httplib_context *ctx ) { +static void timers_exit( struct lh_ctx_t *ctx ) { if ( ctx->timers != NULL ) { diff --git a/src/httplib_uninitialize_ssl.c b/src/httplib_uninitialize_ssl.c index e8f7f14f..30bd09e2 100644 --- a/src/httplib_uninitialize_ssl.c +++ b/src/httplib_uninitialize_ssl.c @@ -31,7 +31,7 @@ #include "httplib_utils.h" /* - * void XX_httplib_unitialize_ssl( struct httplib_context *ctx ); + * void XX_httplib_unitialize_ssl( struct lh_ctx_t *ctx ); * * The function XX_httplib_unititialize_ssl() is used to properly stop the SSL * subsystem. @@ -39,7 +39,7 @@ #if !defined(NO_SSL) -void XX_httplib_uninitialize_ssl( struct httplib_context *ctx ) { +void XX_httplib_uninitialize_ssl( struct lh_ctx_t *ctx ) { UNUSED_PARAMETER(ctx); diff --git a/src/httplib_utils.h b/src/httplib_utils.h index fa6dd3be..b0bf4f05 100644 --- a/src/httplib_utils.h +++ b/src/httplib_utils.h @@ -22,7 +22,7 @@ #define LEAP_YEAR(x) ( ((x)%4) == 0 && ( ((x)%100) != 0 || ((x)%400) == 0 ) ) -void XX_httplib_addenv( const struct httplib_context *ctx, struct cgi_environment *env, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(3, 4); +void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(3, 4); double XX_httplib_difftimespec( const struct timespec *ts_now, const struct timespec *ts_before ); void XX_httplib_gmt_time_string( char *buf, size_t buf_len, time_t *t ); int XX_httplib_inet_pton( int af, const char *src, void *dst, size_t dstlen ); diff --git a/src/httplib_vprintf.c b/src/httplib_vprintf.c index c1dbffe0..128ed2df 100644 --- a/src/httplib_vprintf.c +++ b/src/httplib_vprintf.c @@ -145,7 +145,7 @@ static int alloc_vprintf( char **out_buf, char *prealloc_buf, size_t prealloc_si } /* alloc_vprintf */ -int XX_httplib_vprintf( const struct httplib_context *ctx, struct httplib_connection *conn, const char *fmt, va_list ap ) { +int XX_httplib_vprintf( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const char *fmt, va_list ap ) { char mem[MG_BUF_LEN]; char *buf; diff --git a/src/httplib_vsnprintf.c b/src/httplib_vsnprintf.c index 2c063870..8ee5d332 100644 --- a/src/httplib_vsnprintf.c +++ b/src/httplib_vsnprintf.c @@ -33,7 +33,7 @@ * Report errors if length is exceeded. */ -void XX_httplib_vsnprintf( const struct httplib_context *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ) { +void XX_httplib_vsnprintf( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ) { int n; bool ok; diff --git a/src/httplib_websocket_client_thread.c b/src/httplib_websocket_client_thread.c index a4c8142b..24ded2a2 100644 --- a/src/httplib_websocket_client_thread.c +++ b/src/httplib_websocket_client_thread.c @@ -40,7 +40,7 @@ LIBHTTP_THREAD XX_httplib_websocket_client_thread( void *data ) { struct websocket_client_thread_data *cdata; - struct httplib_context *ctx; + struct lh_ctx_t *ctx; struct httplib_connection *conn; if ( (cdata = data ) == NULL ) return LIBHTTP_THREAD_RETNULL; diff --git a/src/httplib_websocket_client_write.c b/src/httplib_websocket_client_write.c index f522cdc1..50667688 100644 --- a/src/httplib_websocket_client_write.c +++ b/src/httplib_websocket_client_write.c @@ -38,7 +38,7 @@ static void mask_data( const char *in, size_t in_len, uint32_t masking_key, char * otherwise the amount of bytes written. */ -int httplib_websocket_client_write( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen ) { +int httplib_websocket_client_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen ) { int retval; char *masked_data; diff --git a/src/httplib_websocket_write.c b/src/httplib_websocket_write.c index ee6296cf..ba5389cf 100644 --- a/src/httplib_websocket_write.c +++ b/src/httplib_websocket_write.c @@ -25,13 +25,13 @@ #include "httplib_main.h" /* - * int httplib_websocket_write( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen ); + * int httplib_websocket_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen ); * * The function httplib_websocket_write() writes data over a websocket * connection. */ -int httplib_websocket_write( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen ) { +int httplib_websocket_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t dataLen ) { return XX_httplib_websocket_write_exec( ctx, conn, opcode, data, dataLen, 0 ); diff --git a/src/httplib_websocket_write_exec.c b/src/httplib_websocket_write_exec.c index bae57a2c..0e998e53 100644 --- a/src/httplib_websocket_write_exec.c +++ b/src/httplib_websocket_write_exec.c @@ -28,13 +28,13 @@ #include "httplib_main.h" /* - * int XX_httplib_websocket_write_exec( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len, uint32_t masking_key ); + * int XX_httplib_websocket_write_exec( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len, uint32_t masking_key ); * * The function XX_httplib_websocket_write_exec() does the heavy lifting in * writing data over a websocket connectin to a remote peer. */ -int XX_httplib_websocket_write_exec( const struct httplib_context *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len, uint32_t masking_key ) { +int XX_httplib_websocket_write_exec( const struct lh_ctx_t *ctx, struct httplib_connection *conn, int opcode, const char *data, size_t data_len, uint32_t masking_key ) { unsigned char header[14]; size_t header_len; diff --git a/src/httplib_worker_thread.c b/src/httplib_worker_thread.c index a70e48fc..08760ef6 100644 --- a/src/httplib_worker_thread.c +++ b/src/httplib_worker_thread.c @@ -67,7 +67,7 @@ LIBHTTP_THREAD XX_httplib_worker_thread( void *thread_func_param ) { static void *worker_thread_run( struct worker_thread_args *thread_args ) { - struct httplib_context *ctx; + struct lh_ctx_t *ctx; struct httplib_connection *conn; struct httplib_workerTLS tls; union { diff --git a/src/httplib_write.c b/src/httplib_write.c index dc366c94..abb73179 100644 --- a/src/httplib_write.c +++ b/src/httplib_write.c @@ -25,7 +25,7 @@ #include "httplib_main.h" /* - * int httplib_write( const struct httplib_context *ctx, struct httplib_connection *conn, const void *buffie, size_t lennie ); + * int httplib_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const void *buffie, size_t lennie ); * * The function httplib_write() writes a number of bytes over a connection. * The amount of characters written is returned. If an error occurs @@ -39,7 +39,7 @@ * case a monotonic clock with guaranteed increase would be a better choice. */ -int httplib_write( const struct httplib_context *ctx, struct httplib_connection *conn, const void *buffie, size_t lennie ) { +int httplib_write( const struct lh_ctx_t *ctx, struct httplib_connection *conn, const void *buffie, size_t lennie ) { time_t now; int64_t n; diff --git a/src/main.c b/src/main.c index 60abd8df..1456ef61 100644 --- a/src/main.c +++ b/src/main.c @@ -147,7 +147,7 @@ static const char *g_server_name; /* Set by init_server_name() */ static const char *g_icon_name; /* Set by init_server_name() */ static char g_config_file_name[PATH_MAX] = ""; /* Set by process_command_line_arguments() */ -static struct httplib_context *g_ctx; /* Set by start_libhttp() */ +static struct lh_ctx_t *g_ctx; /* Set by start_libhttp() */ static struct tuser_data g_user_data; /* Passed to httplib_start() by start_libhttp() */ @@ -247,7 +247,7 @@ static const char *config_file_top_comment = "# To make a change, remove leading '#', modify option's value,\n" "# save this file and then restart LibHTTP.\n\n"; -static const char * get_url_to_first_open_port(const struct httplib_context *ctx) { +static const char * get_url_to_first_open_port(const struct lh_ctx_t *ctx) { static char url[100]; char ports_str[256]; @@ -272,7 +272,7 @@ static const char * get_url_to_first_open_port(const struct httplib_context *ctx #ifdef ENABLE_CREATE_CONFIG_FILE -static void create_config_file(const struct httplib_context *ctx, const char *path) { +static void create_config_file(const struct lh_ctx_t *ctx, const char *path) { const struct httplib_option *options; const char *value; @@ -539,7 +539,7 @@ static void init_server_name(int argc, const char *argv[]) { } -static int log_message( const struct httplib_context *ctx, const struct httplib_connection *conn, const char *message ) { +static int log_message( const struct lh_ctx_t *ctx, const struct httplib_connection *conn, const char *message ) { struct tuser_data *ud;