libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 2ec6b3c7c94fae62b2dee94f8c0122fafc14423a
parent 0a0fa0f1c6a6b6a798dda2ee9859b297aa65dfb9
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 16 May 2022 16:14:01 +0300

Use '#ifdef PARAM' instead of '#if PARAM' for configuration options

Diffstat:
Msrc/examples/demo.c | 6+++---
Msrc/examples/demo_https.c | 6+++---
Msrc/include/mhd_options.h | 4++--
Msrc/microhttpd/connection.c | 4++--
Msrc/microhttpd/daemon.c | 50+++++++++++++++++++++++++-------------------------
Msrc/microhttpd/memorypool.c | 2+-
Msrc/microhttpd/mhd_byteorder.h | 18+++++++++---------
Msrc/microhttpd/mhd_send.c | 8++++----
Msrc/microhttpd/mhd_sockets.h | 2+-
Msrc/microhttpd/sysfdsetsize.c | 10+++++-----
Msrc/microhttpd/test_options.c | 6+++---
Msrc/microhttpd/test_upgrade.c | 2+-
Msrc/microhttpd/test_upgrade_large.c | 2+-
13 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/src/examples/demo.c b/src/examples/demo.c @@ -388,7 +388,7 @@ update_directory (void) rdc.buf, &free); mark_as_html (response); -#if FORCE_CLOSE +#ifdef FORCE_CLOSE (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); @@ -577,7 +577,7 @@ process_upload_data (void *cls, fn[i] = '_'; uc->fd = open (fn, O_CREAT | O_EXCL -#if O_LARGEFILE +#ifdef O_LARGEFILE | O_LARGEFILE #endif | O_WRONLY, @@ -933,7 +933,7 @@ main (int argc, char *const *argv) &generate_page, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (256 * 1024), -#if PRODUCTION +#ifdef PRODUCTION MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) (64), #endif MHD_OPTION_CONNECTION_TIMEOUT, (unsigned diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c @@ -390,7 +390,7 @@ update_directory (void) rdc.buf, &free); mark_as_html (response); -#if FORCE_CLOSE +#ifdef FORCE_CLOSE (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); @@ -579,7 +579,7 @@ process_upload_data (void *cls, fn[i] = '_'; uc->fd = open (fn, O_CREAT | O_EXCL -#if O_LARGEFILE +#ifdef O_LARGEFILE | O_LARGEFILE #endif | O_WRONLY, @@ -998,7 +998,7 @@ main (int argc, char *const *argv) &generate_page, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (256 * 1024), -#if PRODUCTION +#ifdef PRODUCTION MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) (64), #endif MHD_OPTION_CONNECTION_TIMEOUT, (unsigned diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h @@ -80,7 +80,7 @@ # endif #endif /* MHD_USE_POSIX_THREADS || MHD_USE_W32_THREADS */ -#if OS390 +#if defined(OS390) #define _OPEN_THREADS #define _OPEN_SYS_SOCK_IPV6 #define _OPEN_MSGQ_EXT @@ -109,7 +109,7 @@ #define RESTRICT __restrict__ #endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */ -#if LINUX + 0 && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && \ +#if defined(LINUX) && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && \ ! defined(_LARGEFILE64_SOURCE) /* On Linux, special macro is required to enable definitions of some xxx64 functions */ #define _LARGEFILE64_SOURCE 1 diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -885,7 +885,7 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection) DLL_remove (daemon->urh_head, daemon->urh_tail, urh); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL)) && (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, @@ -904,7 +904,7 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection) #endif /* EPOLL_SUPPORT */ if (MHD_INVALID_SOCKET != urh->mhd.socket) { -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL)) && (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -46,7 +46,7 @@ #include "mhd_send.h" #include "mhd_align.h" -#if HAVE_SEARCH_H +#ifdef HAVE_SEARCH_H #include <search.h> #else #include "tsearch.h" @@ -237,7 +237,7 @@ struct MHD_IPCount * IPv4 address. */ struct in_addr ipv4; -#if HAVE_INET6 +#ifdef HAVE_INET6 /** * IPv6 address. */ @@ -337,7 +337,7 @@ MHD_ip_addr_to_key (const struct sockaddr *addr, } } -#if HAVE_INET6 +#ifdef HAVE_INET6 if (sizeof (struct sockaddr_in6) <= (size_t) addrlen) { /* IPv6 addresses */ @@ -1882,7 +1882,7 @@ thread_main_handle_connection (void *data) fd_set ws; fd_set es; MHD_socket maxsock; -#if WINDOWS +#ifdef WINDOWS #ifdef HAVE_POLL unsigned int extra_slot; #endif /* HAVE_POLL */ @@ -2049,7 +2049,7 @@ thread_main_handle_connection (void *data) /* how did we get here!? */ goto exit; } -#if WINDOWS +#ifdef WINDOWS if (MHD_ITC_IS_VALID_ (daemon->itc) ) { if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), @@ -2087,7 +2087,7 @@ thread_main_handle_connection (void *data) #endif break; } -#if WINDOWS +#ifdef WINDOWS /* Clear ITC before other processing so additional * signals will trigger select() again */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && @@ -2143,7 +2143,7 @@ thread_main_handle_connection (void *data) /* how did we get here!? */ goto exit; } -#if WINDOWS +#ifdef WINDOWS extra_slot = 0; if (MHD_ITC_IS_VALID_ (daemon->itc)) { @@ -2154,7 +2154,7 @@ thread_main_handle_connection (void *data) } #endif if (MHD_sys_poll_ (p, -#if WINDOWS +#ifdef WINDOWS 1 + extra_slot, #else 1, @@ -2170,7 +2170,7 @@ thread_main_handle_connection (void *data) #endif break; } -#if WINDOWS +#ifdef WINDOWS /* Clear ITC before other processing so additional * signals will trigger poll() again */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && @@ -2442,7 +2442,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon, "Server reached connection limit. Closing inbound connection.\n")); #endif MHD_socket_close_chk_ (client_socket); -#if ENFILE +#if defined(ENFILE) && (ENFILE + 0 != 0) errno = ENFILE; #endif return NULL; @@ -2464,7 +2464,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon, MHD_ip_limit_del (daemon, addr, addrlen); -#if EACCESS +#if defined(EACCESS) && (EACCESS + 0 != 0) errno = EACCESS; #endif return NULL; @@ -2580,7 +2580,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon, MHD_DLOG (daemon, _ ("Failed to initialise TLS session.\n")); #endif -#if EPROTO +#if defined(EPROTO) && (EPROTO + 0 != 0) errno = EPROTO; #endif return NULL; @@ -2642,7 +2642,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon, free (connection->addr); free (connection); MHD_PANIC (_ ("Unknown credential type.\n")); -#if EINVAL +#if defined(EINVAL) && (EINVAL + 0 != 0) errno = EINVAL; #endif return NULL; @@ -2754,7 +2754,7 @@ new_connection_process_ (struct MHD_Daemon *daemon, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif -#if ENOMEM +#if defined(ENOMEM) && (ENOMEM + 0 != 0) eno = ENOMEM; #endif (void) 0; /* Mute possible compiler warning */ @@ -2770,7 +2770,7 @@ new_connection_process_ (struct MHD_Daemon *daemon, _ ("Server reached connection limit. " "Closing inbound connection.\n")); #endif -#if ENFILE +#if defined(ENFILE) && (ENFILE + 0 != 0) eno = ENFILE; #endif (void) 0; /* Mute possible compiler warning */ @@ -2973,7 +2973,7 @@ internal_add_connection (struct MHD_Daemon *daemon, (int) FD_SETSIZE); #endif MHD_socket_close_chk_ (client_socket); -#if ENFILE +#if defined(ENFILE) && (ENFILE + 0 != 0) errno = ENFILE; #endif return MHD_NO; @@ -2987,7 +2987,7 @@ internal_add_connection (struct MHD_Daemon *daemon, _ ("Epoll mode supports only non-blocking sockets\n")); #endif MHD_socket_close_chk_ (client_socket); -#if EINVAL +#if defined(EINVAL) && (EINVAL + 0 != 0) errno = EINVAL; #endif return MHD_NO; @@ -3561,7 +3561,7 @@ MHD_add_connection (struct MHD_Daemon *daemon, } /* all pools are at their connection limit, must refuse */ MHD_socket_close_chk_ (client_socket); -#if ENFILE +#if defined(ENFILE) && (ENFILE + 0 != 0) errno = ENFILE; #endif return MHD_NO; @@ -3596,7 +3596,7 @@ MHD_add_connection (struct MHD_Daemon *daemon, static enum MHD_Result MHD_accept_connection (struct MHD_Daemon *daemon) { -#if HAVE_INET6 +#ifdef HAVE_INET6 struct sockaddr_in6 addrstorage; #else struct sockaddr_in addrstorage; @@ -6599,7 +6599,7 @@ MHD_start_daemon_va (unsigned int flags, struct MHD_Daemon *daemon; MHD_socket listen_fd; struct sockaddr_in servaddr4; -#if HAVE_INET6 +#ifdef HAVE_INET6 struct sockaddr_in6 servaddr6; #endif const struct sockaddr *servaddr = NULL; @@ -7032,7 +7032,7 @@ MHD_start_daemon_va (unsigned int flags, } /* check for user supplied sockaddr */ -#if HAVE_INET6 +#ifdef HAVE_INET6 if (0 != (*pflags & MHD_USE_IPv6)) addrlen = sizeof (struct sockaddr_in6); else @@ -7040,7 +7040,7 @@ MHD_start_daemon_va (unsigned int flags, addrlen = sizeof (struct sockaddr_in); if (NULL == servaddr) { -#if HAVE_INET6 +#ifdef HAVE_INET6 if (0 != (*pflags & MHD_USE_IPv6)) { #ifdef IN6ADDR_ANY_INIT @@ -7054,7 +7054,7 @@ MHD_start_daemon_va (unsigned int flags, #ifdef IN6ADDR_ANY_INIT servaddr6.sin6_addr = static_in6any; #endif -#if HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN servaddr6.sin6_len = sizeof (struct sockaddr_in6); #endif servaddr = (struct sockaddr *) &servaddr6; @@ -7069,7 +7069,7 @@ MHD_start_daemon_va (unsigned int flags, servaddr4.sin_port = htons (port); if (0 != INADDR_ANY) servaddr4.sin_addr.s_addr = htonl (INADDR_ANY); -#if HAVE_STRUCT_SOCKADDR_IN_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN servaddr4.sin_len = sizeof (struct sockaddr_in); #endif servaddr = (struct sockaddr *) &servaddr4; @@ -7798,7 +7798,7 @@ close_all_connections (struct MHD_Daemon *daemon) { shutdown (pos->socket_fd, SHUT_RDWR); -#if MHD_WINSOCK_SOCKETS +#ifdef MHD_WINSOCK_SOCKETS if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "e")) ) diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c @@ -31,7 +31,7 @@ #include <string.h> #include <stdint.h> #include "mhd_assert.h" -#if HAVE_SYS_MMAN_H +#ifdef HAVE_SYS_MMAN_H #include <sys/mman.h> #endif #ifdef _WIN32 diff --git a/src/microhttpd/mhd_byteorder.h b/src/microhttpd/mhd_byteorder.h @@ -30,39 +30,39 @@ #include <stdint.h> -#if HAVE_ENDIAN_H +#ifdef HAVE_ENDIAN_H #include <endian.h> #endif -#if HAVE_SYS_PARAM_H +#ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif -#if HAVE_MACHINE_ENDIAN_H +#ifdef HAVE_MACHINE_ENDIAN_H #include <machine/endian.h> #endif -#if HAVE_SYS_ENDIAN_H +#ifdef HAVE_SYS_ENDIAN_H #include <sys/endian.h> #endif -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#if HAVE_SYS_BYTEORDER_H +#ifdef HAVE_SYS_BYTEORDER_H #include <sys/byteorder.h> #endif -#if HAVE_SYS_MACHINE_H +#ifdef HAVE_SYS_MACHINE_H #include <sys/machine.h> #endif -#if HAVE_MACHINE_PARAM_H +#ifdef HAVE_MACHINE_PARAM_H #include <machine/param.h> #endif -#if HAVE_SYS_ISA_DEFS_H +#ifdef HAVE_SYS_ISA_DEFS_H #include <sys/isa_defs.h> #endif diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c @@ -853,7 +853,7 @@ MHD_send_data_ (struct MHD_Connection *connection, if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /* EAGAIN, no longer write-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); @@ -879,7 +879,7 @@ MHD_send_data_ (struct MHD_Connection *connection, /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT else if (buffer_size > (size_t) ret) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); @@ -1099,7 +1099,7 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /* EAGAIN, no longer write-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); @@ -1125,7 +1125,7 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT else if ((header_size + body_size) > (size_t) ret) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h @@ -199,7 +199,7 @@ typedef SOCKET MHD_socket; # define SHUT_RDWR SD_BOTH #endif -#if HAVE_ACCEPT4 + 0 != 0 && (defined(HAVE_SOCK_NONBLOCK) || \ +#if defined(HAVE_ACCEPT4) && (defined(HAVE_SOCK_NONBLOCK) || \ defined(SOCK_CLOEXEC) || defined(SOCK_NOSIGPIPE)) # define USE_ACCEPT4 1 #endif diff --git a/src/microhttpd/sysfdsetsize.c b/src/microhttpd/sysfdsetsize.c @@ -39,22 +39,22 @@ #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) #include <sockLib.h> #endif /* OS_VXWORKS */ -#if HAVE_SYS_SELECT_H +#ifdef HAVE_SYS_SELECT_H #include <sys/select.h> #endif /* HAVE_SYS_SELECT_H */ -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif /* HAVE_SYS_TYPES_H */ -#if HAVE_SYS_TIME_H +#ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif /* HAVE_SYS_TIME_H */ -#if HAVE_TIME_H +#ifdef HAVE_TIME_H #include <time.h> #endif /* HAVE_TIME_H */ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* HAVE_UNISTD_H */ -#if HAVE_SYS_SOCKET_H +#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif /* HAVE_SYS_SOCKET_H */ diff --git a/src/microhttpd/test_options.c b/src/microhttpd/test_options.c @@ -84,7 +84,7 @@ test_ip_addr_option () { struct MHD_Daemon *d; struct sockaddr_in daemon_ip_addr; -#if HAVE_INET6 && defined(USE_IPV6_TESTING) +#if defined(HAVE_INET6) && defined(USE_IPV6_TESTING) struct sockaddr_in6 daemon_ip_addr6; #endif @@ -93,7 +93,7 @@ test_ip_addr_option () daemon_ip_addr.sin_port = 0; daemon_ip_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); -#if HAVE_INET6 && defined(USE_IPV6_TESTING) +#if defined(HAVE_INET6) && defined(USE_IPV6_TESTING) memset (&daemon_ip_addr6, 0, sizeof (struct sockaddr_in6)); daemon_ip_addr6.sin6_family = AF_INET6; daemon_ip_addr6.sin6_port = 0; @@ -109,7 +109,7 @@ test_ip_addr_option () MHD_stop_daemon (d); -#if HAVE_INET6 && defined(USE_IPV6_TESTING) +#if defined(HAVE_INET6) && defined(USE_IPV6_TESTING) d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_IPv6, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, &daemon_ip_addr6, MHD_OPTION_END); diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c @@ -1233,7 +1233,7 @@ run_mhd_loop (struct MHD_Daemon *daemon, else if (0 != (flags & MHD_USE_POLL)) run_mhd_poll_loop (daemon); #endif /* HAVE_POLL */ -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT else if (0 != (flags & MHD_USE_EPOLL)) run_mhd_epoll_loop (daemon); #endif diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c @@ -1421,7 +1421,7 @@ run_mhd_loop (struct MHD_Daemon *daemon, else if (0 != (flags & MHD_USE_POLL)) run_mhd_poll_loop (daemon); #endif /* HAVE_POLL */ -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT else if (0 != (flags & MHD_USE_EPOLL)) run_mhd_epoll_loop (daemon); #endif