diff --git a/Makefile b/Makefile index 5d9a44e8..d5bd3796 100644 --- a/Makefile +++ b/Makefile @@ -323,10 +323,10 @@ OBJLIST = \ ${OBJDIR}httplib_stat${OBJEXT} \ ${OBJDIR}httplib_stop${OBJEXT} \ ${OBJDIR}httplib_store_body${OBJEXT} \ - ${OBJDIR}httplib_strlcpy${OBJEXT} \ ${OBJDIR}httplib_strcasecmp${OBJEXT} \ ${OBJDIR}httplib_strcasestr${OBJEXT} \ ${OBJDIR}httplib_strdup${OBJEXT} \ + ${OBJDIR}httplib_strlcpy${OBJEXT} \ ${OBJDIR}httplib_strncasecmp${OBJEXT} \ ${OBJDIR}httplib_strndup${OBJEXT} \ ${OBJDIR}httplib_substitute_index_file${OBJEXT} \ @@ -402,6 +402,7 @@ ${OBJDIR}httplib_accept_new_connection${OBJEXT} : ${SRCDIR}httplib_accept_new ${OBJDIR}httplib_addenv${OBJEXT} : ${SRCDIR}httplib_addenv.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_atomic_dec${OBJEXT} : ${SRCDIR}httplib_atomic_dec.c \ @@ -420,6 +421,7 @@ ${OBJDIR}httplib_check_acl${OBJEXT} : ${SRCDIR}httplib_check_acl.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_check_authorization${OBJEXT} : ${SRCDIR}httplib_check_authorization.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_check_feature${OBJEXT} : ${SRCDIR}httplib_check_feature.c \ @@ -455,18 +457,22 @@ ${OBJDIR}httplib_connect_client${OBJEXT} : ${SRCDIR}httplib_connect_client.c ${SRCDIR}httplib_memory.h \ ${SRCDIR}httplib_pthread.h \ ${SRCDIR}httplib_ssl.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_connect_socket${OBJEXT} : ${SRCDIR}httplib_connect_socket.c \ ${SRCDIR}httplib_memory.h \ ${SRCDIR}httplib_ssl.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_connect_websocket_client${OBJEXT} : ${SRCDIR}httplib_connect_websocket_client.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_construct_etag${OBJEXT} : ${SRCDIR}httplib_construct_etag.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_consume_socket${OBJEXT} : ${SRCDIR}httplib_consume_socket.c \ @@ -485,12 +491,14 @@ ${OBJDIR}httplib_difftimespec${OBJEXT} : ${SRCDIR}httplib_difftimespec.c ${OBJDIR}httplib_dir_scan_callback${OBJEXT} : ${SRCDIR}httplib_dir_scan_callback.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_discard_unread_request_data${OBJEXT} : ${SRCDIR}httplib_discard_unread_request_data.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_download${OBJEXT} : ${SRCDIR}httplib_download.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_event_queue${OBJEXT} : ${SRCDIR}httplib_event_queue.c \ @@ -527,6 +535,7 @@ ${OBJDIR}httplib_get_context${OBJEXT} : ${SRCDIR}httplib_get_context.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_get_cookie${OBJEXT} : ${SRCDIR}httplib_get_cookie.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_get_first_ssl_listener_index${OBJEXT} : ${SRCDIR}httplib_get_first_ssl_listener_index.c \ @@ -564,6 +573,7 @@ ${OBJDIR}httplib_get_request_len${OBJEXT} : ${SRCDIR}httplib_get_request_len. ${SRCDIR}httplib_main.h ${OBJDIR}httplib_get_response${OBJEXT} : ${SRCDIR}httplib_get_response.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_get_response_code_text${OBJEXT} : ${SRCDIR}httplib_get_response_code_text.c \ @@ -573,6 +583,7 @@ ${OBJDIR}httplib_get_server_ports${OBJEXT} : ${SRCDIR}httplib_get_server_port ${SRCDIR}httplib_main.h ${OBJDIR}httplib_get_system_name${OBJEXT} : ${SRCDIR}httplib_get_system_name.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_get_uri_type${OBJEXT} : ${SRCDIR}httplib_get_uri_type.c \ @@ -591,6 +602,7 @@ ${OBJDIR}httplib_get_var${OBJEXT} : ${SRCDIR}httplib_get_var.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_getreq${OBJEXT} : ${SRCDIR}httplib_getreq.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_global_data${OBJEXT} : ${SRCDIR}httplib_global_data.c \ @@ -602,6 +614,7 @@ ${OBJDIR}httplib_gmt_time_string${OBJEXT} : ${SRCDIR}httplib_gmt_time_string. ${OBJDIR}httplib_handle_cgi_request${OBJEXT} : ${SRCDIR}httplib_handle_cgi_request.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_handle_directory_request${OBJEXT} : ${SRCDIR}httplib_handle_directory_request.c \ @@ -619,6 +632,7 @@ ${OBJDIR}httplib_handle_not_modified_static_file_request${OBJEXT} : ${SRCDIR}htt ${SRCDIR}httplib_main.h ${OBJDIR}httplib_handle_propfind${OBJEXT} : ${SRCDIR}httplib_handle_propfind.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_handle_request${OBJEXT} : ${SRCDIR}httplib_handle_request.c \ @@ -626,6 +640,7 @@ ${OBJDIR}httplib_handle_request${OBJEXT} : ${SRCDIR}httplib_handle_request.c ${SRCDIR}httplib_main.h ${OBJDIR}httplib_handle_static_file_request${OBJEXT} : ${SRCDIR}httplib_handle_static_file_request.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_handle_websocket_request${OBJEXT} : ${SRCDIR}httplib_handle_websocket_request.c \ @@ -644,6 +659,7 @@ ${OBJDIR}httplib_initialize_ssl${OBJEXT} : ${SRCDIR}httplib_initialize_ssl.c ${SRCDIR}httplib_main.h ${OBJDIR}httplib_interpret_uri${OBJEXT} : ${SRCDIR}httplib_interpret_uri.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_is_authorized_for_put${OBJEXT} : ${SRCDIR}httplib_is_authorized_for_put.c \ @@ -668,6 +684,7 @@ ${OBJDIR}httplib_is_valid_port${OBJEXT} : ${SRCDIR}httplib_is_valid_port.c ${SRCDIR}httplib_main.h ${OBJDIR}httplib_is_websocket_protocol${OBJEXT} : ${SRCDIR}httplib_is_websocket_protocol.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_join_thread${OBJEXT} : ${SRCDIR}httplib_join_thread.c \ @@ -687,6 +704,7 @@ ${OBJDIR}httplib_lock_unlock_context${OBJEXT} : ${SRCDIR}httplib_lock_unlock_ ${OBJDIR}httplib_log_access${OBJEXT} : ${SRCDIR}httplib_log_access.c \ ${SRCDIR}httplib_ssl.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_lowercase${OBJEXT} : ${SRCDIR}httplib_lowercase.c \ @@ -722,6 +740,7 @@ ${OBJDIR}httplib_next_option${OBJEXT} : ${SRCDIR}httplib_next_option.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_open_auth_file${OBJEXT} : ${SRCDIR}httplib_open_auth_file.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_opendir${OBJEXT} : ${SRCDIR}httplib_opendir.c \ @@ -729,6 +748,7 @@ ${OBJDIR}httplib_opendir${OBJEXT} : ${SRCDIR}httplib_opendir.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_parse_auth_header${OBJEXT} : ${SRCDIR}httplib_parse_auth_header.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_parse_date_string${OBJEXT} : ${SRCDIR}httplib_parse_date_string.c \ @@ -755,16 +775,20 @@ ${OBJDIR}httplib_poll${OBJEXT} : ${SRCDIR}httplib_poll.c \ ${OBJDIR}httplib_prepare_cgi_environment${OBJEXT} : ${SRCDIR}httplib_prepare_cgi_environment.c \ ${SRCDIR}httplib_memory.h \ ${SRCDIR}httplib_ssl.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_print_dir_entry${OBJEXT} : ${SRCDIR}httplib_print_dir_entry.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_printf${OBJEXT} : ${SRCDIR}httplib_printf.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_process_new_connection${OBJEXT} : ${SRCDIR}httplib_process_new_connection.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_produce_socket${OBJEXT} : ${SRCDIR}httplib_produce_socket.c \ @@ -822,6 +846,7 @@ ${OBJDIR}httplib_remove_bad_file${OBJEXT} : ${SRCDIR}httplib_remove_bad_file. ${SRCDIR}httplib_main.h ${OBJDIR}httplib_remove_directory${OBJEXT} : ${SRCDIR}httplib_remove_directory.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_remove_double_dots${OBJEXT} : ${SRCDIR}httplib_remove_double_dots.c \ @@ -831,6 +856,7 @@ ${OBJDIR}httplib_reset_per_request_attributes${OBJEXT} : ${SRCDIR}httplib_rese ${SRCDIR}httplib_main.h ${OBJDIR}httplib_scan_directory${OBJEXT} : ${SRCDIR}httplib_scan_directory.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_send_authorization_request${OBJEXT} : ${SRCDIR}httplib_send_authorization_request.c \ @@ -844,6 +870,7 @@ ${OBJDIR}httplib_send_file_data${OBJEXT} : ${SRCDIR}httplib_send_file_data.c ${SRCDIR}httplib_main.h ${OBJDIR}httplib_send_http_error${OBJEXT} : ${SRCDIR}httplib_send_http_error.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_send_no_cache_header${OBJEXT} : ${SRCDIR}httplib_send_no_cache_header.c \ @@ -856,6 +883,7 @@ ${OBJDIR}httplib_send_static_cache_header${OBJEXT} : ${SRCDIR}httplib_send_sta ${SRCDIR}httplib_main.h ${OBJDIR}httplib_send_websocket_handshake${OBJEXT} : ${SRCDIR}httplib_send_websocket_handshake.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_set_acl_option${OBJEXT} : ${SRCDIR}httplib_set_acl_option.c \ @@ -872,6 +900,7 @@ ${OBJDIR}httplib_set_gpass_option${OBJEXT} : ${SRCDIR}httplib_set_gpass_optio ${OBJDIR}httplib_set_handler_type${OBJEXT} : ${SRCDIR}httplib_set_handler_type.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_set_non_blocking_mode${OBJEXT} : ${SRCDIR}httplib_set_non_blocking_mode.c \ @@ -895,6 +924,7 @@ ${OBJDIR}httplib_set_tcp_nodelay${OBJEXT} : ${SRCDIR}httplib_set_tcp_nodelay. ${SRCDIR}httplib_main.h ${OBJDIR}httplib_set_thread_name${OBJEXT} : ${SRCDIR}httplib_set_thread_name.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_set_throttle${OBJEXT} : ${SRCDIR}httplib_set_throttle.c \ @@ -922,15 +952,18 @@ ${OBJDIR}httplib_skip_quoted${OBJEXT} : ${SRCDIR}httplib_skip_quoted.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_snprintf${OBJEXT} : ${SRCDIR}httplib_snprintf.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_sockaddr_to_string${OBJEXT} : ${SRCDIR}httplib_sockaddr_to_string.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_spawn_process${OBJEXT} : ${SRCDIR}httplib_spawn_process.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_ssi${OBJEXT} : ${SRCDIR}httplib_ssi.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_ssl_error${OBJEXT} : ${SRCDIR}httplib_ssl_error.c \ @@ -938,8 +971,9 @@ ${OBJDIR}httplib_ssl_error${OBJEXT} : ${SRCDIR}httplib_ssl_error.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_ssl_get_client_cert_info${OBJEXT} : ${SRCDIR}httplib_ssl_get_client_cert_info.c \ - ${SRCDIR}httplib_ssl.h \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_ssl.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_ssl_get_protocol${OBJEXT} : ${SRCDIR}httplib_ssl_get_protocol.c \ @@ -969,6 +1003,7 @@ ${OBJDIR}httplib_start${OBJEXT} : ${SRCDIR}httplib_start.c \ ${SRCDIR}httplib_memory.h \ ${SRCDIR}httplib_pthread.h \ ${SRCDIR}httplib_ssl.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_start_thread${OBJEXT} : ${SRCDIR}httplib_start_thread.c \ @@ -986,16 +1021,18 @@ ${OBJDIR}httplib_stop${OBJEXT} : ${SRCDIR}httplib_stop.c \ ${OBJDIR}httplib_store_body${OBJEXT} : ${SRCDIR}httplib_store_body.c \ ${SRCDIR}httplib_main.h -${OBJDIR}httplib_strlcpy${OBJEXT} : ${SRCDIR}httplib_strlcpy.c \ - ${SRCDIR}httplib_main.h - ${OBJDIR}httplib_strcasecmp${OBJEXT} : ${SRCDIR}httplib_strcasecmp.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_strcasestr${OBJEXT} : ${SRCDIR}httplib_strcasestr.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_strdup${OBJEXT} : ${SRCDIR}httplib_strdup.c \ + ${SRCDIR}httplib_string.h \ + ${SRCDIR}httplib_main.h + +${OBJDIR}httplib_strlcpy${OBJEXT} : ${SRCDIR}httplib_strlcpy.c \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_strncasecmp${OBJEXT} : ${SRCDIR}httplib_strncasecmp.c \ @@ -1003,6 +1040,7 @@ ${OBJDIR}httplib_strncasecmp${OBJEXT} : ${SRCDIR}httplib_strncasecmp.c \ ${OBJDIR}httplib_strndup${OBJEXT} : ${SRCDIR}httplib_strndup.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_substitute_index_file${OBJEXT} : ${SRCDIR}httplib_substitute_index_file.c \ @@ -1037,9 +1075,11 @@ ${OBJDIR}httplib_version${OBJEXT} : ${SRCDIR}httplib_version.c \ ${OBJDIR}httplib_vprintf${OBJEXT} : ${SRCDIR}httplib_vprintf.c \ ${SRCDIR}httplib_memory.h \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_vsnprintf${OBJEXT} : ${SRCDIR}httplib_vsnprintf.c \ + ${SRCDIR}httplib_string.h \ ${SRCDIR}httplib_main.h ${OBJDIR}httplib_websocket_client_thread${OBJEXT} : ${SRCDIR}httplib_websocket_client_thread.c \ diff --git a/src/httplib_addenv.c b/src/httplib_addenv.c index d215a6eb..d050ff04 100644 --- a/src/httplib_addenv.c +++ b/src/httplib_addenv.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" /* * void XX_httplib_addenv( struct cgi_environment *env, const char *fmt, ... ); diff --git a/src/httplib_check_authorization.c b/src/httplib_check_authorization.c index 982c0df8..0bf624ab 100644 --- a/src/httplib_check_authorization.c +++ b/src/httplib_check_authorization.c @@ -22,10 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - +#include "httplib_string.h" /* Return 1 if request is authorised, 0 otherwise. */ int XX_httplib_check_authorization( struct mg_connection *conn, const char *path ) { diff --git a/src/httplib_connect_client.c b/src/httplib_connect_client.c index bbec5938..f0b23e91 100644 --- a/src/httplib_connect_client.c +++ b/src/httplib_connect_client.c @@ -22,14 +22,11 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" #include "httplib_pthread.h" #include "httplib_ssl.h" - - +#include "httplib_string.h" static struct mg_connection * mg_connect_client_impl( const struct mg_client_options *client_options, int use_ssl, char *ebuf, size_t ebuf_len ); diff --git a/src/httplib_connect_socket.c b/src/httplib_connect_socket.c index a75561a5..96ae3f28 100644 --- a/src/httplib_connect_socket.c +++ b/src/httplib_connect_socket.c @@ -22,13 +22,10 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" #include "httplib_ssl.h" - - +#include "httplib_string.h" /* * int XX_httplib_connect_socket(); diff --git a/src/httplib_connect_websocket_client.c b/src/httplib_connect_websocket_client.c index c8947732..7e45ab21 100644 --- a/src/httplib_connect_websocket_client.c +++ b/src/httplib_connect_websocket_client.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" /* * struct mg_connection *mg_connect_websocket_client(); diff --git a/src/httplib_construct_etag.c b/src/httplib_construct_etag.c index 7935d422..7defb1ca 100644 --- a/src/httplib_construct_etag.c +++ b/src/httplib_construct_etag.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * void XX_httplib_construct_etag( char *buf, size_t buf_len, const struct file *filep ); diff --git a/src/httplib_dir_scan_callback.c b/src/httplib_dir_scan_callback.c index d8bbf888..5062d923 100644 --- a/src/httplib_dir_scan_callback.c +++ b/src/httplib_dir_scan_callback.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" void XX_httplib_dir_scan_callback( struct de *de, void *data ) { diff --git a/src/httplib_download.c b/src/httplib_download.c index 373ea3ae..ddfb70c4 100644 --- a/src/httplib_download.c +++ b/src/httplib_download.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * struct mg_connection *mg_download(); diff --git a/src/httplib_get_cookie.c b/src/httplib_get_cookie.c index 2b91bf6c..4db4b89a 100644 --- a/src/httplib_get_cookie.c +++ b/src/httplib_get_cookie.c @@ -22,10 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - +#include "httplib_string.h" /* HCP24: some changes to compare hole var_name */ int mg_get_cookie(const char *cookie_header, const char *var_name, char *dst, size_t dst_size) { diff --git a/src/httplib_get_response.c b/src/httplib_get_response.c index b11c0a87..64b879e8 100644 --- a/src/httplib_get_response.c +++ b/src/httplib_get_response.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * int mg_get_response( struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout ); diff --git a/src/httplib_get_system_name.c b/src/httplib_get_system_name.c index 7497543e..c3e8328e 100644 --- a/src/httplib_get_system_name.c +++ b/src/httplib_get_system_name.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * void XX_httplib_get_system_name( char **sysName ); diff --git a/src/httplib_getreq.c b/src/httplib_getreq.c index 5c01a54d..8263cf8b 100644 --- a/src/httplib_getreq.c +++ b/src/httplib_getreq.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * int XX_httplib_getreq( struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err ); diff --git a/src/httplib_handle_cgi_request.c b/src/httplib_handle_cgi_request.c index 57af3443..d7cf7002 100644 --- a/src/httplib_handle_cgi_request.c +++ b/src/httplib_handle_cgi_request.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" /* * void XX_httplib_handle_cgi_request( struct mg_connection *conn, const char *prog ); diff --git a/src/httplib_handle_propfind.c b/src/httplib_handle_propfind.c index 798db0ac..f7030ad7 100644 --- a/src/httplib_handle_propfind.c +++ b/src/httplib_handle_propfind.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" #if !defined(NO_FILES) diff --git a/src/httplib_handle_static_file_request.c b/src/httplib_handle_static_file_request.c index 6ada0afe..99165df4 100644 --- a/src/httplib_handle_static_file_request.c +++ b/src/httplib_handle_static_file_request.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * void XX_httplib_handle_static_file_request(); diff --git a/src/httplib_interpret_uri.c b/src/httplib_interpret_uri.c index e9505126..c134915c 100644 --- a/src/httplib_interpret_uri.c +++ b/src/httplib_interpret_uri.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * void XX_httplib_interpret_uri(); diff --git a/src/httplib_is_websocket_protocol.c b/src/httplib_is_websocket_protocol.c index f0daac64..d02168e7 100644 --- a/src/httplib_is_websocket_protocol.c +++ b/src/httplib_is_websocket_protocol.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * int XX_httplib_is_websocket_protocol( const struct mg_connection *conn ); diff --git a/src/httplib_log_access.c b/src/httplib_log_access.c index cee749e5..43efaab0 100644 --- a/src/httplib_log_access.c +++ b/src/httplib_log_access.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_ssl.h" - - +#include "httplib_string.h" static const char *header_val( const struct mg_connection *conn, const char *header ); diff --git a/src/httplib_main.h b/src/httplib_main.h index dfda43fa..7631a382 100644 --- a/src/httplib_main.h +++ b/src/httplib_main.h @@ -932,18 +932,12 @@ int XX_httplib_should_decode_url( const struct mg_connection *conn ); int XX_httplib_should_keep_alive( const struct mg_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_snprintf( const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(5, 6); void XX_httplib_sockaddr_to_string(char *buf, size_t len, const union usa *usa ); pid_t XX_httplib_spawn_process( struct mg_connection *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ); int XX_httplib_stat( struct mg_connection *conn, const char *path, struct file *filep ); -const char * XX_httplib_strcasestr( const char *big_str, const char *small_str ); -char * XX_httplib_strdup( const char *str ); -char * XX_httplib_strndup( const char *ptr, size_t len ); void XX_httplib_strlcpy( register char *dst, register const char *src, size_t n ); int XX_httplib_substitute_index_file( struct mg_connection *conn, char *path, size_t path_len, struct file *filep ); const char * XX_httplib_suggest_connection_header( const struct mg_connection *conn ); -int XX_httplib_vprintf( struct mg_connection *conn, const char *fmt, va_list ap ); -void XX_httplib_vsnprintf( const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ); int XX_httplib_websocket_write_exec( struct mg_connection *conn, int opcode, const char *data, size_t dataLen, uint32_t masking_key ); diff --git a/src/httplib_open_auth_file.c b/src/httplib_open_auth_file.c index 7a053edf..42a175ec 100644 --- a/src/httplib_open_auth_file.c +++ b/src/httplib_open_auth_file.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* Use the global passwords file, if specified by auth_gpass option, * or search for .htpasswd in the requested directory. */ diff --git a/src/httplib_parse_auth_header.c b/src/httplib_parse_auth_header.c index 7b0b07c0..a0ba8b2b 100644 --- a/src/httplib_parse_auth_header.c +++ b/src/httplib_parse_auth_header.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* Return 1 on success. Always initializes the ah structure. */ int XX_httplib_parse_auth_header(struct mg_connection *conn, char *buf, size_t buf_size, struct ah *ah) { diff --git a/src/httplib_prepare_cgi_environment.c b/src/httplib_prepare_cgi_environment.c index 804b0249..c6651261 100644 --- a/src/httplib_prepare_cgi_environment.c +++ b/src/httplib_prepare_cgi_environment.c @@ -22,13 +22,10 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" #include "httplib_ssl.h" - - +#include "httplib_string.h" /* * void XX_httplib_prepare_cgi_environment( struct mg_connection *conn, const char *prog, struct cgi_environment *env ); diff --git a/src/httplib_print_dir_entry.c b/src/httplib_print_dir_entry.c index dedfa5ed..a7d8a32a 100644 --- a/src/httplib_print_dir_entry.c +++ b/src/httplib_print_dir_entry.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" void XX_httplib_print_dir_entry( struct de *de ) { diff --git a/src/httplib_printf.c b/src/httplib_printf.c index 6c639082..d2cfa77f 100644 --- a/src/httplib_printf.c +++ b/src/httplib_printf.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" int mg_printf( struct mg_connection *conn, const char *fmt, ... ) { diff --git a/src/httplib_process_new_connection.c b/src/httplib_process_new_connection.c index ed4cfaba..1f35b19e 100644 --- a/src/httplib_process_new_connection.c +++ b/src/httplib_process_new_connection.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" /* * void XX_httplib_process_new_connection( struct mg_connection *conn ); diff --git a/src/httplib_remove_directory.c b/src/httplib_remove_directory.c index e1ddf217..e9d34196 100644 --- a/src/httplib_remove_directory.c +++ b/src/httplib_remove_directory.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" int XX_httplib_remove_directory( struct mg_connection *conn, const char *dir ) { diff --git a/src/httplib_scan_directory.c b/src/httplib_scan_directory.c index 2983b782..39327da4 100644 --- a/src/httplib_scan_directory.c +++ b/src/httplib_scan_directory.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" int XX_httplib_scan_directory( struct mg_connection *conn, const char *dir, void *data, void (*cb)(struct de *, void *) ) { diff --git a/src/httplib_send_http_error.c b/src/httplib_send_http_error.c index bba62915..47a443b8 100644 --- a/src/httplib_send_http_error.c +++ b/src/httplib_send_http_error.c @@ -22,10 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - +#include "httplib_string.h" void XX_httplib_send_http_error( struct mg_connection *conn, int status, const char *fmt, ... ) { diff --git a/src/httplib_send_websocket_handshake.c b/src/httplib_send_websocket_handshake.c index 924f3f71..e6798557 100644 --- a/src/httplib_send_websocket_handshake.c +++ b/src/httplib_send_websocket_handshake.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* * int XX_httplib_send_websocket_handshake( struct mg_connection *conn, const char *websock_key ); diff --git a/src/httplib_set_handler_type.c b/src/httplib_set_handler_type.c index 05076065..e2f7d191 100644 --- a/src/httplib_set_handler_type.c +++ b/src/httplib_set_handler_type.c @@ -22,12 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" /* * void XX_httplib_set_handler_type(); diff --git a/src/httplib_set_thread_name.c b/src/httplib_set_thread_name.c index 11885662..9514cf06 100644 --- a/src/httplib_set_thread_name.c +++ b/src/httplib_set_thread_name.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" #if !defined(NO_THREAD_NAME) #if defined(_WIN32) && defined(_MSC_VER) diff --git a/src/httplib_snprintf.c b/src/httplib_snprintf.c index 5a9f74d0..8846e731 100644 --- a/src/httplib_snprintf.c +++ b/src/httplib_snprintf.c @@ -25,6 +25,7 @@ #include "httplib_main.h" +#include "httplib_string.h" diff --git a/src/httplib_spawn_process.c b/src/httplib_spawn_process.c index ad40644b..d61587ad 100644 --- a/src/httplib_spawn_process.c +++ b/src/httplib_spawn_process.c @@ -22,10 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - +#include "httplib_string.h" #if defined(_WIN32) diff --git a/src/httplib_ssi.c b/src/httplib_ssi.c index edefe35f..229a34de 100644 --- a/src/httplib_ssi.c +++ b/src/httplib_ssi.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" static void send_ssi_file(struct mg_connection *, const char *, struct file *, int); diff --git a/src/httplib_ssl_get_client_cert_info.c b/src/httplib_ssl_get_client_cert_info.c index 51c0ff9f..9b1f9814 100644 --- a/src/httplib_ssl_get_client_cert_info.c +++ b/src/httplib_ssl_get_client_cert_info.c @@ -22,13 +22,10 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" #include "httplib_ssl.h" - - +#include "httplib_string.h" #if !defined(NO_SSL) diff --git a/src/httplib_start.c b/src/httplib_start.c index 3fd9b9f8..1bd0d195 100644 --- a/src/httplib_start.c +++ b/src/httplib_start.c @@ -22,14 +22,11 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" #include "httplib_pthread.h" #include "httplib_ssl.h" - - +#include "httplib_string.h" /* * struct mg_context *mg_start( const struct mg_callbacks *callbacks, void *user_data, const char **options ); diff --git a/src/httplib_strcasestr.c b/src/httplib_strcasestr.c index b235b9b5..83514e30 100644 --- a/src/httplib_strcasestr.c +++ b/src/httplib_strcasestr.c @@ -25,6 +25,7 @@ #include "httplib_main.h" +#include "httplib_string.h" diff --git a/src/httplib_strdup.c b/src/httplib_strdup.c index b795cdef..e443d683 100644 --- a/src/httplib_strdup.c +++ b/src/httplib_strdup.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" char * XX_httplib_strdup( const char *str ) { diff --git a/src/httplib_string.h b/src/httplib_string.h new file mode 100644 index 00000000..fc064e25 --- /dev/null +++ b/src/httplib_string.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 Lammert Bies + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + + +void XX_httplib_snprintf( const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(5, 6); +const char * XX_httplib_strcasestr( const char *big_str, const char *small_str ); +char * XX_httplib_strdup( const char *str ); +char * XX_httplib_strndup( const char *ptr, size_t len ); +int XX_httplib_vprintf( struct mg_connection *conn, const char *fmt, va_list ap ); +void XX_httplib_vsnprintf( const struct mg_connection *conn, int *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ); diff --git a/src/httplib_strndup.c b/src/httplib_strndup.c index b2df256c..367ea50d 100644 --- a/src/httplib_strndup.c +++ b/src/httplib_strndup.c @@ -22,11 +22,9 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - +#include "httplib_string.h" char * XX_httplib_strndup( const char *ptr, size_t len ) { diff --git a/src/httplib_vprintf.c b/src/httplib_vprintf.c index 376a1d8c..fc4ce3af 100644 --- a/src/httplib_vprintf.c +++ b/src/httplib_vprintf.c @@ -22,15 +22,12 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" #include "httplib_memory.h" - - +#include "httplib_string.h" /* Alternative alloc_vprintf() for non-compliant C runtimes */ -static int alloc_vprintf2(char **buf, const char *fmt, va_list ap) { +static int alloc_vprintf2( char **buf, const char *fmt, va_list ap ) { va_list ap_copy; size_t size = MG_BUF_LEN / 4; diff --git a/src/httplib_vsnprintf.c b/src/httplib_vsnprintf.c index 8e5aede3..a4d19576 100644 --- a/src/httplib_vsnprintf.c +++ b/src/httplib_vsnprintf.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ - - #include "httplib_main.h" - - +#include "httplib_string.h" /* Return null terminated string of given maximum length. * Report errors if length is exceeded. */