From fb948c2aa04b5a31615c8361c16884e910f1379f Mon Sep 17 00:00:00 2001 From: Lammert Bies Date: Mon, 2 Jan 2017 14:50:50 +0100 Subject: [PATCH] Callbacks can lock the context --- include/libhttp.h | 48 +++++------ src/httplib_addenv.c | 4 +- src/httplib_authorize.c | 4 +- src/httplib_check_authorization.c | 2 +- src/httplib_close_socket_gracefully.c | 4 +- src/httplib_construct_etag.c | 4 +- src/httplib_create_client_context.c | 2 +- src/httplib_cry.c | 4 +- src/httplib_delete_file.c | 4 +- src/httplib_dir_scan_callback.c | 2 +- src/httplib_fclose_on_exec.c | 2 +- src/httplib_fopen.c | 4 +- src/httplib_forward_body_data.c | 4 +- src/httplib_get_response_code_text.c | 4 +- src/httplib_getreq.c | 4 +- src/httplib_handle_cgi_request.c | 4 +- src/httplib_handle_directory_request.c | 2 +- src/httplib_handle_file_based_request.c | 4 +- src/httplib_handle_form_request.c | 6 +- ..._handle_not_modified_static_file_request.c | 4 +- src/httplib_handle_propfind.c | 12 +-- src/httplib_handle_static_file_request.c | 2 +- src/httplib_handle_websocket_request.c | 2 +- src/httplib_interpret_uri.c | 3 +- src/httplib_is_authorized_for_put.c | 4 +- src/httplib_is_file_in_memory.c | 4 +- src/httplib_is_not_modified.c | 4 +- src/httplib_log_access.c | 4 +- src/httplib_main.h | 84 +++++++++---------- src/httplib_mkcol.c | 4 +- src/httplib_open_auth_file.c | 2 +- src/httplib_prepare_cgi_environment.c | 4 +- src/httplib_print_dir_entry.c | 2 +- src/httplib_put_dir.c | 4 +- src/httplib_put_file.c | 4 +- src/httplib_read_auth_file.c | 4 +- src/httplib_read_websocket.c | 4 +- src/httplib_refresh_trust.c | 4 +- src/httplib_remove_bad_file.c | 4 +- src/httplib_remove_directory.c | 4 +- src/httplib_scan_directory.c | 2 +- src/httplib_send_file.c | 4 +- src/httplib_send_file_data.c | 2 +- src/httplib_send_http_error.c | 2 +- src/httplib_send_websocket_handshake.c | 4 +- src/httplib_set_thread_name.c | 2 +- src/httplib_snprintf.c | 4 +- src/httplib_spawn_process.c | 4 +- src/httplib_ssi.c | 10 +-- src/httplib_ssl.h | 4 +- src/httplib_ssl_use_pem_file.c | 4 +- src/httplib_sslize.c | 4 +- src/httplib_start.c | 2 +- src/httplib_stat.c | 4 +- src/httplib_store_body.c | 4 +- src/httplib_string.h | 4 +- src/httplib_substitute_index_file.c | 4 +- src/httplib_utils.h | 2 +- src/httplib_vsnprintf.c | 2 +- src/httplib_websocket_client_write.c | 4 +- 60 files changed, 174 insertions(+), 173 deletions(-) diff --git a/include/libhttp.h b/include/libhttp.h index 89daaad1..b26710cd 100644 --- a/include/libhttp.h +++ b/include/libhttp.h @@ -283,18 +283,18 @@ struct lh_rqi_t { /* */ /* invoke. For a detailed description, see */ /* https://github.com/lammertb/libhttp/blob/master/docs/UserManual.md */ struct lh_clb_t { /* */ - int (*begin_request)( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); /* */ - void (*end_request)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, int reply_status_code ); /* */ - int (*log_message)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */ - int (*log_access)( const struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_con_t *conn ); /* */ - const char * (*open_file)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, size_t *data_len ); /* */ - void (*init_lua)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, void *lua_context ); /* */ - int (*http_error)( const struct lh_ctx_t *ctx, struct lh_con_t *, 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 ); /* */ + int (*begin_request)( struct lh_ctx_t *ctx, struct lh_con_t *conn ); /* */ + void (*end_request)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, int reply_status_code ); /* */ + int (*log_message)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */ + int (*log_access)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */ + int (*init_ssl)( struct lh_ctx_t *ctx, void *ssl_context, void *user_data ); /* */ + void (*connection_close)( struct lh_ctx_t *ctx, const struct lh_con_t *conn ); /* */ + const char * (*open_file)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, size_t *data_len ); /* */ + void (*init_lua)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, void *lua_context ); /* */ + int (*http_error)( struct lh_ctx_t *ctx, struct lh_con_t *, int status ); /* */ + void (*init_context)( struct lh_ctx_t *ctx ); /* */ + void (*init_thread)( struct lh_ctx_t *ctx, int thread_type ); /* */ + void (*exit_context)( struct lh_ctx_t *ctx ); /* */ }; /* */ /************************************************************************************************/ @@ -333,12 +333,12 @@ struct httplib_form_data_handler { void * user_data; }; -typedef int (*httplib_request_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); -typedef int (*httplib_authorization_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); -typedef int (*httplib_websocket_connect_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); -typedef void (*httplib_websocket_ready_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); -typedef int (*httplib_websocket_data_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int, char *buffer, size_t buflen, void *cbdata ); -typedef void (*httplib_websocket_close_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); +typedef int (*httplib_request_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); +typedef int (*httplib_authorization_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); +typedef int (*httplib_websocket_connect_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); +typedef void (*httplib_websocket_ready_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); +typedef int (*httplib_websocket_data_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, int, char *buffer, size_t buflen, void *cbdata ); +typedef void (*httplib_websocket_close_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata ); typedef LIBHTTP_THREAD_TYPE (LIBHTTP_THREAD_CALLING_CONV *httplib_thread_func_t)(void *arg); @@ -375,7 +375,7 @@ LIBHTTP_API struct lh_con_t * httplib_connect_client( struct lh_ctx_t *ctx, con LIBHTTP_API struct lh_con_t * httplib_connect_client_secure( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options ); LIBHTTP_API struct lh_con_t * 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 lh_clb_t *callbacks, const struct lh_opt_t *options ); -LIBHTTP_API void httplib_cry( enum lh_dbg_t debug_level, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(4, 5); +LIBHTTP_API void httplib_cry( enum lh_dbg_t debug_level, struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_con_t * 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 ); @@ -387,14 +387,14 @@ LIBHTTP_API const char * httplib_get_option( const struct lh_ctx_t *ctx, const LIBHTTP_API uint64_t httplib_get_random( void ); LIBHTTP_API const struct lh_rqi_t * httplib_get_request_info( const struct lh_con_t *conn ); LIBHTTP_API int httplib_get_response( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int timeout ); -LIBHTTP_API const char * httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ); +LIBHTTP_API const char * httplib_get_response_code_text( struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ); LIBHTTP_API int httplib_get_server_ports( const struct lh_ctx_t *ctx, int size, struct lh_slp_t *ports ); LIBHTTP_API void * httplib_get_user_connection_data( const struct lh_con_t *conn ); LIBHTTP_API void * httplib_get_user_data( const struct lh_ctx_t *ctx ); 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 lh_ctx_t *ctx, struct lh_con_t *conn, struct httplib_form_data_handler *fdh ); +LIBHTTP_API int httplib_handle_form_request( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_con_t *conn ); @@ -425,7 +425,7 @@ LIBHTTP_API int httplib_pthread_setspecific( pthread_key_t key, void *value ) LIBHTTP_API int httplib_read( const struct lh_ctx_t *ctx, struct lh_con_t *conn, 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers ); +LIBHTTP_API void httplib_send_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, const char *uri, httplib_authorization_handler handler, void *cbdata ); LIBHTTP_API enum lh_dbg_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum lh_dbg_t new_level ); @@ -435,7 +435,7 @@ LIBHTTP_API void httplib_set_websocket_handler( struct lh_ctx_t *ctx, const ch LIBHTTP_API struct lh_ctx_t * httplib_start( const struct lh_clb_t *callbacks, void *user_data, const struct lh_opt_t *options ); LIBHTTP_API int httplib_start_thread( httplib_thread_func_t func, void *param ); LIBHTTP_API void httplib_stop( struct lh_ctx_t *ctx ); -LIBHTTP_API int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); +LIBHTTP_API int64_t httplib_store_body( struct lh_ctx_t *ctx, struct lh_con_t *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 ); @@ -449,7 +449,7 @@ 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 lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len ); +LIBHTTP_API int httplib_websocket_client_write( struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len ); LIBHTTP_API int httplib_websocket_write( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len ); LIBHTTP_API int httplib_write( const struct lh_ctx_t *ctx, struct lh_con_t * conn, const void *buf, size_t len ); diff --git a/src/httplib_addenv.c b/src/httplib_addenv.c index c8720e16..6f34f06e 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 lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... ); + * void XX_httplib_addenv( 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 lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... ) { +void XX_httplib_addenv( 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 7a50c17e..5af9a514 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 lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ); + * bool XX_httplib_authorize( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) { +bool XX_httplib_authorize( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) { struct read_auth_file_struct workdata; char buf[MG_BUF_LEN]; diff --git a/src/httplib_check_authorization.c b/src/httplib_check_authorization.c index 893900e4..870088b6 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { +bool XX_httplib_check_authorization( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { char fname[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_close_socket_gracefully.c b/src/httplib_close_socket_gracefully.c index ea78a99e..75f53c76 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 lh_ctx_t *ctx, struct lh_con_t *conn ); + * void XX_httplib_close_socket_gracefully( struct lh_ctx_t *ctx, struct lh_con_t *conn ); * * The function XX_httplib_close_socket_gracefully() closes a socket in a * graceful way. */ -void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct lh_con_t *conn ) { +void XX_httplib_close_socket_gracefully( struct lh_ctx_t *ctx, struct lh_con_t *conn ) { #if defined(_WIN32) char buf[MG_BUF_LEN]; diff --git a/src/httplib_construct_etag.c b/src/httplib_construct_etag.c index 1d93d48c..e560e37e 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 lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ); + * void XX_httplib_construct_etag( 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 lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ) { +void XX_httplib_construct_etag( 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_create_client_context.c b/src/httplib_create_client_context.c index d2468ae6..48a7f215 100644 --- a/src/httplib_create_client_context.c +++ b/src/httplib_create_client_context.c @@ -34,7 +34,7 @@ struct lh_ctx_t *httplib_create_client_context( const struct lh_clb_t *callbacks, const struct lh_opt_t *options ) { struct lh_ctx_t *ctx; - void (*exit_callback)(const struct lh_ctx_t *ctx); + void (*exit_callback)(struct lh_ctx_t *ctx); exit_callback = NULL; ctx = httplib_calloc( 1, sizeof(struct lh_ctx_t) ); diff --git a/src/httplib_cry.c b/src/httplib_cry.c index e5bca1e8..3f5ed60b 100644 --- a/src/httplib_cry.c +++ b/src/httplib_cry.c @@ -26,14 +26,14 @@ #include "httplib_ssl.h" /* - * void httplib_cry( enum lh_dbg_t debug_level, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... ); + * void httplib_cry( enum lh_dbg_t debug_level, struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_dbg_t debug_level, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... ) { +void httplib_cry( enum lh_dbg_t debug_level, struct lh_ctx_t *ctx, const struct lh_con_t *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 7d8cdb0c..c2965d15 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); + * void XX_httplib_delete_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { +void XX_httplib_delete_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { struct de de; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_dir_scan_callback.c b/src/httplib_dir_scan_callback.c index ebe3781b..5ac19f2a 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 lh_ctx_t *ctx, struct de *de, void *data ) { +void XX_httplib_dir_scan_callback( struct lh_ctx_t *ctx, struct de *de, void *data ) { struct dir_scan_data *dsd; struct de* old_entries; diff --git a/src/httplib_fclose_on_exec.c b/src/httplib_fclose_on_exec.c index 359e7acc..6f2c1113 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 lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn ) { +void XX_httplib_fclose_on_exec( struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn ) { if ( ctx == NULL || filep == NULL || filep->fp == NULL ) return; diff --git a/src/httplib_fopen.c b/src/httplib_fopen.c index 6b52add9..db88778e 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 lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep ); + * bool XX_httplib_fopen( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep ) { +bool XX_httplib_fopen( struct lh_ctx_t *ctx, const struct lh_con_t *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 b547fdde..f2042c37 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 lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl ); + * bool XX_httplib_forward_body_data( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl ) { +bool XX_httplib_forward_body_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl ) { const char *expect; const char *body; diff --git a/src/httplib_get_response_code_text.c b/src/httplib_get_response_code_text.c index 4b87505d..bfe6198b 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 lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ); + * const char *httplib_get_response_code_text( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ) { +const char *httplib_get_response_code_text( struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ) { /* * See IANA HTTP status code assignment: diff --git a/src/httplib_getreq.c b/src/httplib_getreq.c index a12dc1fe..5b5eca03 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 lh_ctx_t *ctx, struct lh_con_t *conn, int *err ); + * bool XX_httplib_getreq( struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err ); * * The function XX_httplib_getreq() processes a request from a remote client. */ -bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err ) { +bool XX_httplib_getreq( struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err ) { const char *cl; diff --git a/src/httplib_handle_cgi_request.c b/src/httplib_handle_cgi_request.c index dbaf2c06..e4038740 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog ); + * void XX_httplib_handle_cgi_request( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog ) { +void XX_httplib_handle_cgi_request( struct lh_ctx_t *ctx, struct lh_con_t *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 28b51948..b55b7edf 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ) { +void XX_httplib_handle_directory_request( struct lh_ctx_t *ctx, struct lh_con_t *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 30250319..4969170a 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *file ); + * void XX_httplib_handle_file_based_request( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *file ) { +void XX_httplib_handle_file_based_request( struct lh_ctx_t *ctx, struct lh_con_t *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 d07a07b2..c5a6210c 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 lh_ctx_t *ctx, const struct lh_con_t *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( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_ } -static int url_encoded_field_get( const struct lh_ctx_t *ctx, const struct lh_con_t *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( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, struct httplib_form_data_handler *fdh ) { +int httplib_handle_form_request( struct lh_ctx_t *ctx, struct lh_con_t *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 779f767c..ea624832 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 lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ); + * void XX_httplib_handle_not_modified_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) { +void XX_httplib_handle_not_modified_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *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 bf5d899c..ce1cf03d 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep ); + * static void print_props( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep ) { +static void print_props( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep ) { char mtime[64]; @@ -63,13 +63,13 @@ static void print_props( const struct lh_ctx_t *ctx, struct lh_con_t *conn, cons } /* print_props */ /* - * static void print_dav_dir_entry( const struct lh_ctx_t *ctx, struct de *de, void *data ); + * static void print_dav_dir_entry( 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 lh_ctx_t *ctx, struct de *de, void *data ) { +static void print_dav_dir_entry( 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 lh_ctx_t *ctx, struct de *de, void } /* print_dav_dir_entry */ /* - * void XX_httplib_handle_propfind( const stuct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); + * void XX_httplib_handle_propfind( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); * * The function XX_httlib_handle_propfind() handles a propfind request. */ -void XX_httplib_handle_propfind( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { +void XX_httplib_handle_propfind( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { const char *depth; char date[64]; diff --git a/src/httplib_handle_static_file_request.c b/src/httplib_handle_static_file_request.c index 0e52abab..22562bd1 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ) { +void XX_httplib_handle_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *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 d85cd903..5947fa1f 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 lh_ctx_t *ctx, struct lh_con_t *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( struct lh_ctx_t *ctx, struct lh_con_t *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_interpret_uri.c b/src/httplib_interpret_uri.c index 773bcbb1..460e0f5f 100644 --- a/src/httplib_interpret_uri.c +++ b/src/httplib_interpret_uri.c @@ -34,6 +34,7 @@ * The function XX_httplib_interpret_uri() interprets an URI and decides what * type of request is involved. The function takes the following parameters: * + * ctx: in: The context in which to communicate * conn: in: The request (must be valid) * filename: out: Filename * filename_buf_len: in: Size of the filename buffer @@ -44,7 +45,7 @@ * is_put_or_delete_request: out: put/delete file? */ -void XX_httplib_interpret_uri( const struct lh_ctx_t *ctx, struct lh_con_t *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( struct lh_ctx_t *ctx, struct lh_con_t *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 acb70f42..80e6e4e2 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 lh_ctx_t *ctx, struct lh_con_t *conn ); + * bool XX_httplib_is_authorized_for_put( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn ) { +bool XX_httplib_is_authorized_for_put( struct lh_ctx_t *ctx, struct lh_con_t *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 50757b6c..14d45e1a 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 lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep ); + * bool XX_httplib_is_file_in_memory( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep ) { +bool XX_httplib_is_file_in_memory( struct lh_ctx_t *ctx, const struct lh_con_t *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 89350e67..3e3b6b56 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 lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ); + * bool XX_httplib_is_not_modified( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ) { +bool XX_httplib_is_not_modified( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ) { char etag[64]; const char *ims = httplib_get_header( conn, "If-Modified-Since" ); diff --git a/src/httplib_log_access.c b/src/httplib_log_access.c index 401c488f..46cc4df7 100644 --- a/src/httplib_log_access.c +++ b/src/httplib_log_access.c @@ -32,12 +32,12 @@ static const char *header_val( const struct lh_con_t *conn, const char *header ); /* - * void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct lh_con_t *conn ); + * void XX_httplib_log_access( struct lh_ctx_t *ctx, const struct lh_con_t *conn ); * * The function XX_httplib_log_access() logs an access of a client. */ -void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct lh_con_t *conn ) { +void XX_httplib_log_access( struct lh_ctx_t *ctx, const struct lh_con_t *conn ) { const struct lh_rqi_t *ri; struct file fi; diff --git a/src/httplib_main.h b/src/httplib_main.h index da463a65..a9b15074 100644 --- a/src/httplib_main.h +++ b/src/httplib_main.h @@ -788,27 +788,27 @@ void SHA1Update( SHA1_CTX *context, const unsigned char *data, uint32_t len ); 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 lh_con_t *conn, struct file *filep ); +bool XX_httplib_authorize( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, uint32_t remote_ip ); -bool XX_httplib_check_authorization( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); +bool XX_httplib_check_authorization( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx ); void XX_httplib_close_connection( struct lh_ctx_t *ctx, struct lh_con_t *conn ); -void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); +void XX_httplib_close_socket_gracefully( struct lh_ctx_t *ctx, struct lh_con_t *conn ); int WINCDECL XX_httplib_compare_dir_entries( const void *p1, const void *p2 ); 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 ); +void XX_httplib_construct_etag( 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 lh_con_t *conn, const char *path ); -void XX_httplib_dir_scan_callback( const struct lh_ctx_t *ctx, struct de *de, void *data ); +void XX_httplib_delete_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); +void XX_httplib_dir_scan_callback( struct lh_ctx_t *ctx, struct de *de, void *data ); void XX_httplib_discard_unread_request_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); int XX_httplib_fclose( struct file *filep ); -void XX_httplib_fclose_on_exec( const struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn ); +void XX_httplib_fclose_on_exec( struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn ); const char * XX_httplib_fgets( char *buf, size_t size, struct file *filep, char **p ); -bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep ); -bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl ); +bool XX_httplib_fopen( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep ); +bool XX_httplib_forward_body_data( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_rqi_t *ri, const char *name ); @@ -819,35 +819,35 @@ int XX_httplib_get_request_handler( struct lh_ctx_t *ctx, struct lh_con_t *con 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 lh_ctx_t *ctx, struct lh_con_t *conn, int *err ); -void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog ); -void XX_httplib_handle_directory_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ); -void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); -void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ); -void XX_httplib_handle_propfind( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); +bool XX_httplib_getreq( struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err ); +void XX_httplib_handle_cgi_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog ); +void XX_httplib_handle_directory_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ); +void XX_httplib_handle_file_based_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); +void XX_httplib_handle_not_modified_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ); +void XX_httplib_handle_propfind( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); void XX_httplib_handle_request( struct lh_ctx_t *ctx, struct lh_con_t *conn ); -void XX_httplib_handle_ssi_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); -void XX_httplib_handle_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *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 lh_con_t *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_ssi_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); +void XX_httplib_handle_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ); +void XX_httplib_handle_websocket_request( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx ); -void XX_httplib_interpret_uri( const struct lh_ctx_t *ctx, struct lh_con_t *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 lh_con_t *conn ); -bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep ); +void XX_httplib_interpret_uri( struct lh_ctx_t *ctx, struct lh_con_t *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( struct lh_ctx_t *ctx, struct lh_con_t *conn ); +bool XX_httplib_is_file_in_memory( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ); +bool XX_httplib_is_not_modified( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ); bool XX_httplib_is_put_or_delete_method( const struct lh_con_t *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 lh_con_t *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 lh_con_t *conn ); +void XX_httplib_log_access( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); +void XX_httplib_mkcol( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); +void XX_httplib_open_auth_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, char *buf, size_t buf_size, struct ah *ah ); @@ -857,33 +857,33 @@ int XX_httplib_parse_http_message( char *buf, int len, struct lh_rqi_t *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 lh_ctx_t *ctx, struct lh_con_t *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_prepare_cgi_environment( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env ); +void XX_httplib_print_dir_entry( struct lh_ctx_t *ctx, struct de *de ); void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct lh_con_t *conn ); bool XX_httplib_process_options( struct lh_ctx_t *ctx, const struct lh_opt_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 lh_con_t *conn, char *buf, int len, double timeout ); int XX_httplib_pull_all( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *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 lh_con_t *conn, const char *path ); -void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct lh_con_t *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_put_dir( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); +void XX_httplib_put_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); +bool XX_httplib_read_auth_file( 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 lh_con_t *conn, char *buf, int bufsiz, int *nread ); -void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ); +void XX_httplib_read_websocket( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_con_t *conn, int ssl_index ); -int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); -void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ); -int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ); +int XX_httplib_refresh_trust( struct lh_ctx_t *ctx, struct lh_con_t *conn ); +void XX_httplib_remove_bad_file( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ); +int XX_httplib_remove_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ); void XX_httplib_remove_double_dots_and_double_slashes( char *s ); void XX_httplib_reset_per_request_attributes( struct lh_con_t *conn ); -int XX_httplib_scan_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(const struct lh_ctx_t *ctx, struct de *, void *) ); +int XX_httplib_scan_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(struct lh_ctx_t *ctx, struct de *, void *) ); void XX_httplib_send_authorization_request( struct lh_ctx_t *ctx, struct lh_con_t *conn ); -void XX_httplib_send_file_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len ); -void XX_httplib_send_http_error( const struct lh_ctx_t *ctx, struct lh_con_t *, int, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(4, 5); +void XX_httplib_send_file_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len ); +void XX_httplib_send_http_error( struct lh_ctx_t *ctx, struct lh_con_t *, 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 lh_con_t *conn ); void XX_httplib_send_options( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); int XX_httplib_send_static_cache_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); -int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key ); +int XX_httplib_send_websocket_handshake( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx ); @@ -892,7 +892,7 @@ int XX_httplib_set_non_blocking_mode( SOCKET sock ); 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 lh_ctx_t *ctx, const char *name ); +void XX_httplib_set_thread_name( 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 lh_ctx_t *ctx ); bool XX_httplib_should_decode_url( const struct lh_ctx_t *ctx ); @@ -900,10 +900,10 @@ bool XX_httplib_should_keep_alive( const struct lh_ctx_t *ctx, const struct lh 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 lh_ctx_t *ctx, struct lh_con_t *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( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); -int XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep ); +int XX_httplib_stat( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ); +int XX_httplib_substitute_index_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_con_t *conn ); LIBHTTP_THREAD XX_httplib_websocket_client_thread( void *data ); int XX_httplib_websocket_write_exec( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen, uint32_t masking_key ); diff --git a/src/httplib_mkcol.c b/src/httplib_mkcol.c index 574e8f2c..444156cb 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); + * void XX_httplib_mkcol( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { +void XX_httplib_mkcol( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { int rc; int body_len; diff --git a/src/httplib_open_auth_file.c b/src/httplib_open_auth_file.c index 42349a07..07035eaf 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { +void XX_httplib_open_auth_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { char name[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_prepare_cgi_environment.c b/src/httplib_prepare_cgi_environment.c index e9a0631c..f1db4f69 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env ); + * void XX_httplib_prepare_cgi_environment( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env ) { +void XX_httplib_prepare_cgi_environment( struct lh_ctx_t *ctx, struct lh_con_t *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 184ecc0d..1f64885b 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 lh_ctx_t *ctx, struct de *de ) { +void XX_httplib_print_dir_entry( struct lh_ctx_t *ctx, struct de *de ) { char size[64]; char mod[64]; diff --git a/src/httplib_put_dir.c b/src/httplib_put_dir.c index 8b2f51da..274ca68a 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( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); + * int XX_httplib_put_dir( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { +int XX_httplib_put_dir( struct lh_ctx_t *ctx, struct lh_con_t *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 16aa639e..0d1959d7 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); + * void XX_httplib_put_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { +void XX_httplib_put_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { struct file file = STRUCT_FILE_INITIALIZER; const char *range; diff --git a/src/httplib_read_auth_file.c b/src/httplib_read_auth_file.c index 6cbbf4a3..e7ceca11 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 lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ); + * bool XX_httplib_read_auth_file( 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 lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ) { +bool XX_httplib_read_auth_file( 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_websocket.c b/src/httplib_read_websocket.c index 73bf2b6b..8dff14e7 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 lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *calback_data ); + * void XX_httplib_read_websocket( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ) { +void XX_httplib_read_websocket( struct lh_ctx_t *ctx, struct lh_con_t *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_refresh_trust.c b/src/httplib_refresh_trust.c index 265ae9fd..9d6be948 100644 --- a/src/httplib_refresh_trust.c +++ b/src/httplib_refresh_trust.c @@ -33,7 +33,7 @@ static volatile int reload_lock = 0; static long int data_check = 0; /* - * int XX_httplib_refresh_trust( struct lh_con_t *conn ); + * int XX_httplib_refresh_trust( struct lh_ctx_t *ctx, struct lh_con_t *conn ); * * The function XX_httplib_refresh_trust() is used to reload a certificate if * it only has a short trust span. @@ -41,7 +41,7 @@ static long int data_check = 0; #if !defined(NO_SSL) -int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct lh_con_t *conn ) { +int XX_httplib_refresh_trust( struct lh_ctx_t *ctx, struct lh_con_t *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 f765bf3d..3c271ea4 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 lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ); + * void XX_httplib_remove_bad_file( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ) { +void XX_httplib_remove_bad_file( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ) { int r = httplib_remove( path ); diff --git a/src/httplib_remove_directory.c b/src/httplib_remove_directory.c index 829bf3af..75dd325b 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ); + * int XX_httplib_remove_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ); * * The function XX_httplib_remove_directory() removes recursively a directory * tree. */ -int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ) { +int XX_httplib_remove_directory( struct lh_ctx_t *ctx, struct lh_con_t *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 9bb667d7..8a41a40d 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(const struct lh_ctx_t *ctx, struct de *, void *) ) { +int XX_httplib_scan_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(struct lh_ctx_t *ctx, struct de *, void *) ) { char path[PATH_MAX]; char error_string[ERROR_STRING_LEN]; diff --git a/src/httplib_send_file.c b/src/httplib_send_file.c index d89ce9a2..89d2ec2b 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers ); + * void httplib_send_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers ) { +void httplib_send_file( struct lh_ctx_t *ctx, struct lh_con_t *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 5b9ce9d3..53e2b041 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 lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len ) { +void XX_httplib_send_file_data( struct lh_ctx_t *ctx, struct lh_con_t *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 323c41ca..1e41e5a3 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 lh_ctx_t *ctx, struct lh_con_t *conn, int status, const char *fmt, ... ) { +void XX_httplib_send_http_error( struct lh_ctx_t *ctx, struct lh_con_t *conn, int status, const char *fmt, ... ) { char buf[MG_BUF_LEN]; va_list ap; diff --git a/src/httplib_send_websocket_handshake.c b/src/httplib_send_websocket_handshake.c index 0d67364d..3cd78d98 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key ); + * int XX_httplib_send_websocket_handshake( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key ) { +int XX_httplib_send_websocket_handshake( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key ) { static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; const char *protocol; diff --git a/src/httplib_set_thread_name.c b/src/httplib_set_thread_name.c index d0c44f94..b520d2ab 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 lh_ctx_t *ctx, const char *name ) { +void XX_httplib_set_thread_name( 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_snprintf.c b/src/httplib_snprintf.c index 8ab408be..f1ff5afc 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 lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ); + * void XX_httplib_snprintf( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ) { +void XX_httplib_snprintf( struct lh_ctx_t *ctx, const struct lh_con_t *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 34c8277c..995e7660 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 lh_ctx_t *ctx, struct lh_con_t *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( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *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( struct lh_ctx_t *ctx, struct lh_con_t *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 a8bc8371..ce03b031 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *, struct file *, int ); +static void send_ssi_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *, struct file *, int ); -static void do_ssi_include( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *ssi, char *tag, int include_level ) { +static void do_ssi_include( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, c #if !defined(NO_POPEN) -static void do_ssi_exec( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *tag ) { +static void do_ssi_exec( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, int include_level ) { +static void send_ssi_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, co } /* send_ssi_file */ -void XX_httplib_handle_ssi_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { +void XX_httplib_handle_ssi_file_request( struct lh_ctx_t *ctx, struct lh_con_t *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 f994c210..271797a1 100644 --- a/src/httplib_ssl.h +++ b/src/httplib_ssl.h @@ -140,8 +140,8 @@ void XX_httplib_ssl_get_client_cert_info( struct lh_con_t *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 lh_ctx_t *ctx, const char *pem ); -int XX_httplib_sslize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ); +int XX_httplib_ssl_use_pem_file( struct lh_ctx_t *ctx, const char *pem ); +int XX_httplib_sslize( struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ); void XX_httplib_tls_dtor( void *key ); 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 209f01d4..afaf6d3d 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 lh_ctx_t *ctx, const char *pem ); + * int XX_httplib_ssl_use_pem_file( 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 lh_ctx_t *ctx, const char *pem ) { +int XX_httplib_ssl_use_pem_file( 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 fc9a248e..b7919e99 100644 --- a/src/httplib_sslize.c +++ b/src/httplib_sslize.c @@ -29,14 +29,14 @@ #include "httplib_ssl.h" /* - * int XX_httplib_sslize( struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ); + * int XX_httplib_sslize( lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ); * * The fucntion XX_httplib_sslize() initiates SSL on a connection. */ #if !defined(NO_SSL) -int XX_httplib_sslize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ) { +int XX_httplib_sslize( struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ) { int ret; int err; diff --git a/src/httplib_start.c b/src/httplib_start.c index 29946d9f..5d24025f 100644 --- a/src/httplib_start.c +++ b/src/httplib_start.c @@ -43,7 +43,7 @@ struct lh_ctx_t *httplib_start( const struct lh_clb_t *callbacks, void *user_dat struct lh_ctx_t *ctx; int i; - void (*exit_callback)(const struct lh_ctx_t *ctx); + void (*exit_callback)(struct lh_ctx_t *ctx); struct httplib_workerTLS tls; /* diff --git a/src/httplib_stat.c b/src/httplib_stat.c index c97d044f..bf16fa88 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 lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { +int XX_httplib_stat( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, const ch #else -int XX_httplib_stat( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { +int XX_httplib_stat( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) { struct stat st; diff --git a/src/httplib_store_body.c b/src/httplib_store_body.c index 7fce1808..6ef915dd 100644 --- a/src/httplib_store_body.c +++ b/src/httplib_store_body.c @@ -28,14 +28,14 @@ #include "httplib_main.h" /* - * int64_t httplib_store_body( struct lh_con_t *conn, const char *path ); + * int64_t httplib_store_body( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ); * * The function httplib_store_body() stores in incoming body for future * processing. The function returns the number of bytes actually read, or a * negative number to indicate a failure. */ -int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) { +int64_t httplib_store_body( struct lh_ctx_t *ctx, struct lh_con_t *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 d2b21322..4d5abf1d 100644 --- a/src/httplib_string.h +++ b/src/httplib_string.h @@ -22,6 +22,6 @@ -void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(6, 7); +void XX_httplib_snprintf( struct lh_ctx_t *ctx, const struct lh_con_t *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 lh_con_t *conn, const char *fmt, va_list ap ); -void XX_httplib_vsnprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ); +void XX_httplib_vsnprintf( struct lh_ctx_t *ctx, const struct lh_con_t *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 b7bca85d..ceed4e34 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 lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep ); + * bool XX_httplib_substitute_index_file( struct lh_ctx_t *ctx, struct lh_con_t *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 lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep ) { +int XX_httplib_substitute_index_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep ) { const char *list; struct file file = STRUCT_FILE_INITIALIZER; diff --git a/src/httplib_utils.h b/src/httplib_utils.h index b0bf4f05..a16bfc3b 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 lh_ctx_t *ctx, struct cgi_environment *env, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(3, 4); +void XX_httplib_addenv( 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_vsnprintf.c b/src/httplib_vsnprintf.c index 898d6da8..a2be9a47 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 lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ) { +void XX_httplib_vsnprintf( struct lh_ctx_t *ctx, const struct lh_con_t *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_write.c b/src/httplib_websocket_client_write.c index af24ae4a..301129c1 100644 --- a/src/httplib_websocket_client_write.c +++ b/src/httplib_websocket_client_write.c @@ -31,14 +31,14 @@ static void mask_data( const char *in, size_t in_len, uint32_t masking_key, char *out ); /* - * int httplib_websocket_client_write( struct lh_con_t *conn, int opcode, const char *data, size_t dataLen ); + * int httplib_websocket_client_write( struct lh_ctx *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen ); * * The function httplib_websocket_client_write() is used to write as a client * to a websocket server. The function returns -1 if an error occures, * otherwise the amount of bytes written. */ -int httplib_websocket_client_write( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen ) { +int httplib_websocket_client_write( struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen ) { int retval; char *masked_data;